mirror of
https://github.com/kierankihn/uno-game.git
synced 2025-12-27 02:13:18 +08:00
refractor(game): simplify nextPlayer logic in GameState
This commit is contained in:
@@ -204,18 +204,16 @@ namespace UNO::GAME {
|
||||
void GameState<PlayerStateType>::nextPlayer()
|
||||
{
|
||||
if (this->isReversed_ == false) {
|
||||
this->currentPlayer_ = std::next(this->currentPlayer_);
|
||||
if (this->currentPlayer_ == this->players_.end()) {
|
||||
this->currentPlayer_ = std::next(this->currentPlayer_);
|
||||
this->currentPlayer_ = this->players_.begin();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this->currentPlayer_ == this->players_.begin()) {
|
||||
this->currentPlayer_ = std::prev(this->players_.end());
|
||||
}
|
||||
else {
|
||||
this->currentPlayer_ = std::prev(this->currentPlayer_);
|
||||
this->currentPlayer_ = this->players_.end();
|
||||
}
|
||||
this->currentPlayer_ = std::prev(this->currentPlayer_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user