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;

    private boolean isBroke;

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

    public void use(Entity target){
        durability -= defense;
    }


    public boolean checkBreak() {
        if(isBroke){             // if armor broke by dragon return true
            return true;
        }
        if (durability <= 0) {
            isBroke = true;
            defense = 0;
            return true;

        }
        else {
            isBroke= false;
            return false;

        }

    }

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

    public int getDefense() {
        return defense;
    }

    public int getDurability() {
        return durability;
    }

    public void setMaxDefense(int maxDefense) {
        this.maxDefense = maxDefense;
    }

    public void setMaxDurability(int maxDurability) {
        this.maxDurability = maxDurability;
    }

    public boolean isBroke() {
        return isBroke;
    }

    public void brokeArmor(){
        isBroke =true;
    }   // for dragon attak
}
