using CounterDrone.Core.Models;

namespace CounterDrone.Core.Algorithms
{
    /// <summary>毁伤模型路由器 — 根据气溶胶类型分派</summary>
    public class DamageModelRouter : IDamageModel
    {
        private readonly InertGasDamageModel _inertGas = new();
        private readonly ActiveMaterialDamageModel _activeMaterial = new();
        private readonly ActiveFuelDamageModel _activeFuel = new();

        public float CalculateDamage(TargetType droneType, PowerType powerType,
            AerosolType aerosolType, float cloudDensity, float exposureTime, float deltaTime)
        {
            return aerosolType switch
            {
                AerosolType.InertGas => _inertGas.CalculateDamage(droneType, powerType, aerosolType, cloudDensity, exposureTime, deltaTime),
                AerosolType.ActiveMaterial => _activeMaterial.CalculateDamage(droneType, powerType, aerosolType, cloudDensity, exposureTime, deltaTime),
                AerosolType.ActiveFuel => _activeFuel.CalculateDamage(droneType, powerType, aerosolType, cloudDensity, exposureTime, deltaTime),
                _ => 0f,
            };
        }

        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;
        }
    }
}
