mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-22 07:10:25 -08:00
nextTurn cleanup -> fixed the bug that the game would begin with active player 0 even if there is no player 0
This commit is contained in:
@@ -138,7 +138,8 @@ void Server_Game::startGameIfReady()
|
||||
query.exec();
|
||||
}
|
||||
*/
|
||||
setActivePlayer(0);
|
||||
activePlayer = -1;
|
||||
nextTurn();
|
||||
}
|
||||
|
||||
void Server_Game::stopGameIfFinished()
|
||||
@@ -254,6 +255,21 @@ void Server_Game::setActivePhase(int _activePhase)
|
||||
sendGameEvent(new Event_SetActivePhase(-1, activePhase));
|
||||
}
|
||||
|
||||
void Server_Game::nextTurn()
|
||||
{
|
||||
const QList<int> keys = players.keys();
|
||||
int listPos = -1;
|
||||
if (activePlayer != -1)
|
||||
listPos = keys.indexOf(activePlayer);
|
||||
do {
|
||||
++listPos;
|
||||
if (listPos == keys.size())
|
||||
listPos = 0;
|
||||
} while (players.value(keys[listPos])->getSpectator());
|
||||
|
||||
setActivePlayer(keys[listPos]);
|
||||
}
|
||||
|
||||
QList<ServerInfo_Player *> Server_Game::getGameState(Server_Player *playerWhosAsking) const
|
||||
{
|
||||
QList<ServerInfo_Player *> result;
|
||||
|
||||
Reference in New Issue
Block a user