GBAlatro
A Demake of Balatro for the GBA
Loading...
Searching...
No Matches
joker.h File Reference

Functions relative to the handling of Jokers. More...

#include "card.h"
#include "game.h"
#include "graphic_utils.h"
#include "item.h"
#include "random.h"
#include <maxmod.h>

Go to the source code of this file.

Data Structures

struct  Joker
 
struct  JokerObject
 
struct  JokerEffect
 
struct  JokerInfo
 

Macros

#define MAX_ACTIVE_JOKERS   8
 
#define MAX_DEFINABLE_JOKERS   150
 
#define JOKER_SPRITE_OFFSET   16
 
#define JOKER_STARTING_LAYER   26
 
#define JOKER_TID   (JOKER_STARTING_LAYER * JOKER_SPRITE_OFFSET)
 
#define JOKER_BASE_PB   4
 
#define JOKER_LAST_PB   (NUM_PALETTES - 1)
 
#define BASE_EDITION   0
 
#define FOIL_EDITION   1
 
#define HOLO_EDITION   2
 
#define POLY_EDITION   3
 
#define NEGATIVE_EDITION   4
 
#define MAX_EDITIONS   5
 
#define COMMON_JOKER   0
 
#define UNCOMMON_JOKER   1
 
#define RARE_JOKER   2
 
#define LEGENDARY_JOKER   3
 
#define MAX_RARITIES   (LEGENDARY_JOKER + 1)
 
#define COMMON_JOKER_CHANCE   70
 
#define UNCOMMON_JOKER_CHANCE   25
 
#define RARE_JOKER_CHANCE   5
 
#define LEGENDARY_JOKER_CHANCE   0
 
#define JOKER_EFFECT_FLAG_NONE   0
 
#define JOKER_EFFECT_FLAG_CHIPS   (1 << 0)
 
#define JOKER_EFFECT_FLAG_MULT   (1 << 1)
 
#define JOKER_EFFECT_FLAG_XMULT   (1 << 2)
 
#define JOKER_EFFECT_FLAG_MONEY   (1 << 3)
 
#define JOKER_EFFECT_FLAG_RETRIGGER   (1 << 4)
 
#define JOKER_EFFECT_FLAG_EXPIRE   (1 << 5)
 
#define JOKER_EFFECT_FLAG_MESSAGE   (1 << 6)
 
#define MAX_JOKER_OBJECTS   32
 
#define STENCIL_JOKER_ID   15
 
#define SHORTCUT_JOKER_ID   48
 
#define BRAINSTORM_JOKER_ID   41
 
#define PAREIDOLIA_JOKER_ID   46
 
#define FOUR_FINGERS_JOKER_ID   50
 
#define BLUEPRINT_JOKER_ID   52
 

Typedefs

typedef struct JokerObject JokerObject
 
typedef u32(* JokerEffectFunc) (Joker *joker, Card *scored_card, enum JokerEvent joker_event, JokerEffect **joker_effect)
 
typedef int(* JokerDescFunc) (Joker *joker, Rect dest_rect)
 

Enumerations

enum  JokerEvent {
  JOKER_EVENT_ON_JOKER_CREATED , JOKER_EVENT_ON_HAND_PLAYED , JOKER_EVENT_ON_CARD_SCORED , JOKER_EVENT_ON_CARD_SCORED_END ,
  JOKER_EVENT_ON_CARD_HELD , JOKER_EVENT_INDEPENDENT , JOKER_EVENT_ON_HAND_SCORED_END , JOKER_EVENT_ON_HAND_DISCARDED ,
  JOKER_EVENT_ON_ROUND_END , JOKER_EVENT_ON_BLIND_SELECTED
}
 

Functions

const JokerInfoget_joker_registry_entry (int joker_id)
 
size_t get_joker_registry_size (void)
 
void joker_init ()
 
Jokerjoker_new (u8 id)
 
void joker_destroy (Joker **joker)
 
