Files
balatro-gba/include/game.h
Rickey 92cb9f9883
Some checks failed
Build and Deploy Doxygen Docs / docs (push) Has been cancelled
Refactor/state machine (#470)
* initial additions

* Move current_blind to game vars

* tmp

* tmp

* tmp

* tmp

* tmp

* tmp

* tmp

* Compile but is broken

* temp fix for token location

* tmp

* Working, lets clean up

* remove todo

* Remove odd reroll blind variable

* fix skipping blind screen

* fix reroll

* remove magic for blind token locations

* clang format

* Cleanup button highlight in blind menu

* some cleanup

* Add layout file for global UI rects

* remove dead code

* Clang format

* clang format it up

* Move reset top left funct to gfx utils

* make note of soon-to-be removed vars

* Cleanup gamevars declaration

* Cleanup layout file

* Apply suggestions from code review

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Add include for stdbool.h in common_ui.h

* Cleanup rect declaration

* Start moving state machine stuff to new file

* quick tmp

* oops, add new files

* working call list

* fixed pointer stuff

* working as per norm

* working replacement

* move defines to static const

* fix compile issue

* Add some missing "void"s

* Working new substates

* add statemachine to blind select

* Fix game restart statemachine leak

* clang-format

* Clang format

* Rework shop exit logic

* Use new state machine in shop

* Remove substates entirely

* Remove debug stuff

* Clang format

* document state machine better

* update list tests

* clang-format

* Update for PR

* Claaaaang format

* another clang-format

* Remove extra state in round_end

* cleanup docs for removals in lists

* clang-format... again

* update doxygen format

* Clang format

* Update list docs

* Update lists tests

* Fix bad conflict resolution

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-22 18:06:13 -07:00

128 lines
3.5 KiB
C

#ifndef GAME_H
#define GAME_H
#include "bitset.h"
#include "game/common_ui.h"
#include "game_variables.h"
#include "graphic_utils.h"
#include <tonc.h>
#define MAX_DECK_SIZE 52
#define MAX_JOKERS_HELD_SIZE 5 // This doesn't account for negatives right now.
#define MAX_SHOP_JOKERS 2 // TODO: Make this dynamic and allow for other items besides jokers
#define MAX_SELECTION_SIZE 5
#define FRAMES(x) (((x) + (g_game_vars.game_speed) - 1) / (g_game_vars.game_speed))
// TODO: Can make these dynamic to support interest-related jokers and vouchers
#define MAX_INTEREST 5
#define INTEREST_PER_5 1
// Input bindings
#define SELECT_CARD KEY_A
#define DESELECT_CARDS KEY_B
#define PEEK_DECK KEY_L // Not implemented
#define SORT_HAND KEY_R
#define PAUSE_GAME KEY_START // Not implemented
#define SELL_KEY KEY_L
// Matching the position of the on-screen buttons
#define PLAY_HAND_KEY KEY_L
// Same value as SELL_KEY - activated on the joker row, while this is activated on the hand row
#define DISCARD_HAND_KEY KEY_R
struct List;
typedef struct List List;
// Utility functions for other files
typedef struct CardObject CardObject;
typedef struct Card Card;
typedef struct JokerObject JokerObject;
// Enum value names in ../include/def_state_info_table.h
enum GameState
{
#define DEF_STATE_INFO(stateEnum, on_init, on_update, on_exit) stateEnum,
#include "def_state_info_table.h"
#undef DEF_STATE_INFO
GAME_STATE_MAX,
GAME_STATE_UNDEFINED
};
enum PlayState
{
PLAY_STARTING,
PLAY_BEFORE_SCORING,
PLAY_SCORING_CARDS,
PLAY_SCORING_CARD_JOKERS,
PLAY_SCORING_HELD_CARDS,
PLAY_SCORING_INDEPENDENT_JOKERS,
PLAY_SCORING_HAND_SCORED_END,
PLAY_ENDING,
PLAY_ENDED
};
// Game functions
void game_init(void);
/**
* @brief Called when exiting the Game Over screen (both win or lose) to reset game variables
* and start a fresh new run.
*
* WARNING: This function is currently only meant to be called from the "GAME_OVER" state
* and shouldn't be called from other states, otherwise some data such as shop jokers
* may not be properly reset.
*/
void game_reset(void);
void game_update(void);
void game_change_state(enum GameState new_game_state);
CardObject** get_played_array(void);
int get_played_top(void);
int get_scored_card_index(void);
bool is_joker_owned(int joker_id);
bool card_is_face(Card* card);
void add_joker(JokerObject* joker_object);
void remove_owned_joker(int owned_joker_idx);
List* get_jokers_list(void);
List* get_expired_jokers_list(void);
List* get_discarded_jokers_list(void);
List* get_shop_jokers_list(void);
Bitset* get_avail_jokers_bitset(void);
void set_shop_joker_avail(int joker_id, bool avail);
int get_deck_top(void);
int get_num_discards_remaining(void);
int get_num_hands_remaining(void);
u32 get_chips(void);
void set_chips(u32 new_chips);
void display_chips(void);
u32 get_mult(void);
void set_mult(u32 new_mult);
void display_mult(void);
void display_money(void);
void set_retrigger(bool new_retrigger);
// joker specific functions
bool is_shortcut_joker_active(void);
int get_straight_and_flush_size(void);
void game_start(void);
// Temporary change for Refactor. Currently this compatibility binder is to allow
// simultaneous integration of the new system in `common_ui` with the the existing
// old system incrementally and without losing functionality.
void change_background_legacy(enum BackgroundId id);
void display_round(void);
void reset_background(void);
void display_hands(void);
void display_discards(void);
void display_score(u32 value);
#endif // GAME_H