mirror of
https://github.com/kierankihn/uno-game.git
synced 2025-12-27 02:13:18 +08:00
fix(game): preserve currentPlayer index when adding a new player
This commit is contained in:
@@ -195,7 +195,9 @@ namespace UNO::GAME {
|
||||
template<PlayerStateTypeConcept PlayerStateType>
|
||||
void GameState<PlayerStateType>::addPlayer(PlayerStateType playerState)
|
||||
{
|
||||
this->currentPlayer_ = this->players_.push_back(std::move(playerState), this->currentPlayer_);
|
||||
int currentPlayerIndex = this->currentPlayer_ - this->players_.begin();
|
||||
this->players_.push_back(std::move(playerState));
|
||||
this->currentPlayer_ = this->players_.begin() + currentPlayerIndex;
|
||||
}
|
||||
|
||||
template<PlayerStateTypeConcept PlayerStateType>
|
||||
|
||||
Reference in New Issue
Block a user