package org.project.entity;

public abstract class Entity {

    protected String name;
    protected int hp;
    protected int maxHP;
    protected int mp;
    protected int maxMP;
    protected boolean alive = true;

    public Entity(String name , int maxHP , int maxMP){
        this.name = name;
        this.maxHP = maxHP;
        this.hp = maxHP;
        this.maxMP = maxMP;
        this.mp = maxMP;
    }

    public abstract  void attack(Entity target);

    public  abstract void defend();

    public void heal(int amount){
        hp += amount;
        if(hp > maxHP) hp=maxHP;
    }

    public void consumeMana(int amount){
        mp -= amount;
        if(mp < 0 ) mp=0;
    }

    public void fillMana(int amount){
        mp += amount;
        if(mp > maxMP) mp=maxMP;
    }

    public void takeDamage(int damage){
        hp -= damage;
        if(hp <= 0 ){
            hp=0;
            alive = false;
            System.out.println(name + " failed! ");
        }
    }

    public boolean isAlive(){
        return alive;
    }

    public int getHp(){
        return hp;
    }

    public int getMp(){
        return mp;
    }
    public int getMaxHP(){
        return maxHP;
    }

    public int getMaxMP(){
        return maxMP;
    }

    public String getName() {
        return name;
    }
}
