[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:
@@ -309,8 +309,8 @@ static void game_blind_select_display_blind_panel()
|
||||
|
||||
static void game_blind_select_exit(void)
|
||||
{
|
||||
reset_background();
|
||||
game_change_state(GAME_STATE_PLAYING);
|
||||
change_background(BG_NONE, false);
|
||||
game_change_state(GAME_STATE_ROUND);
|
||||
}
|
||||
|
||||
static Rect game_blind_select_get_req_score_rect(enum BlindTokens blind)
|
||||
@@ -484,7 +484,7 @@ void game_blind_select_on_exit(void)
|
||||
sprite_destroy(&blind_select_tokens[BIG_BLIND]);
|
||||
sprite_destroy(&blind_select_tokens[BOSS_BLIND]);
|
||||
|
||||
reset_background();
|
||||
change_background(BG_NONE, false);
|
||||
selection_y = 0;
|
||||
|
||||
state_machine_remove(&blind_select_sm);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "game.h"
|
||||
#include "game/main_menu.h"
|
||||
#include "game/options_menu.h"
|
||||
#include "game/round.h"
|
||||
#include "game/round_end.h"
|
||||
#include "game/run_setup.h"
|
||||
#include "game/shop.h"
|
||||
@@ -15,8 +16,8 @@ static enum BackgroundId background = BG_NONE;
|
||||
// Map to fill in for refactor
|
||||
static const BackgroundRenderCallback bgCallbacks[] = {
|
||||
[BG_NONE] = NULL,
|
||||
[BG_CARD_SELECTING] = NULL,
|
||||
[BG_CARD_PLAYING] = NULL,
|
||||
[BG_CARD_SELECTING] = game_round_change_background_selecting,
|
||||
[BG_CARD_PLAYING] = game_round_change_background_playing,
|
||||
[BG_ROUND_END] = game_round_end_change_background,
|
||||
[BG_SHOP] = game_shop_change_background,
|
||||
[BG_BLIND_SELECT] = game_blind_select_change_background,
|
||||
@@ -25,19 +26,20 @@ static const BackgroundRenderCallback bgCallbacks[] = {
|
||||
[BG_MAIN_MENU] = game_main_menu_change_background,
|
||||
};
|
||||
|
||||
enum BackgroundId get_current_background(void)
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
void change_background(enum BackgroundId id, bool force_redraw)
|
||||
{
|
||||
if (force_redraw)
|
||||
{
|
||||
background = BG_NONE;
|
||||
reset_background();
|
||||
}
|
||||
if (id != background && bgCallbacks[id] != NULL)
|
||||
{
|
||||
bgCallbacks[id]();
|
||||
}
|
||||
background = id;
|
||||
|
||||
// Can be removed once all states have their own "change_background" func
|
||||
change_background_legacy(id);
|
||||
}
|
||||
|
||||
+2074
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user