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
+1
View File
@@ -99,6 +99,7 @@ bool card_is_face(Card *card);
int get_deck_top(void); int get_deck_top(void);
int get_num_discards_remaining(void); int get_num_discards_remaining(void);
int get_num_hands_remaining(void);
int get_money(void); int get_money(void);
#endif // GAME_H #endif // GAME_H
+4
View File
@@ -191,6 +191,10 @@ int get_num_discards_remaining(void) {
return discards; return discards;
} }
int get_num_hands_remaining(void) {
return hands;
}
int get_money(void) { int get_money(void) {
return money; return money;
} }
+17 -7
View File
@@ -341,12 +341,8 @@ static JokerEffect reserved_parking_joker_effect(Joker *joker, Card *scored_card
int hand_size = hand_get_size(); int hand_size = hand_get_size();
for (int i = 0; i < hand_size; i++ ) for (int i = 0; i < hand_size; i++ )
{ {
switch (hand[i]->card->rank) { if ((random() % 2 == 0) && card_is_face(scored_card)) {
case KING: case QUEEN: case JACK:
if (random() % 2 == 0)
effect.money += 1; effect.money += 1;
default:
break;
} }
} }
@@ -358,8 +354,7 @@ static JokerEffect business_card_joker_effect(Joker *joker, Card *scored_card) {
if (scored_card == NULL) if (scored_card == NULL)
return effect; return effect;
if (card_is_face(scored_card)) { if ((random() % 2 == 0) && card_is_face(scored_card)) {
if (random() % 2 == 0)
effect.money = 2; effect.money = 2;
} }
@@ -455,6 +450,20 @@ static JokerEffect odd_todd_joker_effect(Joker *joker, Card *scored_card) {
return effect; 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 index of a joker in the registry matches its ID.
* The joker sprites are matched by ID so the position in the registry * The joker sprites are matched by ID so the position in the registry
* determines the joker's sprite. * determines the joker's sprite.
@@ -505,6 +514,7 @@ const JokerInfo joker_registry[] = {
{ COMMON_JOKER, 4, abstract_joker_effect }, { COMMON_JOKER, 4, abstract_joker_effect },
{ UNCOMMON_JOKER, 6, bull_joker_effect}, { UNCOMMON_JOKER, 6, bull_joker_effect},
{ UNCOMMON_JOKER, ?, abstract_joker_effect },
#endif #endif
}; };