86 lines
2.1 KiB
C
86 lines
2.1 KiB
C
/**
|
|
* Copyright (c) 2021 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "../libs.h"
|
|
#include "../util/flags.h"
|
|
#include "../util/array.h"
|
|
#include "../poker/card.h"
|
|
|
|
#define POKER_PLAYER_COUNT_MAX 5
|
|
#define POKER_PLAYER_HAND_SIZE_MAX 2
|
|
#define POKER_PLAYER_STATE_FOLDED flagDefine(0)
|
|
#define POKER_PLAYER_STATE_OUT flagDefine(1)
|
|
#define POKER_PLAYER_STATE_HAS_BET_THIS_ROUND flagDefine(2)
|
|
|
|
#define POKER_GRAVE_SIZE_MAX CARD_DECK_SIZE
|
|
|
|
#define POKER_COMMUNITY_SIZE_MAX 5
|
|
#define POKER_POT_COUNT_MAX POKER_PLAYER_COUNT_MAX
|
|
|
|
typedef struct {
|
|
int32_t chips;
|
|
card_t cards[POKER_PLAYER_HAND_SIZE_MAX];
|
|
uint8_t cardCount;
|
|
uint8_t state;
|
|
} poker2player_t;
|
|
|
|
typedef struct {
|
|
int32_t chips;
|
|
uint8_t players[POKER_PLAYER_COUNT_MAX];
|
|
uint8_t playerCount;
|
|
} poker2pot_t;
|
|
|
|
typedef struct {
|
|
card_t deck[CARD_DECK_SIZE];
|
|
uint8_t deckSize;
|
|
|
|
card_t grave[POKER_GRAVE_SIZE_MAX];
|
|
uint8_t graveSize;
|
|
|
|
card_t community[POKER_COMMUNITY_SIZE_MAX];
|
|
uint8_t communitySize;
|
|
|
|
poker2pot_t pots[POKER_POT_COUNT_MAX];
|
|
uint8_t potCount;
|
|
|
|
poker2player_t players[POKER_PLAYER_COUNT_MAX];
|
|
uint8_t playerCount;
|
|
|
|
uint8_t playerDealer;
|
|
uint8_t playerSmallBlind;
|
|
uint8_t playerBigBlind;
|
|
|
|
|
|
uint8_t state;
|
|
} poker2_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void pokerInit(poker2_t *poker);
|
|
void pokerResetRound(poker2_t *poker);
|
|
void pokerNewDealer(poker2_t *poker);
|
|
void pokerTakeBlinds(poker2_t *poker, int32_t small, int32_t big);
|
|
|
|
uint8_t pokerPotAdd(poker2_t *poker);
|
|
void pokerPotAddPlayer(poker2pot_t *pot, uint8_t playerIndex);
|
|
|
|
void pokerTurn(poker2_t *poker, uint8_t count);
|
|
void pokerBurn(poker2_t *poker, uint8_t count);
|
|
|
|
uint8_t pokerPlayerAdd(poker2_t *poker);
|
|
void pokerPlayerDeal(poker2_t *poker, poker2player_t *player, uint8_t count);
|
|
void pokerPlayerChipsAdd(poker2player_t *player, int32_t chips);
|
|
void pokerPlayerDealAll(poker2_t *poker, uint8_t count);
|
|
void pokerPlayerBetPot(
|
|
poker2_t *poker, poker2pot_t *pot, uint8_t playerIndex, int32_t chips
|
|
);
|
|
void pokerPlayerBet(poker2_t *poker, uint8_t playerIndex, int32_t chips); |