Refactor round 1

This commit is contained in:
2021-07-12 15:04:10 -07:00
parent 223f5be854
commit 8b45b976d4
24 changed files with 653 additions and 508 deletions

View File

@ -38,12 +38,14 @@
#include "input/input.h"
// Poker Game Logic
#include "poker/bet.h"
#include "poker/card.h"
#include "poker/chip.h"
#include "poker/dealer.h"
#include "poker/player.h"
#include "poker/poker.h"
#include "poker/render.h"
#include "poker/strings.h"
#include "poker/winner.h"
// Utility Objects
#include "util/array.h"

26
include/dawn/poker/bet.h Normal file
View File

@ -0,0 +1,26 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "../libs.h"
/** How many chips each player has by defautl */
#define POKER_BET_PLAYER_CHIPS_DEFAULT 10000
/** The default blind cost for the big blind. */
#define POKER_BET_BLIND_BIG_DEFAULT 600
/** The default blind cost for the small blind. (Defaults half big blind) */
#define POKER_BET_BLIND_SMALL_DEFAULT (POKER_BET_BLIND_BIG_DEFAULT/2)
typedef struct {
/** Blinds */
uint32_t blindSmall, blindBig;
/** Current pot of chips */
uint32_t pot;
} pokerbet_t;

View File

@ -1,8 +0,0 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once

View File

@ -0,0 +1,27 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "../libs.h"
#include "card.h"
#include "../display/texture.h"
#include "../display/tileset.h"
#include "../display/primitive.h"
/** How many cards the dealer can hold in their hand */
#define POKER_DEALER_HAND 5
/** Representation of the dealer state */
typedef struct {
/** Dealer Hand */
card_t cards[POKER_DEALER_HAND];
uint8_t cardsFacing;
texture_t dealerTexture;
tileset_t dealerTileset;
primitive_t dealerPrimitive;
} pokerdealer_t;

View File