u32 joker_get_score_effect (Joker *joker, Card *scored_card, enum JokerEvent joker_event, JokerEffect **joker_effect)
 
const char * joker_get_rarity_string (u8 rarity)
 
u16 joker_get_rarity_color (u8 rarity, bool main_color)
 Get Joker rarity panel color.
 
int joker_get_sell_value (const Joker *joker)
 
JokerObjectjoker_object_new (Joker *joker)
 
void joker_object_destroy (JokerObject **joker_object)
 
void joker_object_shake (JokerObject *joker_object, mm_word sound_id)
 
int joker_object_get_buy_price (Item *joker_object)
 Returns the buy price of the joker object.
 
void joker_object_add_to_owned (Item *joker_object)
 Add a Joker to the list of owned Jokers and place it in the joker row.
 
void joker_object_dispose (Item **joker_object)
 Destroy a JokerObject item, free its resources, and make it available to be rolled.
 
void joker_set_rollable (int joker_id, bool rollable)
 Set whether a Joker is available to be rolled for the shop, packs, etc.
 
void joker_reset_rollable_jokers (void)
 Reset rollable jokers to include all jokers in the registry.
 
Itemjoker_object_roll_new (enum RngSequence key)
 Roll and create a new JokerObject item.
 
bool joker_object_score (JokerObject *joker_object, CardObject *card_object, enum JokerEvent joker_event)
 
Spritejoker_object_get_sprite (JokerObject *joker_object)
 

Detailed Description

Functions relative to the handling of Jokers.

Definition in file joker.h.

Macro Definition Documentation

◆ BASE_EDITION

#define BASE_EDITION   0

Definition at line 33 of file joker.h.

◆ BLUEPRINT_JOKER_ID

#define BLUEPRINT_JOKER_ID   52

Definition at line 99 of file joker.h.

◆ BRAINSTORM_JOKER_ID

#define BRAINSTORM_JOKER_ID   41

Definition at line 96 of file joker.h.

◆ COMMON_JOKER

#define COMMON_JOKER   0

Definition at line 41 of file joker.h.

◆ COMMON_JOKER_CHANCE

#define COMMON_JOKER_CHANCE   70

Definition at line 51 of file joker.h.

◆ FOIL_EDITION

#define FOIL_EDITION   1

Definition at line 34 of file joker.h.

◆ FOUR_FINGERS_JOKER_ID

#define FOUR_FINGERS_JOKER_ID   50

Definition at line 98 of file joker.h.

◆ HOLO_EDITION

#define HOLO_EDITION   2

Definition at line 35 of file joker.h.

◆ JOKER_BASE_PB

#define JOKER_BASE_PB   4

Definition at line 27 of file joker.h.

◆ JOKER_EFFECT_FLAG_CHIPS

#define JOKER_EFFECT_FLAG_CHIPS   (1 << 0)

Definition at line 83 of file joker.h.

◆ JOKER_EFFECT_FLAG_EXPIRE

#define JOKER_EFFECT_FLAG_EXPIRE   (1 << 5)

Definition at line 88 of file joker.h.

◆ JOKER_EFFECT_FLAG_MESSAGE

#define JOKER_EFFECT_FLAG_MESSAGE   (1 << 6)

Definition at line 89 of file joker.h.

◆ JOKER_EFFECT_FLAG_MONEY

#define JOKER_EFFECT_FLAG_MONEY   (1 << 3)

Definition at line 86 of file joker.h.

◆ JOKER_EFFECT_FLAG_MULT

#define JOKER_EFFECT_FLAG_MULT   (1 << 1)

Definition at line 84 of file joker.h.

◆ JOKER_EFFECT_FLAG_NONE

#define JOKER_EFFECT_FLAG_NONE   0

Definition at line 82 of file joker.h.

◆ JOKER_EFFECT_FLAG_RETRIGGER

