#pragma once

#include <map>
#include <optional>
#include <string>
#include <vector>

#include "entt/entity/entity.hpp"

#include "GameConfig.h"
#include "ShipLayout.h"

class EntityAdmin;

// Effective stats for a ship with a given layout, after applying all passive
// module modifiers per REQ-MOD-STAT-CALC. Values are in display units:
// speeds in tiles/s, ranges in tiles, accelerations in tiles/s² or rad/s².
struct ShipStats
{
    float hp;
    float maxSpeed_tps;
    float sensorRange_tiles;
    float mainAcceleration_tpss;
    float maneuveringAcceleration_tpss;
    float angularAcceleration_radpss;
    float maxRotationSpeed_radps;
    int   cargoCapacity = 0;

    struct WeaponStats
    {
        float combinedDps;
        float maxRange_tiles;
    };

    struct SalvageStats
    {
        float combinedCollectionRate;
        float maxRange_tiles;
    };

    struct RepairStats
    {
        float combinedRepairRate_hps;
        float maxRange_tiles;
    };

    std::optional<WeaponStats>  weapons;
    std::optional<SalvageStats> salvage;
    std::optional<RepairStats>  repair;
};

ShipStats calculateShipStats(const GameConfig& config,
                              const std::string& shipId,
                              const std::vector<PlacedModule>& modules);

ShipStats buildShipStatsFromEntity(const EntityAdmin& admin, entt::entity shipEntity);

