Prefix all getters with "get"
This commit is contained in:
@@ -533,9 +533,9 @@ TEST_CASE("Blueprint placement: buildings land at anchor + offset from cursor",
|
||||
|
||||
REQUIRE(idA != kInvalidBuildingId);
|
||||
REQUIRE(idB != kInvalidBuildingId);
|
||||
REQUIRE(sim.buildings().isTileOccupied(cursor + offsetA)); // (-6, 0)
|
||||
REQUIRE(sim.buildings().isTileOccupied(cursor + offsetB)); // (-4, 0)
|
||||
REQUIRE_FALSE(sim.buildings().isTileOccupied(cursor)); // center not occupied
|
||||
REQUIRE(sim.getBuildings().isTileOccupied(cursor + offsetA)); // (-6, 0)
|
||||
REQUIRE(sim.getBuildings().isTileOccupied(cursor + offsetB)); // (-4, 0)
|
||||
REQUIRE_FALSE(sim.getBuildings().isTileOccupied(cursor)); // center not occupied
|
||||
}
|
||||
|
||||
TEST_CASE("Blueprint placement: cost is deducted for each building in sequence", "[blueprint]")
|
||||
@@ -544,20 +544,20 @@ TEST_CASE("Blueprint placement: cost is deducted for each building in sequence",
|
||||
|
||||
// Find belt cost from config (belt cost = 2 in test config).
|
||||
int beltCost = 0;
|
||||
for (const BuildingDef& def : sim.config().buildings.buildings)
|
||||
for (const BuildingDef& def : sim.getConfig().buildings.buildings)
|
||||
{
|
||||
if (def.type == BuildingType::Belt) { beltCost = def.cost; break; }
|
||||
}
|
||||
REQUIRE(beltCost > 0);
|
||||
|
||||
const int startBlocks = sim.buildingBlocksStock();
|
||||
const int startBlocks = sim.getBuildingBlocksStock();
|
||||
REQUIRE(startBlocks >= 2 * beltCost); // test config has enough starting blocks
|
||||
|
||||
SimulationTestAccess::place(sim,BuildingType::Belt, QPoint(-6, 0), Rotation::East);
|
||||
REQUIRE(sim.buildingBlocksStock() == startBlocks - beltCost);
|
||||
REQUIRE(sim.getBuildingBlocksStock() == startBlocks - beltCost);
|
||||
|
||||
SimulationTestAccess::place(sim,BuildingType::Belt, QPoint(-4, 0), Rotation::East);
|
||||
REQUIRE(sim.buildingBlocksStock() == startBlocks - 2 * beltCost);
|
||||
REQUIRE(sim.getBuildingBlocksStock() == startBlocks - 2 * beltCost);
|
||||
}
|
||||
|
||||
TEST_CASE("Blueprint placement: insufficient blocks returns kInvalidBuildingId and deducts nothing",
|
||||
@@ -567,7 +567,7 @@ TEST_CASE("Blueprint placement: insufficient blocks returns kInvalidBuildingId a
|
||||
|
||||
// Find miner cost (15 in test config) — expensive enough to exhaust a small stock.
|
||||
int minerCost = 0;
|
||||
for (const BuildingDef& def : sim.config().buildings.buildings)
|
||||
for (const BuildingDef& def : sim.getConfig().buildings.buildings)
|
||||
{
|
||||
if (def.type == BuildingType::Miner) { minerCost = def.cost; break; }
|
||||
}
|
||||
@@ -576,26 +576,26 @@ TEST_CASE("Blueprint placement: insufficient blocks returns kInvalidBuildingId a
|
||||
// Drain the stock by placing miners until we no longer have enough.
|
||||
// Non-overlapping columns: miner body is 2 wide, so step by 2.
|
||||
int col = -2;
|
||||
while (sim.buildingBlocksStock() >= minerCost)
|
||||
while (sim.getBuildingBlocksStock() >= minerCost)
|
||||
{
|
||||
SimulationTestAccess::place(sim,BuildingType::Miner, QPoint(col, 0), Rotation::East);
|
||||
col -= 2;
|
||||
}
|
||||
|
||||
const int blocksBeforeAttempt = sim.buildingBlocksStock();
|
||||
const int blocksBeforeAttempt = sim.getBuildingBlocksStock();
|
||||
const BuildingId id = SimulationTestAccess::place(sim,
|
||||
BuildingType::Miner, QPoint(col - 2, 0), Rotation::East);
|
||||
|
||||
// Placement must fail and leave the stock unchanged.
|
||||
REQUIRE(id == kInvalidBuildingId);
|
||||
REQUIRE(sim.buildingBlocksStock() == blocksBeforeAttempt);
|
||||
REQUIRE(sim.getBuildingBlocksStock() == blocksBeforeAttempt);
|
||||
}
|
||||
|
||||
TEST_CASE("Simulation: tryPlaceBuilding rejects terrain-invalid placement and charges nothing",
|
||||
"[blueprint]")
|
||||
{
|
||||
Simulation sim(loadConfig());
|
||||
const int startBlocks = sim.buildingBlocksStock();
|
||||
const int startBlocks = sim.getBuildingBlocksStock();
|
||||
|
||||
// A miner is all-asteroid; placing it in space (x >= 0) violates the terrain
|
||||
// rule, so it must be rejected without consuming building blocks.
|
||||
@@ -603,8 +603,8 @@ TEST_CASE("Simulation: tryPlaceBuilding rejects terrain-invalid placement and ch
|
||||
SimulationTestAccess::place(sim,BuildingType::Miner, QPoint(0, 0), Rotation::East);
|
||||
|
||||
REQUIRE(id == kInvalidBuildingId);
|
||||
REQUIRE(sim.buildingBlocksStock() == startBlocks);
|
||||
REQUIRE(sim.buildings().allSites().empty());
|
||||
REQUIRE(sim.getBuildingBlocksStock() == startBlocks);
|
||||
REQUIRE(sim.getBuildings().getAllSites().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Simulation: tryPlaceBuilding accepts a valid asteroid spot, occupies tiles, charges cost",
|
||||
@@ -613,12 +613,12 @@ TEST_CASE("Simulation: tryPlaceBuilding accepts a valid asteroid spot, occupies
|
||||
Simulation sim(loadConfig());
|
||||
|
||||
int minerCost = 0;
|
||||
for (const BuildingDef& def : sim.config().buildings.buildings)
|
||||
for (const BuildingDef& def : sim.getConfig().buildings.buildings)
|
||||
{
|
||||
if (def.type == BuildingType::Miner) { minerCost = def.cost; break; }
|
||||
}
|
||||
REQUIRE(minerCost > 0);
|
||||
const int startBlocks = sim.buildingBlocksStock();
|
||||
const int startBlocks = sim.getBuildingBlocksStock();
|
||||
|
||||
// Miner mask ["AA","A>"] East at (-3,0) → all-asteroid body at
|
||||
// (-3,0),(-2,0),(-3,1); a valid spot.
|
||||
@@ -626,12 +626,12 @@ TEST_CASE("Simulation: tryPlaceBuilding accepts a valid asteroid spot, occupies
|
||||
SimulationTestAccess::place(sim,BuildingType::Miner, QPoint(-3, 0), Rotation::East);
|
||||
|
||||
REQUIRE(id != kInvalidBuildingId);
|
||||
REQUIRE(sim.buildingBlocksStock() == startBlocks - minerCost);
|
||||
REQUIRE(sim.buildings().isTileOccupied(QPoint(-3, 0)));
|
||||
REQUIRE(sim.buildings().isTileOccupied(QPoint(-2, 0)));
|
||||
REQUIRE(sim.buildings().isTileOccupied(QPoint(-3, 1)));
|
||||
REQUIRE(sim.getBuildingBlocksStock() == startBlocks - minerCost);
|
||||
REQUIRE(sim.getBuildings().isTileOccupied(QPoint(-3, 0)));
|
||||
REQUIRE(sim.getBuildings().isTileOccupied(QPoint(-2, 0)));
|
||||
REQUIRE(sim.getBuildings().isTileOccupied(QPoint(-3, 1)));
|
||||
// The output-port tile (1,1)+anchor = (-2,1) is not a body cell.
|
||||
REQUIRE_FALSE(sim.buildings().isTileOccupied(QPoint(-2, 1)));
|
||||
REQUIRE_FALSE(sim.getBuildings().isTileOccupied(QPoint(-2, 1)));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -671,7 +671,7 @@ TEST_CASE("Blueprint placement: setRecipe on construction site stores recipe", "
|
||||
|
||||
SimulationTestAccess::buildings(sim).setRecipe(id, "mine_iron_ore");
|
||||
|
||||
const ConstructionSite* site = sim.buildings().findSite(id);
|
||||
const ConstructionSite* site = sim.getBuildings().findSite(id);
|
||||
REQUIRE(site != nullptr);
|
||||
REQUIRE(site->recipeId == "mine_iron_ore");
|
||||
}
|
||||
@@ -692,7 +692,7 @@ TEST_CASE("Blueprint placement: recipe transfers to building after construction
|
||||
sim.tick();
|
||||
}
|
||||
|
||||
const Building* b = sim.buildings().findBuilding(id);
|
||||
const Building* b = sim.getBuildings().findBuilding(id);
|
||||
REQUIRE(b != nullptr);
|
||||
REQUIRE(b->recipeId == "mine_copper_ore");
|
||||
}
|
||||
@@ -712,8 +712,8 @@ TEST_CASE("Blueprint creation: a construction site is captured", "[blueprint]")
|
||||
const BuildingId id =
|
||||
SimulationTestAccess::place(sim, BuildingType::Belt, QPoint(-2, 0), Rotation::East);
|
||||
REQUIRE(id != kInvalidBuildingId);
|
||||
REQUIRE(sim.buildings().findSite(id) != nullptr);
|
||||
REQUIRE(sim.buildings().findBuilding(id) == nullptr);
|
||||
REQUIRE(sim.getBuildings().findSite(id) != nullptr);
|
||||
REQUIRE(sim.getBuildings().findBuilding(id) == nullptr);
|
||||
|
||||
const Blueprint bp = captureBlueprintFromSelection(sim, { id });
|
||||
|
||||
@@ -748,14 +748,14 @@ TEST_CASE("Blueprint creation: mixed operational building and construction site
|
||||
REQUIRE(idA != kInvalidBuildingId);
|
||||
SimulationTestAccess::buildings(sim).setRecipe(idA, "mine_iron_ore");
|
||||
for (int i = 0; i <= static_cast<int>(secondsToTicks(10.0)); ++i) { sim.tick(); }
|
||||
REQUIRE(sim.buildings().findBuilding(idA) != nullptr);
|
||||
REQUIRE(sim.getBuildings().findBuilding(idA) != nullptr);
|
||||
|
||||
// Building B: place and configure, but leave as a construction site.
|
||||
const BuildingId idB =
|
||||
SimulationTestAccess::place(sim, BuildingType::Miner, QPoint(-6, 0), Rotation::East);
|
||||
REQUIRE(idB != kInvalidBuildingId);
|
||||
SimulationTestAccess::buildings(sim).setRecipe(idB, "mine_copper_ore");
|
||||
REQUIRE(sim.buildings().findSite(idB) != nullptr);
|
||||
REQUIRE(sim.getBuildings().findSite(idB) != nullptr);
|
||||
|
||||
const Blueprint bp = captureBlueprintFromSelection(sim, { idA, idB });
|
||||
|
||||
@@ -779,7 +779,7 @@ TEST_CASE("Blueprint creation: selectionHasPlaceableBuilding sees a construction
|
||||
const BuildingId id =
|
||||
SimulationTestAccess::place(sim, BuildingType::Miner, QPoint(-2, 0), Rotation::East);
|
||||
REQUIRE(id != kInvalidBuildingId);
|
||||
REQUIRE(sim.buildings().findSite(id) != nullptr);
|
||||
REQUIRE(sim.getBuildings().findSite(id) != nullptr);
|
||||
REQUIRE(selectionHasPlaceableBuilding(sim, { id }));
|
||||
}
|
||||
|
||||
@@ -859,7 +859,7 @@ TEST_CASE("Blueprint placement: setShipLayout on construction site stores layout
|
||||
|
||||
SimulationTestAccess::buildings(sim).setShipLayout(id, layout);
|
||||
|
||||
const ConstructionSite* site = sim.buildings().findSite(id);
|
||||
const ConstructionSite* site = sim.getBuildings().findSite(id);
|
||||
REQUIRE(site != nullptr);
|
||||
REQUIRE(site->shipLayout.has_value());
|
||||
REQUIRE(site->shipLayout->placedModules.size() == 1);
|
||||
@@ -885,7 +885,7 @@ TEST_CASE("Blueprint placement: ship layout transfers to building after construc
|
||||
|
||||
// Shipyard construction_time_seconds = 30 in the test config.
|
||||
double constructionTime = 0.0;
|
||||
for (const BuildingDef& def : sim.config().buildings.buildings)
|
||||
for (const BuildingDef& def : sim.getConfig().buildings.buildings)
|
||||
{
|
||||
if (def.type == BuildingType::Shipyard) { constructionTime = def.constructionTimeSeconds; break; }
|
||||
}
|
||||
@@ -896,7 +896,7 @@ TEST_CASE("Blueprint placement: ship layout transfers to building after construc
|
||||
sim.tick();
|
||||
}
|
||||
|
||||
const Building* b = sim.buildings().findBuilding(id);
|
||||
const Building* b = sim.getBuildings().findBuilding(id);
|
||||
REQUIRE(b != nullptr);
|
||||
REQUIRE(b->shipLayout.has_value());
|
||||
REQUIRE(b->shipLayout->placedModules.size() == 1);
|
||||
|
||||
Reference in New Issue
Block a user