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/common_ui.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 "skip_tag.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 JOKER_SCORE_TEXT_Y   48
 
#define HELD_CARD_SCORE_TEXT_Y   108
 
#define MAX_CARD_SCORE_STR_LEN   2
 
#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 round_button_row_get_size (void)
 
static bool round_button_row_on_selection_changed (SelectionGrid *selection_grid, int row_idx, const Selection *prev_selection, const Selection *new_selection)
 
static void round_button_row_on_key_hit (SelectionGrid *selection_grid, Selection *selection)
 
static void round_hand_row_on_key_transit (SelectionGrid *selection_grid, Selection *selection)
 
static bool round_hand_row_on_selection_changed (SelectionGrid *selection_grid, int row_idx, const Selection *prev_selection, const Selection *new_selection)
 
static int 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 round_discard_on_pressed (void)
 "Discard" button implementation.
 
static void round_play_hand_on_pressed (void)
 "Play" button implementation.
 
static void round_sort_by_rank_on_pressed (void)
 "Rank" sorting button implementation.
 
static void 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 Card * discard_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 round_change_background_selecting (void)
 Change to the round card selection background.
 
void round_change_background_playing (void)
 Change to the round card playing background.
 
static void round_execute_discard (void)
 Triggers the discard of the currently selected cards in hand.
 
static void round_execute_play_hand (void)
 Triggers the playing of the currently selected cards in hand.
 
static void round_button_set_highlight (int btn_idx, bool highlight)
 
static void round_process_hand_select_input (void)
 
static void 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 round_is_over (void)
 Determines if the round is over, be it because we lost or won the round.
 
static void 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 round_process_card_draw (void)
 
static void round_discarded_cards_loop (void)
 
static void select_cards_in_played_hand (void)
 
static void cards_in_hand_update_loop (void)
 
static void 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 round_process_flaming_score (void)
 
static void joker_scoring_increment_text_cursor (int *cursor_pos_x)
 
static bool joker_object_score (JokerObject *joker_object, CardObject *card_object, enum JokerEvent joker_event)
 
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 round_on_init (void)
 Round state initialization.
 
void 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 CardObject * s_played_hand [MAX_SELECTION_SIZE] = {NULL}
 
static int s_played_top = -1
 
static Card * s_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 42 of file round.c.

◆ BLIND_BG_SECONDARY_PAL_IDX

#define BLIND_BG_SECONDARY_PAL_IDX   18

Definition at line 41 of file round.c.

◆ BLIND_BG_SHADOW_PAL_IDX

#define BLIND_BG_SHADOW_PAL_IDX   5

Definition at line 40 of file round.c.

◆ CARD_FOCUSED_SEL_Y

#define CARD_FOCUSED_SEL_Y   20

Definition at line 60 of file round.c.

◆ CARD_FOCUSED_UNSEL_Y

#define CARD_FOCUSED_UNSEL_Y   10

Definition at line 58 of file round.c.

◆ CARD_UNFOCUSED_SEL_Y

#define CARD_UNFOCUSED_SEL_Y   15

Definition at line 59 of file round.c.

◆ DISCARD_BTN_BORDER_PAL_IDX

#define DISCARD_BTN_BORDER_PAL_IDX   8

Definition at line 36 of file round.c.

◆ DISCARD_BTN_PAL_IDX

#define DISCARD_BTN_PAL_IDX   13

Definition at line 35 of file round.c.

◆ GAME_PLAYING_HAND_SEL_Y

#define GAME_PLAYING_HAND_SEL_Y   1

Definition at line 55 of file round.c.

◆ HELD_CARD_SCORE_TEXT_Y

#define HELD_CARD_SCORE_TEXT_Y   108

Definition at line 63 of file round.c.

◆ JOKER_SCORE_TEXT_Y

#define JOKER_SCORE_TEXT_Y   48

Definition at line 62 of file round.c.

◆ MAX_CARD_SCORE_STR_LEN

#define MAX_CARD_SCORE_STR_LEN   2

Definition at line 64 of file round.c.

◆ NUM_SCORE_FLAMES_FRAMES

#define NUM_SCORE_FLAMES_FRAMES   8

Definition at line 70 of file round.c.

◆ NUM_SCORE_LERP_STEPS

#define NUM_SCORE_LERP_STEPS   16

Definition at line 52 of file round.c.

◆ PITCH_STEP_DISCARD_SFX

#define PITCH_STEP_DISCARD_SFX   (-64)

