using UnityEngine;

namespace FastArena
{
    public class Mortal : MonoBehaviour
    {
        public int HP { get; private set; }
        public int MaxHP;

        private void Awake()
        {
            HP = MaxHP;
        }

        public void Damage(int dmg)
        {
            HP -= dmg;
            if (HP <= 0) Kill();
        }

        public void Heal(int h)
        {
            HP += h;
            if (HP <= 0) Kill();
            else if (HP > MaxHP) HP = MaxHP;
        }

        public void Kill()
        {
            Destroy(gameObject);
        }
    }
}