GBAlatro
A Demake of Balatro for the GBA
Loading...
Searching...
No Matches
round.c File Reference

Data structures and implementation of functions relative to the Rounds we play. More...

#include "game/round.h"
#include "audio_utils.h"
#include "background_gfx.h"
#include "button.h"
#include "game.h"
#include "game/joker_row.h"
#include "graphic_utils.h"
#include "hand.h"
#include "joker.h"
#include "layout.h"
#include "list.h"
#include "selection_grid.h"
#include "soundbank.h"
#include "timer.h"
#include "util.h"
#include <stdlib.h>
#include <tonc.h>

Go to the source code of this file.

Macros

#define PLAY_HAND_BTN_PAL_IDX   6
 
#define PLAY_HAND_BTN_BORDER_PAL_IDX   7
 
#define DISCARD_BTN_PAL_IDX   13
 
#define DISCARD_BTN_BORDER_PAL_IDX   8
 
#define SORT_BTNS_PAL_IDX   9
 
#define SORT_BY_RANK_BTN_BORDER_PAL_IDX   22
 
#define SORT_BY_SUIT_BTN_BORDER_PAL_IDX   23
 
#define BLIND_BG_SHADOW_PAL_IDX   5
 
#define BLIND_BG_SECONDARY_PAL_IDX   18
 
#define BLIND_BG_PRIMARY_PAL_IDX   19
 
#define PITCH_STEP_DISCARD_SFX   (-64)
 
#define PITCH_STEP_DRAW_SFX   24
 
#define PITCH_STEP_UNDISCARD_SFX   (2 * PITCH_STEP_DRAW_SFX)
 
#define NUM_SCORE_LERP_STEPS   16
 
#define TM_SCORE_LERP_INTERVAL   2
 
#define GAME_PLAYING_HAND_SEL_Y   1
 
#define CARD_FOCUSED_UNSEL_Y   10
 
#define CARD_UNFOCUSED_SEL_Y   15
 
#define CARD_FOCUSED_SEL_Y   20
 
#define SCORED_CARD_TEXT_Y   48
 
#define SCORE_FLAMES_ANIM_FREQ   5
 
#define NUM_SCORE_FLAMES_FRAMES   8
 
#define SCORE_FLAME_FRAME_WIDTH   3
 

Enumerations

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
}
 

Functions

static int game_round_button_row_get_size (void)
 
static bool game_round_button_row_on_selection_changed (SelectionGrid *selection_grid, int row_idx, const Selection *prev_selection, const Selection *new_selection)
 
static void game_round_button_row_on_key_hit (SelectionGrid *selection_grid, Selection *selection)
 
static void game_round_hand_row_on_key_transit (SelectionGrid *selection_grid, Selection *selection)
 
static bool game_round_hand_row_on_selection_changed (SelectionGrid *selection_grid, int row_idx, const Selection *prev_selection, const Selection *new_selection)
 
static int game_round_hand_row_get_size (void)
 
static int hand_sel_idx_to_card_idx (int selection_index)
 Converts a selection index from the selection grid into a card index within the hand array.
 
static void game_round_discard_on_pressed (void)
 "Discard" button implementation.
 
static void game_round_play_hand_on_pressed (void)
 "Play" button implementation.
 
static void game_round_sort_by_rank_on_pressed (void)
 "Rank" sorting button implementation.
 
static void game_round_sort_by_suit_on_pressed (void)
 "Suit" sorting button implementation.
 
static bool can_discard_hand (void)
 Determines whether the "Discard" button can be pressed or not.
 
static bool can_play_hand (void)
 Determines whether the "Play" button can be pressed or not.
 
int get_played_top (void)
 Get the index of the last played card.
 
int get_played_size (void)
 Get the number of cards played.
 
static void played_push (CardObject *card_object)
 Push a new card to play at the end of the associated array.
 
int get_discard_top (void)
 Get the index of the last discarded card.
 
static void discard_push (Card *card)
 Push a new card to discard at the end of the associated array.
 
static Carddiscard_pop ()
 Remove and recover the last discarded card.
 
int get_scored_card_index (void)
 Get the index of the card that is currently being scored.
 
void set_retrigger (bool new_retrigger)
 Set whether the current card should get triggered again.
 
static GBAL_UNUSED void get_played_distribution (u8 ranks_out[NUM_RANKS], u8 suits_out[NUM_SUITS])
 Outputs the distribution of ranks and suits in the played stack.
 
void game_round_change_background_selecting (void)
 Change to the round card selection background.
 
void game_round_change_background_playing (void)
 Change to the round card playing background.
 
