Defining a basic system for jokers

This commit is contained in:
cellos51
2025-07-17 21:47:50 -04:00
parent ea2e503222
commit 4a5644eddb
10 changed files with 139 additions and 23 deletions
+1
View File
@@ -0,0 +1 @@
-gB4 -Mw4 -Mh4 -m!
Binary file not shown.

After

Width:  |  Height:  |  Size: 862 B

+1 -1
View File
@@ -38,7 +38,7 @@ enum BlindState
BLIND_SKIPPED
};
void blinds_init();
void blind_init();
int blind_get_requirement(int type, int ante);
int blind_get_reward(int type);
+3
View File
@@ -52,6 +52,9 @@ typedef struct
bool selected;
} CardObject;
// Card functions
void card_init();
// Card methods
Card *card_new(u8 suit, u8 rank);
void card_destroy(Card **card);
+79
View File
@@ -0,0 +1,79 @@
#ifndef JOKER_H
#define JOKER_H
#define JOKER_TID 880 // Tile ID for the starting index in the tile memory
#define JOKER_PB 4 // Palette bank for the default jokers
#include "sprite.h"
#include "card.h"
#define BASE_EDITION 0
#define FOIL_EDITION 1
#define HOLO_EDITION 2
#define POLY_EDITION 3
#define NEGATIVE_EDITION 4
#define COMMON_JOKER 0
#define UNCOMMON_JOKER 1
#define RARE_JOKER 2
#define LEGENDARY_JOKER 3
#define MAX_JOKERS 2 // The current maximum jokers added
#define DEFAULT_JOKER_ID 0
#define GREEDY_JOKER_ID 1 // This is just an example to show the patern of making joker IDs
typedef struct
{
u8 id; // Unique ID for the joker, used to identify different jokers
u8 modifier; // base, foil, holo, poly, negative
u8 value;
u8 rarity;
} Joker;
typedef struct // copy of CardObject in card.h
{
Joker *joker;
Sprite *sprite;
FIXED tx, ty;
FIXED x, y;
FIXED vx, vy;
FIXED tscale;
FIXED scale;
FIXED vscale;
FIXED trotation;
FIXED rotation;
FIXED vrotation;
} JokerObject;
typedef struct // These jokers are triggered after the played hand has finished scoring.
{
int chips;
int mult;
int xmult;
int money;
bool retrigger; // Retrigger played hand (e.g. "Dusk" joker, even though on the wiki it says "On Scored" it makes more sense to have it here)
} IndependentEffect;
typedef struct
{
int chips;
int mult;
int xmult;
int money;
bool retrigger; // Retrigger scored card
} OnScoredEffect;
void joker_init();
Joker *joker_new(u8 id);
void joker_destroy(Joker **joker);
// Unique effects like "Four Fingers" or "Credit Card" will be hard coded into game.c with a conditional check for the joker ID from the players owned jokers
// game.c should probably be restructured so most of the variables in it are moved to some sort of global variable header file so they can be easily accessed and modified for the jokers
IndependentEffect joker_independent_effect(Joker *joker);
OnScoredEffect joker_on_scored(Joker *joker, Card *scored_card);
void joker_object_score(JokerObject *joker_object); // This doesn't actually score anything, it just performs an animation and plays a sound effect
#endif // JOKER_H
+5 -9
View File
@@ -4,24 +4,20 @@
#include "blinds_gfx.h"
#include "graphic_utils.h"
// Palettes for the blinds (Transparency, Text Color, Shadow, Highlight, Main Color) Use this: http://www.budmelvin.com/dev/15bitconverter.html
static const u16 small_blind_token_palette[PAL_ROW_LEN] = {0x0000, 0x7FFF, 0x34A1, 0x5DCB, 0x5104, 0x55A0, 0x2D01, 0x34E0};
static const u16 big_blind_token_palette[PAL_ROW_LEN] = {0x0000, 0x2527, 0x15F5, 0x36FC, 0x1E9C, 0x01B4, 0x0D0A, 0x010E};
static const u16 boss_blind_token_palette[PAL_ROW_LEN] = {0x0000, 0x2CC9, 0x3D0D, 0x5E14, 0x5171}; // This variable is temporary, each boss blind will have its own unique palette
void blinds_init()
void blind_init()
{
// Blind graphics (fighting grit every step of the way as usual)
GRIT_CPY(&tile_mem[4][SMALL_BLIND_TID], blinds_gfxTiles);
// Palettes for the blinds (Transparency, Text Color, Shadow, Highlight, Main Color) Use this: http://www.budmelvin.com/dev/15bitconverter.html
// Small Blind
memcpy16(&pal_obj_mem[16 * SMALL_BLIND_PB], &small_blind_token_palette, sizeof(small_blind_token_palette) / 2);
// Big Blind
memcpy16(&pal_obj_mem[16 * BIG_BLIND_PB], &big_blind_token_palette, sizeof(big_blind_token_palette) / 2);
memcpy16(&pal_obj_mem[PAL_ROW_LEN * SMALL_BLIND_PB], &small_blind_token_palette, sizeof(small_blind_token_palette) / 2);
memcpy16(&pal_obj_mem[PAL_ROW_LEN * BIG_BLIND_PB], &big_blind_token_palette, sizeof(big_blind_token_palette) / 2);
// Boss Blind (This is temporary. Each boss blind is unique and will have to have its own graphics and palette which will probably be stored in some huge array)
memcpy16(&pal_obj_mem[16 * BOSS_BLIND_PB], &boss_blind_token_palette, sizeof(boss_blind_token_palette) / 2);
memcpy16(&pal_obj_mem[PAL_ROW_LEN * BOSS_BLIND_PB], &boss_blind_token_palette, sizeof(boss_blind_token_palette) / 2);
}
int blind_get_requirement(int type, int ante)
+8
View File
@@ -3,6 +3,8 @@
#include <maxmod.h>
#include <stdlib.h>
#include "deck_gfx.h"
// Audio
#include "soundbank.h"
@@ -14,6 +16,12 @@ const static u16 card_sprite_lut[NUM_SUITS][NUM_RANKS] = {
{624, 640, 656, 672, 688, 704, 720, 736, 752, 768, 784, 800, 816}
};
void card_init()
{
GRIT_CPY(&tile_mem[4], deck_gfxTiles);
GRIT_CPY(pal_obj_mem, deck_gfxPal);
}
// Card methods
Card *card_new(u8 suit, u8 rank)
{
+2 -7
View File
@@ -776,11 +776,6 @@ void hand_set_focus(int index)
mmEffectEx(&sfx_focus);
}
int hand_get_focus()
{
return card_focused;
}
void hand_select()
{
if (hand_state != HAND_SELECT || hand[card_focused] == NULL) return;
@@ -978,11 +973,11 @@ static void game_playing_process_input_and_state()
{
if (key_hit(KEY_LEFT))
{
hand_set_focus(hand_get_focus() + 1); // The reason why this adds 1 is because the hand is drawn from right to left. There is no particular reason for this, it's just how I did it.
hand_set_focus(card_focused + 1); // The reason why this adds 1 is because the hand is drawn from right to left. There is no particular reason for this, it's just how I did it.
}
else if (key_hit(KEY_RIGHT))
{
hand_set_focus(hand_get_focus() - 1);
hand_set_focus(card_focused - 1);
}
if (key_hit(KEY_A))
+36
View File
@@ -0,0 +1,36 @@
#include <tonc.h>
#include "joker.h"
#include "joker_gfx.h"
#include "graphic_utils.h"
const static u8 joker_data_lut[MAX_JOKERS][2] = // Rarity, Value
{
{COMMON_JOKER, 2}, // Default Joker
{COMMON_JOKER, 5}, // Greedy Joker
};
void joker_init()
{
GRIT_CPY(&tile_mem[4][JOKER_TID], joker_gfxTiles);
memcpy16(&pal_obj_mem[PAL_ROW_LEN * JOKER_PB], joker_gfxPal, sizeof(joker_gfxPal) / 2);
}
Joker *joker_new(u8 id)
{
Joker *joker = malloc(sizeof(Joker));
joker->id = id; // TODO: Make this random later
joker->modifier = BASE_EDITION; // TODO: Make this random later
joker->value = joker_data_lut[id][1];
joker->rarity = joker_data_lut[id][0];
return joker;
}
void joker_destroy(Joker **joker)
{
if (*joker == NULL) return;
free(*joker);
*joker = NULL;
}
+4 -6
View File
@@ -6,10 +6,10 @@
#include "card.h"
#include "game.h"
#include "blind.h"
#include "joker.h"
#include "graphic_utils.h"
// Graphics
#include "deck_gfx.h"
#include "background_gfx.h"
#include "affine_background_gfx.h"
@@ -60,10 +60,6 @@ void init()
pal_bg_bank[14][15] = 0x213F; // Red
pal_bg_bank[15][15] = CLR_WHITE;
// Deck graphics
GRIT_CPY(&tile_mem[4], deck_gfxTiles);
GRIT_CPY(pal_obj_mem, deck_gfxPal);
// Set up the video mode
// BG0 is the TTE text layer
REG_BG0CNT = BG_PRIO(0) | BG_CBB(TTE_CBB) | BG_SBB(TTE_SBB) | BG_4BPP;
@@ -101,7 +97,9 @@ void init()
// Initialize subsystems
sprite_init();
blinds_init();
card_init();
blind_init();
joker_init();
game_init();
}