import Entity_Attribute_Manager from "../../Entity/Managers/Entity_Attribute_Manager";
export default class Actor_Attribute_Manager {
    static initialize(actor, attributes) {
        for (let i = 0; i < attributes.length; i++) {
            this.set(actor, attributes[i]);
        }
    }
    static set(actor, attribute) {
        actor.entity.setDynamicProperty(attribute.id, JSON.stringify(attribute));
        Entity_Attribute_Manager.set(attribute.id, actor.entity, attribute.amount.max);
    }
    static remove(actor, attribute_ID) {
        actor.entity.setDynamicProperty(attribute_ID);
    }
    static get(actor, attribute_ID) {
        const data = actor.entity.getDynamicProperty(attribute_ID);
        if (data == undefined)
            return undefined;
        const attribute = JSON.parse(data);
        return attribute;
    }
    static get_Max(actor, attribute_ID) {
        const attribute = this.get(actor, attribute_ID);
        if (attribute == undefined)
            return undefined;
        return attribute.amount.max;
    }
    static get_Min(actor, attribute_ID) {
        const attribute = this.get(actor, attribute_ID);
        if (attribute == undefined)
            return undefined;
        return attribute.amount.min;
    }
    static get_Current(actor, attribute_ID) {
        const attribute = this.get(actor, attribute_ID);
        if (attribute == undefined)
            return undefined;
        return attribute.amount.value;
    }
    static increase(actor, attribute_ID, amount) {
        let attribute = this.get(actor, attribute_ID);
        if (attribute == undefined)
            return false;
        attribute.amount.value = attribute.amount.value + amount;
        if (attribute.amount.value > attribute.amount.max)
            attribute.amount.value = attribute.amount.max;
        this.set(actor, attribute);
        return true;
    }
    static decrease(actor, attribute_ID, amount) {
        let attribute = this.get(actor, attribute_ID);
        if (attribute == undefined)
            return false;
        attribute.amount.value = attribute.amount.value - amount;
        if (attribute.amount.value < attribute.amount.min || attribute.amount.value <= 0)
            return false;
        this.set(actor, attribute);
        return true;
    }
}
