EraTypes LeagueHelpers::GetGameEraForTrigger()
{
EraTypes eGameEra = NO_ERA;
// Game era is one era less than the most advanced player
EraTypes eMostAdvancedEra = NO_ERA;
for (int i = 0; i < MAX_MAJOR_CIVS; i++)
{
if (GET_PLAYER((PlayerTypes)i).isAlive())
{
EraTypes e = GET_PLAYER((PlayerTypes)i).GetCurrentEra();
if (GET_PLAYER((PlayerTypes)i).GetCurrentEra() > eMostAdvancedEra)
{
eMostAdvancedEra = e;
}
}
}
if (eMostAdvancedEra - 1 > NO_ERA)
{
eGameEra = (EraTypes) ((int)eMostAdvancedEra - 1);
}
// Unless half or more civs are in this era too, then it is this era
int iInMostAdvancedEra = 0;
for (int i = 0; i < MAX_MAJOR_CIVS; i++)
{
if (GET_PLAYER((PlayerTypes)i).isAlive())
{
EraTypes e = GET_PLAYER((PlayerTypes)i).GetCurrentEra();
CvAssert(e <= eMostAdvancedEra);
if (e == eMostAdvancedEra)
{
iInMostAdvancedEra++;
}
}
}
if (iInMostAdvancedEra >= (GC.getGame().countMajorCivsAlive() / 2))
{
eGameEra = eMostAdvancedEra;
}
return eGameEra;
}