Definition at line 45 of file round.c.

◆ PITCH_STEP_DRAW_SFX

#define PITCH_STEP_DRAW_SFX   24

Definition at line 46 of file round.c.

◆ PITCH_STEP_UNDISCARD_SFX

#define PITCH_STEP_UNDISCARD_SFX   (2 * PITCH_STEP_DRAW_SFX)

Definition at line 47 of file round.c.

◆ PLAY_HAND_BTN_BORDER_PAL_IDX

#define PLAY_HAND_BTN_BORDER_PAL_IDX   7

Definition at line 34 of file round.c.

◆ PLAY_HAND_BTN_PAL_IDX

#define PLAY_HAND_BTN_PAL_IDX   6

Definition at line 33 of file round.c.

◆ SCORE_FLAME_FRAME_WIDTH

#define SCORE_FLAME_FRAME_WIDTH   3

Definition at line 71 of file round.c.

◆ SCORE_FLAMES_ANIM_FREQ

#define SCORE_FLAMES_ANIM_FREQ   5

Definition at line 69 of file round.c.

◆ SCORED_CARD_TEXT_Y

#define SCORED_CARD_TEXT_Y   48

Definition at line 61 of file round.c.

◆ SORT_BTNS_PAL_IDX

#define SORT_BTNS_PAL_IDX   9

Definition at line 37 of file round.c.

◆ SORT_BY_RANK_BTN_BORDER_PAL_IDX

#define SORT_BY_RANK_BTN_BORDER_PAL_IDX   22

Definition at line 38 of file round.c.

◆ SORT_BY_SUIT_BTN_BORDER_PAL_IDX

#define SORT_BY_SUIT_BTN_BORDER_PAL_IDX   23

Definition at line 39 of file round.c.

◆ TM_SCORE_LERP_INTERVAL

#define TM_SCORE_LERP_INTERVAL   2

Definition at line 53 of file round.c.

Enumeration Type Documentation

◆ PlayState

enum PlayState

Definition at line 193 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 432 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 445 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 1140 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 758 of file round.c.

◆ cards_in_hand_update_loop()

static void cards_in_hand_update_loop ( void  )
inlinestatic

Definition at line 1276 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 1640 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 294 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 282 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 270 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 319 of file round.c.

◆ get_played_size()

int get_played_size ( void  )

Get the number of cards played.

Returns
int

Definition at line 253 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 248 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 301 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 711 of file round.c.

◆ joker_object_score()

static bool joker_object_score ( JokerObject *  joker_object,
CardObject *  card_object,
enum JokerEvent  joker_event 
)
static

Definition at line 1510 of file round.c.

◆ joker_scoring_increment_text_cursor()

static void joker_scoring_increment_text_cursor ( int *  cursor_pos_x)
static

Definition at line 1497 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 1698 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 1974 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 1929 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 1784 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 1715 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 1898 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 1834 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 1871 of file round.c.

◆ play_starting_played_cards_update()

static void play_starting_played_cards_update ( int  played_idx)
inlinestatic

Definition at line 1658 of file round.c.

◆ played_cards_update_loop()

static void played_cards_update_loop ( void  )
inlinestatic

Definition at line 2030 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 263 of file round.c.

◆ round_button_row_get_size()

static int round_button_row_get_size ( void  )
static

Definition at line 662 of file round.c.

◆ round_button_row_on_key_hit()

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

Definition at line 697 of file round.c.

◆ round_button_row_on_selection_changed()

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

Definition at line 672 of file round.c.

◆ round_button_set_highlight()

static void round_button_set_highlight ( int  btn_idx,
bool  highlight 
)
inlinestatic

Definition at line 667 of file round.c.

◆ round_change_background_playing()

void round_change_background_playing ( void  )

Change to the round card playing background.

Definition at line 405 of file round.c.

◆ round_change_background_selecting()

void round_change_background_selecting ( void  )

Change to the round card selection background.

Definition at line 343 of file round.c.

◆ round_discard_on_pressed()

static void round_discard_on_pressed ( void  )
static

"Discard" button implementation.

Definition at line 469 of file round.c.

◆ round_discarded_cards_loop()

static void round_discarded_cards_loop ( void  )
inlinestatic

Definition at line 1185 of file round.c.

◆ round_execute_discard()

static void round_execute_discard ( void  )
inlinestatic

Triggers the discard of the currently selected cards in hand.

Definition at line 455 of file round.c.

◆ round_execute_play_hand()

static void round_execute_play_hand ( void  )
inlinestatic

