// Copyright (c) 2022 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #pragma once #include "Card.hpp" #include "PokerPot.hpp" #include "PokerWinning.hpp" #include "PokerTurn.hpp" #include "event/Event.hpp" #define POKER_PLAYER_CHIPS_DEFAULT 10000 /** Maximum cards a players' hand can hold */ #define POKER_PLAYER_HAND_SIZE_MAX 2 #define POKER_PLAYER_MAX_RAISES 0x02 namespace Dawn { class PokerGame; class PokerPlayer : public std::enable_shared_from_this { public: std::weak_ptr pokerGame; uint8_t playerIndex; int32_t chips = 0; int32_t currentBet = 0; uint8_t timesRaised = 0; bool_t isFolded = false; bool_t isOut = false; bool_t hasBetThisRound = false; bool_t isShowingHand = false; bool_t isHuman = false; std::vector hand; Event<> eventChipsChanged; /** * Constructor for the PokerPlayer class. * * @param pokerGame Poker game this player is a part of. * @param playerIndex Index of the player in the game. */ PokerPlayer( const std::weak_ptr pokerGame, const uint8_t playerIndex ); /** * Adds chips to the player. This will also update the players' state. * * @param chips Count of chips to add. */ void addChips(const int32_t chips); /** * Sets the chips a player has. * * @param chips Chips to set to the player. */ void setChips(const int32_t chips); /** * Returns true if the player still needs to bet this betting round. * * @return True if betting is still required by this player. */ bool_t needsToBetThisRound(); /** * Let a player bet chips into the pot. * * @param pot Poker pot to bet in to. * @param amount The amount of chips the player is betting. */ void bet(struct PokerPot &pot, const int32_t amount); /** * Let a player bet chips into the current pot. * * @param amount The amount of chips the player is betting. */ void bet(const int32_t amount); /** * Player folds. */ void fold(); /** * Returns the AI result for a turn done by a non human player. * * @return Some information about the move the player is trying to perform */ struct PokerTurn getAITurn(); /** * Calculates and returns the winning state for a given player * * @return The winning state for this current players hand. */ struct PokerWinning getWinning(); /** * Returns the sum of chips in the pot(s) that the specified player is in. * This does not consider the pot, player or hand, just the pure sum of * chips. * * @return The sum of chips from the pots the player is within. */ int32_t getSumOfChips(); /** * Get the bet necessary for a specific player to make a call. This takes * the players current bet and the bet necessary to call into the pot and * will return the difference. * * @return The count of chips needed to call into the current active pot. */ int32_t getCallBet(); /** * Returns whether or not the player can check, or if they need to either * fold, call or bet. * * @return True if they can check. */ bool_t canCheck(); }; }