static void game_round_execute_discard (void)
 Triggers the discard of the currently selected cards in hand.
 
static void game_round_execute_play_hand (void)
 Triggers the playing of the currently selected cards in hand.
 
static void game_round_button_set_highlight (int btn_idx, bool highlight)
 
static void game_round_process_hand_select_input (void)
 
static void game_round_handle_round_over (void)
 Evaluates if we have won or lost when we can no longer play so that we land on the correct Game Over screen.
 
static void card_in_hand_loop_handle_discard_and_shuffling (int card_idx, FIXED *hand_x, FIXED *hand_y, bool *break_loop)
 
static void select_flush_and_straight_cards_in_played_hand (void)
 
static void select_all_five_cards_in_played_hand (void)
 
static void select_four_of_a_kind_cards_in_played_hand (void)
 
static void select_three_of_a_kind_cards_in_played_hand (void)
 
static void select_two_pair_cards_in_played_hand (void)
 
static void select_pair_cards_in_played_hand (void)
 
static void select_highcard_cards_in_played_hand (void)
 
static bool game_round_is_over (void)
 Determines if the round is over, be it because we lost or won the round.
 
static void game_round_process_input_and_state (void)
 
static void card_draw (void)
 Draw the next card at the top of the Deck and play a little Sprite animation to position it in our hand.
 
static void game_round_process_card_draw (void)
 
static void game_round_discarded_cards_loop (void)
 
static void select_cards_in_played_hand (void)
 
static void cards_in_hand_update_loop (void)
 
static void game_round_ui_text_update (void)
 
void toggle_flaming_score (void)
 Checks whether the score that would result from the current Chips and Mult exceeds the current Blind's score requirement, and applies the flaming effect if needed.
 
static void game_round_process_flaming_score (void)
 
static bool check_and_score_joker_for_event (ListItr *starting_joker_itr, CardObject *card_object, enum JokerEvent joker_event)
 Iterate over the Jokers List until we encounter one that scores for the specified event.
 
static void play_starting_played_cards_update (int played_idx)
 
static bool play_before_scoring_cards_update (void)
 Returns true if the Jokers scoring loop has returned early for event JOKER_EVENT_ON_HAND_PLAYED.
 
static bool play_scoring_cards_update (void)
 Score all played cards in order, then Jokers after each one.
 
static bool play_scoring_card_jokers_update (void)
 Activate Jokers for event JOKER_EVENT_ON_CARD_SCORED_END for the previous scored card, if any.
 
static bool play_scoring_held_cards_update (int played_idx)
 Activate Jokers for event JOKER_EVENT_ON_CARD_HELD for the previous scored card, if any.
 
static bool play_scoring_independent_jokers_update (int played_idx)
 Score Jokers normally for event JOKER_EVENT_INDEPENDENT.
 
static bool play_scoring_hand_scored_end_update (int played_idx)
 Trigger all Jokers for event JOKER_EVENT_ON_HAND_SCORED_END once they are done scoring.
 
static void play_ending_played_cards_update (int played_idx)
 This is the reverse of PLAY_STARTING. The cards get reset back to their neutral position sequentially.
 
static bool play_ended_played_cards_update (int played_idx)
 Returns true if the card at index played_idx has been discarded. Basically a copy of HAND_DISCARD.
 
static void played_cards_update_loop (void)
 
void game_round_on_init (void)
 Round state initialization.
 
void game_round_on_update (void)
 Round state update.
 

Variables

static const Rect SCORE_FLAME_RESET = {26, 20, 28, 20}
 
static const Rect SCORE_FLAME_FRAMES_START = {26, 21, 28, 21}
 
static const BG_POINT SCORE_FLAME_CHIPS_POS = {1, 9}
 
static const BG_POINT SCORE_FLAME_MULT_POS = {5, 9}
 
static const BG_POINT TOP_LEFT_BLIND_TITLE_POINT = {0, 21}
 
static const Rect BIG_BLIND_TITLE_SRC_RECT = {0, 26, 8, 26 }
 
static const Rect BOSS_BLIND_TITLE_SRC_RECT = {0, 27, 8, 27 }
 
static const Rect HAND_BG_RECT_SELECTING = {9, 11, 24, 17 }
 
static const Rect HAND_SIZE_RECT_SELECT = {120, 128, 160, 136 }
 
static const Rect HAND_SIZE_RECT_PLAYING = {120, 152, 160, 160 }
 
static const Rect PLAYED_CARDS_SCORES_RECT = {72, 48, 240, 56 }
 
static const Rect HELD_CARDS_SCORES_RECT = {72, 108, 240, 116 }
 
