package org.project.item.armors;

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

public abstract class Armor implements Item {
    private int defense;
    private int maxDefense;
    private int durability;
    private int maxDurability;

    private boolean isBroke;
    private int id;
    private String name;

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

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

    public void repair() {
        isBroke = false;
        defense = maxDefense;
        durability = maxDurability;
        System.out.println("🔨 " + name + " has been repaired!");
    }

    public int getDefense() {
        return defense;
    }

    public int getDurability() {
        return durability;
    }

    public boolean isBroke() {
        return isBroke;
    }

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

    @Override
    public int getId() {
        return id;
    }

    @Override
    public void use(Entity target)
    {
        System.out.println("🛡️ " + name + " is equipped!");
    }
}
