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

public class CardDispatcher : MonoBehaviour
{
    public void ExecuteCardAction(Card c, HealthComponent target)
    {
        // Player loses 5 points for every card they play
        PlayerStats.Score -= 5;

        HealthComponent playerHealth = GetComponent<Choreographer>().PlayerEntity.GetComponent<HealthComponent>();
        EnergyComponent playerEnergy = GetComponent<Choreographer>().PlayerEntity.GetComponent<EnergyComponent>();

        if (c.CardName == "Might of the Druid")
        {
            target.PendingDamage += 4.0f;
        }
        if (c.CardName == "Awaken the Forest")
        {
            target.PendingDamage += 7.0f;
        }
        if (c.CardName == "Barkskin")
        {
            playerHealth.BarkskinActive = true;
        }
        if (c.CardName == "Choking Vines")
        {
            target.PendingDamage += 3.0f;
            playerHealth.PendingHeal += 2.0f;
        }
        if (c.CardName == "Owls of the Night")
        {
            HealthComponent[] hcs = FindObjectsOfType<HealthComponent>();
            foreach(HealthComponent hc in hcs)
            {
                Team team = hc.GetComponent<Team>();
                if (team != null && team.team == TeamValue.Enemy)
                {
                    hc.PendingDamage += 3.0f;
                }
            }

        }
        if (c.CardName == "Hurricane")
        {
            HealthComponent[] hcs = FindObjectsOfType<HealthComponent>();
            foreach (HealthComponent hc in hcs)
            {
                Team team = hc.GetComponent<Team>();
                if (team != null && team.team == TeamValue.Enemy)
                {
                    hc.PendingDamage += 8.0f;
                }
            }

        }
        if (c.CardName == "Pit Trap")
        {
            target.PendingDamage += 5.0f;
            SwingTimerComponent stc = target.GetComponent<SwingTimerComponent>();
            if (stc != null)
            {
                stc.TurnsRemaining += 1;
                stc.DirtyUI = true;
            }
        }
        if (c.CardName == "Awakened Sorrow")
        {
            target.PendingDamage += playerEnergy.Energy * 3.0f;
            playerEnergy.Energy = 0;
        }



    }
}
