Merge pull request #159 from MathisMartin31/main
Add Pareidolia and Acrobat Jokers
This commit is contained in:
+1
-1
@@ -38,7 +38,7 @@
|
|||||||
#define IMPOSSIBLY_HIGH_CARD_VALUE 100
|
#define IMPOSSIBLY_HIGH_CARD_VALUE 100
|
||||||
|
|
||||||
// Card types
|
// Card types
|
||||||
typedef struct
|
typedef struct Card
|
||||||
{
|
{
|
||||||
u8 suit;
|
u8 suit;
|
||||||
u8 rank;
|
u8 rank;
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ typedef struct List List;
|
|||||||
|
|
||||||
// Utility functions for other files
|
// Utility functions for other files
|
||||||
typedef struct CardObject CardObject; // forward declaration, actually declared in card.h
|
typedef struct CardObject CardObject; // forward declaration, actually declared in card.h
|
||||||
|
typedef struct Card Card;
|
||||||
typedef struct JokerObject JokerObject;
|
typedef struct JokerObject JokerObject;
|
||||||
CardObject** get_hand_array(void);
|
CardObject** get_hand_array(void);
|
||||||
int get_hand_top(void);
|
int get_hand_top(void);
|
||||||
@@ -93,9 +94,12 @@ int hand_get_size(void);
|
|||||||
CardObject** get_played_array(void);
|
CardObject** get_played_array(void);
|
||||||
int get_played_top(void);
|
int get_played_top(void);
|
||||||
List* get_jokers(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_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
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#define GREEDY_JOKER_ID 1 // This is just an example to show the patern of making joker IDs
|
#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_STENCIL_ID 16
|
||||||
#define JOKER_BRAINSTORM_ID 40
|
#define JOKER_BRAINSTORM_ID 40
|
||||||
|
#define PAREIDOLIA_JOKER_ID 41
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|||||||
+34
-3
@@ -192,6 +192,18 @@ List *get_jokers(void) {
|
|||||||
return jokers;
|
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)
|
void add_joker(JokerObject *joker_object)
|
||||||
{
|
{
|
||||||
list_append(jokers, 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);
|
list_remove_by_idx(jokers, joker_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_deck_top(void) {
|
int get_deck_top(void)
|
||||||
|
{
|
||||||
return deck_top;
|
return deck_top;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_num_discards_remaining(void) {
|
int get_num_discards_remaining(void)
|
||||||
|
{
|
||||||
return discards;
|
return discards;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_money(void) {
|
int get_num_hands_remaining(void)
|
||||||
|
{
|
||||||
|
return hands;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_money(void)
|
||||||
|
{
|
||||||
return money;
|
return money;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,6 +538,17 @@ enum HandType hand_get_type()
|
|||||||
return res_hand_type; // should be HIGH_CARD
|
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)
|
/* Copies the appropriate item into the top left panel (blind/shop icon)
|
||||||
* from where it was put outside the screenview
|
* from where it was put outside the screenview
|
||||||
*/
|
*/
|
||||||
|
|||||||
+1
-1
@@ -157,7 +157,7 @@ void joker_destroy(Joker **joker)
|
|||||||
JokerEffect joker_get_score_effect(Joker *joker, Card *scored_card)
|
JokerEffect joker_get_score_effect(Joker *joker, Card *scored_card)
|
||||||
{
|
{
|
||||||
const JokerInfo *jinfo = get_joker_registry_entry(joker->id);
|
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);
|
return jinfo->effect(joker, scored_card);
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-18
@@ -337,12 +337,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(hand[i]->card)) {
|
||||||
case KING: case QUEEN: case JACK:
|
|
||||||
if (random() % 2 == 0)
|
|
||||||
effect.money += 1;
|
effect.money += 1;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,12 +350,8 @@ static JokerEffect business_card_joker_effect(Joker *joker, Card *scored_card) {
|
|||||||
if (scored_card == NULL)
|
if (scored_card == NULL)
|
||||||
return effect;
|
return effect;
|
||||||
|
|
||||||
switch (scored_card->rank) {
|
if ((random() % 2 == 0) && card_is_face(scored_card)) {
|
||||||
case KING: case QUEEN: case JACK:
|
|
||||||
if (random() % 2 == 0)
|
|
||||||
effect.money = 2;
|
effect.money = 2;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return effect;
|
return effect;
|
||||||
@@ -383,11 +375,8 @@ static JokerEffect scary_face_joker_effect(Joker *joker, Card *scored_card) {
|
|||||||
if (scored_card == NULL)
|
if (scored_card == NULL)
|
||||||
return effect;
|
return effect;
|
||||||
|
|
||||||
switch (scored_card->rank) {
|
if (card_is_face(scored_card)) {
|
||||||
case KING: case QUEEN: case JACK:
|
|
||||||
effect.chips = 30;
|
effect.chips = 30;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return effect;
|
return effect;
|
||||||
@@ -420,11 +409,8 @@ static JokerEffect smiley_face_joker_effect(Joker *joker, Card *scored_card) {
|
|||||||
if (scored_card == NULL)
|
if (scored_card == NULL)
|
||||||
return effect;
|
return effect;
|
||||||
|
|
||||||
switch (scored_card->rank) {
|
if (card_is_face(scored_card)) {
|
||||||
case KING: case QUEEN: case JACK:
|
|
||||||
effect.mult = 5;
|
effect.mult = 5;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return effect;
|
return effect;
|
||||||
@@ -458,6 +444,20 @@ static JokerEffect odd_todd_joker_effect(Joker *joker, Card *scored_card) {
|
|||||||
return effect;
|
return effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__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) {
|
static JokerEffect the_duo_joker_effect(Joker *joker, Card *scored_card) {
|
||||||
JokerEffect effect = {0};
|
JokerEffect effect = {0};
|
||||||
if (scored_card != NULL)
|
if (scored_card != NULL)
|
||||||
@@ -674,6 +674,8 @@ const JokerInfo joker_registry[] = {
|
|||||||
// The following jokers don't have sprites yet,
|
// The following jokers don't have sprites yet,
|
||||||
// uncomment them when their sprites are added.
|
// uncomment them when their sprites are added.
|
||||||
#if 0
|
#if 0
|
||||||
|
{ UNCOMMON_JOKER, 5, NULL /* Pareidolia */ }, // 41
|
||||||
|
{ UNCOMMON_JOKER, 6, acrobat_joker_effect },
|
||||||
{ UNCOMMON_JOKER, 7, bootstraps_joker_effect},
|
{ UNCOMMON_JOKER, 7, bootstraps_joker_effect},
|
||||||
{ COMMON_JOKER, 5, shoot_the_moon_joker_effect},
|
{ COMMON_JOKER, 5, shoot_the_moon_joker_effect},
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user