[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:
+5
-13
@@ -1,6 +1,7 @@
|
||||
#include "joker.h"
|
||||
|
||||
#include "card.h"
|
||||
#include "game/round.h"
|
||||
#include "game_variables.h"
|
||||
#include "graphic_utils.h"
|
||||
#include "pool.h"
|
||||
@@ -291,10 +292,6 @@ bool joker_object_score(
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 chips = get_chips();
|
||||
u32 mult = get_mult();
|
||||
int money = g_game_vars.money;
|
||||
|
||||
if (effect_flags_ret & JOKER_EFFECT_FLAG_RETRIGGER)
|
||||
{
|
||||
set_retrigger(joker_effect->retrigger);
|
||||
@@ -320,7 +317,7 @@ bool joker_object_score(
|
||||
mm_word sfx_id;
|
||||
if (effect_flags_ret & JOKER_EFFECT_FLAG_CHIPS)
|
||||
{
|
||||
chips = u32_protected_add(chips, joker_effect->chips);
|
||||
g_game_vars.chips = u32_protected_add(g_game_vars.chips, joker_effect->chips);
|
||||
char score_buffer[INT_MAX_DIGITS + 2]; // For '+' and null terminator
|
||||
snprintf(score_buffer, sizeof(score_buffer), "+%lu", joker_effect->chips);
|
||||
set_and_shift_text(score_buffer, &cursorPosX, &cursorPosY, TTE_BLUE_PB);
|
||||
@@ -328,7 +325,7 @@ bool joker_object_score(
|
||||
}
|
||||
if (effect_flags_ret & JOKER_EFFECT_FLAG_MULT)
|
||||
{
|
||||
mult = u32_protected_add(mult, joker_effect->mult);
|
||||
g_game_vars.mult = u32_protected_add(g_game_vars.mult, joker_effect->mult);
|
||||
char score_buffer[INT_MAX_DIGITS + 2];
|
||||
snprintf(score_buffer, sizeof(score_buffer), "+%lu", joker_effect->mult);
|
||||
set_and_shift_text(score_buffer, &cursorPosX, &cursorPosY, TTE_RED_PB);
|
||||
@@ -337,7 +334,7 @@ bool joker_object_score(
|
||||
// if xmult is zero, DO NOT multiply by it
|
||||
if (effect_flags_ret & JOKER_EFFECT_FLAG_XMULT && joker_effect->xmult > 0)
|
||||
{
|
||||
mult = u32_protected_mult(mult, joker_effect->xmult);
|
||||
g_game_vars.mult = u32_protected_mult(g_game_vars.mult, joker_effect->xmult);
|
||||
char score_buffer[INT_MAX_DIGITS + 2];
|
||||
snprintf(score_buffer, sizeof(score_buffer), "X%lu", joker_effect->xmult);
|
||||
set_and_shift_text(score_buffer, &cursorPosX, &cursorPosY, TTE_RED_PB);
|
||||
@@ -345,7 +342,7 @@ bool joker_object_score(
|
||||
}
|
||||
if (effect_flags_ret & JOKER_EFFECT_FLAG_MONEY)
|
||||
{
|
||||
money += joker_effect->money;
|
||||
g_game_vars.money += joker_effect->money;
|
||||
char score_buffer[INT_MAX_DIGITS + 2];
|
||||
snprintf(score_buffer, sizeof(score_buffer), "%d$", joker_effect->money);
|
||||
set_and_shift_text(score_buffer, &cursorPosX, &cursorPosY, TTE_YELLOW_PB);
|
||||
@@ -364,11 +361,6 @@ bool joker_object_score(
|
||||
list_push_back(get_expired_jokers_list(), joker_object);
|
||||
}
|
||||
|
||||
// Update values
|
||||
set_chips(chips);
|
||||
set_mult(mult);
|
||||
g_game_vars.money = money;
|
||||
|
||||
// Update displays
|
||||
display_chips();
|
||||
display_mult();
|
||||
|
||||
Reference in New Issue
Block a user