1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00
This commit is contained in:
DjWarmonger 2015-10-24 18:16:57 +02:00
parent 61692ba168
commit eb0af0096e

View File

@ -1510,6 +1510,25 @@ void CGameHandler::newTurn()
elem->newTurn(); elem->newTurn();
} }
//count days without town for all players, regardless of their turn order
for (auto p = gs->players.begin(); p != gs->players.end(); p++)
{
PlayerState * playerState = &p->second;
if (playerState->status == EPlayerStatus::INGAME)
{
if (playerState->towns.empty())
{
if (playerState->daysWithoutCastle)
++(*playerState->daysWithoutCastle);
else playerState->daysWithoutCastle = 0;
}
else
{
playerState->daysWithoutCastle = boost::none;
}
}
}
synchronizeArtifactHandlerLists(); //new day events may have changed them. TODO better of managing that synchronizeArtifactHandlerLists(); //new day events may have changed them. TODO better of managing that
} }
void CGameHandler::run(bool resume) void CGameHandler::run(bool resume)
@ -1590,18 +1609,6 @@ void CGameHandler::run(bool resume)
PlayerState * playerState = &gs->players[playerColor]; //can't copy CBonusSystemNode by value PlayerState * playerState = &gs->players[playerColor]; //can't copy CBonusSystemNode by value
if (playerState->status == EPlayerStatus::INGAME) if (playerState->status == EPlayerStatus::INGAME)
{ {
//count days without town
if (playerState->towns.empty())
{
if (playerState->daysWithoutCastle)
++(*playerState->daysWithoutCastle);
else playerState->daysWithoutCastle = 0;
}
else
{
playerState->daysWithoutCastle = boost::none; //TODO: reset this immediatelly when player conquers any castle
}
//if player runs out of time, he shouldn't get the turn (especially AI) //if player runs out of time, he shouldn't get the turn (especially AI)
checkVictoryLossConditionsForAll(); checkVictoryLossConditionsForAll();