Clang format and refactor game.h/c + update Bracket Alignment to BlockIndent (#259)
* Refactor and clang-format game.h/c * Updated clang-format AlignAfterOpenBracket: BlockIndent and ColumnLimit: 100 and refactored all files accordingly --------- Co-authored-by: MeirGavish <meir.gavish@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
MeirGavish
Copilot
parent
43d837571e
commit
291edaf4f2
+2
-1
@@ -2,7 +2,8 @@
|
||||
#define BLIND_H
|
||||
|
||||
#include "sprite.h"
|
||||
// The GBA's max uint value is around 4 billion, so we're going to not add endless mode for simplicity's sake
|
||||
// The GBA's max uint value is around 4 billion, so we're going to not add endless mode for
|
||||
// simplicity's sake
|
||||
#define MAX_ANTE 8
|
||||
|
||||
#define SMALL_BLIND_PB 1
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// (stateEnum, on_init, on_update, on_exit)
|
||||
DEF_STATE_INFO(GAME_STATE_SPLASH_SCREEN, splash_screen_on_init, splash_screen_on_update, splash_screen_on_exit)
|
||||
DEF_STATE_INFO(GAME_STATE_MAIN_MENU, game_main_menu_on_init, game_main_menu_on_update, _noop)
|
||||
DEF_STATE_INFO(GAME_STATE_PLAYING, game_round_on_init, game_playing_on_update, _noop)
|
||||
DEF_STATE_INFO(GAME_STATE_ROUND_END, _noop, game_round_end_on_update, game_round_end_on_exit)
|
||||
DEF_STATE_INFO(GAME_STATE_SHOP, _noop, game_shop_on_update, game_shop_on_exit)
|
||||
DEF_STATE_INFO(GAME_STATE_BLIND_SELECT, _noop, game_blind_select_on_update, game_blind_select_on_exit)
|
||||
DEF_STATE_INFO(GAME_STATE_MAIN_MENU, game_main_menu_on_init, game_main_menu_on_update, noop)
|
||||
DEF_STATE_INFO(GAME_STATE_PLAYING, game_round_on_init, game_playing_on_update, noop)
|
||||
DEF_STATE_INFO(GAME_STATE_ROUND_END, noop, game_round_end_on_update, game_round_end_on_exit)
|
||||
DEF_STATE_INFO(GAME_STATE_SHOP, noop, game_shop_on_update, game_shop_on_exit)
|
||||
DEF_STATE_INFO(GAME_STATE_BLIND_SELECT, noop, game_blind_select_on_update, game_blind_select_on_exit)
|
||||
DEF_STATE_INFO(GAME_STATE_LOSE, game_lose_on_init, game_lose_on_update, game_over_on_exit)
|
||||
DEF_STATE_INFO(GAME_STATE_WIN, game_win_on_init, game_win_on_update, game_over_on_exit)
|
||||
|
||||
+47
-46
@@ -3,17 +3,33 @@
|
||||
|
||||
#include <tonc.h>
|
||||
|
||||
#define MAX_HAND_SIZE 16
|
||||
#define MAX_DECK_SIZE 52
|
||||
#define MAX_HAND_SIZE 16
|
||||
#define MAX_DECK_SIZE 52
|
||||
#define MAX_JOKERS_HELD_SIZE 5 // This doesn't account for negatives right now.
|
||||
#define MAX_SHOP_JOKERS 2 // TODO: Make this dynamic and allow for other items besides jokers
|
||||
#define MAX_SELECTION_SIZE 5
|
||||
#define FRAMES(x) (((x) + game_speed - 1) / game_speed)
|
||||
#define MAX_SHOP_JOKERS 2 // TODO: Make this dynamic and allow for other items besides jokers
|
||||
#define MAX_SELECTION_SIZE 5
|
||||
#define FRAMES(x) (((x) + game_speed - 1) / game_speed)
|
||||
|
||||
// TODO: Can make these dynamic to support interest-related jokers and vouchers
|
||||
#define MAX_INTEREST 5
|
||||
// TODO: Can make these dynamic to support interest-related jokers and vouchers
|
||||
#define MAX_INTEREST 5
|
||||
#define INTEREST_PER_5 1
|
||||
|
||||
// Input bindings
|
||||
#define SELECT_CARD KEY_A
|
||||
#define DESELECT_CARDS KEY_B
|
||||
#define PEEK_DECK KEY_L // Not implemented
|
||||
#define SORT_HAND KEY_R
|
||||
#define PAUSE_GAME KEY_START // Not implemented
|
||||
#define SELL_KEY KEY_L
|
||||
|
||||
struct List;
|
||||
typedef struct List List;
|
||||
|
||||
// Utility functions for other files
|
||||
typedef struct CardObject CardObject;
|
||||
typedef struct Card Card;
|
||||
typedef struct JokerObject JokerObject;
|
||||
|
||||
enum BackgroundId
|
||||
{
|
||||
BG_NONE,
|
||||
@@ -25,14 +41,6 @@ enum BackgroundId
|
||||
BG_MAIN_MENU
|
||||
};
|
||||
|
||||
// Input bindings
|
||||
#define SELECT_CARD KEY_A
|
||||
#define DESELECT_CARDS KEY_B
|
||||
#define PEEK_DECK KEY_L // Not implemented
|
||||
#define SORT_HAND KEY_R
|
||||
#define PAUSE_GAME KEY_START // Not implemented
|
||||
#define SELL_KEY KEY_L
|
||||
|
||||
// Enum value names in ../include/def_state_info_table.h
|
||||
enum GameState
|
||||
{
|
||||
@@ -47,7 +55,9 @@ enum HandState
|
||||
{
|
||||
HAND_DRAW,
|
||||
HAND_SELECT,
|
||||
HAND_SHUFFLING, // This is actually a misnomer because it's used for the deck, but it mechanically makes sense to be a state of the hand
|
||||
// This is actually a misnomer because it's used for the deck
|
||||
// but it mechanically makes sense to be a state of the hand
|
||||
HAND_SHUFFLING,
|
||||
HAND_DISCARD,
|
||||
HAND_PLAY,
|
||||
HAND_PLAYING
|
||||
@@ -85,7 +95,7 @@ enum HandType
|
||||
FLUSH_FIVE
|
||||
};
|
||||
|
||||
typedef struct
|
||||
typedef struct
|
||||
{
|
||||
int substate;
|
||||
void (*on_init)();
|
||||
@@ -98,40 +108,31 @@ void game_init();
|
||||
void game_update();
|
||||
void game_change_state(enum GameState new_game_state);
|
||||
|
||||
struct List;
|
||||
typedef struct List List;
|
||||
|
||||
// Utility functions for other files
|
||||
typedef struct CardObject CardObject; // forward declaration, actually declared in card.h
|
||||
typedef struct Card Card;
|
||||
typedef struct JokerObject JokerObject;
|
||||
|
||||
CardObject** get_hand_array(void);
|
||||
int get_hand_top(void);
|
||||
int hand_get_size(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);
|
||||
List* get_jokers_list(void);
|
||||
List* get_expired_jokers_list(void);
|
||||
CardObject** get_hand_array(void);
|
||||
int get_hand_top(void);
|
||||
int hand_get_size(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);
|
||||
List* get_jokers_list(void);
|
||||
List* get_expired_jokers_list(void);
|
||||
|
||||
int get_deck_top(void);
|
||||
int get_num_discards_remaining(void);
|
||||
int get_num_hands_remaining(void);
|
||||
|
||||
u32 get_chips(void);
|
||||
void set_chips(u32 new_chips);
|
||||
void display_chips();
|
||||
u32 get_mult(void);
|
||||
void set_mult(u32 new_mult);
|
||||
void display_mult();
|
||||
int get_money(void);
|
||||
void set_money(int new_money);
|
||||
void display_money();
|
||||
void set_retrigger(bool new_retrigger);
|
||||
|
||||
u32 get_chips(void);
|
||||
void set_chips(u32 new_chips);
|
||||
void display_chips();
|
||||
u32 get_mult(void);
|
||||
void set_mult(u32 new_mult);
|
||||
void display_mult();
|
||||
int get_money(void);
|
||||
void set_money(int new_money);
|
||||
void display_money();
|
||||
void set_retrigger(bool new_retrigger);
|
||||
|
||||
int get_game_speed(void);
|
||||
void set_game_speed(int new_game_speed);
|
||||
|
||||
@@ -15,7 +15,13 @@ bool hand_contains_straight(u8* ranks);
|
||||
bool hand_contains_flush(u8* suits);
|
||||
|
||||
int find_flush_in_played_cards(CardObject** played, int top, int min_len, bool* out_selection);
|
||||
int find_straight_in_played_cards(CardObject** played, int top, bool shortcut_active, int min_len, bool* out_selection);
|
||||
int find_straight_in_played_cards(
|
||||
CardObject** played,
|
||||
int top,
|
||||
bool shortcut_active,
|
||||
int min_len,
|
||||
bool* out_selection
|
||||
);
|
||||
void select_paired_cards_in_hand(CardObject** played, int top, bool* selection);
|
||||
|
||||
#endif
|
||||
|
||||
+7
-5
@@ -5,8 +5,8 @@
|
||||
* List Implementation
|
||||
* ===================
|
||||
*
|
||||
* - This @ref List operates as a linked list @ref ListNodes. It operates as a regular doubly-linked list
|
||||
* but doesn't allocate memory and rather gets @ref ListNodes from a pool.
|
||||
* - This @ref List operates as a linked list @ref ListNodes. It operates as a regular
|
||||
* doubly-linked list but doesn't allocate memory and rather gets @ref ListNodes from a pool.
|
||||
*/
|
||||
#ifndef LIST_H
|
||||
#define LIST_H
|
||||
@@ -23,7 +23,8 @@ typedef struct ListNode ListNode;
|
||||
struct ListNode
|
||||
{
|
||||
/**
|
||||
* @brief The previous @ref ListNode in the associated @ref List, NULL if at the `head` of the list
|
||||
* @brief The previous @ref ListNode in the associated @ref List, NULL if at the `head` of the
|
||||
* list
|
||||
*/
|
||||
ListNode* prev;
|
||||
|
||||
@@ -99,8 +100,9 @@ typedef struct
|
||||
/**
|
||||
* Create a list.
|
||||
*
|
||||
* While this function does not allocate memory for the list itself, the list does allocate memory for each element.
|
||||
* So every created list must be freed with @ref list_clear to ensure the list's nodes are deleted properly.
|
||||
* While this function does not allocate memory for the list itself, the list does allocate memory
|
||||
* for each element. So every created list must be freed with @ref list_clear to ensure the list's
|
||||
* nodes are deleted properly.
|
||||
*
|
||||
* @return A @ref List with head and tail reset.
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,7 @@ struct SelectionGridRow
|
||||
|
||||
struct SelectionGrid
|
||||
{
|
||||
SelectionGridRow* rows;
|
||||
const SelectionGridRow* rows;
|
||||
const int num_rows;
|
||||
Selection selection;
|
||||
};
|
||||
@@ -38,4 +38,4 @@ void selection_grid_process_input(SelectionGrid* selection_grid);
|
||||
void selection_grid_move_selection_horz(SelectionGrid* selection_grid, int direction_tribool);
|
||||
void selection_grid_move_selection_vert(SelectionGrid* selection_grid, int direction_tribool);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user