package org.project.item.armors;

import org.project.item.Item;


public abstract class Armor implements Item {
    private int defense;
    private int maxDefense;
    private int durability;
    private int maxDurability;
    private String name;
    private int price;
    private boolean isBroke;

    public Armor(int defense, int durability, String name, int price) {
        this.defense = defense;
        this.maxDefense = defense;
        this.durability = durability;
        this.maxDurability = durability;
        this.isBroke = false;
        this.name = name;
        this.price = price;
    }
    public void reduceDurability(int amount) {
        if (!isBroke) {
            durability -= amount;
            checkBreak();
        }
    }
    public void checkBreak() {
        if (durability <= 0) {
            isBroke = true;
            defense = 0;
            durability = 0;
        }
    }
    public void repair() {
        isBroke = false;
        defense = maxDefense;
        durability = maxDurability;
    }
    public int getDefense() {
        return defense;
    }
    public int getDurability() {
        return durability;
    }
    public boolean isBroke() {
        return isBroke;
    }

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