diff --git a/docs/requirements.md b/docs/requirements.md index a8e6922..c1a52df 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -280,7 +280,7 @@ A separate executable target (`balancing`) that links against `lib` but contains - REQ-BAL-SIM-AI: Ships use the same AI and stats as in the main game. All ships use aggressive stance and closest-target priority. Ships with no target in sensor range advance toward the enemy team's HQ. Ships that detect an enemy in sensor range engage it as in the normal game (REQ-SHP-COMBAT, REQ-SHP-ENEMY-AI). - REQ-BAL-SIM-SPEED: Each arena runs its simulation at maximum tick rate (as many ticks per second as the hardware allows), with no rendering. - REQ-BAL-SIM-PARALLEL: All arenas are simulated in parallel, each on its own thread. -- REQ-BAL-SIM-END: An arena fight ends when either team's HQ is destroyed or all ships of one team have been destroyed. When the fight ends, the simulation for that arena stops. +- REQ-BAL-SIM-END: An arena fight ends when either team's HQ is destroyed or all ships and defence stations of one team have been destroyed. If a team has no defence stations, destroying all its ships is sufficient. When the fight ends, the simulation for that arena stops. ### UI diff --git a/src/balancing/ArenaSimulation.cpp b/src/balancing/ArenaSimulation.cpp index d97a001..5b2e86d 100644 --- a/src/balancing/ArenaSimulation.cpp +++ b/src/balancing/ArenaSimulation.cpp @@ -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(); } }