Triggers the playing of the currently selected cards in hand.

Definition at line 499 of file round.c.

◆ round_hand_row_get_size()

static int round_hand_row_get_size ( void  )
static

Definition at line 526 of file round.c.

◆ round_hand_row_on_key_transit()

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

Definition at line 626 of file round.c.

◆ round_hand_row_on_selection_changed()

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

Definition at line 549 of file round.c.

◆ round_handle_round_over()

static void 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 728 of file round.c.

◆ round_is_over()

static bool 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 1054 of file round.c.

◆ round_on_init()

void round_on_init ( void  )

Round state initialization.

Definition at line 2130 of file round.c.

◆ round_on_update()

void round_on_update ( void  )

Round state update.

Definition at line 2204 of file round.c.

◆ round_play_hand_on_pressed()

static void round_play_hand_on_pressed ( void  )
static

"Play" button implementation.

Definition at line 515 of file round.c.

◆ round_process_card_draw()

static void round_process_card_draw ( void  )
inlinestatic

Definition at line 1167 of file round.c.

◆ round_process_flaming_score()

static void round_process_flaming_score ( void  )
inlinestatic

Definition at line 1469 of file round.c.

◆ round_process_hand_select_input()

static void round_process_hand_select_input ( void  )
inlinestatic

Definition at line 719 of file round.c.

◆ round_process_input_and_state()

static void round_process_input_and_state ( void  )
inlinestatic

Definition at line 1060 of file round.c.

◆ round_sort_by_rank_on_pressed()

static void round_sort_by_rank_on_pressed ( void  )
static

"Rank" sorting button implementation.

Definition at line 483 of file round.c.

◆ round_sort_by_suit_on_pressed()

static void round_sort_by_suit_on_pressed ( void  )
static

"Suit" sorting button implementation.

Definition at line 491 of file round.c.

◆ round_ui_text_update()

static void round_ui_text_update ( void  )
inlinestatic

Definition at line 1398 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 898 of file round.c.

◆ select_cards_in_played_hand()

static void select_cards_in_played_hand ( void  )
inlinestatic

Definition at line 1234 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 851 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 906 of file round.c.

◆ select_highcard_cards_in_played_hand()

static void select_highcard_cards_in_played_hand ( void  )
inlinestatic

Definition at line 1033 of file round.c.

◆ select_pair_cards_in_played_hand()

static void select_pair_cards_in_played_hand ( void  )
inlinestatic

Definition at line 1013 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 944 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 975 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 306 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 1446 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 85 of file round.c.

◆ BOSS_BLIND_TITLE_SRC_RECT

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

Definition at line 86 of file round.c.

◆ CARD_DISCARD_PNT

const BG_POINT CARD_DISCARD_PNT = {240, 70}
static

Definition at line 102 of file round.c.

◆ CARD_DRAW_POS

const BG_POINT CARD_DRAW_POS = {208, 110}
static

Definition at line 101 of file round.c.

◆ CARD_SWAP_TIME_THRESHOLD

const int CARD_SWAP_TIME_THRESHOLD = 6
static

Definition at line 546 of file round.c.

◆ GAME_PLAYING_INIT_SEL

const Selection GAME_PLAYING_INIT_SEL = {0, 1}
static

Definition at line 159 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, round_play_hand_on_pressed, can_play_hand },
{SORT_BY_RANK_BTN_BORDER_PAL_IDX, SORT_BTNS_PAL_IDX, round_sort_by_rank_on_pressed, NULL },
{SORT_BY_SUIT_BTN_BORDER_PAL_IDX, SORT_BTNS_PAL_IDX, round_sort_by_suit_on_pressed, NULL },
{DISCARD_BTN_BORDER_PAL_IDX, DISCARD_BTN_PAL_IDX, round_discard_on_pressed, can_discard_hand},
}
static void round_sort_by_suit_on_pressed(void)
"Suit" sorting button implementation.
Definition round.c:491
static void round_play_hand_on_pressed(void)
"Play" button implementation.
Definition round.c:515
static bool can_play_hand(void)
Determines whether the "Play" button can be pressed or not.
Definition round.c:445
static bool can_discard_hand(void)
Determines whether the "Discard" button can be pressed or not.
Definition round.c:432
static void round_sort_by_rank_on_pressed(void)
"Rank" sorting button implementation.
Definition round.c:483
static void round_discard_on_pressed(void)
"Discard" button implementation.
Definition round.c:469

Definition at line 181 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:55

