import { system } from "@minecraft/server";
import { coordExtractor } from "./../../util/utils.js";


const weaponBoost = new Map([
        ["glaive", 1],
        ["rapier", 3],
    ])

const ability = {
    name: 'armorBreaker',
    display_name: "Armor Breaker",
    effect_icon: "textures/items/diamond",
    description: 'Reduce Enemy max armor for a short period',
    indexNum: 2,
    execute(player, target, mode, dmg) {
        system.runTimeout(()=>{
            let oldRedux = JSON.parse(target.getDynamicProperty("resetingStatus"))
            if(oldRedux.effects.AB == undefined) {
                oldRedux.effects["AB"] = {
                    dur: 30,
                    redux: (dmg * 0.15)
                }
                let Loa = coordExtractor(target,1)
            } else {
                oldRedux.effects["AB"] = {
                    dur: 30,
                    redux: oldRedux.effects.AB.redux + (dmg * 0.15)
                }
            }
            let newRedux = oldRedux
            target.setDynamicProperty("resetingStatus",JSON.stringify(newRedux))
        },3) 
    },
    resetStats(player) {
        let statuser = JSON.parse(player.getDynamicProperty("resetingStatus"))
        statuser["Boost"] = statuser.Boost - 0.5
        player.setDynamicProperty("resetingStatus", JSON.stringify(statuser))
        player.setProperty("aura:color", 0)
    }
}

export default ability