static const BG_POINT CARD_DRAW_POS = {208, 110}
 
static const BG_POINT CARD_DISCARD_PNT = {240, 70}
 
static const BG_POINT HAND_START_POS = {120, 90}
 
static const BG_POINT HAND_PLAY_POS = {120, 70}
 
static SelectionGridRow game_round_selection_rows []
 
static const Selection GAME_PLAYING_INIT_SEL = {0, 1}
 
static SelectionGrid game_round_selection_grid
 
static Button game_round_buttons []
 
static enum PlayState play_state = PLAY_STARTING
 
static const int HAND_SPACING_LUT [MAX_HAND_SIZE]
 
static CardObjects_played_hand [MAX_SELECTION_SIZE] = {NULL}
 
static int s_played_top = -1
 
static Cards_discard_pile [MAX_DECK_SIZE] = {NULL}
 
static int s_discard_top = -1
 
static int s_scored_card_index = 0
 
static bool s_retrigger = false
 
static ListItr s_joker_scored_itr
 
static ListItr s_joker_card_scored_end_itr
 
static ListItr s_joker_round_end_itr
 
static u32 s_temp_score = 0
 
static bool s_score_flames_active = false
 
static FIXED s_lerped_score = 0
 
static FIXED s_lerped_temp_score = 0
 
static bool s_sound_played = false
 
static bool s_discarded_card = false
 
static int s_cards_drawn = 0
 
static int s_cards_discarded = 0
 
static bool s_moving_card = false
 
static bool s_card_moved_too_fast = false
 
static bool s_card_selected_instead_of_moved = false
 
static const int CARD_SWAP_TIME_THRESHOLD = 6
 
static int s_selection_hit_timer = UNDEFINED
 

Detailed Description

Data structures and implementation of functions relative to the Rounds we play.

Definition in file round.c.

Macro Definition Documentation

◆ BLIND_BG_PRIMARY_PAL_IDX

#define BLIND_BG_PRIMARY_PAL_IDX   19

Definition at line 40 of file round.c.

◆ BLIND_BG_SECONDARY_PAL_IDX

#define BLIND_BG_SECONDARY_PAL_IDX   18

Definition at line 39 of file round.c.

◆ BLIND_BG_SHADOW_PAL_IDX

#define BLIND_BG_SHADOW_PAL_IDX   5

Definition at line 38 of file round.c.

◆ CARD_FOCUSED_SEL_Y

#define CARD_FOCUSED_SEL_Y   20

Definition at line 58 of file round.c.

◆ CARD_FOCUSED_UNSEL_Y

#define CARD_FOCUSED_UNSEL_Y   10

Definition at line 56 of file round.c.

◆ CARD_UNFOCUSED_SEL_Y

#define CARD_UNFOCUSED_SEL_Y   15

Definition at line 57 of file round.c.

◆ DISCARD_BTN_BORDER_PAL_IDX

#define DISCARD_BTN_BORDER_PAL_IDX   8

Definition at line 34 of file round.c.

◆ DISCARD_BTN_PAL_IDX

#define DISCARD_BTN_PAL_IDX   13

Definition at line 33 of file round.c.

◆ GAME_PLAYING_HAND_SEL_Y

#define GAME_PLAYING_HAND_SEL_Y   1

Definition at line 53 of file round.c.

◆ NUM_SCORE_FLAMES_FRAMES

#define NUM_SCORE_FLAMES_FRAMES   8

Definition at line 65 of file round.c.

◆ NUM_SCORE_LERP_STEPS

#define NUM_SCORE_LERP_STEPS   16

Definition at line 50 of file round.c.

◆ PITCH_STEP_DISCARD_SFX

#define PITCH_STEP_DISCARD_SFX   (-64)

Definition at line 43 of file round.c.

◆ PITCH_STEP_DRAW_SFX

#define PITCH_STEP_DRAW_SFX   24

Definition at line 44 of file round.c.

◆ PITCH_STEP_UNDISCARD_SFX

#define PITCH_STEP_UNDISCARD_SFX   (2 * PITCH_STEP_DRAW_SFX)

Definition at line 45 of file round.c.

◆ PLAY_HAND_BTN_BORDER_PAL_IDX

#define PLAY_HAND_BTN_BORDER_PAL_IDX   7

Definition at line 32 of file round.c.

◆ PLAY_HAND_BTN_PAL_IDX

#define PLAY_HAND_BTN_PAL_IDX   6

Definition at line 31 of file round.c.

◆ SCORE_FLAME_FRAME_WIDTH

#define SCORE_FLAME_FRAME_WIDTH   3

