[Refactor] Separate Round logic into its own file (#570)

* Everything works, need to clean up

* cleanup

* fix rebase issue

* clang format

* docs

* clang format

* clang format

* address part of review

* Protect against edge case when discarding at end of hand

* Protect undiscard against popping a discarded card that doesn't exist

* Protect against out of bounds access to the `played` cards stack

* fix condition in `select_four_of_a_kind_cards_in_played_hand`

* change `get_played_top() + 1` to `get_played_size()`

* move `can_play/discard_hand` functions to round.c

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
This commit is contained in:
Geralt
2026-06-27 16:57:37 -07:00
committed by GitHub
co-authored by MathisMartin31
parent f722b9eef4
commit 45eac259a5
12 changed files with 2207 additions and 2015 deletions
+7 -28
View File
@@ -51,19 +51,6 @@ enum GameState
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);
@@ -81,9 +68,6 @@ void game_update(void);
void game_change_state(enum GameState new_game_state);
enum GameState game_get_state(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);
void add_joker(JokerObject* joker_object);
@@ -92,19 +76,19 @@ List* get_jokers_list(void);
List* get_expired_jokers_list(void);
List* get_discarded_jokers_list(void);
int deck_get_size(void);
int get_deck_top(void);
void deck_push(Card* card);
Card* deck_pop(void);
void deck_shuffle(void);
int get_num_discards_remaining(void);
int get_num_hands_remaining(void);
void display_deck_size_max(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);
void display_ante(void);
// joker specific functions
bool is_shortcut_joker_active(void);
@@ -112,16 +96,11 @@ 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_temp_score(u32 value);
void erase_temp_score(void);
void display_score(u32 value);
#endif // GAME_H