mirror of
https://github.com/kierankihn/uno-game.git
synced 2025-12-27 10:23:16 +08:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user