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