Testing some stuff for scenarios, with the default winning conditions on, even if you are completely wiped out, the game will not give the "you lose" message. Normally if the default winning conditions are on, you win and lose based on the buildings destroyed.
I changed this a while back so that it wouldn't count as losing if your team still had buildings left and the game wouldn't end until there was a winner (ie teams with buildings = 1) instead of "if this faction has no buildings then lose and exit". It might be good to have the previous early out behaviour for scenarios (see comment in current code).
Previous code:
GameStatus SimulationInterface::checkWinnerStandard() {
//lose
bool lose = false;
if (!hasBuilding(world->getThisFaction())) {
lose = true;
for (int i=0; i < world->getFactionCount(); ++i) {
if (!world->getFaction(i)->isAlly(world->getThisFaction())) {
stats->setVictorious(i);
}
}
gameOver = true;
return GameStatus::LOST;
}
//win
if (!lose) {
bool win = true;
for (int i=0; i < world->getFactionCount(); ++i) {
if (i != world->getThisFactionIndex()) {
if (hasBuilding(world->getFaction(i))
&& !world->getFaction(i)->isAlly(world->getThisFaction())) {
win = false;
}
}
}
//if win
if (win) {
for (int i=0; i < world->getFactionCount(); ++i) {
if (world->getFaction(i)->isAlly(world->getThisFaction())) {
stats->setVictorious(i);
}
}
gameOver = true;
return GameStatus::WON;
}
}
return GameStatus::NO_CHANGE;
}
Current code:
GameStatus SimulationInterface::checkWinnerStandard() {
bool teams[GameConstants::maxPlayers] = {false};
int activeTeams = 0;
// if any faction in the team has a building set to active
for (int i = 0; i < world->getFactionCount(); ++i) {
// only bother setting once for each active team
if (!teams[world->getFaction(i)->getTeam()] && hasBuilding(world->getFaction(i))) {
activeTeams++;
teams[world->getFaction(i)->getTeam()] = true;
}
}
bool thisTeamWin = teams[world->getThisFaction()->getTeam()];
// has game ended?
if (activeTeams <= 1 /*|| !thisTeamWin*/) { // uncomment to get previous early out behaviour
gameOver = true;
// set victory
for (int i = 0; i < world->getFactionCount(); ++i) {
if (teams[world->getFaction(i)->getTeam()]) {
stats->setVictorious(i);
}
}
if (thisTeamWin) {
return GameStatus::WON;
} else {
return GameStatus::LOST;
}
}
return GameStatus::NO_CHANGE;
}