mirror of
https://github.com/kierankihn/uno-game.git
synced 2025-12-27 02:13:18 +08:00
fix(game): ensure updateStateByDraw correctly increments player's card count and advances to the next player
This commit is contained in:
@@ -66,7 +66,9 @@ namespace UNO::GAME {
|
||||
if (this->drawCount_ == 0) {
|
||||
this->drawCount_ = 1;
|
||||
}
|
||||
this->currentPlayer_->setRemainingCardCount((this->currentPlayer_->getRemainingCardCount() + this->drawCount_));
|
||||
this->currentPlayer_->draw(this->deck_.draw(this->drawCount_));
|
||||
this->drawCount_ = 0;
|
||||
this->nextPlayer();
|
||||
}
|
||||
} // namespace UNO::GAME
|
||||
@@ -266,11 +266,9 @@ namespace UNO::GAME {
|
||||
void GameState<PlayerStateType>::updateStateByDraw()
|
||||
{
|
||||
if (this->drawCount_ == 0) {
|
||||
this->currentPlayer_->setRemainingCardCount(this->currentPlayer_->getRemainingCardCount() + 1);
|
||||
}
|
||||
else {
|
||||
this->currentPlayer_->setRemainingCardCount((this->currentPlayer_->getRemainingCardCount() + this->drawCount_));
|
||||
this->drawCount_ = 1;
|
||||
}
|
||||
this->currentPlayer_->setRemainingCardCount((this->currentPlayer_->getRemainingCardCount() + this->drawCount_));
|
||||
this->drawCount_ = 0;
|
||||
this->nextPlayer();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user