Definition at line 66 of file round.c.

◆ SCORE_FLAMES_ANIM_FREQ

#define SCORE_FLAMES_ANIM_FREQ   5

Definition at line 64 of file round.c.

◆ SCORED_CARD_TEXT_Y

#define SCORED_CARD_TEXT_Y   48

Definition at line 59 of file round.c.

◆ SORT_BTNS_PAL_IDX

#define SORT_BTNS_PAL_IDX   9

Definition at line 35 of file round.c.

◆ SORT_BY_RANK_BTN_BORDER_PAL_IDX

#define SORT_BY_RANK_BTN_BORDER_PAL_IDX   22

Definition at line 36 of file round.c.

◆ SORT_BY_SUIT_BTN_BORDER_PAL_IDX

#define SORT_BY_SUIT_BTN_BORDER_PAL_IDX   23

Definition at line 37 of file round.c.

◆ TM_SCORE_LERP_INTERVAL

#define TM_SCORE_LERP_INTERVAL   2

Definition at line 51 of file round.c.

Enumeration Type Documentation

◆ PlayState

enum PlayState

Definition at line 188 of file round.c.

Function Documentation

◆ can_discard_hand()

static bool can_discard_hand ( void  )
static

Determines whether the "Discard" button can be pressed or not.

Returns
true if the hand can be discarded, false otherwise

Definition at line 427 of file round.c.

◆ can_play_hand()

static bool can_play_hand ( void  )
static

Determines whether the "Play" button can be pressed or not.

Returns
true if the hand can be played, false otherwise

Definition at line 440 of file round.c.

◆ card_draw()

static void card_draw ( void  )
inlinestatic

Draw the next card at the top of the Deck and play a little Sprite animation to position it in our hand.

Definition at line 1125 of file round.c.

◆ card_in_hand_loop_handle_discard_and_shuffling()

static void card_in_hand_loop_handle_discard_and_shuffling ( int  card_idx,
FIXED *  hand_x,
FIXED *  hand_y,
bool *  break_loop 
)
inlinestatic

Definition at line 753 of file round.c.

◆ cards_in_hand_update_loop()

static void cards_in_hand_update_loop ( void  )
inlinestatic

Definition at line 1261 of file round.c.

◆ check_and_score_joker_for_event()

static bool check_and_score_joker_for_event ( ListItr starting_joker_itr,
CardObject card_object,
enum JokerEvent  joker_event 
)
static

Iterate over the Jokers List until we encounter one that scores for the specified event.

Parameters
starting_joker_itriterator for the owned Jokers List
card_objectcard currently scored, can be NULL for some joker_event
joker_eventthe event we are scoring the Jokers for
Returns
true if a scoring Joker was encountered, false if not
See also
JokerEvent

Definition at line 1486 of file round.c.

◆ discard_pop()

static Card * discard_pop ( )
inlinestatic

Remove and recover the last discarded card.

Returns
pointer to the CardObject representing the last discarded card

Definition at line 289 of file round.c.

◆ discard_push()

static void discard_push ( Card card)
inlinestatic

Push a new card to discard at the end of the associated array.

Parameters
card_objectthe CardObject we just discarded
See also
played_push

Definition at line 277 of file round.c.

◆ game_round_button_row_get_size()

static int game_round_button_row_get_size ( void  )
static

Definition at line 657 of file round.c.

◆ game_round_button_row_on_key_hit()

static void game_round_button_row_on_key_hit ( SelectionGrid selection_grid,
Selection *  selection 
)
static

Definition at line 692 of file round.c.

◆ game_round_button_row_on_selection_changed()

static bool game_round_button_row_on_selection_changed ( SelectionGrid selection_grid,
int  row_idx,
const Selection *  prev_selection,
const Selection *  new_selection 
)
static

Definition at line 667 of file round.c.

◆ game_round_button_set_highlight()

static void game_round_button_set_highlight ( int  btn_idx,
bool  highlight 
)
inlinestatic

Definition at line 662 of file round.c.

◆ game_round_change_background_playing()

void game_round_change_background_playing ( void  )

Change to the round card playing background.

Definition at line 400 of file round.c.

◆ game_round_change_background_selecting()

void game_round_change_background_selecting ( void  )

Change to the round card selection background.

Definition at line 338 of file round.c.

◆ game_round_discard_on_pressed()

static void game_round_discard_on_pressed ( void  )
static

"Discard" button implementation.

Definition at line 464 of file round.c.

◆ game_round_discarded_cards_loop()

static void game_round_discarded_cards_loop ( void  )
inlinestatic

Definition at line 1170 of file round.c.

