fix(game): ensure updateStateByDraw correctly increments player's card count and advances to the next player

This commit is contained in:
Kieran Kihn
2025-11-17 14:55:38 +08:00
parent f8666b18b1
commit 2c312343d7
2 changed files with 4 additions and 4 deletions

View File

@@ -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

View File

@@ -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();
}