Refactor/hand (#490)
* move all hand funcs to their new file. now to clean up * WIP * Cleanup + doc hand.h * clang format * Refactor loose variables in hand.c into a proper Hand struct * Fix some more issues * Apply *some* suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * remove outdated comment * fix rebase issue * fix rng_info missing from g_game_vars init --------- Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot Autofix powered by AI
MathisMartin31
parent
d7414157a5
commit
2329c4c681
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <tonc.h>
|
||||
|
||||
#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
|
||||
@@ -54,18 +53,6 @@ enum GameState
|
||||
GAME_STATE_UNDEFINED
|
||||
};
|
||||
|
||||
enum HandState
|
||||
{
|
||||
HAND_DRAW,
|
||||
HAND_SELECT,
|
||||
// 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
|
||||
};
|
||||
|
||||
enum PlayState
|
||||
{
|
||||
PLAY_STARTING,
|
||||
@@ -79,53 +66,6 @@ enum PlayState
|
||||
PLAY_ENDED
|
||||
};
|
||||
|
||||
// Hand types
|
||||
enum HandType
|
||||
{
|
||||
NONE,
|
||||
HIGH_CARD,
|
||||
PAIR,
|
||||
TWO_PAIR,
|
||||
THREE_OF_A_KIND,
|
||||
STRAIGHT,
|
||||
FLUSH,
|
||||
FULL_HOUSE,
|
||||
FOUR_OF_A_KIND,
|
||||
STRAIGHT_FLUSH,
|
||||
ROYAL_FLUSH,
|
||||
FIVE_OF_A_KIND,
|
||||
FLUSH_HOUSE,
|
||||
FLUSH_FIVE
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
// Store all contained hands to optimize "whole hand condition" Jokers
|
||||
typedef struct ContainedHandTypes
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
u16 HIGH_CARD : 1;
|
||||
u16 PAIR : 1;
|
||||
u16 TWO_PAIR : 1;
|
||||
u16 THREE_OF_A_KIND : 1;
|
||||
u16 STRAIGHT : 1;
|
||||
u16 FLUSH : 1;
|
||||
u16 FULL_HOUSE : 1;
|
||||
u16 FOUR_OF_A_KIND : 1;
|
||||
u16 STRAIGHT_FLUSH : 1;
|
||||
u16 ROYAL_FLUSH : 1;
|
||||
u16 FIVE_OF_A_KIND : 1;
|
||||
u16 FLUSH_HOUSE : 1;
|
||||
u16 FLUSH_FIVE : 1;
|
||||
u16 : 3;
|
||||
};
|
||||
u16 value;
|
||||
};
|
||||
} ContainedHandTypes;
|
||||
// clang-format on
|
||||
|
||||
// Game functions
|
||||
void game_init();
|
||||
|
||||
@@ -142,9 +82,6 @@ void game_reset();
|
||||
void game_update();
|
||||
void game_change_state(enum GameState new_game_state);
|
||||
|
||||
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);
|
||||
@@ -159,9 +96,6 @@ List* get_shop_jokers_list(void);
|
||||
Bitset* get_avail_jokers_bitset(void);
|
||||
void set_shop_joker_avail(int joker_id, bool avail);
|
||||
|
||||
ContainedHandTypes* get_contained_hands(void);
|
||||
enum HandType* get_hand_type(void);
|
||||
|
||||
int get_deck_top(void);
|
||||
int get_num_discards_remaining(void);
|
||||
int get_num_hands_remaining(void);
|
||||
|
||||
Reference in New Issue
Block a user