Added a state info map which keeps track of a particular state's on_init, on_update and on_exit functions. A few of the on_update functions have sub-states, which create extremely long switch statements. Not sure if perhaps the best route would be to keep the switch statements but break the cases into individual functions or if we should keep track of substates. The latter sounds like it could get complicated and really messy quick. Problem for another day.
131 lines
2.9 KiB
C
131 lines
2.9 KiB
C
#ifndef GAME_H
|
|
#define GAME_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
|
|
#define MAX_SELECTION_SIZE 5
|
|
#define MAX_CARD_SCORE_DIGITS 2 // Current digit limit for score received from cards including mult etc. from jokers
|
|
#define MAX_CARD_SCORE_STR_LEN (MAX_CARD_SCORE_DIGITS + 1) // For the '+' or 'X'
|
|
#define FRAMES(x) (((x) + game_speed - 1) / game_speed)
|
|
|
|
// TODO: Turn into enum?
|
|
#define BG_ID_CARD_SELECTING 1
|
|
#define BG_ID_CARD_PLAYING 2
|
|
#define BG_ID_ROUND_END 3
|
|
#define BG_ID_SHOP 4
|
|
#define BG_ID_BLIND_SELECT 5
|
|
#define BG_ID_MAIN_MENU 6
|
|
|
|
// 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 GameState
|
|
{
|
|
GAME_STATE_SPLASH_SCREEN,
|
|
GAME_STATE_MAIN_MENU,
|
|
GAME_STATE_PLAYING,
|
|
GAME_STATE_ROUND_END,
|
|
GAME_STATE_SHOP,
|
|
GAME_STATE_BLIND_SELECT,
|
|
GAME_STATE_LOSE,
|
|
GAME_STATE_WIN,
|
|
GAME_STATE_MAX
|
|
};
|
|
|
|
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
|
|
HAND_DISCARD,
|
|
HAND_PLAY,
|
|
HAND_PLAYING
|
|
};
|
|
|
|
enum PlayState
|
|
{
|
|
PLAY_PLAYING,
|
|
PLAY_SCORING,
|
|
PLAY_ENDING,
|
|
PLAY_ENDED
|
|
};
|
|
|
|
// Hand types
|
|
enum HandType
|
|
{
|
|
NONE,
|
|
HIGH_CARD,
|
|
PAIR,
|
|
TWO_PAIR,
|
|
THREE_OF_A_KIND,
|
|
FOUR_OF_A_KIND,
|
|
STRAIGHT,
|
|
FLUSH,
|
|
FULL_HOUSE,
|
|
STRAIGHT_FLUSH,
|
|
ROYAL_FLUSH,
|
|
FIVE_OF_A_KIND,
|
|
FLUSH_HOUSE,
|
|
FLUSH_FIVE
|
|
};
|
|
|
|
typedef struct
|
|
{
|
|
int round;
|
|
int ante;
|
|
int money;
|
|
int score;
|
|
int temp_score;
|
|
int chips;
|
|
int mult;
|
|
int current_blind;
|
|
} RunState;
|
|
|
|
typedef struct
|
|
{
|
|
enum GameState state;
|
|
void (*on_init)();
|
|
void (*on_update)();
|
|
void (*on_exit)();
|
|
} StateInfo;
|
|
|
|
// Game functions
|
|
void game_init();
|
|
void game_update();
|
|
void game_change_state(enum GameState new_game_state);
|
|
|
|
// Forward declaration
|
|
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);
|
|
List* get_jokers(void);
|
|
bool is_joker_owned(int joker_id);
|
|
bool card_is_face(Card *card);
|
|
|
|
int get_deck_top(void);
|
|
int get_num_discards_remaining(void);
|
|
int get_num_hands_remaining(void);
|
|
int get_money(void);
|
|
|
|
int get_game_speed(void);
|
|
void set_game_speed(int new_game_speed);
|
|
|
|
#endif // GAME_H
|