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


const ability = {
    name: 'lashes',
    display_name: "Lashes",
    effect_icon: "textures/items/diamond",
    description: 'Reduce Enemy max health for a short period',
    indexNum: 2,
    execute(player, target, mode, dmg) {
        system.runTimeout(()=>{
            let oldRedux = JSON.parse(target.getDynamicProperty("resetingStatus"))
            if(oldRedux.effects.HR == undefined) {
                oldRedux.effects["HR"] = {
                    dur: 30,
                    redux: (dmg * 0.15)
                }
                let Loa = coordExtractor(target,1)
                target.dimension.spawnParticle(`combat:bleed_activate`,Loa);
            } else {
                oldRedux.effects["HR"] = {
                    dur: 30,
                    redux: oldRedux.effects.HR.redux + (dmg * 0.15)
                }
            }
            let newRedux = oldRedux
            target.setDynamicProperty("resetingStatus",JSON.stringify(newRedux))
        },5) 
    },
    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