Definition at line 161 of file round.c.

◆ game_round_selection_rows

SelectionGridRow game_round_selection_rows[]
static
Initial value:
= {
{
0,
{.wrap = false}
},
{
1,
round_hand_row_get_size,
round_hand_row_on_selection_changed,
round_hand_row_on_key_transit,
{.wrap = true}
},
{
2,
round_button_row_get_size,
round_button_row_on_selection_changed,
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:92
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 134 of file round.c.

◆ HAND_BG_RECT_SELECTING

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

Definition at line 95 of file round.c.

◆ HAND_PLAY_POS

const BG_POINT HAND_PLAY_POS = {120, 70}
static

Definition at line 104 of file round.c.

◆ HAND_SIZE_RECT_PLAYING

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

Definition at line 97 of file round.c.

◆ HAND_SIZE_RECT_SELECT

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

Definition at line 96 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 213 of file round.c.

◆ HAND_START_POS

const BG_POINT HAND_START_POS = {120, 90}
static

Definition at line 103 of file round.c.

◆ HELD_CARDS_SCORES_RECT

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

Definition at line 99 of file round.c.

◆ play_state

enum PlayState play_state = PLAY_STARTING
static

Definition at line 206 of file round.c.

◆ PLAYED_CARDS_SCORES_RECT

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

Definition at line 98 of file round.c.

◆ s_card_moved_too_fast

bool s_card_moved_too_fast = false
static

Definition at line 540 of file round.c.

◆ s_card_selected_instead_of_moved

bool s_card_selected_instead_of_moved = false
static

Definition at line 541 of file round.c.

◆ s_cards_discarded

int s_cards_discarded = 0
static

Definition at line 242 of file round.c.

◆ s_cards_drawn

int s_cards_drawn = 0
static

Definition at line 241 of file round.c.

◆ s_discard_pile

Card* s_discard_pile[MAX_DECK_SIZE] = {NULL}
static

Definition at line 220 of file round.c.

◆ s_discard_top

int s_discard_top = -1
static

Definition at line 221 of file round.c.

◆ s_discarded_card

bool s_discarded_card = false
static

Definition at line 239 of file round.c.

◆ s_joker_card_scored_end_itr

ListItr s_joker_card_scored_end_itr
static

Definition at line 229 of file round.c.

◆ s_joker_round_end_itr

ListItr s_joker_round_end_itr
static

Definition at line 230 of file round.c.

◆ s_joker_scored_itr

ListItr s_joker_scored_itr
static

Definition at line 228 of file round.c.

◆ s_lerped_score

FIXED s_lerped_score = 0
static

Definition at line 234 of file round.c.

◆ s_lerped_temp_score

FIXED s_lerped_temp_score = 0
static

Definition at line 235 of file round.c.

◆ s_moving_card

bool s_moving_card = false
static

Definition at line 536 of file round.c.

◆ s_played_hand

CardObject* s_played_hand[MAX_SELECTION_SIZE] = {NULL}
static

Definition at line 217 of file round.c.

◆ s_played_top

int s_played_top = -1
static

Definition at line 218 of file round.c.

◆ s_retrigger

bool s_retrigger = false
static

Definition at line 225 of file round.c.

◆ s_score_flames_active

bool s_score_flames_active = false
static

Definition at line 233 of file round.c.

◆ s_scored_card_index

int s_scored_card_index = 0
static

Definition at line 224 of file round.c.

◆ s_selection_hit_timer

int s_selection_hit_timer = UNDEFINED
static

Definition at line 547 of file round.c.

◆ s_sound_played

bool s_sound_played = false
static

Definition at line 238 of file round.c.

◆ s_temp_score

u32 s_temp_score = 0
static

Definition at line 232 of file round.c.

◆ SCORE_FLAME_CHIPS_POS

const BG_POINT SCORE_FLAME_CHIPS_POS = {1, 9}
static

Definition at line 74 of file round.c.

◆ SCORE_FLAME_FRAMES_START

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

Definition at line 73 of file round.c.

◆ SCORE_FLAME_MULT_POS

const BG_POINT SCORE_FLAME_MULT_POS = {5, 9}
static

Definition at line 75 of file round.c.

◆ SCORE_FLAME_RESET

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

Definition at line 72 of file round.c.

◆ TOP_LEFT_BLIND_TITLE_POINT

const BG_POINT TOP_LEFT_BLIND_TITLE_POINT = {0, 21}
static

Definition at line 84 of file round.c.