e7f550ce22
* background * Implement Options button * Update main menu artwork * add options menu tiles * prepare options menu handling * incorporate main menu refactor * toto * add all menu interactions * do not reset selection_x in main_menu * options struct * fix rebase from ricfehr3's repo * Implement high contrast cards * Save/Load options values to SRAM * load options on game_init and validate data within the load_options function * Get changes from ricfehr3's PR * recover fix for glitched ace * clang format * clang format * clang format * Save 500B of image data by using only minimal set of tiles instead of keeping final window in source file * clang format * clang format * Implement Options button * Update main menu artwork * progress, leaving it alone for now until discussion * make game_vars an extern * Move options vars into their own struct * rollback previous commit * Implement save validation. Version check to come * implement data validity + version check for game saves * clang format * Save position in rng sequence for consistent run after load * fix rebase issues * fix rebase issue * remove unused/duplicate define * Oops, made a mistake when testing PR #424 * encode high contrast palette into an image, and load it at game_start * document save.c/h and correct typos * correct alignment * game speed and high contrast buttons working * small cleanup * sliders also work again now * clang format * Moved balatro_version extern declaration to version.h file * removed unsused variable * make showing ROM version a toggle * move ante, round and money to the GameVariables struct * Rename SaveCheckInfo struct to SaveHeader for clarity * Add SaveHeader struct explanation * clang format * Revert unnecessary tileset optimization * SFX now follows the sound volume slider * clang format * Music now follows volume slider * Changed volume slider increment from 5 to 20 to avoid having the music sound too rough under 20% volume * refactor main_menu.c to use SelectionGrid and Button structs * clang format * make a "new" save button so we don't save during the state transition * clang format * Reduced state transition flicker by only changing affine background to a different one * Fix loading game too late in game init sequence * First batch of suggestions from @MeirGavish * Remove unnecessary intermediary buffers for high contrast palette swapping * comment row warp hack for button input * Add some of Copilot's suggestions * rename balatro_version into gbalatro_version for rebranding reasons + version display erase screen fix * remove unnecessary NULL check on `on_selection_changed` method * implement small game speed arrow buttons animation * factorize some code * remove unnecessary data validation in load_game(), since we already checked the header * Implement @MeirGavish 's suggestion regarding splitting the huge `on_update` function * clang format * implement @ricfehr3 's suggestion about keeping last selected button instead of using an obscure `on_boot` boolean * Apply @ricfehr3's suggestions * fix clang-format flags --------- Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
185 lines
4.4 KiB
C
185 lines
4.4 KiB
C
#ifndef GAME_H
|
|
#define GAME_H
|
|
|
|
#include "blind.h"
|
|
#include "game/common_ui.h"
|
|
#include "game_variables.h"
|
|
|
|
#include <tonc.h>
|
|
|
|
extern GameVariables g_game_vars;
|
|
|
|
#define MAX_HAND_SIZE 16
|
|
#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 HandState
|
|
{
|
|
HAND_DRAW,
|
|
HAND_SELECT,
|
|
// This is actually a misnomer because it's used for the deck
|
|
// but it mechanically makes sense to be a state of the hand
|
|
HAND_SHUFFLING,
|
|
HAND_DISCARD,
|
|
HAND_PLAY,
|
|
HAND_PLAYING
|
|
};
|
|
|
|
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
|
|
};
|
|
|
|
// Hand types
|
|
enum HandType
|
|
{
|
|
NONE,
|
|
HIGH_CARD,
|
|
PAIR,
|
|
TWO_PAIR,
|
|
THREE_OF_A_KIND,
|
|
STRAIGHT,
|
|
FLUSH,
|
|
FULL_HOUSE,
|
|
FOUR_OF_A_KIND,
|
|
STRAIGHT_FLUSH,
|
|
ROYAL_FLUSH,
|
|
FIVE_OF_A_KIND,
|
|
FLUSH_HOUSE,
|
|
FLUSH_FIVE
|
|
};
|
|
|
|
// clang-format off
|
|
// Store all contained hands to optimize "whole hand condition" Jokers
|
|
typedef struct ContainedHandTypes
|
|
{
|
|
union
|
|
{
|
|
struct
|
|
{
|
|
u16 HIGH_CARD : 1;
|
|
u16 PAIR : 1;
|
|
u16 TWO_PAIR : 1;
|
|
u16 THREE_OF_A_KIND : 1;
|
|
u16 STRAIGHT : 1;
|
|
u16 FLUSH : 1;
|
|
u16 FULL_HOUSE : 1;
|
|
u16 FOUR_OF_A_KIND : 1;
|
|
u16 STRAIGHT_FLUSH : 1;
|
|
u16 ROYAL_FLUSH : 1;
|
|
u16 FIVE_OF_A_KIND : 1;
|
|
u16 FLUSH_HOUSE : 1;
|
|
u16 FLUSH_FIVE : 1;
|
|
u16 : 3;
|
|
};
|
|
u16 value;
|
|
};
|
|
} ContainedHandTypes;
|
|
// clang-format on
|
|
|
|
typedef void (*GameStateCallback)(void);
|
|
|
|
typedef struct
|
|
{
|
|
int substate;
|
|
GameStateCallback on_init;
|
|
GameStateCallback on_update;
|
|
GameStateCallback on_exit;
|
|
} StateInfo;
|
|
|
|
// Game functions
|
|
void game_init();
|
|
void game_update();
|
|
void game_change_state(enum GameState new_game_state);
|
|
|
|
CardObject** get_hand_array(void);
|
|
int get_hand_top(void);
|
|
int hand_get_size(void);
|
|
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);
|
|
List* get_jokers_list(void);
|
|
List* get_expired_jokers_list(void);
|
|
|
|
ContainedHandTypes* get_contained_hands(void);
|
|
enum HandType* get_hand_type(void);
|
|
|
|
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);
|
|
enum BlindType get_current_blind(void);
|
|
enum BlindType get_next_boss_blind(void);
|
|
|
|
u32 get_rand(void);
|
|
|
|
// 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);
|
|
|
|
#endif // GAME_H
|