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_DEFINABLE_JOKERS   150
 
#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  JokerRarity : u8 {
  COMMON_JOKER , UNCOMMON_JOKER , RARE_JOKER , LEGENDARY_JOKER ,
  MAX_RARITIES
}
 
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 JokerInfo * get_joker_registry_entry (int joker_id)
 
size_t get_joker_registry_size (void)
 
void joker_init ()
 
Joker * joker_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)
 
int joker_get_sell_value (const Joker *joker)
 Returns the sell value of the joker.
 
int joker_get_buy_price (const Joker *joker)
 Returns the buy price of the joker.
 
const char * joker_object_get_name (Item *joker_object)
 Get Joker name.
 
ItemDescSubtypeInfo joker_object_get_rarity_info (Item *joker_object)
 Get Joker rarity name and associated panel color.
 
JokerObject * joker_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.
 
int joker_object_get_sell_price (Item *joker_object)
 Returns the sell 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.
 
int joker_object_print_description (Item *joker_object, Rect dest_rect)
 Print the description of the requested Joker centered within the specified Rect.
 
int joker_roll_id_with_rarity (int joker_rarity)
 Rolls a random Joker among the available ones of a certain rarity.
 
int joker_roll_id (enum JokerRarity joker_rarity, enum RngSequence key)
 Rolls a random Joker among the available ones of a certain rarity.
 
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.
 
Item * joker_object_roll_new (enum RngSequence key)
 Roll and create a new JokerObject item.
 
Sprite * joker_object_get_sprite (JokerObject *joker_object)
 

Detailed Description

Functions relative to the handling of Jokers.

Definition in file joker.h.

Macro Definition Documentation

◆ BLUEPRINT_JOKER_ID

#define BLUEPRINT_JOKER_ID   52

Definition at line 80 of file joker.h.

◆ BRAINSTORM_JOKER_ID

#define BRAINSTORM_JOKER_ID   41

Definition at line 77 of file joker.h.

◆ COMMON_JOKER_CHANCE

#define COMMON_JOKER_CHANCE   70

Definition at line 32 of file joker.h.

◆ FOUR_FINGERS_JOKER_ID

#define FOUR_FINGERS_JOKER_ID   50

Definition at line 79 of file joker.h.

◆ JOKER_EFFECT_FLAG_CHIPS

#define JOKER_EFFECT_FLAG_CHIPS   (1 << 0)

Definition at line 64 of file joker.h.

◆ JOKER_EFFECT_FLAG_EXPIRE

#define JOKER_EFFECT_FLAG_EXPIRE   (1 << 5)

Definition at line 69 of file joker.h.

◆ JOKER_EFFECT_FLAG_MESSAGE

#define JOKER_EFFECT_FLAG_MESSAGE   (1 << 6)

Definition at line 70 of file joker.h.

◆ JOKER_EFFECT_FLAG_MONEY

#define JOKER_EFFECT_FLAG_MONEY   (1 << 3)

Definition at line 67 of file joker.h.

◆ JOKER_EFFECT_FLAG_MULT

#define JOKER_EFFECT_FLAG_MULT   (1 << 1)

Definition at line 65 of file joker.h.

◆ JOKER_EFFECT_FLAG_NONE

#define JOKER_EFFECT_FLAG_NONE   0

Definition at line 63 of file joker.h.

◆ JOKER_EFFECT_FLAG_RETRIGGER

#define JOKER_EFFECT_FLAG_RETRIGGER   (1 << 4)

Definition at line 68 of file joker.h.

◆ JOKER_EFFECT_FLAG_XMULT

#define JOKER_EFFECT_FLAG_XMULT   (1 << 2)

Definition at line 66 of file joker.h.

◆ LEGENDARY_JOKER_CHANCE

#define LEGENDARY_JOKER_CHANCE   0

Definition at line 35 of file joker.h.

◆ MAX_DEFINABLE_JOKERS

#define MAX_DEFINABLE_JOKERS   150

Definition at line 17 of file joker.h.

◆ MAX_JOKER_OBJECTS

#define MAX_JOKER_OBJECTS   32

Definition at line 72 of file joker.h.

◆ PAREIDOLIA_JOKER_ID

#define PAREIDOLIA_JOKER_ID   46

Definition at line 78 of file joker.h.

◆ RARE_JOKER_CHANCE

#define RARE_JOKER_CHANCE   5

Definition at line 34 of file joker.h.

◆ SHORTCUT_JOKER_ID

#define SHORTCUT_JOKER_ID   48

