also require defence station to be destroyed for balancing fight to finish
This commit is contained in:
@@ -339,25 +339,38 @@ void ArenaSimulation::tickDeaths()
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if all ships of one team are destroyed.
|
||||
bool team1HasShips = false;
|
||||
bool team2HasShips = false;
|
||||
m_shipSystem->forEach([&team1HasShips, &team2HasShips](Ship& s)
|
||||
// Check if all ships and defence stations of one team are destroyed.
|
||||
bool team1HasUnits = false;
|
||||
bool team2HasUnits = false;
|
||||
m_shipSystem->forEach([&team1HasUnits, &team2HasUnits](Ship& s)
|
||||
{
|
||||
if (s.isEnemy)
|
||||
{
|
||||
team2HasShips = true;
|
||||
team2HasUnits = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
team1HasShips = true;
|
||||
team1HasUnits = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!team1HasShips || !team2HasShips)
|
||||
for (const Building& b : m_buildingSystem->allBuildings())
|
||||
{
|
||||
if (b.type == BuildingType::PlayerDefenceStation)
|
||||
{
|
||||
team1HasUnits = true;
|
||||
}
|
||||
else if (b.type == BuildingType::EnemyDefenceStation
|
||||
&& b.id != m_team2HqId)
|
||||
{
|
||||
team2HasUnits = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!team1HasUnits || !team2HasUnits)
|
||||
{
|
||||
m_finished = true;
|
||||
m_winnerTeam = team1HasShips ? 0 : 1;
|
||||
m_winnerTeam = team1HasUnits ? 0 : 1;
|
||||
updateStatus();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user