mirror of
https://github.com/kierankihn/uno-game.git
synced 2025-12-27 02:13:18 +08:00
feat(server): add game reset and end game handling
- Introduced `reset` method in `ServerGameState` to allow game state reinitialization. - Added `handleEndGame` in `UnoServer` to detect and process game conclusion.
This commit is contained in:
@@ -157,4 +157,19 @@ namespace UNO::GAME {
|
||||
this->nextPlayer();
|
||||
return cards;
|
||||
}
|
||||
|
||||
void ServerGameState::reset()
|
||||
{
|
||||
discardPile_.clear();
|
||||
isReversed_ = false;
|
||||
drawCount_ = 0;
|
||||
|
||||
for (auto &player : players_) {
|
||||
while (!player.isEmpty()) {
|
||||
player.play(*player.getCards().begin());
|
||||
}
|
||||
}
|
||||
|
||||
currentPlayer_ = players_.begin();
|
||||
}
|
||||
} // namespace UNO::GAME
|
||||
Reference in New Issue
Block a user