80 lines
2.2 KiB
C
80 lines
2.2 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 "card.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 flagDefine(0)
|
|
|
|
/** State for whether or not a player is showing their hand */
|
|
#define POKER_PLAYER_STATE_SHOWING flagDefine(1)
|
|
|
|
/** State for whether or not the player is out */
|
|
#define POKER_PLAYER_STATE_OUT flagDefine(2)
|
|
|
|
/** Flag that is reset at the start of each round, and set when move occurs. */
|
|
#define POKER_PLAYER_STATE_ROUND_MOVE flagDefine(3)
|
|
|
|
/** 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 */
|
|
card_t cards[POKER_PLAYER_HAND];
|
|
uint8_t cardCount;
|
|
|
|
/** Current State of player */
|
|
uint8_t state;
|
|
|
|
/** Chips in players' posession */
|
|
int32_t chips;
|
|
|
|
/** Current bet in current round player has placed */
|
|
int32_t currentBet;
|
|
} pokerplayer_t;
|
|
|
|
/**
|
|
* Returns true if the player is still alive and in the current game/
|
|
* Defined as: Not out, not folded.
|
|
*
|
|
* @param player Player to check
|
|
* @returns True if alive/in teh current game.
|
|
*/
|
|
bool pokerPlayerIsAlive(pokerplayer_t *player);
|
|
|
|
/**
|
|
* Returns true if the player provided is human or not.
|
|
*
|
|
* @param poker Poker game instance.
|
|
* @param player Player instance.
|
|
* @returns True if the player is human.
|
|
*/
|
|
bool pokerPlayerIsHuman(poker_t *poker, pokerplayer_t *player);
|
|
|
|
/**
|
|
* Resets a poker player's state (for a new round).
|
|
*
|
|
* @param player Player to reset.
|
|
*/
|
|
void pokerPlayerReset(pokerplayer_t *player); |