make repair ships standby with rest of fleet if there is no one to repair (instead of advancing towards the enemy stations)

This commit is contained in:
2026-06-18 21:43:55 +02:00
parent abab2bbb6e
commit c371b43a6d
14 changed files with 208 additions and 4 deletions

View File

@@ -563,6 +563,33 @@ TEST_CASE("BehaviorSystem: repair ship orbits damaged friendly ship",
REQUIRE(intent(f.admin, repairShip).orbitRadius_tiles == Approx(orbitRadius));
}
// ---------------------------------------------------------------------------
// StandbyBehavior (repair ships hold with the fleet when idle)
// ---------------------------------------------------------------------------
TEST_CASE("BehaviorSystem: idle repair ship stands by with the fleet instead of charging the enemy",
"[behavior]")
{
Fixture f;
const ShipLayoutConfig repairLayout = makeSingleModuleLayout("repair_tool");
const entt::entity repairShip = f.ships.spawn("repair_ship", 1, QVector2D(0.0f, 0.0f),
false, repairLayout);
// A healthy ally (nothing to repair) and a far enemy station (no threat in range).
const entt::entity ally = f.ships.spawn("interceptor", 1, QVector2D(50.0f, 0.0f));
const std::vector<QPoint> body{QPoint(0, 0)};
f.admin.spawnStation(QPoint(1000, 0), QSize(1, 1), body, 100.0f, 100.0f, /*isEnemy=*/true);
f.decide();
// With no damaged ally and no enemy in sensor range the repair ship neither
// repairs nor retreats: it stands by (REQ-SHP-STANDBY), steering toward its
// fleet (the ally) rather than charging the distant enemy station.
REQUIRE(winnerOf(f.admin, repairShip) == BehaviorKind::Standby);
REQUIRE(intent(f.admin, repairShip).active);
REQUIRE(intent(f.admin, repairShip).target.x() == Approx(pos(f.admin, ally).value.x()));
REQUIRE(intent(f.admin, repairShip).target.y() == Approx(pos(f.admin, ally).value.y()));
}
TEST_CASE("BehaviorSystem: repair ship heals damaged ally within repair range",
"[behavior]")
{
@@ -1114,8 +1141,11 @@ TEST_CASE("SensorRange: repair ship does not retreat from enemy beyond sensor ra
f.decide();
// Beyond sensor range the enemy is no threat, so the repair ship does not flee;
// with nothing to repair it holds with the fleet (REQ-SHP-STANDBY) rather than
// retreating or charging the enemy.
REQUIRE(winnerOf(f.admin, repairShip) != BehaviorKind::Retreat);
REQUIRE(intent(f.admin, repairShip).target.x() > pos(f.admin, repairShip).value.x());
REQUIRE(winnerOf(f.admin, repairShip) == BehaviorKind::Standby);
}
TEST_CASE("SensorRange: repair ship does not acquire damaged ally beyond sensor range", "[sensor]")