package org.project.item.armors;

public abstract class Armor {

    private int defense;
    private int maxDefense;
    private int durability;
    private int maxDurability;

    private boolean isBroke;

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

    public void checkBreak() {
        if (durability <= 0) {
            durability = 0;
            isBroke = true;
            defense = 0;
        }
    }

    public void takeDamage(int amount) {
        durability -= amount;
        checkBreak();
    }


    public void repair() {
        isBroke = false;
        defense = maxDefense;
        durability = maxDurability;
    }

    public int getDefense() {
        if (isBroke) {
            return 0;
        }
        return defense;
    }

    public int getDurability() {
        return durability;
    }

    public boolean isBroke() {
        return isBroke;
    }
}