#define JOKER_EFFECT_FLAG_RETRIGGER   (1 << 4)

Definition at line 87 of file joker.h.

◆ JOKER_EFFECT_FLAG_XMULT

#define JOKER_EFFECT_FLAG_XMULT   (1 << 2)

Definition at line 85 of file joker.h.

◆ JOKER_LAST_PB

#define JOKER_LAST_PB   (NUM_PALETTES - 1)

Definition at line 28 of file joker.h.

◆ JOKER_SPRITE_OFFSET

#define JOKER_SPRITE_OFFSET   16

Definition at line 23 of file joker.h.

◆ JOKER_STARTING_LAYER

#define JOKER_STARTING_LAYER   26

Definition at line 24 of file joker.h.

◆ JOKER_TID

#define JOKER_TID   (JOKER_STARTING_LAYER * JOKER_SPRITE_OFFSET)

Definition at line 26 of file joker.h.

◆ LEGENDARY_JOKER

#define LEGENDARY_JOKER   3

Definition at line 44 of file joker.h.

◆ LEGENDARY_JOKER_CHANCE

#define LEGENDARY_JOKER_CHANCE   0

Definition at line 54 of file joker.h.

◆ MAX_ACTIVE_JOKERS

#define MAX_ACTIVE_JOKERS   8

Definition at line 19 of file joker.h.

◆ MAX_DEFINABLE_JOKERS

#define MAX_DEFINABLE_JOKERS   150

Definition at line 21 of file joker.h.

◆ MAX_EDITIONS

#define MAX_EDITIONS   5

Definition at line 39 of file joker.h.

◆ MAX_JOKER_OBJECTS

#define MAX_JOKER_OBJECTS   32

Definition at line 91 of file joker.h.

◆ MAX_RARITIES

#define MAX_RARITIES   (LEGENDARY_JOKER + 1)

Definition at line 46 of file joker.h.

◆ NEGATIVE_EDITION

#define NEGATIVE_EDITION   4

Definition at line 37 of file joker.h.

◆ PAREIDOLIA_JOKER_ID

#define PAREIDOLIA_JOKER_ID   46

Definition at line 97 of file joker.h.

◆ POLY_EDITION

#define POLY_EDITION   3

Definition at line 36 of file joker.h.

◆ RARE_JOKER

#define RARE_JOKER   2

Definition at line 43 of file joker.h.

◆ RARE_JOKER_CHANCE

#define RARE_JOKER_CHANCE   5

Definition at line 53 of file joker.h.

◆ SHORTCUT_JOKER_ID

#define SHORTCUT_JOKER_ID   48

Definition at line 95 of file joker.h.

◆ STENCIL_JOKER_ID

#define STENCIL_JOKER_ID   15

Definition at line 94 of file joker.h.

◆ UNCOMMON_JOKER

#define UNCOMMON_JOKER   1

Definition at line 42 of file joker.h.

◆ UNCOMMON_JOKER_CHANCE

#define UNCOMMON_JOKER_CHANCE   25

Definition at line 52 of file joker.h.

Typedef Documentation

◆ JokerDescFunc

typedef int(* JokerDescFunc) (Joker *joker, Rect dest_rect)

Definition at line 143 of file joker.h.

◆ JokerEffectFunc

typedef u32(* JokerEffectFunc) (Joker *joker, Card *scored_card, enum JokerEvent joker_event, JokerEffect **joker_effect)

Definition at line 136 of file joker.h.

Enumeration Type Documentation

◆ JokerEvent

enum JokerEvent

Definition at line 58 of file joker.h.

Function Documentation

◆ get_joker_registry_entry()

const JokerInfo * get_joker_registry_entry ( int  joker_id)

Definition at line 248 of file joker_effects.c.

◆ get_joker_registry_size()

size_t get_joker_registry_size ( void  )

Definition at line 257 of file joker_effects.c.

◆ joker_destroy()

void joker_destroy ( Joker **  joker)

