package org.project.item.armors;

public abstract class Armor {
    private String name;
    private int defense;
    private int durability;
    private int maxDurability;
    private boolean isBroken;

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

    public int damageTaken(int damage) {
        if (isBroken) {
            return damage;
        }
        double percent = (100.0 - defense) / 100.0;
        return (int) (damage * percent);
    }

    public void reduceDurability(int amount) {
        this.durability -= amount;
        checkBreak();
    }


    public void checkBreak() {
        if (this.durability <= 0 && !isBroken) {
            this.durability = 0;
            this.isBroken = true;
            System.out.println("Your Armor Has Broken!");
        }
    }


    public void repair() {
        this.isBroken = false;
        this.durability = 100;
    }

    public String getName() {
        return name;
    }

    public int getDefense() {
        return defense;
    }

    public int getDurability() {
        return durability;
    }
}
