package org.project.item.armors;
import org.project.entity.Entity;
import org.project.item.Item;

// TODO: UPDATE IMPLEMENTATION
public abstract class Armor implements Item {
    private int defense;
    private int maxDefense;
    private int durability;
    private int maxDurability;
    protected String name;
    private boolean isBroke;

    public Armor(String name , int defense, int durability) {
        this.name = name;
        this.defense = defense;
        this.maxDefense = defense;
        this.maxDurability = durability;
        this.durability = durability;
    }
    @Override
    public void use(Entity target) {

        System.out.println(
                target.getName() +
                        " equipped armor!"
        );
    }
    @Override
    public String getName() {
        return name;
    }
    public void checkBreak() {
        if (durability <= 0) {
            isBroke = true;
            defense = 0;
        }
    }

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

    public int getDefense() {
        return defense;
    }

    public int getDurability() {
        return durability;
    }

    public boolean isBroke() {
        return isBroke;
    }

}
