Add artifact win condition (#3)

Reviewed-on: #3
Co-authored-by: Malte Langkabel <malte.langkabel@gmail.com>
Co-committed-by: Malte Langkabel <malte.langkabel@gmail.com>
This commit was merged in pull request #3.
This commit is contained in:
2026-07-01 20:27:29 +00:00
committed by mlangkabel
parent d74ba5bfad
commit 0a7e9a34ef
20 changed files with 516 additions and 63 deletions

View File

@@ -141,6 +141,8 @@ void Simulation::reset(unsigned int seed)
m_nextBuildingId = 1;
m_buildingBlocksStock = m_config.world.startingBuildingBlocks;
m_gameOver = false;
m_isWon = false;
m_artifactCount = 0;
m_hqBuildingId = kInvalidBuildingId;
m_hqProxyEntity = entt::null;
m_playerStation1Entity = entt::null;
@@ -677,7 +679,14 @@ void Simulation::generateSchematicChoices(int destroyedStationLevel)
if (pool.empty()) { return; }
const int numChoices = std::min(static_cast<int>(pool.size()), 3);
const double artifactChance = std::clamp(
m_config.world.artifacts.artifactChanceFormula.evaluate(
static_cast<double>(destroyedStationLevel)),
0.0, 1.0);
std::uniform_real_distribution<double> realDist(0.0, 1.0);
const bool artifactRolled = realDist(m_rng) < artifactChance;
const int numChoices = std::min(static_cast<int>(pool.size()), artifactRolled ? 2 : 3);
m_pendingSchematicChoices.clear();
const std::set<std::string> currentShipIds = getUnlockedShipSchematicIds();
@@ -750,6 +759,17 @@ void Simulation::generateSchematicChoices(int destroyedStationLevel)
m_pendingSchematicChoices.push_back(option);
}
if (artifactRolled)
{
SchematicChoiceOption artifactOption;
artifactOption.schematicId = "";
artifactOption.type = SchematicType::Artifact;
artifactOption.displayName = "Artifact";
artifactOption.isNewUnlock = false;
artifactOption.targetLevel = 0;
m_pendingSchematicChoices.push_back(std::move(artifactOption));
}
}
void Simulation::applySchematicChoice(int choiceIndex)
@@ -757,6 +777,17 @@ void Simulation::applySchematicChoice(int choiceIndex)
assert(choiceIndex >= 0 && choiceIndex < static_cast<int>(m_pendingSchematicChoices.size()));
const SchematicChoiceOption& chosen = m_pendingSchematicChoices[static_cast<std::size_t>(choiceIndex)];
if (chosen.type == SchematicType::Artifact)
{
m_artifactCount += 1;
if (m_artifactCount >= m_config.world.artifacts.artifactWinCount)
{
m_isWon = true;
}
m_pendingSchematicChoices.clear();
return;
}
if (chosen.type == SchematicType::Recipe)
{
m_unlockedRecipeSchematicIds.insert(chosen.schematicId);
@@ -961,6 +992,8 @@ unsigned long long Simulation::computeStateChecksum() const
hasher.append(m_nextBuildingId);
hasher.append(m_buildingBlocksStock);
hasher.append(m_gameOver);
hasher.append(m_isWon);
hasher.append(m_artifactCount);
// WaveSystem scalar state, reached through existing accessors.
hasher.append(threatLevel());
@@ -1074,6 +1107,16 @@ bool Simulation::isGameOver() const
return m_gameOver;
}
bool Simulation::isWon() const
{
return m_isWon;
}
int Simulation::artifactCount() const
{
return m_artifactCount;
}
double Simulation::threatLevel() const
{
return m_waveSystem->threatLevel();