derive threat cost dynamically

This commit is contained in:
2026-06-13 21:50:00 +02:00
parent 3716c2b734
commit 10c5ad678f
28 changed files with 498 additions and 79 deletions

View File

@@ -6,6 +6,7 @@
#include "GameConfig.h"
#include "ShipStatsCalculator.h"
#include "ThreatCostCalculator.h"
namespace
{
@@ -103,6 +104,11 @@ ShipStatsPanel::ShipStatsPanel(const GameConfig* config, QWidget* parent)
m_repairSection->setVisible(false);
layout->addWidget(m_repairSection);
// Threat cost — debug-only, initially hidden.
m_threatCostLabel = makeStatLabel(this);
m_threatCostLabel->setVisible(false);
layout->addWidget(m_threatCostLabel);
layout->addStretch();
}
@@ -115,6 +121,10 @@ void ShipStatsPanel::refresh(const std::string& shipId,
moduleLevelOverrides);
const QString hpText = tr("HP: %1").arg(static_cast<int>(stats.hp + 0.5f));
applyStats(stats, hpText);
const double threat = calculateShipThreatCost(m_config->threatCosts, *m_config,
shipId, modules);
setThreatCost(threat);
}
void ShipStatsPanel::refreshFromLive(const ShipStats& stats, float currentHp)
@@ -180,3 +190,15 @@ void ShipStatsPanel::applyStats(const ShipStats& stats, const QString& hpText)
m_repairSection->setVisible(false);
}
}
void ShipStatsPanel::setThreatCost(double cost)
{
m_threatCostLabel->setText(tr("Threat Cost: %1").arg(cost, 0, 'f', 1));
m_threatCostLabel->setVisible(m_debugDraw);
}
void ShipStatsPanel::setDebugDrawEnabled(bool enabled)
{
m_debugDraw = enabled;
m_threatCostLabel->setVisible(m_debugDraw);
}