also require defence station to be destroyed for balancing fight to finish

This commit is contained in:
2026-05-03 11:27:16 +02:00
parent 4eaae5d940
commit 426870158c
2 changed files with 22 additions and 9 deletions

View File

@@ -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();
}
}