Merge pull request #159 from MathisMartin31/main

Add Pareidolia and Acrobat Jokers
This commit is contained in:
MeirGavish
2025-10-09 20:43:36 +03:00
committed by GitHub
6 changed files with 72 additions and 34 deletions
+1 -1
View File
@@ -38,7 +38,7 @@
#define IMPOSSIBLY_HIGH_CARD_VALUE 100
// Card types
typedef struct
typedef struct Card
{
u8 suit;
u8 rank;
+4
View File
@@ -86,6 +86,7 @@ typedef struct List List;
// Utility functions for other files
typedef struct CardObject CardObject; // forward declaration, actually declared in card.h
typedef struct Card Card;
typedef struct JokerObject JokerObject;
CardObject** get_hand_array(void);
int get_hand_top(void);
@@ -93,9 +94,12 @@ int hand_get_size(void);
CardObject** get_played_array(void);
int get_played_top(void);
List* get_jokers(void);
bool is_joker_owned(int joker_id);
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
+2 -1
View File
@@ -37,6 +37,7 @@
#define GREEDY_JOKER_ID 1 // This is just an example to show the patern of making joker IDs
#define JOKER_STENCIL_ID 16
#define JOKER_BRAINSTORM_ID 40
#define PAREIDOLIA_JOKER_ID 41
typedef struct
{
@@ -92,4 +93,4 @@ bool joker_object_is_selected(JokerObject* joker_object);
Sprite* joker_object_get_sprite(JokerObject* joker_object);
#endif // JOKER_H
#endif // JOKER_H
+34 -3
View File
@@ -192,6 +192,18 @@ List *get_jokers(void) {
return jokers;
}
bool is_joker_owned(int joker_id) {
for (int k = 0; k < list_get_size(jokers); k++)
{
JokerObject *joker = list_get(jokers, k);
if (joker->joker->id == joker_id)
{
return true;
}
}
return false;
}
void add_joker(JokerObject *joker_object)
{
list_append(jokers, joker_object);
@@ -202,15 +214,23 @@ void remove_held_joker(int joker_idx)
list_remove_by_idx(jokers, joker_idx);
}
int get_deck_top(void) {
int get_deck_top(void)
{
return deck_top;
}
int get_num_discards_remaining(void) {
int get_num_discards_remaining(void)
{
return discards;
}
int get_money(void) {
int get_num_hands_remaining(void)
{
return hands;
}
int get_money(void)
{
return money;
}
@@ -518,6 +538,17 @@ enum HandType hand_get_type()
return res_hand_type; // should be HIGH_CARD
}
// Returns true if the card is *considered* a face card
bool card_is_face(Card *card) {
// Card is a face card, or Pareidolia is present
return (
card->rank == JACK ||
card->rank == QUEEN ||
card->rank == KING ||
is_joker_owned(PAREIDOLIA_JOKER_ID)
);
}
/* Copies the appropriate item into the top left panel (blind/shop icon)
* from where it was put outside the screenview
*/
+1 -1
View File
@@ -157,7 +157,7 @@ void joker_destroy(Joker **joker)
JokerEffect joker_get_score_effect(Joker *joker, Card *scored_card)
{
const JokerInfo *jinfo = get_joker_registry_entry(joker->id);
if (!jinfo) return (JokerEffect){0};
if (!jinfo || jinfo->effect == NULL) return (JokerEffect){0};
return jinfo->effect(joker, scored_card);
}
+30 -28
View File
@@ -337,12 +337,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(hand[i]->card)) {
effect.money += 1;
}
}
@@ -354,12 +350,8 @@ static JokerEffect business_card_joker_effect(Joker *joker, Card *scored_card) {
if (scored_card == NULL)
return effect;
switch (scored_card->rank) {
case KING: case QUEEN: case JACK:
if (random() % 2 == 0)
effect.money = 2;
default:
break;
if ((random() % 2 == 0) && card_is_face(scored_card)) {
effect.money = 2;
}
return effect;
@@ -383,11 +375,8 @@ static JokerEffect scary_face_joker_effect(Joker *joker, Card *scored_card) {
if (scored_card == NULL)
return effect;
switch (scored_card->rank) {
case KING: case QUEEN: case JACK:
effect.chips = 30;
default:
break;
if (card_is_face(scored_card)) {
effect.chips = 30;
}
return effect;
@@ -420,11 +409,8 @@ static JokerEffect smiley_face_joker_effect(Joker *joker, Card *scored_card) {
if (scored_card == NULL)
return effect;
switch (scored_card->rank) {
case KING: case QUEEN: case JACK:
effect.mult = 5;
default:
break;
if (card_is_face(scored_card)) {
effect.mult = 5;
}
return effect;
@@ -458,7 +444,21 @@ static JokerEffect odd_todd_joker_effect(Joker *joker, Card *scored_card) {
return effect;
}
static JokerEffect the_duo_joker_effect(Joker *joker, Card *scored_card) {
__attribute__((unused))
static JokerEffect acrobat_joker_effect(Joker *joker, Card *scored_card) {
JokerEffect effect = {0};
if (scored_card == NULL)
return effect;
// 0 remaining hands mean we're scoring the last hand
if (get_num_hands_remaining() == 0) {
effect.xmult = 3;
}
return effect;
}
static JokerEffect the_duo_joker_effect(Joker *joker, Card *scored_card) {
JokerEffect effect = {0};
if (scored_card != NULL)
return effect; // if card != null, we are not at the end-phase of scoring yet
@@ -473,7 +473,7 @@ static JokerEffect odd_todd_joker_effect(Joker *joker, Card *scored_card) {
return effect;
}
static JokerEffect the_trio_joker_effect(Joker *joker, Card *scored_card) {
static JokerEffect the_trio_joker_effect(Joker *joker, Card *scored_card) {
JokerEffect effect = {0};
if (scored_card != NULL)
return effect; // if card != null, we are not at the end-phase of scoring yet
@@ -488,7 +488,7 @@ static JokerEffect odd_todd_joker_effect(Joker *joker, Card *scored_card) {
return effect;
}
static JokerEffect the_family_joker_effect(Joker *joker, Card *scored_card) {
static JokerEffect the_family_joker_effect(Joker *joker, Card *scored_card) {
JokerEffect effect = {0};
if (scored_card != NULL)
return effect; // if card != null, we are not at the end-phase of scoring yet
@@ -503,7 +503,7 @@ static JokerEffect odd_todd_joker_effect(Joker *joker, Card *scored_card) {
return effect;
}
static JokerEffect the_order_joker_effect(Joker *joker, Card *scored_card) {
static JokerEffect the_order_joker_effect(Joker *joker, Card *scored_card) {
JokerEffect effect = {0};
if (scored_card != NULL)
return effect; // if card != null, we are not at the end-phase of scoring yet
@@ -517,7 +517,7 @@ static JokerEffect odd_todd_joker_effect(Joker *joker, Card *scored_card) {
return effect;
}
static JokerEffect the_tribe_joker_effect(Joker *joker, Card *scored_card) {
static JokerEffect the_tribe_joker_effect(Joker *joker, Card *scored_card) {
JokerEffect effect = {0};
if (scored_card != NULL)
return effect; // if card != null, we are not at the end-phase of scoring yet
@@ -674,6 +674,8 @@ const JokerInfo joker_registry[] = {
// The following jokers don't have sprites yet,
// uncomment them when their sprites are added.
#if 0
{ UNCOMMON_JOKER, 5, NULL /* Pareidolia */ }, // 41
{ UNCOMMON_JOKER, 6, acrobat_joker_effect },
{ UNCOMMON_JOKER, 7, bootstraps_joker_effect},
{ COMMON_JOKER, 5, shoot_the_moon_joker_effect},
#endif
@@ -690,4 +692,4 @@ const JokerInfo* get_joker_registry_entry(int joker_id) {
size_t get_joker_registry_size(void) {
return joker_registry_size;
}
}