diff --git a/defs.h b/defs.h index 8522fa8..a7aaaa5 100644 --- a/defs.h +++ b/defs.h @@ -771,6 +771,8 @@ extern spriteinfo_t spriteinfo[]; extern int curcard; extern int deck[]; +extern int forcegoodcard; +extern int nextforcegoodcard; extern char *datadir; diff --git a/globals.h b/globals.h index b65ec1e..a8e110f 100644 --- a/globals.h +++ b/globals.h @@ -15,6 +15,8 @@ char *datadir; int curcard; int deck[DECKSIZE]; +int forcegoodcard; +int nextforcegoodcard; SDL_Surface *levelbg; // level background image diff --git a/rc.c b/rc.c index f3979f9..79e8c02 100644 --- a/rc.c +++ b/rc.c @@ -267,6 +267,9 @@ int main (int argc, char **argv) { player->invuln = INVULNTIME; player->score = 0; player->lives = 3; + forcegoodcard = B_FALSE; + nextforcegoodcard = B_FALSE; + @@ -856,6 +859,11 @@ void nextlevel(void) { /* reset level stats */ level->gotpowerup = B_FALSE; + + // this is based on the max number of monsters killed + // simulatneously on the previous level... + forcegoodcard = nextforcegoodcard; + nextforcegoodcard = B_FALSE; if (player->hasbell) { playedbell = B_FALSE; @@ -4166,9 +4174,6 @@ void dogravity(sprite_t *s) { s->netlen += s->netspeed; s->netting++; if (s->netting % 2 == 0) { - if (s->netspeed == 0) { - printf("maxlen %d\n",s->netlen); - } if (s->netspeed > -NETSPEED) { s->netspeed--; } else { @@ -4445,8 +4450,9 @@ void dogravity(sprite_t *s) { } } - } + } // end if gotsomething || PW_MACE + // play sound effect if (!hitboss) { if (gotsomething >= 1) { playfx(FX_KILL); @@ -4456,6 +4462,12 @@ void dogravity(sprite_t *s) { } } + // killing 5 at a time gives us a bonus on the next level... + if (gotsomething >= 5) { + nextforcegoodcard = B_TRUE; + forcegoodcard = B_TRUE; // and on this level if we get one... + } + gotsomething = B_FALSE; @@ -6412,38 +6424,6 @@ char *getpokermsg2(int effect, char *buf) { return buf; } -int getcardsuit(int cardid) { - if ((cardid >= P_FIRSTHEART) && (cardid <= (P_FIRSTHEART + 12))) { - return CS_HEART; - } else if ((cardid >= P_FIRSTDIAMOND) && (cardid <= (P_FIRSTDIAMOND + 12))) { - return CS_DIAMOND; - } else if ((cardid >= P_FIRSTSPADE) && (cardid <= (P_FIRSTSPADE + 12))) { - return CS_SPADE; - } else { - return CS_CLUB; - } -} -int getcardvalue(int cardid) { - int points; - points = cardid; - switch (getcardsuit(cardid)) { - case CS_HEART: - points -= P_FIRSTHEART; - break; - case CS_DIAMOND: - points -= P_FIRSTDIAMOND; - break; - case CS_SPADE: - points -= P_FIRSTSPADE; - break; - case CS_CLUB: - default: - points -= P_FIRSTCLUB; - break; - } - - return (points+1); -} void handleinput(void) { diff --git a/rc.h b/rc.h index a2c3c4f..04da968 100644 --- a/rc.h +++ b/rc.h @@ -74,8 +74,6 @@ int getpokereffect(sprite_t *pl); void dopokereffect(sprite_t *pl, int effect); char *getpokermsg(int effect); char *getpokermsg2(int effect, char *buf); -int getcardvalue(int cardid); -int getcardsuit(int cardid); void handleinput(void); int keydown(int checkfor); void trytojump(sprite_t *pl); diff --git a/shared.c b/shared.c index d5dd6d4..2f23dfe 100644 --- a/shared.c +++ b/shared.c @@ -2857,6 +2857,24 @@ int getrandomcard(void) { } } } + + // are we forcing it to be good? + if (forcegoodcard) { + int okay = B_FALSE; + int csuit,cval; + for (i = 0; i < player->numcards; i++) { + cval = getcardvalue(player->card[i]); + csuit = getcardsuit(player->card[i]); + if (csuit == getcardsuit(cardid)) okay = B_TRUE; + if (cval == (getcardvalue(cardid))) okay = B_TRUE; + if (cval == (getcardvalue(cardid)+1)) okay = B_TRUE; + if (cval == (getcardvalue(cardid)-1)) okay = B_TRUE; + } + // if not a good card, go to next one + if (!okay) { + gotit = B_TRUE; + } + } } //printf("returning cardid %d\n",cardid); @@ -3013,3 +3031,36 @@ int getlevel(int lev) { return wnum; } + +int getcardsuit(int cardid) { + if ((cardid >= P_FIRSTHEART) && (cardid <= (P_FIRSTHEART + 12))) { + return CS_HEART; + } else if ((cardid >= P_FIRSTDIAMOND) && (cardid <= (P_FIRSTDIAMOND + 12))) { + return CS_DIAMOND; + } else if ((cardid >= P_FIRSTSPADE) && (cardid <= (P_FIRSTSPADE + 12))) { + return CS_SPADE; + } else { + return CS_CLUB; + } +} +int getcardvalue(int cardid) { + int points; + points = cardid; + switch (getcardsuit(cardid)) { + case CS_HEART: + points -= P_FIRSTHEART; + break; + case CS_DIAMOND: + points -= P_FIRSTDIAMOND; + break; + case CS_SPADE: + points -= P_FIRSTSPADE; + break; + case CS_CLUB: + default: + points -= P_FIRSTCLUB; + break; + } + + return (points+1); +} diff --git a/shared.h b/shared.h index 85ccebd..f4fe5f6 100644 --- a/shared.h +++ b/shared.h @@ -56,6 +56,8 @@ char *getcardletter(int num); int getrandomcard(void); char *getcardname(int id); void shufflecards(void); +int getcardvalue(int cardid); +int getcardsuit(int cardid); int getworld(int lev); int getlevel(int lev); // for doco