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:
Kieran Kihn
2025-12-04 13:28:36 +08:00
parent 535e62c852
commit 766e9f9a21
4 changed files with 55 additions and 0 deletions

View File

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