using System;
using CounterDrone.Core.Models;

namespace CounterDrone.Core.Algorithms
{
    /// <summary>吸入式灭火 — 累积伤害</summary>
    public class InertGasDamageModel : IDamageModel
    {
        private const float DamageRate = 0.15f;       // 每秒毁伤率

        public float CalculateDamage(DroneType droneType, PowerType powerType,
            AerosolType aerosolType, float cloudDensity, float exposureTime, float deltaTime)
        {
            if (aerosolType != AerosolType.InertGas) return 0f;
            var sensitivity = powerType == PowerType.Piston ? 1.5f : 1.0f;
            return DamageRate * sensitivity * deltaTime;
        }

        public float RequiredExposureSeconds(DroneType droneType, PowerType powerType, AerosolType aerosolType)
        {
            if (aerosolType != AerosolType.InertGas) return float.MaxValue;
            var sensitivity = powerType == PowerType.Piston ? 1.5f : 1.0f;
            return 1.0f / (DamageRate * sensitivity);
        }

        public DamageStage GetDamageStage(float accumulatedDamage)
        {
            if (accumulatedDamage >= 1.0f) return DamageStage.Destroyed;
            if (accumulatedDamage >= 0.6f) return DamageStage.AttitudeLoss;
            if (accumulatedDamage >= 0.25f) return DamageStage.EngineAnomaly;
            return DamageStage.Normal;
        }
    }
}
