using UnityEngine;
using System.Collections;

public class Enemy : MonoBehaviour {

    public float hp;
    [SerializeField]
    Combat.Elements weakness;
    [SerializeField]
    Combat.Elements strenght;

    Combat comb;

    void Awake()
    {
        comb = FindObjectOfType<Combat>();
    }

    
    public void GenerateEnemy(int hp, Combat.Elements str, Combat.Elements weak)
    {
        this.hp = hp;
        strenght = str;
        weakness = weak;
    }

    public int TakesDamage(int damage, Combat.Elements element)
    {
        int value = 0;

        if(element == weakness)
        {
            damage = damage * 2;
            value = 2;
        }

        if(element == strenght)
        {
            hp += 2;
            value = 1;
        }

        hp -= damage;

        if(hp <= 0)
        {
            comb.EndCombat();
        }

        return value;
    }
}
