Refactor/round end (#479)

* Initial round_end extraction

* move hands to game vars

* Checkpoint

* Finish removing all variables for state fns

* Move over round_end substate functions

* Move over round_end with compile

* working in general

* Fix round start state issue

* clang-format

* Fix clang format issue

* PR fixes and standardize types in game vars struct

* Clang-format
This commit is contained in:
Rickey
2026-05-13 18:22:02 -07:00
committed by GitHub
parent 57ec84fcc7
commit b1c2b7f35e
10 changed files with 606 additions and 547 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ DEF_STATE_INFO(GAME_STATE_MAIN_MENU, game_main_menu_on_init, game_main_me
DEF_STATE_INFO(GAME_STATE_OPTIONS_MENU, game_options_menu_on_init, game_options_menu_on_update, game_options_menu_on_exit)
DEF_STATE_INFO(GAME_STATE_GAME_START, noop, game_start, noop )
DEF_STATE_INFO(GAME_STATE_PLAYING, game_round_on_init, game_playing_on_update, noop )
DEF_STATE_INFO(GAME_STATE_ROUND_END, noop, game_round_end_on_update, game_round_end_on_exit )
DEF_STATE_INFO(GAME_STATE_ROUND_END, game_round_end_on_init, game_round_end_on_update, game_round_end_on_exit )
DEF_STATE_INFO(GAME_STATE_SHOP, noop, game_shop_on_update, game_shop_on_exit )
DEF_STATE_INFO(GAME_STATE_BLIND_SELECT, game_blind_select_on_init, game_blind_select_on_update, game_blind_select_on_exit)
DEF_STATE_INFO(GAME_STATE_LOSE, game_lose_on_init, game_over_on_update, game_over_on_exit )
+3
View File
@@ -192,5 +192,8 @@ void display_round(void);
void reset_top_left_panel_bottom_row(void);
void reset_background(void);
void display_hands(void);
void display_discards(void);
void display_score(u32 value);
#endif // GAME_H
+1 -3
View File
@@ -6,8 +6,6 @@
#ifndef GAME_OPTIONS_MENU_H
#define GAME_OPTIONS_MENU_H
#include "game_variables.h"
/**
* @brief Change the options menu background
*/
@@ -28,4 +26,4 @@ void game_options_menu_on_update(void);
*/
void game_options_menu_on_exit(void);
#endif // GAME_OPTIONS_MENU_H
#endif // GAME_OPTIONS_MENU_H
+29
View File
@@ -0,0 +1,29 @@
/**
* @file round_end.h
*
* @brief Round end game state functions
*/
#ifndef GAME_ROUND_END_H
#define GAME_ROUND_END_H
/**
* @brief Change to the round end background
*/
void game_round_end_change_background(void);
/**
* @brief Round end state initialization
*/
void game_round_end_on_init(void);
/**
* @brief Round end state update
*/
void game_round_end_on_update(void);
/**
* @brief Round end cleanup
*/
void game_round_end_on_exit(void);
#endif // GAME_ROUND_END_H
+12 -3
View File
@@ -23,6 +23,9 @@
#define DEFAULT_MUSIC_VOLUME VOLUME_OPTION_MAX
#define DEFAULT_SOUND_VOLUME VOLUME_OPTION_MAX
#define MAX_HANDS 4
#define MAX_DISCARDS 4
/**
* @brief A central location for all game variables.
*
@@ -39,9 +42,9 @@ typedef struct
// Variables visible by the player
int round;
int ante;
int money;
s32 round;
s32 ante;
s32 money;
// Blind variables
@@ -49,6 +52,12 @@ typedef struct
enum BlindType next_boss_blind;
enum BlindState blinds_states[NUM_BLINDS_PER_ANTE];
s32 hands;
s32 discards;
u32 score;
Sprite* playing_blind_token;
Sprite* round_end_blind_token;
// Options variables
// BY DEFAULT IS SET TO 1, but if changed to 2 or more, should speed up all (or most) of the
+11 -7
View File
@@ -9,13 +9,17 @@
#include "graphic_utils.h"
// clang-format off
// Points x y
static const BG_POINT CUR_BLIND_TOKEN_POS = {8, 18};
static const BG_POINT TOP_LEFT_PANEL_POINT = {0, 0, };
// Rects left top right bottom
static const Rect TOP_LEFT_PANEL_ANIM_RECT = {0, 0, 8, 4};
static const Rect POP_MENU_ANIM_RECT = {9, 7, 24, 31};
static const Rect TOP_LEFT_ITEM_SRC_RECT = {0, 20, 8, 25};
// Points x y
static const BG_POINT CUR_BLIND_TOKEN_POS = {8, 18};
static const BG_POINT TOP_LEFT_PANEL_POINT = {0, 0};
static const BG_POINT ROUND_END_REWARDS_ELLIPSIS_POS = {10, 13};
// Rects left top right bottom
static const Rect TOP_LEFT_PANEL_ANIM_RECT = {0, 0, 8, 4};
static const Rect POP_MENU_ANIM_RECT = {9, 7, 24, 31};
static const Rect TOP_LEFT_ITEM_SRC_RECT = {0, 20, 8, 25};
static const Rect BLIND_REWARD_RECT = {40, 32, 64, 40};
static const Rect BLIND_REQ_TEXT_RECT = {32, 24, 64, 32};
static const Rect HAND_SIZE_RECT = {128, 128, 152, 160}; // Seems to include both SELECT and PLAYING
// clang-format on
#endif // LAYOUT_H
+8
View File
@@ -9,6 +9,14 @@
#define TM_ZERO 0
#define TM_REWARDS_ELLIPSIS_PRINT_START 2
#define TM_REWARDS_ELLIPSIS_PRINT_END 16
#define TM_REWARD_DISPLAY_INTERVAL 15
#define TM_REWARD_INCREMENT_INTERVAL 20
#define TM_DISPLAY_REWARDS_CONT_WAIT (TM_REWARDS_ELLIPSIS_PRINT_END + TM_REWARD_DISPLAY_INTERVAL)
#define TM_HAND_REWARD_INCR_WAIT (TM_DISPLAY_REWARDS_CONT_WAIT + TM_REWARD_DISPLAY_INTERVAL)
#define MENU_POP_OUT_ANIM_FRAMES 20
#endif // TIMER_H