package org.project.entity.players;

import org.project.entity.Entity;
import org.project.item.armors.Armor;
import org.project.item.weapons.Weapon;


public abstract class Player extends Entity{
    protected String name;
    private Armor armor;
    private int mp;
    private int maxMP;
    private boolean defensing;

    public Player(String name, int hp, int maxHP, int mp, int maxMP, Weapon weapon, Armor armor) {
        super(weapon, hp, maxHP);
        this.name = name;
        this.mp = mp;
        this.maxMP = maxMP;
        this.armor = armor;

        defensing = false;
    }

    public void lightAttack(Entity target) {
        target.takeDamage(super.getWeapon().getDamage());
    }

    @Override
    public void takeDamage(int damage) {
        if(!isDefensing()){
            super.takeDamage(damage);
        }
    }

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

    public boolean reduceMana(int amount) {
        if(mp - amount >= 0) {
            mp -= amount;
            return true;
        }
        return false;
    }



    public String getName() { return name; }

    public int getMp() { return mp; }

    public int getMaxMP() { return maxMP; }

    public Armor getArmor() { return armor; }

    public boolean isDefensing() { return defensing; }
    public void setDefensing(boolean defensing) {this.defensing = defensing; }
}
