Implement config-driven unlock groups so that multiple things can be unlocked at once (including buildings)
This commit is contained in:
@@ -305,26 +305,35 @@ TEST_CASE("WaveSystem: push schematic choices have valid ids", "[wave]")
|
||||
|
||||
for (const SchematicChoiceOption& opt : choices)
|
||||
{
|
||||
bool validId = false;
|
||||
for (const ShipDef& def : sim.getConfig().ships.ships)
|
||||
if (opt.isArtifact) { continue; }
|
||||
bool validGroup = false;
|
||||
for (const UnlockGroupDef& group : sim.getConfig().unlocks.groups)
|
||||
{
|
||||
if (def.id == opt.schematicId) { validId = true; break; }
|
||||
if (group.id == opt.unlockGroupId) { validGroup = true; break; }
|
||||
}
|
||||
if (!validId)
|
||||
REQUIRE(validGroup);
|
||||
// Every granted item must resolve to a defined ship/module/building/recipe.
|
||||
for (const GrantedSchematic& grant : opt.grantedItems)
|
||||
{
|
||||
bool validId = false;
|
||||
for (const ShipDef& def : sim.getConfig().ships.ships)
|
||||
{
|
||||
if (def.id == grant.id) { validId = true; break; }
|
||||
}
|
||||
for (const ModuleDef& def : sim.getConfig().modules.modules)
|
||||
{
|
||||
if (def.id == opt.schematicId) { validId = true; break; }
|
||||
if (def.id == grant.id) { validId = true; break; }
|
||||
}
|
||||
for (const BuildingDef& def : sim.getConfig().buildings.buildings)
|
||||
{
|
||||
if (def.id == grant.id) { validId = true; break; }
|
||||
}
|
||||
}
|
||||
if (!validId)
|
||||
{
|
||||
for (const RecipeDef& def : sim.getConfig().recipes.recipes)
|
||||
{
|
||||
if (def.id == opt.schematicId) { validId = true; break; }
|
||||
if (def.id == grant.id) { validId = true; break; }
|
||||
}
|
||||
REQUIRE(validId);
|
||||
}
|
||||
REQUIRE(validId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +352,7 @@ TEST_CASE("WaveSystem: schematic choices have no duplicates", "[wave]")
|
||||
std::set<std::string> ids;
|
||||
for (const SchematicChoiceOption& opt : choices)
|
||||
{
|
||||
ids.insert(opt.schematicId);
|
||||
ids.insert(opt.isArtifact ? std::string("<artifact>") : opt.unlockGroupId);
|
||||
}
|
||||
REQUIRE(ids.size() == choices.size());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user