◆ game_round_execute_discard()

static void game_round_execute_discard ( void  )
inlinestatic

Triggers the discard of the currently selected cards in hand.

Definition at line 450 of file round.c.

◆ game_round_execute_play_hand()

static void game_round_execute_play_hand ( void  )
inlinestatic

Triggers the playing of the currently selected cards in hand.

Definition at line 494 of file round.c.

◆ game_round_hand_row_get_size()

static int game_round_hand_row_get_size ( void  )
static

Definition at line 521 of file round.c.

◆ game_round_hand_row_on_key_transit()

static void game_round_hand_row_on_key_transit ( SelectionGrid selection_grid,
Selection *  selection 
)
static

Definition at line 621 of file round.c.

◆ game_round_hand_row_on_selection_changed()

static bool game_round_hand_row_on_selection_changed ( SelectionGrid selection_grid,
int  row_idx,
const Selection *  prev_selection,
const Selection *  new_selection 
)
static

Definition at line 544 of file round.c.

◆ game_round_handle_round_over()

static void game_round_handle_round_over ( void  )
inlinestatic

Evaluates if we have won or lost when we can no longer play so that we land on the correct Game Over screen.

Definition at line 723 of file round.c.

◆ game_round_is_over()

static bool game_round_is_over ( void  )
inlinestatic

Determines if the round is over, be it because we lost or won the round.

Returns
true if the round is over, false if we can still play.

Definition at line 1049 of file round.c.

◆ game_round_on_init()

void game_round_on_init ( void  )

Round state initialization.

Definition at line 1975 of file round.c.

◆ game_round_on_update()

void game_round_on_update ( void  )

Round state update.

Definition at line 2046 of file round.c.

◆ game_round_play_hand_on_pressed()

static void game_round_play_hand_on_pressed ( void  )
static

"Play" button implementation.

Definition at line 510 of file round.c.

◆ game_round_process_card_draw()

static void game_round_process_card_draw ( void  )
inlinestatic

Definition at line 1152 of file round.c.

◆ game_round_process_flaming_score()

static void game_round_process_flaming_score ( void  )
inlinestatic

Definition at line 1448 of file round.c.

◆ game_round_process_hand_select_input()

static void game_round_process_hand_select_input ( void  )
inlinestatic

Definition at line 714 of file round.c.

◆ game_round_process_input_and_state()

static void game_round_process_input_and_state ( void  )
inlinestatic

Definition at line 1055 of file round.c.

◆ game_round_sort_by_rank_on_pressed()

static void game_round_sort_by_rank_on_pressed ( void  )
static

"Rank" sorting button implementation.

Definition at line 478 of file round.c.

◆ game_round_sort_by_suit_on_pressed()

static void game_round_sort_by_suit_on_pressed ( void  )
static

"Suit" sorting button implementation.

Definition at line 486 of file round.c.

◆ game_round_ui_text_update()

static void game_round_ui_text_update ( void  )
inlinestatic

Definition at line 1380 of file round.c.

◆ get_discard_top()

int get_discard_top ( void  )

Get the index of the last discarded card.

Returns
int

Definition at line 265 of file round.c.

◆ get_played_distribution()

static GBAL_UNUSED void get_played_distribution ( u8  ranks_out[NUM_RANKS],
u8  suits_out[NUM_SUITS] 
)
static

Outputs the distribution of ranks and suits in the played stack.

Parameters
ranks_outoutput - updated such as ranks_out[rank] is the number of cards of rank in the played stack. Must be of size NUM_RANKS.
suits_outoutput - updated such as suits_out[suit] is the number of cards if suit in the played stack. Must be of size NUM_SUITS

Definition at line 314 of file round.c.

◆ get_played_size()

int get_played_size ( void  )

Get the number of cards played.

Returns
int

Definition at line 248 of file round.c.

◆ get_played_top()

int get_played_top ( void  )

Get the index of the last played card.

Returns
int

Definition at line 243 of file round.c.

◆ get_scored_card_index()

int get_scored_card_index ( void  )

Get the index of the card that is currently being scored.

Returns
int

Definition at line 296 of file round.c.

◆ hand_sel_idx_to_card_idx()

static int hand_sel_idx_to_card_idx ( int  selection_index)
inlinestatic

Converts a selection index from the selection grid into a card index within the hand array.

Parameters
selection_indexThe selection index from the selection grid.
Returns
The index within the hand stack array. Note that the result is not valid if hand size is 0.

Definition at line 706 of file round.c.

◆ play_before_scoring_cards_update()

static bool play_before_scoring_cards_update ( void  )
inlinestatic