Definition at line 151 of file joker.c.

◆ joker_get_rarity_color()

u16 joker_get_rarity_color ( u8  rarity,
bool  main_color 
)

Get Joker rarity panel color.

The colors are organized in the card_rarity_pal_gfx.png file which is organized like this:

  • 0 -> transparency
  • 1,2 -> Common Joker
  • 3,4 -> Uncommon Joker
  • 5,6 -> Rare Joker
  • 7,8 -> Legendary Joker / Tarot Card
  • 9,10 -> Planet Card
  • 11,12 -> Spectral Card
  • 13,14 -> Voucher
Parameters
rarityValue of the rarity (Common, Rare...)
main_colorWhether we want the main or shadow color
Returns
u16 value of the color, not a pointer

Definition at line 179 of file joker.c.

◆ joker_get_rarity_string()

const char * joker_get_rarity_string ( u8  rarity)

Definition at line 171 of file joker.c.

◆ joker_get_score_effect()

u32 joker_get_score_effect ( Joker joker,
Card scored_card,
enum JokerEvent  joker_event,
JokerEffect **  joker_effect 
)

Definition at line 157 of file joker.c.

◆ joker_get_sell_value()

int joker_get_sell_value ( const Joker joker)

Definition at line 196 of file joker.c.

◆ joker_init()

void joker_init ( )

Definition at line 118 of file joker.c.

◆ joker_new()

Joker * joker_new ( u8  id)

Definition at line 129 of file joker.c.

◆ joker_object_add_to_owned()

void joker_object_add_to_owned ( Item joker_object)

Add a Joker to the list of owned Jokers and place it in the joker row.

Parameters
joker_objectThe JokerObject to add cast to Item*

Definition at line 301 of file joker.c.

◆ joker_object_destroy()

void joker_object_destroy ( JokerObject **  joker_object)

Definition at line 252 of file joker.c.

◆ joker_object_dispose()

void joker_object_dispose ( Item **  joker_object)

Destroy a JokerObject item, free its resources, and make it available to be rolled.

Parameters
joker_objectPointer to the JokerObject Item* to destroy; set to NULL.

Definition at line 273 of file joker.c.

◆ joker_object_get_buy_price()

int joker_object_get_buy_price ( Item joker_object)

Returns the buy price of the joker object.

Parameters
joker_objectthe joker object whose price to return.
Returns
UNDEFINED in case of error, the buy price of the joker otherwise.

Definition at line 293 of file joker.c.

◆ joker_object_get_sprite()

Sprite * joker_object_get_sprite ( JokerObject joker_object)

Definition at line 563 of file joker.c.

◆ joker_object_new()

JokerObject * joker_object_new ( Joker joker)

Definition at line 204 of file joker.c.

◆ joker_object_roll_new()

Item * joker_object_roll_new ( enum RngSequence  key)

Roll and create a new JokerObject item.

Parameters
keyto the RNG sequence that will be used to roll the Joker ID.
Returns
Newly created Item* (JokerObject) or NULL if none available.

Definition at line 389 of file joker.c.

◆ joker_object_score()

bool joker_object_score ( JokerObject joker_object,
CardObject card_object,
enum JokerEvent  joker_event 
)

Definition at line 464 of file joker.c.

◆ joker_object_shake()

void joker_object_shake ( JokerObject joker_object,
mm_word  sound_id 
)

Definition at line 288 of file joker.c.

◆ joker_reset_rollable_jokers()

void joker_reset_rollable_jokers ( void  )

Reset rollable jokers to include all jokers in the registry.

Definition at line 338 of file joker.c.

◆ joker_set_rollable()

void joker_set_rollable ( int  joker_id,
bool  rollable 
)

Set whether a Joker is available to be rolled for the shop, packs, etc.

Parameters
joker_idThe ID of the joker whose availability to set.
rollabletrue to make it rollable, false otherwise.

Definition at line 310 of file joker.c.