refactor(server): move addPlayer implementation to ServerGameState

- Relocated `addPlayer` method from template-based `GameState` to `ServerGameState`.
- Updated method signature and comments for better clarity.
This commit is contained in:
Kieran Kihn
2025-12-07 19:32:40 +08:00
parent a1c46b8c9b
commit d266f1c514
2 changed files with 13 additions and 15 deletions

View File

@@ -167,6 +167,13 @@ namespace UNO::GAME {
ServerGameState::ServerGameState() : serverGameStage_(ServerGameStage::PRE_GAME) {}
void ServerGameState::addPlayer(ServerPlayerState playerState)
{
long long currentPlayerIndex = this->currentPlayer_ - this->players_.begin();
this->players_.push_back(std::move(playerState));
this->currentPlayer_ = this->players_.begin() + currentPlayerIndex;
}
void ServerGameState::init()
{
while (discardPile_.isEmpty() || discardPile_.getFront().getType() > CardType::NUM9) {