/** * Copyright (c) 2021 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "../card.h" #include "../../display/render.h" #include "../../display/spritebatch.h" #include "../../display/texture.h" #include "../../display/tileset.h" #include "../../display/framebuffer.h" /** How many cards a player can hold in their hand */ #define HOLDEM_PLAYER_HAND 2 /** How many cards the dealer can hold in their hand */ #define HOLDEM_DEALER_HAND 5 /** How many players in a holdem game (excludes dealer) */ #define HOLDEM_PLAYER_COUNT 5 /** State for whether or not a player has folded */ #define HOLDEM_STATE_FOLDED 0x01 /** State for whether or not a player is showing their hand */ #define HOLDEM_STATE_SHOWING 0x02 #define HOLDEM_GAME_FRAME_HEIGHT RENDER_STATE.height #define HOLDEM_GAME_FRAME_LEFT_WIDTH RENDER_STATE.width*0.65 #define HOLDEM_GAME_FRAME_RIGHT_WIDTH (\ RENDER_STATE.width - HOLDEM_GAME_FRAME_LEFT_WIDTH - 1\ ) #define HOLDEM_GAME_CARD_WIDTH 0.05 #define HOLDEM_GAME_CARD_HEIGHT 0.07 #define HOLDEM_GAME_CARD_DEPTH 0.0005 /** How many actions the queue can hold */ #define HOLDEM_GAME_ACTION_QUEUE_SIZE 12 /** How much data (in length of sizeof size_t) each action has available */ #define HOLDEM_GAME_ACTION_DATA_SIZE 256 /** Texas Hold'em Player State */ typedef struct { /** Cards in the players' hand */ card_t cards[HOLDEM_PLAYER_HAND]; uint8_t cardCount; /** Current State of player */ uint8_t state; /** Chips in players' posession */ uint32_t chips; /** Current bet in current round player has placed */ uint32_t currentBet; } holdemplayer_t; /** Representation of a Texas Hold'em Match State */ typedef struct { /** Current Card Deck */ card_t deck[CARD_DECK_SIZE]; /** Count of cards in the deck */ uint8_t deckSize; /** How big is the current small blind */ uint32_t blindSmall; /** How big is the current big blind */ uint32_t blindBig; /** Current round pot */ uint32_t pot; /** Cards that have been dealt */ card_t cards[HOLDEM_DEALER_HAND]; /** How many dealt cards are face up */ uint8_t cardsFacing; /** Player States */ holdemplayer_t players[HOLDEM_PLAYER_COUNT]; } holdemmatch_t; /** Callback for actions to use */ typedef void (*holdemActionCallback)(int32_t index, void *data); /** Texas Hold'em Game action that can be queued and executed */ typedef struct { holdemActionCallback init; holdemActionCallback update; holdemActionCallback dispose; } holdemaction_t; typedef struct { holdemmatch_t match; texture_t *kagamiTexture; tileset_t *kagamiTileset; primitive_t *kagamiQuad; /** Action and Allocated Data Space */ holdemaction_t actionQueue[HOLDEM_GAME_ACTION_QUEUE_SIZE]; void *actionData[HOLDEM_GAME_ACTION_DATA_SIZE*HOLDEM_GAME_ACTION_QUEUE_SIZE]; /** Poker Table */ primitive_t *tablePrimitive; texture_t *tableTexture; texture_t *cardTexture; tileset_t *cardTileset; primitive_t *cardPrimitive; texture_t *fontTexture; tileset_t *fontTileset; spritebatch_t *fontBatch; /** Game Render Frames */ framebuffer_t *frameLeft; framebuffer_t *frameRight; primitive_t *quadLeft; primitive_t *quadRight; camera_t cameraLeft; camera_t cameraRight; } holdemgame_t; extern holdemgame_t HOLDEM_GAME_STATE;