// Copyright (c) 2022 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #pragma once #include "scene/SceneItemComponent.hpp" #include "Card.hpp" #include "scene/Scene.hpp" #include "PokerPot.hpp" #include "util/mathutils.hpp" #include "display/animation/Easing.hpp" #include "PokerWinning.hpp" #include "PokerTurn.hpp" #include "util/random.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 SceneItemComponent { public: PokerGame *pokerGame; 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; /** * Creates a PokerPlayer instance. * * @param item Item that this poker player belongs to. */ PokerPlayer(SceneItem *item); /** Override for scene item component event for init */ void onStart() override; /** * Adds chips to the player. This will also update the players' state. * * @param chips Count of chips to add. */ void addChips(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, int32_t amount); /** * Let a player bet chips into the current pot. * * @param amount The amount of chips the player is betting. */ void bet(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(); }; }