package org.project.entity.enemies;

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

public abstract class Enemy implements Entity
{
    protected String name;
    protected int maxHealth;
    protected int health;
    protected int damage;
    protected int xpReward;

    protected boolean stunned = false;

    public Enemy(String name, int maxHealth, int damage, int xpReward)
    {
        this.name = name;
        this.maxHealth = maxHealth;
        this.health = maxHealth;
        this.damage = damage;
        this.xpReward = xpReward;
    }

    public abstract void attack(Player player);

    public void takeDamage(int amount)
    {
        health -= amount;

        if (health < 0)
            health = 0;

        System.out.println(Colors.RED + name + " took " + amount + " damage!" + Colors.RESET);
    }

    public int getXpReward()
    {
        return xpReward;
    }

    public void setStunned(boolean stunned)
    {
        this.stunned = stunned;
    }

    public boolean isStunned()
    {
        return stunned;
    }

    @Override
    public String getName()
    {
        return name;
    }

    @Override
    public int getHealth()
    {
        return health;
    }

    @Override
    public int getMaxHealth()
    {
        return maxHealth;
    }

    @Override
    public boolean isAlive()
    {
        return health > 0;
    }
}
