package org.project.entity.players;

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

public abstract class Player implements Entity {
    protected String name;
    Weapon weapon;
    protected int hp;
    private int maxHP;
    protected int mp;
    private int maxMP;
    private int xp;
    private boolean defending = false;
    private boolean stunned = false;
    private boolean dodged = false;


    public Player(String name, int hp, int mp, Weapon weapon) {
        this.name = name;
        this.hp = hp;
        this.mp = mp;
        this.weapon = weapon;
    }

    public void heavyAttack(Entity target){ // Uses weapons
        target.takeDamage(weapon.getDamage());
        mp -= weapon.getManaCost();
    }

    public abstract void lightAttack(Entity target);

    @Override
    public void defend() {
       defending = true;
    }

    @Override
    public void takeDamage(int damage) {
        hp -= damage;
    }

    @Override
    public void heal(int health) {
        hp += health;
        if (hp > maxHP) {
            hp = maxHP;
        }
    }

    @Override
    public void stun(boolean value) {
        stunned = value;
    }

    @Override
    public void dodge(boolean value) {
        dodged = value;
    }

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


    // Getter Methods
    public String getName() {
        return name;
    }

    public int getHp() {
        return hp;
    }

    public int getMaxHP() {
        return maxHP;
    }

    public int getMp() {
        return mp;
    }

    public int getMaxMP() {
        return maxMP;
    }

    public Weapon getWeapon() {
        return weapon;
    }

    public boolean isDefending() {
        return defending;
    }

    public boolean isDodged() {
        return dodged;
    }
}
