package org.project.entity.enemies;

import org.project.entity.Entity;
import org.project.entity.players.Player;


public abstract class Enemy extends Entity {

    protected final EnemyStats stats;
    private boolean stunned;

    public Enemy(EnemyStats stats) {
        super(stats.maxHP);
        this.stats = stats;
        stunned = false;
    }

    @Override
    public void takeDamage(int damage) {
        super.takeDamage(damage);
        System.out.println("\u001B[32mYour attack dealt " + damage + " damage to the enemy!\u001B[0m");
    }

    public void attack(Player target) {
        if(!stunned) {
            System.out.println("\u001B[31m" + getType() + " attacked you!\u001B[0m");
            target.takeDamage(stats.damage);
        }

        else {
            System.out.println("The enemy was stunned and missed its turn!");
            stunned = false;
        }
    }

    public abstract String getType();

    public int getXpReward() {return stats.xpReward;}
    public boolean isStunned() { return stunned; }
    public void setStunned(boolean stunned) {this.stunned = stunned; }
}
