schematic selection dialog
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
#include "StationBodyComponent.h"
|
||||
#include "WeaponComponent.h"
|
||||
#include "ModulesConfig.h"
|
||||
#include "RecipesConfig.h"
|
||||
#include "SchematicChoiceOption.h"
|
||||
#include "ShipsConfig.h"
|
||||
#include "Simulation.h"
|
||||
#include "Tick.h"
|
||||
@@ -247,7 +249,7 @@ TEST_CASE("WaveSystem: destroying both enemy stations triggers a push", "[wave]"
|
||||
REQUIRE(enemyCount == 2);
|
||||
}
|
||||
|
||||
TEST_CASE("WaveSystem: push emits exactly one SchematicDropEvent", "[wave]")
|
||||
TEST_CASE("WaveSystem: push generates pending schematic choices", "[wave]")
|
||||
{
|
||||
Simulation sim(loadConfig(), 42);
|
||||
|
||||
@@ -259,11 +261,13 @@ TEST_CASE("WaveSystem: push emits exactly one SchematicDropEvent", "[wave]")
|
||||
|
||||
sim.tick();
|
||||
|
||||
const std::vector<SchematicDropEvent> events = sim.drainSchematicDropEvents();
|
||||
REQUIRE(events.size() == 1);
|
||||
REQUIRE(sim.hasSchematicChoicesPending());
|
||||
const std::vector<SchematicChoiceOption>& choices = sim.getPendingSchematicChoices();
|
||||
REQUIRE(choices.size() >= 1);
|
||||
REQUIRE(choices.size() <= 3);
|
||||
}
|
||||
|
||||
TEST_CASE("WaveSystem: push schematic drop awards a known ship id", "[wave]")
|
||||
TEST_CASE("WaveSystem: push schematic choices have valid ids", "[wave]")
|
||||
{
|
||||
Simulation sim(loadConfig(), 42);
|
||||
|
||||
@@ -274,23 +278,68 @@ TEST_CASE("WaveSystem: push schematic drop awards a known ship id", "[wave]")
|
||||
});
|
||||
|
||||
sim.tick();
|
||||
const std::vector<SchematicDropEvent> events = sim.drainSchematicDropEvents();
|
||||
REQUIRE(events.size() == 1);
|
||||
const std::vector<SchematicChoiceOption>& choices = sim.getPendingSchematicChoices();
|
||||
REQUIRE_FALSE(choices.empty());
|
||||
|
||||
bool validId = false;
|
||||
for (const ShipDef& def : sim.config().ships.ships)
|
||||
for (const SchematicChoiceOption& opt : choices)
|
||||
{
|
||||
if (def.id == events[0].schematicId) { validId = true; break; }
|
||||
}
|
||||
if (!validId)
|
||||
{
|
||||
for (const ModuleDef& def : sim.config().modules.modules)
|
||||
bool validId = false;
|
||||
for (const ShipDef& def : sim.config().ships.ships)
|
||||
{
|
||||
if (def.id == events[0].schematicId) { validId = true; break; }
|
||||
if (def.id == opt.schematicId) { validId = true; break; }
|
||||
}
|
||||
if (!validId)
|
||||
{
|
||||
for (const ModuleDef& def : sim.config().modules.modules)
|
||||
{
|
||||
if (def.id == opt.schematicId) { validId = true; break; }
|
||||
}
|
||||
}
|
||||
if (!validId)
|
||||
{
|
||||
for (const RecipeDef& def : sim.config().recipes.recipes)
|
||||
{
|
||||
if (def.id == opt.schematicId) { validId = true; break; }
|
||||
}
|
||||
}
|
||||
REQUIRE(validId);
|
||||
}
|
||||
REQUIRE(validId);
|
||||
REQUIRE(events[0].newLevel >= 1);
|
||||
}
|
||||
|
||||
TEST_CASE("WaveSystem: schematic choices have no duplicates", "[wave]")
|
||||
{
|
||||
Simulation sim(loadConfig(), 42);
|
||||
|
||||
sim.admin().forEach<StationBodyComponent, FactionComponent, HealthComponent>(
|
||||
[](entt::entity /*e*/, const StationBodyComponent& /*sb*/, const FactionComponent& f, HealthComponent& h)
|
||||
{
|
||||
if (f.isEnemy) { h.hp = -1.0f; }
|
||||
});
|
||||
|
||||
sim.tick();
|
||||
const std::vector<SchematicChoiceOption>& choices = sim.getPendingSchematicChoices();
|
||||
std::set<std::string> ids;
|
||||
for (const SchematicChoiceOption& opt : choices)
|
||||
{
|
||||
ids.insert(opt.schematicId);
|
||||
}
|
||||
REQUIRE(ids.size() == choices.size());
|
||||
}
|
||||
|
||||
TEST_CASE("WaveSystem: applySchematicChoice clears pending and applies", "[wave]")
|
||||
{
|
||||
Simulation sim(loadConfig(), 42);
|
||||
|
||||
sim.admin().forEach<StationBodyComponent, FactionComponent, HealthComponent>(
|
||||
[](entt::entity /*e*/, const StationBodyComponent& /*sb*/, const FactionComponent& f, HealthComponent& h)
|
||||
{
|
||||
if (f.isEnemy) { h.hp = -1.0f; }
|
||||
});
|
||||
|
||||
sim.tick();
|
||||
REQUIRE(sim.hasSchematicChoicesPending());
|
||||
sim.applySchematicChoice(0);
|
||||
REQUIRE_FALSE(sim.hasSchematicChoicesPending());
|
||||
}
|
||||
|
||||
TEST_CASE("WaveSystem: push places new enemy stations further right", "[wave]")
|
||||
|
||||
Reference in New Issue
Block a user