fix(game): update Card::canBePlayedOn to include draw count validation

- Modified `canBePlayedOn` method to consider `drawCount` for additional play restrictions.
- Updated `GameState::updateStateByCard` to pass `drawCount` when validating playable cards.
This commit is contained in:
Kieran Kihn
2025-11-17 21:33:36 +08:00
parent b7dcaabc28
commit b027e5c4db
3 changed files with 6 additions and 5 deletions

View File

@@ -285,7 +285,7 @@ namespace UNO::GAME {
template<PlayerStateTypeConcept PlayerStateType>
void GameState<PlayerStateType>::updateStateByCard(const Card &card)
{
if (this->discardPile_.isEmpty() == false && card.canBePlayedOn(this->discardPile_.getFront()) == false) {
if (this->discardPile_.isEmpty() == false && card.canBePlayedOn(this->discardPile_.getFront(), this->drawCount_) == false) {
throw std::invalid_argument("Card cannot be played");
}
this->currentPlayer_->play(card);