using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public class AbilityConditionManager
{
    public BaseAbility ability;
    public List<AbilityCastCondition> castConditions = new List<AbilityCastCondition>();


    public bool CanCastAbility(NPCControllerBase npc)
    {
        foreach (AbilityCastCondition condition in castConditions)
        {
            switch (condition.conditionType)
            {
                case AbilityCastConditionType.Mana:
                    {
                        if (npc.Mana.EnoughMana(ability.manaCost))
                            continue;
                        else return false;
                    }
                case AbilityCastConditionType.Health:
                    {
                        if (npc.Health.EnoughHealth(ability.manaCost))
                            continue;
                        else return false;
                    }
                case AbilityCastConditionType.MeleeDistance:
                    {
                        if (npc.IsCloseEnough(npc.currentTarget.transform.position, npc.MeleeRange))
                            continue;
                        else return false;
                    }
                case AbilityCastConditionType.RangedDistance:
                    {
                        if (npc.IsCloseEnough(npc.currentTarget.transform.position, npc.ProjectileRange))
                            continue;
                        else return false;
                    }
                case AbilityCastConditionType.Cooldown:
                    {
                        if (!npc.abilityCooldownTracker.OnCooldown(ability))
                            continue;
                        else return false;
                    }
            }
        }
        return true;
    }
}