Returns true if the Jokers scoring loop has returned early for event JOKER_EVENT_ON_HAND_PLAYED.

Returns
bool
See also
check_and_score_joker_for_event

Definition at line 1544 of file round.c.

◆ play_ended_played_cards_update()

static bool play_ended_played_cards_update ( int  played_idx)
static

Returns true if the card at index played_idx has been discarded. Basically a copy of HAND_DISCARD.

Parameters
played_idxthe index of the played card being considered.
Returns
bool

Definition at line 1820 of file round.c.

◆ play_ending_played_cards_update()

static void play_ending_played_cards_update ( int  played_idx)
inlinestatic

This is the reverse of PLAY_STARTING. The cards get reset back to their neutral position sequentially.

Parameters
played_idxindex of the card currently considered

Definition at line 1775 of file round.c.

◆ play_scoring_card_jokers_update()

static bool play_scoring_card_jokers_update ( void  )
inlinestatic

Activate Jokers for event JOKER_EVENT_ON_CARD_SCORED_END for the previous scored card, if any.

Returns
true if the Joker scoring loop has returned early
See also
check_and_score_joker_for_event

Definition at line 1630 of file round.c.

◆ play_scoring_cards_update()

static bool play_scoring_cards_update ( void  )
inlinestatic

Score all played cards in order, then Jokers after each one.

Returns
true if the Cards scoring loop has returned early.

Definition at line 1561 of file round.c.

◆ play_scoring_hand_scored_end_update()

static bool play_scoring_hand_scored_end_update ( int  played_idx)
inlinestatic

Trigger all Jokers for event JOKER_EVENT_ON_HAND_SCORED_END once they are done scoring.

Returns
true if the Joker scoring loop has returned early
See also
check_and_score_joker_for_event

Definition at line 1744 of file round.c.

◆ play_scoring_held_cards_update()

static bool play_scoring_held_cards_update ( int  played_idx)
inlinestatic

Activate Jokers for event JOKER_EVENT_ON_CARD_HELD for the previous scored card, if any.

Returns
true if the Joker scoring loop has returned early
See also
check_and_score_joker_for_event

Definition at line 1680 of file round.c.

◆ play_scoring_independent_jokers_update()

static bool play_scoring_independent_jokers_update ( int  played_idx)
inlinestatic

Score Jokers normally for event JOKER_EVENT_INDEPENDENT.

Returns
true if the Joker scoring loop has returned early
See also
check_and_score_joker_for_event

Definition at line 1717 of file round.c.

◆ play_starting_played_cards_update()

static void play_starting_played_cards_update ( int  played_idx)
inlinestatic

Definition at line 1504 of file round.c.

◆ played_cards_update_loop()

static void played_cards_update_loop ( void  )
inlinestatic

Definition at line 1876 of file round.c.

◆ played_push()

static void played_push ( CardObject card_object)
inlinestatic

Push a new card to play at the end of the associated array.

Parameters
card_objectthe CardObject we just played

Definition at line 258 of file round.c.

◆ select_all_five_cards_in_played_hand()

static void select_all_five_cards_in_played_hand ( void  )
inlinestatic

Definition at line 893 of file round.c.

◆ select_cards_in_played_hand()

static void select_cards_in_played_hand ( void  )
inlinestatic

Definition at line 1219 of file round.c.

◆ select_flush_and_straight_cards_in_played_hand()

static void select_flush_and_straight_cards_in_played_hand ( void  )
inlinestatic

Definition at line 846 of file round.c.

◆ select_four_of_a_kind_cards_in_played_hand()

static void select_four_of_a_kind_cards_in_played_hand ( void  )
inlinestatic

Definition at line 901 of file round.c.

◆ select_highcard_cards_in_played_hand()

static void select_highcard_cards_in_played_hand ( void  )
inlinestatic

Definition at line 1028 of file round.c.

◆ select_pair_cards_in_played_hand()

static void select_pair_cards_in_played_hand ( void  )
inlinestatic

Definition at line 1008 of file round.c.

◆ select_three_of_a_kind_cards_in_played_hand()

static void select_three_of_a_kind_cards_in_played_hand ( void  )
inlinestatic

Definition at line 939 of file round.c.

◆ select_two_pair_cards_in_played_hand()

static void select_two_pair_cards_in_played_hand ( void  )
inlinestatic

Definition at line 970 of file round.c.

◆ set_retrigger()

void set_retrigger ( bool  new_retrigger)

Set whether the current card should get triggered again.

Parameters
new_retriggertrue if the card should trigger again, false if not

Definition at line 301 of file round.c.

◆ toggle_flaming_score()

