Implement config-driven unlock groups so that multiple things can be unlocked at once (including buildings)

This commit is contained in:
2026-07-22 21:34:59 +02:00
parent a8a6a04f1e
commit a9082c57f3
36 changed files with 1005 additions and 543 deletions

View File

@@ -1,5 +1,7 @@
#include "catch.hpp"
#include <algorithm>
#include "Building.h"
#include "BuildingConfig.h"
#include "BuildingSystem.h"
@@ -46,7 +48,17 @@ const ShipDef* findAvailableSchematic(const GameConfig& cfg)
{
for (const ShipDef& def : cfg.ships.ships)
{
if (def.unlockAtStationLevel == -1) { return &def; }
// A ship starts unlocked iff no unlock group grants it (REQ-LOCK-EXPLICIT).
bool granted = false;
for (const UnlockGroupDef& group : cfg.unlocks.groups)
{
if (std::find(group.ships.begin(), group.ships.end(), def.id) != group.ships.end())
{
granted = true;
break;
}
}
if (!granted) { return &def; }
}
return nullptr;
}