@ -7,14 +7,24 @@
#pragma once
#include "../libs.h"
#include "bet.h"
#include "dealer.h"
#include "card.h"
#include "../display/texture.h"
#include "../display/primitive.h"
#include "../display/tileset.h"
/** How many cards a player can hold in their hand */
#define POKER_PLAYER_HAND 2
/** How many players in a poker game (excludes dealer) */
#define POKER_PLAYER_COUNT 5
////////////////////////////////////////////////////////////////////////////////
// Player States
////////////////////////////////////////////////////////////////////////////////
/** State for whether or not a player has folded */
#define POKER_PLAYER_STATE_FOLDED 0x01
@ -27,6 +37,11 @@
/** The index that the player who is the human... is */
#define POKER_PLAYER_HUMAN_INDEX 0x02
////////////////////////////////////////////////////////////////////////////////
// Player Definition
////////////////////////////////////////////////////////////////////////////////
/** Poker Player State */
typedef struct {
/** Cards in the players' hand */
@ -42,10 +57,11 @@ typedef struct {
/** Current bet in current round player has placed */
uint32_t currentBet;
// Rendering assets
texture_t bodyTexture;
primitive_t bodyPrimitive;
texture_t faceTexture;
primitive_t facePrimitive;
primitive_t facePrimitive;
} pokerplayer_t;

View File

@ -7,15 +7,19 @@
#pragma once
#include "../libs.h"
#include "bet.h"
#include "dealer.h"
#include "player.h"
#include "card.h"
#include "render.h"
#include "winner.h"
#include "../display/camera.h"
#include "../display/shader.h"
#include "../display/texture.h"
#include "../display/tileset.h"
#include "../display/framebuffer.h"
#include "../display/primitive.h"
/** Rounds that the game can be in */
#define POKER_ROUND_MATCH 0x00
@ -31,22 +35,9 @@
#define POKER_ROUND_BET3 0x0A
#define POKER_ROUND_WINNER 0x0B
/** How many cards the dealer can hold in their hand */
#define POKER_DEALER_HAND 5
/** How many cards the grave can hold */
#define POKER_GRAVE_SIZE CARD_DECK_SIZE
/** How many players in a poker game (excludes dealer) */
#define POKER_PLAYER_COUNT 5
/** How many chips each player has by defautl */
#define POKER_PLAYER_CHIPS_DEFAULT 10000
/** The default blind cost for the big blind. Small Blind is half this */
#define POKER_BLIND_BIG_DEFAULT 600
#define POKER_BLIND_SMALL_DEFAULT (POKER_BLIND_BIG_DEFAULT/2)
/** GUI Height fix (To keep gui scaling nicely we use a fixed height) */
#define POKER_GUI_HEIGHT 2160
@ -57,44 +48,10 @@
#define POKER_TURN_CARD_COUNT 1
#define POKER_RIVER_CARD_COUNT 1
/** Winning Types */
#define POKER_WINNING_TYPE_NULL 0x00
#define POKER_WINNING_TYPE_ROYAL_FLUSH 0x01
#define POKER_WINNING_TYPE_STRAIGHT_FLUSH 0x02
#define POKER_WINNING_TYPE_FOUR_OF_A_KIND 0x03
#define POKER_WINNING_TYPE_FULL_HOUSE 0x04
#define POKER_WINNING_TYPE_FLUSH 0x05
#define POKER_WINNING_TYPE_STRAIGHT 0x06
#define POKER_WINNING_TYPE_THREE_OF_A_KIND 0x07
#define POKER_WINNING_TYPE_TWO_PAIR 0x08
#define POKER_WINNING_TYPE_PAIR 0x09
#define POKER_WINNNIG_TYPE_HIGH_CARD 0x0A
/** How many cards make a winning set */
#define POKER_WINNING_SET_SIZE 5
/** Holds information about the winning player state */
typedef struct {
/** The full set of both the dealer and player's hand */
card_t full[POKER_PLAYER_HAND + POKER_DEALER_HAND];
uint8_t fullSize;
/** Holds the winning set */
card_t set[POKER_WINNING_SET_SIZE];
uint8_t setSize;
/** Winning Type */
uint8_t type;
/** If there was a kicker card it will be here, otherwise -1 for no kicker */
card_t kicker;
} pokerwinning_t;
typedef struct {
//////////////////////////////////////////////////////////////////////////////
// Poker Logic Variables
//////////////////////////////////////////////////////////////////////////////
/** Current Card Deck */
card_t deck[CARD_DECK_SIZE];
uint8_t deckSize;
@ -103,50 +60,44 @@ typedef struct {
card_t grave[POKER_GRAVE_SIZE];
uint8_t graveSize;
/** Blinds */
uint32_t blindSmall, blindBig;
/** Dealer Hand */
card_t cards[POKER_DEALER_HAND];
uint8_t cardsFacing;
/** Poker betting state */
pokerbet_t bet;
/** Player States */
pokerdealer_t dealer;
pokerplayer_t players[POKER_PLAYER_COUNT];
/** Winning States */
pokerwinning_t winnings[POKER_PLAYER_COUNT];
uint8_t winners[POKER_PLAYER_COUNT];
uint8_t winnerCount;
/** The current round the game is on */
uint8_t round;
pokerwinner_t winner;
/** The current player that is the dealer */
uint8_t roundDealer;
uint8_t roundSmallBlind;
uint8_t roundBigBlind;
/** Current pot of chips */
uint32_t pot;
//////////////////////////////////////////////////////////////////////////////
// Round variables
//////////////////////////////////////////////////////////////////////////////
uint32_t roundTextCounter;
/** The current round the game is on */
uint8_t round;
/** For Betting round, which player is currently betting */
uint8_t roundBetCurrent;
uint32_t roundTextCounter;
//////////////////////////////////////////////////////////////////////////////
// Rendering Variables
//////////////////////////////////////////////////////////////////////////////
/** Frames to hold the world and GUI render outputs */
framebuffer_t frameWorld, frameGui;
/** Game's Font */
font_t font;
/** Game's Shader */
shader_t shader;
/** Camera for the world and the GUI */
camera_t cameraWorld, cameraGui, cameraTest;
@ -162,19 +113,6 @@ typedef struct {
/** Information about the current rendered text */
fonttextinfo_t *talkTextInfo;
/** Match Scene Variables */
float matchStart;
texture_t dealerTexture;
tileset_t dealerTileset;
primitive_t dealerPrimitive;
texture_t chipTexture;
primitive_t chipPrimitive;

View File

@ -0,0 +1,54 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "../libs.h"
#include "player.h"
#include "dealer.h"
/** Size of the FULL hand used to calculate a winning. */
#define POKER_WINNING_FULL_SIZE POKER_PLAYER_HAND+POKER_DEALER_HAND
/** How many cards make a winning set */
#define POKER_WINNING_SET_SIZE 5
/** Winning Types */
#define POKER_WINNING_TYPE_NULL 0x00
#define POKER_WINNING_TYPE_ROYAL_FLUSH 0x01
#define POKER_WINNING_TYPE_STRAIGHT_FLUSH 0x02
#define POKER_WINNING_TYPE_FOUR_OF_A_KIND 0x03
#define POKER_WINNING_TYPE_FULL_HOUSE 0x04
#define POKER_WINNING_TYPE_FLUSH 0x05
#define POKER_WINNING_TYPE_STRAIGHT 0x06
#define POKER_WINNING_TYPE_THREE_OF_A_KIND 0x07
#define POKER_WINNING_TYPE_TWO_PAIR 0x08
#define POKER_WINNING_TYPE_PAIR 0x09
#define POKER_WINNNIG_TYPE_HIGH_CARD 0x0A
/** Holds information about a player's winning state */
typedef struct {
/** The full set of both the dealer and player's hand */
card_t full[POKER_WINNING_FULL_SIZE];
uint8_t fullSize;
/** Holds the winning set */
card_t set[POKER_WINNING_SET_SIZE];
uint8_t setSize;
/** Winning Type */
uint8_t type;
/** If there was a kicker card it will be here, otherwise -1 for no kicker */
card_t kicker;
} pokerplayerwinning_t;
typedef struct {
/** Winning States */
pokerplayerwinning_t winnings[POKER_PLAYER_COUNT];
uint8_t winners[POKER_PLAYER_COUNT];
uint8_t winnerCount;
} pokerwinner_t;