void toggle_flaming_score ( void  )

Checks whether the score that would result from the current Chips and Mult exceeds the current Blind's score requirement, and applies the flaming effect if needed.

Definition at line 1425 of file round.c.

Variable Documentation

◆ BIG_BLIND_TITLE_SRC_RECT

const Rect BIG_BLIND_TITLE_SRC_RECT = {0, 26, 8, 26 }
static

Definition at line 80 of file round.c.

◆ BOSS_BLIND_TITLE_SRC_RECT

const Rect BOSS_BLIND_TITLE_SRC_RECT = {0, 27, 8, 27 }
static

Definition at line 81 of file round.c.

◆ CARD_DISCARD_PNT

const BG_POINT CARD_DISCARD_PNT = {240, 70}
static

Definition at line 97 of file round.c.

◆ CARD_DRAW_POS

const BG_POINT CARD_DRAW_POS = {208, 110}
static

Definition at line 96 of file round.c.

◆ CARD_SWAP_TIME_THRESHOLD

const int CARD_SWAP_TIME_THRESHOLD = 6
static

Definition at line 541 of file round.c.

◆ GAME_PLAYING_INIT_SEL

const Selection GAME_PLAYING_INIT_SEL = {0, 1}
static

Definition at line 154 of file round.c.

◆ game_round_buttons

Button game_round_buttons[]
static
Initial value:
= {
{PLAY_HAND_BTN_BORDER_PAL_IDX, PLAY_HAND_BTN_PAL_IDX, game_round_play_hand_on_pressed, can_play_hand },
{SORT_BY_RANK_BTN_BORDER_PAL_IDX, SORT_BTNS_PAL_IDX, game_round_sort_by_rank_on_pressed, NULL },
{SORT_BY_SUIT_BTN_BORDER_PAL_IDX, SORT_BTNS_PAL_IDX, game_round_sort_by_suit_on_pressed, NULL },
{DISCARD_BTN_BORDER_PAL_IDX, DISCARD_BTN_PAL_IDX, game_round_discard_on_pressed, can_discard_hand},
}
static void game_round_play_hand_on_pressed(void)
"Play" button implementation.
Definition round.c:510
static void game_round_sort_by_suit_on_pressed(void)
"Suit" sorting button implementation.
Definition round.c:486
static bool can_play_hand(void)
Determines whether the "Play" button can be pressed or not.
Definition round.c:440
static bool can_discard_hand(void)
Determines whether the "Discard" button can be pressed or not.
Definition round.c:427
static void game_round_discard_on_pressed(void)
"Discard" button implementation.
Definition round.c:464
static void game_round_sort_by_rank_on_pressed(void)
"Rank" sorting button implementation.
Definition round.c:478

Definition at line 176 of file round.c.

◆ game_round_selection_grid

SelectionGrid game_round_selection_grid
static
Initial value:
= {
game_round_selection_rows,
NUM_ELEM_IN_ARR(game_round_selection_rows),
GAME_PLAYING_INIT_SEL
}
#define NUM_ELEM_IN_ARR(arr)
Get the number of elements in an array.
Definition util.h:43

Definition at line 156 of file round.c.

◆ game_round_selection_rows

SelectionGridRow game_round_selection_rows[]
static
Initial value:
= {
{
0,
{.wrap = false}
},
{
1,
game_round_hand_row_get_size,
game_round_hand_row_on_selection_changed,
game_round_hand_row_on_key_transit,
{.wrap = true}
},
{
2,
game_round_button_row_get_size,
game_round_button_row_on_selection_changed,
game_round_button_row_on_key_hit,
{.wrap = false}
}
}
bool jokers_sel_row_on_selection_changed(SelectionGrid *selection_grid, int row_idx, const Selection *prev_selection, const Selection *new_selection)
Handle directional inputs on the Jokers' row at the top of the game screen.
Definition joker_row.c:16
void jokers_sel_row_on_key_transit(SelectionGrid *selection_grid, Selection *selection)
Handle button inputs on the Jokers' row at the top of the game screen.
Definition joker_row.c:100
int jokers_sel_row_get_size(void)
Returns the size of the Jokers' row at the top of the game screen. Is equal to the number of Jokers o...
Definition joker_row.c:11

Definition at line 129 of file round.c.

◆ HAND_BG_RECT_SELECTING

const Rect HAND_BG_RECT_SELECTING = {9, 11, 24, 17 }
static

Definition at line 90 of file round.c.

◆ HAND_PLAY_POS

const BG_POINT HAND_PLAY_POS = {120, 70}
static

Definition at line 99 of file round.c.

