diff --git a/src/game/GameState.cpp b/src/game/GameState.cpp index 82b3ea6..fc2c90c 100644 --- a/src/game/GameState.cpp +++ b/src/game/GameState.cpp @@ -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) { diff --git a/src/game/GameState.h b/src/game/GameState.h index f87cde7..fef86de 100644 --- a/src/game/GameState.h +++ b/src/game/GameState.h @@ -175,12 +175,6 @@ namespace UNO::GAME { [[nodiscard]] size_t getDrawCount() const; - /** - * 向对局中添加玩家 - * @param playerState 要添加的玩家状态 - */ - void addPlayer(PlayerStateType playerState); - /** * 清空玩家 */ @@ -235,15 +229,6 @@ namespace UNO::GAME { return this->drawCount_; } - - template - void GameState::addPlayer(PlayerStateType playerState) - { - int currentPlayerIndex = this->currentPlayer_ - this->players_.begin(); - this->players_.push_back(std::move(playerState)); - this->currentPlayer_ = this->players_.begin() + currentPlayerIndex; - } - template void GameState::nextPlayer() { @@ -398,6 +383,12 @@ namespace UNO::GAME { */ void init(); + /** + * 向对局中添加玩家 + * @param playerState 要添加的玩家状态 + */ + void addPlayer(ServerPlayerState playerState); + /** * 由于用户摸牌而改变状态 */