Basic animations
This commit is contained in:
@ -25,7 +25,7 @@ void PokerGame::newGame() {
|
||||
auto it = this->players.begin();
|
||||
while(it != this->players.end()) {
|
||||
auto player = *it;
|
||||
player->chips = POKER_PLAYER_CHIPS_DEFAULT;
|
||||
player->setChips(POKER_PLAYER_CHIPS_DEFAULT);
|
||||
player->isOut = false;
|
||||
++it;
|
||||
}
|
||||
|
@ -24,6 +24,12 @@ void PokerPlayer::addChips(int32_t chips) {
|
||||
|
||||
this->chips += chips;
|
||||
if(this->chips > 0) this->isOut = false;
|
||||
eventChipsChanged.invoke();
|
||||
}
|
||||
|
||||
void PokerPlayer::setChips(int32_t chips) {
|
||||
this->chips = 0;
|
||||
this->addChips(chips);
|
||||
}
|
||||
|
||||
bool_t PokerPlayer::needsToBetThisRound() {
|
||||
@ -39,7 +45,7 @@ void PokerPlayer::bet(struct PokerPot *pot, int32_t chips) {
|
||||
assertTrue(chips >= 0);
|
||||
assertTrue(!this->isFolded);
|
||||
assertTrue(!this->isOut);
|
||||
this->chips -= chips;
|
||||
this->setChips(this->chips - chips);
|
||||
this->currentBet += chips;
|
||||
this->hasBetThisRound = true;
|
||||
if(chips > 0) {
|
||||
|
@ -37,6 +37,8 @@ namespace Dawn {
|
||||
bool_t isHuman = false;
|
||||
std::vector<struct Card> hand;
|
||||
|
||||
Event<> eventChipsChanged;
|
||||
|
||||
/**
|
||||
* Creates a PokerPlayer instance.
|
||||
*
|
||||
@ -54,6 +56,13 @@ namespace Dawn {
|
||||
*/
|
||||
void addChips(int32_t chips);
|
||||
|
||||
/**
|
||||
* Sets the chips a player has.
|
||||
*
|
||||
* @param chips Chips to set to the player.
|
||||
*/
|
||||
void setChips(int32_t chips);
|
||||
|
||||
/**
|
||||
* Returns true if the player still needs to bet this betting round.
|
||||
*
|
||||
|
Reference in New Issue
Block a user