package org.project.item.armors;

// TODO: UPDATE IMPLEMENTATION
public abstract class Armor {
    private int defense;
    private int maxDefense;
    private int durability;
    private int maxDurability;

    private boolean isBroken;

    public Armor(int defense, int durability) {
        this.defense = defense;
        this.maxDefense = defense;
        this.durability = durability;
        this.maxDurability = durability;
        this.isBroken = false;
    }

    public void takeHit(int damage)
    {
        durability -= damage;

        if (durability < 0)
        {
            durability = 0;
        }

        checkBroken();
    }

    public void checkBroken() {
        if (durability <= 0) {
            isBroken = true;
            defense = 0;
        }
    }

    // TODO: (BONUS) UPDATE THE REPAIR METHOD
    public void repair()
    {
        isBroken = false;
        defense = maxDefense;
        durability = maxDurability;
    }

    public int getDefense()
    {
        return defense;
    }

    public int getDurability()
    {
        return durability;
    }

    public int getMaxDefense()
    {
        return maxDefense;
    }

    public int getMaxDurability()
    {
        return maxDurability;
    }

    public boolean isBroken()
    {
        return isBroken;
    }

    public abstract String getArmorName();
}
