Adds XMult, Joker Stencil and Misprint (rebase)
This commit is contained in:
+7
-4
@@ -74,9 +74,12 @@ void game_update();
|
||||
|
||||
// Utility functions for other files
|
||||
typedef struct CardObject CardObject; // forward declaration, actually declared in card.h
|
||||
CardObject **get_hand_array(void);
|
||||
CardObject **get_played_array(void);
|
||||
int get_hand_top(void);
|
||||
int get_played_top(void);
|
||||
typedef struct JokerObject JokerObject;
|
||||
CardObject** get_hand_array(void);
|
||||
int get_hand_top(void);
|
||||
CardObject** get_played_array(void);
|
||||
int get_played_top(void);
|
||||
JokerObject** get_jokers(void);
|
||||
int get_jokers_top(void);
|
||||
|
||||
#endif // GAME_H
|
||||
+1
-1
@@ -39,7 +39,7 @@ typedef struct
|
||||
bool processed;
|
||||
} Joker;
|
||||
|
||||
typedef struct // copy of CardObject in card.h
|
||||
typedef struct JokerObject // copy of CardObject in card.h
|
||||
{
|
||||
Joker *joker;
|
||||
SpriteObject* sprite_object;
|
||||
|
||||
+27
-16
@@ -214,6 +214,31 @@ static const Rect SHOP_REROLL_RECT = {88, 96, UNDEFINED, UNDEFI
|
||||
#define PITCH_STEP_UNDISCARD_SFX 2*PITCH_STEP_DRAW_SFX
|
||||
// Naming the stage where cards return from the discard pile to the deck "undiscard"
|
||||
|
||||
// get-functions, for other files to view game state (mainly for jokers)
|
||||
CardObject **get_hand_array(void) {
|
||||
return hand;
|
||||
}
|
||||
|
||||
int get_hand_top(void) {
|
||||
return hand_top;
|
||||
}
|
||||
|
||||
CardObject **get_played_array(void) {
|
||||
return played;
|
||||
}
|
||||
|
||||
int get_played_top(void) {
|
||||
return played_top;
|
||||
}
|
||||
|
||||
JokerObject **get_jokers(void) {
|
||||
return jokers;
|
||||
}
|
||||
|
||||
int get_jokers_top(void) {
|
||||
return jokers_top;
|
||||
}
|
||||
|
||||
// General functions
|
||||
void set_seed(int seed)
|
||||
{
|
||||
@@ -290,22 +315,6 @@ void sort_cards()
|
||||
}
|
||||
}
|
||||
|
||||
CardObject **get_hand_array(void) {
|
||||
return hand;
|
||||
}
|
||||
|
||||
int get_hand_top(void) {
|
||||
return hand_top;
|
||||
}
|
||||
|
||||
CardObject **get_played_array(void) {
|
||||
return played;
|
||||
}
|
||||
|
||||
int get_played_top(void) {
|
||||
return played_top;
|
||||
}
|
||||
|
||||
enum HandType hand_get_type()
|
||||
{
|
||||
enum HandType res_hand_type = NONE;
|
||||
@@ -1813,6 +1822,8 @@ static void game_shop_create_items(JokerObject *shop_jokers[], bool first_time)
|
||||
}
|
||||
|
||||
u8 joker_id = random() % get_joker_registry_size();
|
||||
// TODO: don't pick a joker that we already own
|
||||
// TODO: weight the random choice by joker rarity
|
||||
|
||||
shop_jokers[i] = joker_object_new(joker_new(joker_id));
|
||||
shop_jokers[i]->sprite_object->x = int2fx(120 + i * 32);
|
||||
|
||||
+6
-1
@@ -229,7 +229,7 @@ bool joker_object_score(JokerObject *joker_object, Card* scored_card, int *chips
|
||||
{
|
||||
*chips += joker_effect.chips;
|
||||
*mult += joker_effect.mult;
|
||||
// TODO: XMult
|
||||
*mult *= joker_effect.xmult > 0 ? joker_effect.xmult : 1; // if xmult is zero, DO NOT multiply by it
|
||||
*money += joker_effect.money;
|
||||
// TODO: Retrigger
|
||||
|
||||
@@ -247,6 +247,11 @@ bool joker_object_score(JokerObject *joker_object, Card* scored_card, int *chips
|
||||
tte_set_special(0xE000); // Red
|
||||
snprintf(score_buffer, sizeof(score_buffer), "+%d", joker_effect.mult);
|
||||
}
|
||||
else if (joker_effect.xmult > 0)
|
||||
{
|
||||
tte_set_special(0xE000); // Red
|
||||
snprintf(score_buffer, sizeof(score_buffer), "X%d", joker_effect.xmult);
|
||||
}
|
||||
else if (joker_effect.money > 0)
|
||||
{
|
||||
tte_set_special(0xC000); // Yellow
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "joker.h"
|
||||
#include "util.h"
|
||||
#include "hand_analysis.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
static const int JOKER_STENCIL_ID = 16;
|
||||
|
||||
static JokerEffect default_joker_effect(Joker *joker, Card *scored_card) {
|
||||
JokerEffect effect = {0};
|
||||
@@ -184,6 +186,36 @@ static JokerEffect half_joker_effect(Joker *joker, Card *scored_card) {
|
||||
return effect;
|
||||
}
|
||||
|
||||
static JokerEffect joker_stencil_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
|
||||
|
||||
// +1 xmult per empty joker slot...
|
||||
int jokers_top = get_jokers_top();
|
||||
effect.xmult = (MAX_JOKERS_HELD_SIZE-1) - jokers_top;
|
||||
|
||||
// ...and also each stencil_joker adds +1 xmult
|
||||
JokerObject** jokers = get_jokers();
|
||||
for (int i = 0; i < jokers_top; i++ )
|
||||
{
|
||||
if (jokers[i]->joker->id == JOKER_STENCIL_ID)
|
||||
effect.xmult++;
|
||||
}
|
||||
|
||||
return effect;
|
||||
}
|
||||
|
||||
static JokerEffect misprint_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
|
||||
|
||||
effect.mult = random() % 24;
|
||||
|
||||
return effect;
|
||||
}
|
||||
|
||||
const JokerInfo joker_registry[] = {
|
||||
{ COMMON_JOKER, 2, default_joker_effect }, // DEFAULT_JOKER_ID = 0
|
||||
{ COMMON_JOKER, 5, greedy_joker_effect }, // GREEDY_JOKER_ID = 1
|
||||
@@ -201,6 +233,8 @@ const JokerInfo joker_registry[] = {
|
||||
{ COMMON_JOKER, 4, devious_joker_effect },
|
||||
{ COMMON_JOKER, 4, crafty_joker_effect },
|
||||
{ COMMON_JOKER, 5, half_joker_effect },
|
||||
{ UNCOMMON_JOKER, 8, joker_stencil_effect },
|
||||
{ COMMON_JOKER, 4, misprint_joker_effect },
|
||||
};
|
||||
|
||||
static const size_t joker_registry_size = NUM_ELEM_IN_ARR(joker_registry);
|
||||
|
||||
Reference in New Issue
Block a user