Add a "get_num_hands_remaining" function and implement the Acrobat Joker

This commit is contained in:
MonteCrysto
2025-09-30 23:06:13 +02:00
parent c781ee9666
commit de7c9d4d60
3 changed files with 24 additions and 9 deletions

View File

@@ -99,6 +99,7 @@ bool card_is_face(Card *card);
int get_deck_top(void);
int get_num_discards_remaining(void);
int get_num_hands_remaining(void);
int get_money(void);
#endif // GAME_H

View File

@@ -191,6 +191,10 @@ int get_num_discards_remaining(void) {
return discards;
}
int get_num_hands_remaining(void) {
return hands;
}
int get_money(void) {
return money;
}

View File

@@ -341,12 +341,8 @@ static JokerEffect reserved_parking_joker_effect(Joker *joker, Card *scored_card
int hand_size = hand_get_size();
for (int i = 0; i < hand_size; i++ )
{
switch (hand[i]->card->rank) {
case KING: case QUEEN: case JACK:
if (random() % 2 == 0)
effect.money += 1;
default:
break;
if ((random() % 2 == 0) && card_is_face(scored_card)) {
effect.money += 1;
}
}
@@ -358,9 +354,8 @@ static JokerEffect business_card_joker_effect(Joker *joker, Card *scored_card) {
if (scored_card == NULL)
return effect;
if (card_is_face(scored_card)) {
if (random() % 2 == 0)
effect.money = 2;
if ((random() % 2 == 0) && card_is_face(scored_card)) {
effect.money = 2;
}
return effect;
@@ -455,6 +450,20 @@ static JokerEffect odd_todd_joker_effect(Joker *joker, Card *scored_card) {
return effect;
}
__attribute__((unused))
static JokerEffect abstract_joker_effect(Joker *joker, Card *scored_card) {
JokerEffect effect = {0};
if (scored_card == NULL)
return effect;
// 0 remaining hands mean it's the last hand
if (get_num_hands_remaining() == 0) {
effect.xmult = 3;
}
return effect;
}
/* The index of a joker in the registry matches its ID.
* The joker sprites are matched by ID so the position in the registry
* determines the joker's sprite.
@@ -505,6 +514,7 @@ const JokerInfo joker_registry[] = {
{ COMMON_JOKER, 4, abstract_joker_effect },
{ UNCOMMON_JOKER, 6, bull_joker_effect},
{ UNCOMMON_JOKER, ?, abstract_joker_effect },
#endif
};