Add a "get_num_hands_remaining" function and implement the Acrobat Joker
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-9
@@ -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:
|
effect.money += 1;
|
||||||
if (random() % 2 == 0)
|
|
||||||
effect.money += 1;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,9 +354,8 @@ 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return effect;
|
return effect;
|
||||||
@@ -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
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user