using System.Collections.Generic;
using CombatLibrary.CombatLibrary.CombatCore.CustomizeTimeLogic.FxLogic;
using GameLogic.Combat.Buff;
using GameLogic.Combat.CombatTool;
using GameLogic.Combat.Hero;
using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
namespace GameLogic.Combat.Skill
{
    /// 
    /// 狐狸随机为队友清除一个debuff
    /// 
    public class S9102 : SkillBasic
    {
        protected override void ProUseSkill()
        {
            CombatHeroEntity[] allHero =
                CombatController.currActiveCombat.CombatHeroController.GetHero(CombatHeroEntity.IsEnemy,out int maxCount);
            List debuffHero = new List();
            for (int i = 0; i < maxCount; i++)
            {
                List allBuff = allHero[i].BuffControl.GetBuffBasicForBuffType(2, 1);
                if (allBuff.Count > 0)
                {
                    debuffHero.Add(allHero[i]);
                }
            }
            CombatHeroEntity target = null;
            if (debuffHero.Count > 0)
            {
                int index = CombatCalculateTool.Instance.GetOdd(0, debuffHero.Count);
                target = debuffHero[index];
            }
            else if (allHero.Length > 0)
            {
                int index = CombatCalculateTool.Instance.GetOdd(0, allHero.Length);
                target = allHero[index];
            }
            BetterList currTarget = new BetterList();
            if (target != null)
            {
                currTarget.Add(target.GetMainHotPoin());
            }
            ActivationTimeLineData("9102", currTarget: currTarget);
        }
        protected override void ProDefaultTimeLineTrigger(string groupName, CombatHeroHitPoint targetEntity,
            ITimelineFxLogic timelineFxLogic,
            TriggerData triggerData, ISkillFeatures skillFeatures)
        {
            List allBuff = targetEntity.combatHeroEntity.BuffControl.GetBuffBasicForBuffType(2, 1);
            if (allBuff.Count > 0)
            {
                int index = CombatCalculateTool.Instance.GetOdd(0, allBuff.Count);
                targetEntity.combatHeroEntity.BuffControl.RemoveBuff(allBuff[index]);
            }
        }
    }
}