◆ HAND_SIZE_RECT_PLAYING

const Rect HAND_SIZE_RECT_PLAYING = {120, 152, 160, 160 }
static

Definition at line 92 of file round.c.

◆ HAND_SIZE_RECT_SELECT

const Rect HAND_SIZE_RECT_SELECT = {120, 128, 160, 136 }
static

Definition at line 91 of file round.c.

◆ HAND_SPACING_LUT

const int HAND_SPACING_LUT[MAX_HAND_SIZE]
static
Initial value:
=
{28, 28, 28, 28, 27, 21, 18, 15, 13, 12, 10, 9, 9, 8, 8, 7}

Definition at line 208 of file round.c.

◆ HAND_START_POS

const BG_POINT HAND_START_POS = {120, 90}
static

Definition at line 98 of file round.c.

◆ HELD_CARDS_SCORES_RECT

const Rect HELD_CARDS_SCORES_RECT = {72, 108, 240, 116 }
static

Definition at line 94 of file round.c.

◆ play_state

enum PlayState play_state = PLAY_STARTING
static

Definition at line 201 of file round.c.

◆ PLAYED_CARDS_SCORES_RECT

const Rect PLAYED_CARDS_SCORES_RECT = {72, 48, 240, 56 }
static

Definition at line 93 of file round.c.

◆ s_card_moved_too_fast

bool s_card_moved_too_fast = false
static

Definition at line 535 of file round.c.

◆ s_card_selected_instead_of_moved

bool s_card_selected_instead_of_moved = false
static

Definition at line 536 of file round.c.

◆ s_cards_discarded

int s_cards_discarded = 0
static

Definition at line 237 of file round.c.

◆ s_cards_drawn

int s_cards_drawn = 0
static

Definition at line 236 of file round.c.

◆ s_discard_pile

Card* s_discard_pile[MAX_DECK_SIZE] = {NULL}
static

Definition at line 215 of file round.c.

◆ s_discard_top

int s_discard_top = -1
static

Definition at line 216 of file round.c.

◆ s_discarded_card

bool s_discarded_card = false
static

Definition at line 234 of file round.c.

◆ s_joker_card_scored_end_itr

ListItr s_joker_card_scored_end_itr
static

Definition at line 224 of file round.c.

◆ s_joker_round_end_itr

ListItr s_joker_round_end_itr
static

Definition at line 225 of file round.c.

◆ s_joker_scored_itr

ListItr s_joker_scored_itr
static

Definition at line 223 of file round.c.

◆ s_lerped_score

FIXED s_lerped_score = 0
static

Definition at line 229 of file round.c.

◆ s_lerped_temp_score

FIXED s_lerped_temp_score = 0
static

Definition at line 230 of file round.c.

◆ s_moving_card

bool s_moving_card = false
static

Definition at line 531 of file round.c.

◆ s_played_hand

CardObject* s_played_hand[MAX_SELECTION_SIZE] = {NULL}
static

Definition at line 212 of file round.c.

◆ s_played_top

int s_played_top = -1
static

Definition at line 213 of file round.c.

◆ s_retrigger

bool s_retrigger = false
static

Definition at line 220 of file round.c.

◆ s_score_flames_active

bool s_score_flames_active = false
static

Definition at line 228 of file round.c.

◆ s_scored_card_index

int s_scored_card_index = 0
static

Definition at line 219 of file round.c.

◆ s_selection_hit_timer

int s_selection_hit_timer = UNDEFINED
static

Definition at line 542 of file round.c.

◆ s_sound_played

bool s_sound_played = false
static

Definition at line 233 of file round.c.

◆ s_temp_score

u32 s_temp_score = 0
static

Definition at line 227 of file round.c.

◆ SCORE_FLAME_CHIPS_POS

const BG_POINT SCORE_FLAME_CHIPS_POS = {1, 9}
static

Definition at line 69 of file round.c.

◆ SCORE_FLAME_FRAMES_START

const Rect SCORE_FLAME_FRAMES_START = {26, 21, 28, 21}
static

Definition at line 68 of file round.c.

◆ SCORE_FLAME_MULT_POS

const BG_POINT SCORE_FLAME_MULT_POS = {5, 9}
static

Definition at line 70 of file round.c.

◆ SCORE_FLAME_RESET

const Rect SCORE_FLAME_RESET = {26, 20, 28, 20}
static

Definition at line 67 of file round.c.

◆ TOP_LEFT_BLIND_TITLE_POINT

const BG_POINT TOP_LEFT_BLIND_TITLE_POINT = {0, 21}
static

Definition at line 79 of file round.c.