Prefix all getters with "get"
This commit is contained in:
@@ -183,7 +183,7 @@ TEST_CASE("CombatSystem: player station fires at enemy ship in range", "[combat]
|
||||
// Find the player station entity via ECS.
|
||||
entt::entity stationEntity = entt::null;
|
||||
QVector2D stationCenter;
|
||||
sim.admin().forEach<StationBodyComponent, FactionComponent>(
|
||||
sim.getAdmin().forEach<StationBodyComponent, FactionComponent>(
|
||||
[&](entt::entity e, const StationBodyComponent& sb, const FactionComponent& f)
|
||||
{
|
||||
if (!f.isEnemy && stationEntity == entt::null)
|
||||
@@ -194,12 +194,12 @@ TEST_CASE("CombatSystem: player station fires at enemy ship in range", "[combat]
|
||||
sb.anchor.y() + sb.footprint.height() / 2.0f);
|
||||
}
|
||||
});
|
||||
REQUIRE(sim.admin().isValid(stationEntity));
|
||||
REQUIRE(sim.getAdmin().isValid(stationEntity));
|
||||
|
||||
const ShipDef* combatDef = findCombatShip(sim.config());
|
||||
const ShipDef* combatDef = findCombatShip(sim.getConfig());
|
||||
REQUIRE(combatDef != nullptr);
|
||||
|
||||
const entt::entity enemyShip = sim.ships().spawn(
|
||||
const entt::entity enemyShip = sim.getShips().spawn(
|
||||
combatDef->id,
|
||||
QVector2D(stationCenter.x() + 1.0f, stationCenter.y()),
|
||||
/*isEnemy=*/true);
|
||||
@@ -221,7 +221,7 @@ TEST_CASE("CombatSystem: enemy station fires at player ship in range", "[combat]
|
||||
|
||||
entt::entity stationEntity = entt::null;
|
||||
QVector2D stationCenter;
|
||||
sim.admin().forEach<StationBodyComponent, FactionComponent>(
|
||||
sim.getAdmin().forEach<StationBodyComponent, FactionComponent>(
|
||||
[&](entt::entity e, const StationBodyComponent& sb, const FactionComponent& f)
|
||||
{
|
||||
if (f.isEnemy && stationEntity == entt::null)
|
||||
@@ -232,12 +232,12 @@ TEST_CASE("CombatSystem: enemy station fires at player ship in range", "[combat]
|
||||
sb.anchor.y() + sb.footprint.height() / 2.0f);
|
||||
}
|
||||
});
|
||||
REQUIRE(sim.admin().isValid(stationEntity));
|
||||
REQUIRE(sim.getAdmin().isValid(stationEntity));
|
||||
|
||||
const ShipDef* combatDef = findCombatShip(sim.config());
|
||||
const ShipDef* combatDef = findCombatShip(sim.getConfig());
|
||||
REQUIRE(combatDef != nullptr);
|
||||
|
||||
sim.ships().spawn(
|
||||
sim.getShips().spawn(
|
||||
combatDef->id,
|
||||
QVector2D(stationCenter.x() - 1.0f, stationCenter.y()),
|
||||
/*isEnemy=*/false);
|
||||
@@ -259,7 +259,7 @@ TEST_CASE("CombatSystem: player ship fires at enemy station in range", "[combat]
|
||||
|
||||
entt::entity stationEntity = entt::null;
|
||||
QVector2D stationCenter;
|
||||
sim.admin().forEach<StationBodyComponent, FactionComponent>(
|
||||
sim.getAdmin().forEach<StationBodyComponent, FactionComponent>(
|
||||
[&](entt::entity e, const StationBodyComponent& sb, const FactionComponent& f)
|
||||
{
|
||||
if (f.isEnemy && stationEntity == entt::null)
|
||||
@@ -270,12 +270,12 @@ TEST_CASE("CombatSystem: player ship fires at enemy station in range", "[combat]
|
||||
sb.anchor.y() + sb.footprint.height() / 2.0f);
|
||||
}
|
||||
});
|
||||
REQUIRE(sim.admin().isValid(stationEntity));
|
||||
REQUIRE(sim.getAdmin().isValid(stationEntity));
|
||||
|
||||
const ShipDef* combatDef = findCombatShip(sim.config());
|
||||
const ShipDef* combatDef = findCombatShip(sim.getConfig());
|
||||
REQUIRE(combatDef != nullptr);
|
||||
|
||||
const entt::entity playerShip = sim.ships().spawn(
|
||||
const entt::entity playerShip = sim.getShips().spawn(
|
||||
combatDef->id,
|
||||
QVector2D(stationCenter.x() - 1.0f, stationCenter.y()),
|
||||
/*isEnemy=*/false);
|
||||
@@ -390,17 +390,17 @@ TEST_CASE("CombatSystem: dead ship is removed after tick step 9", "[combat]")
|
||||
{
|
||||
Simulation sim(loadConfig(), 42);
|
||||
|
||||
const ShipDef* combatDef = findCombatShip(sim.config());
|
||||
const ShipDef* combatDef = findCombatShip(sim.getConfig());
|
||||
REQUIRE(combatDef != nullptr);
|
||||
|
||||
const entt::entity ship = sim.ships().spawn(combatDef->id,
|
||||
const entt::entity ship = sim.getShips().spawn(combatDef->id,
|
||||
QVector2D(10.0f, 10.0f));
|
||||
|
||||
sim.admin().get<HealthComponent>(ship).hp = -1.0f;
|
||||
sim.getAdmin().get<HealthComponent>(ship).hp = -1.0f;
|
||||
|
||||
sim.tick();
|
||||
|
||||
REQUIRE_FALSE(sim.admin().isValid(ship));
|
||||
REQUIRE_FALSE(sim.getAdmin().isValid(ship));
|
||||
}
|
||||
|
||||
TEST_CASE("CombatSystem: scrap is spawned on ship death", "[combat]")
|
||||
@@ -411,15 +411,15 @@ TEST_CASE("CombatSystem: scrap is spawned on ship death", "[combat]")
|
||||
// (REQ-RES-SCRAP-DROP): round(threat * scrap_per_threat). The interceptor's
|
||||
// threat is 59.0 and the test config sets scrap_per_threat = 1.0, so it drops
|
||||
// round(59.0 * 1.0) = 59 scrap.
|
||||
const entt::entity ship = sim.ships().spawn("interceptor",
|
||||
const entt::entity ship = sim.getShips().spawn("interceptor",
|
||||
QVector2D(10.0f, 10.0f));
|
||||
sim.admin().get<HealthComponent>(ship).hp = -1.0f;
|
||||
sim.getAdmin().get<HealthComponent>(ship).hp = -1.0f;
|
||||
|
||||
sim.tick();
|
||||
|
||||
const std::vector<ScrapInfo> scraps = sim.scraps().allScrapInfo();
|
||||
const std::vector<ScrapInfo> scraps = sim.getScraps().getAllScrapInfo();
|
||||
REQUIRE(scraps.size() == 1);
|
||||
CHECK(sim.admin().get<ScrapDataComponent>(scraps[0].entity).amount == 59);
|
||||
CHECK(sim.getAdmin().get<ScrapDataComponent>(scraps[0].entity).amount == 59);
|
||||
}
|
||||
|
||||
TEST_CASE("CombatSystem: HQ death sets game over", "[combat]")
|
||||
@@ -427,7 +427,7 @@ TEST_CASE("CombatSystem: HQ death sets game over", "[combat]")
|
||||
Simulation sim(loadConfig(), 42);
|
||||
|
||||
// Damage the HQ proxy entity (has HqProxy + Health).
|
||||
sim.admin().forEach<HqProxyComponent, HealthComponent>(
|
||||
sim.getAdmin().forEach<HqProxyComponent, HealthComponent>(
|
||||
[](entt::entity /*e*/, const HqProxyComponent& /*hq*/, HealthComponent& h)
|
||||
{
|
||||
h.hp = -1.0f;
|
||||
|
||||
Reference in New Issue
Block a user