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:
Max-Wilhelm Bruker
2010-08-11 01:17:45 +02:00
parent cbfbc542e7
commit ad40194f25
3 changed files with 19 additions and 13 deletions

View File

@@ -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;