Definition at line 76 of file joker.h.

◆ STENCIL_JOKER_ID

#define STENCIL_JOKER_ID   15

Definition at line 75 of file joker.h.

◆ UNCOMMON_JOKER_CHANCE

#define UNCOMMON_JOKER_CHANCE   25

Definition at line 33 of file joker.h.

Typedef Documentation

◆ JokerDescFunc

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

Definition at line 123 of file joker.h.

◆ JokerEffectFunc

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

Definition at line 116 of file joker.h.

Enumeration Type Documentation

◆ JokerEvent

enum JokerEvent

Definition at line 39 of file joker.h.

◆ JokerRarity

enum JokerRarity : u8

Definition at line 20 of file joker.h.

Function Documentation

◆ get_joker_registry_entry()

const JokerInfo * get_joker_registry_entry ( int  joker_id)

Definition at line 247 of file joker_effects.c.

◆ get_joker_registry_size()

size_t get_joker_registry_size ( void  )

Definition at line 256 of file joker_effects.c.

◆ joker_destroy()

void joker_destroy ( Joker **  joker)

Definition at line 138 of file joker.c.

◆ joker_get_buy_price()

int joker_get_buy_price ( const Joker *  joker)

Returns the buy price of the joker.

Parameters
jokerPointer to the joker - if NULL returns UNDEFINED
Returns
UNDEFINED if error occurred, the joker's sell value otherwise

Definition at line 201 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 144 of file joker.c.

◆ joker_get_sell_value()

int joker_get_sell_value ( const Joker *  joker)

Returns the sell value of the joker.

Parameters
jokerPointer to the joker - if NULL returns UNDEFINED
Returns
UNDEFINED if error occurred, the joker's sell value otherwise

Definition at line 208 of file joker.c.

◆ joker_init()

void joker_init ( )

Definition at line 106 of file joker.c.

◆ joker_new()

Joker * joker_new ( u8  id)

Definition at line 117 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 337 of file joker.c.

◆ joker_object_destroy()

void joker_object_destroy ( JokerObject **  joker_object)

Definition at line 264 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 286 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 321 of file joker.c.

◆ joker_object_get_name()

const char * joker_object_get_name ( Item *  joker_object)

Get Joker name.

Parameters
joker_objectthe Joker we want to get the name of
Returns
const string containing the name of the Joker, NULL if joker data is invalid

Definition at line 158 of file joker.c.

◆ joker_object_get_rarity_info()

ItemDescSubtypeInfo joker_object_get_rarity_info ( Item *  joker_object)

Get Joker rarity name and associated panel color.

Parameters
joker_objectpointer to a JokerObject we need the rarity's info of
Returns
struct containing values of all info on this Joker's rarity
See also
item_get_subtype_info

Definition at line 168 of file joker.c.

◆ joker_object_get_sell_price()

int joker_object_get_sell_price ( Item *  joker_object)

Returns the sell price of the joker object.

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

Definition at line 329 of file joker.c.

◆ joker_object_get_sprite()

Sprite * joker_object_get_sprite ( JokerObject *  joker_object)

Definition at line 482 of file joker.c.

◆ joker_object_new()

JokerObject * joker_object_new ( Joker *  joker)

Definition at line 216 of file joker.c.

◆ joker_object_print_description()

int joker_object_print_description ( Item *  joker_object,
Rect  dest_rect 
)

Print the description of the requested Joker centered within the specified Rect.

Parameters
joker_objectJoker to print the description of
dest_rectRectangular region the description must fit in. In case the text is too big, it will overflow downwards while still respecting left and right boundaries.
Returns
the number of lines the description was actually printed on

Definition at line 301 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 418 of file joker.c.

◆ joker_object_shake()

void joker_object_shake ( JokerObject *  joker_object,
mm_word  sound_id 
)

Definition at line 316 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 373 of file joker.c.

◆ joker_roll_id()

int joker_roll_id ( enum JokerRarity  joker_rarity,
enum RngSequence  key 
)

Rolls a random Joker among the available ones of a certain rarity.

Parameters
joker_raritythe rarity of the joker we want to roll
keyto the RNG sequence used
Returns
rolled Joker ID

Definition at line 384 of file joker.c.

◆ joker_roll_id_with_rarity()

int joker_roll_id_with_rarity ( int  joker_rarity)

Rolls a random Joker among the available ones of a certain rarity.

Parameters
joker_raritythe rarity of the joker we want to roll
Returns
rolled joker ID

◆ 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 345 of file joker.c.