import { world, system } from "@minecraft/server";
import { cooldowns } from "./../../util/utils.js";

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

const ability = {
    name: 'P3',
    display_name: "Power Up",
    button_icon: "textures/ui/abilities/power_up",
    registry_name: "power_up",
    description: 'Power Up yourself',
    indexNum: 12,
    level: "basic",
    cooldown: 12,
    damages: 10,
    charge_type: "charge_till_end",
    charge_count: 3,
    charge_interval: 10,
    canSwitch : false,
    filters: ["all"],
    slots: ["ability"],
    cdname: "pwrupcd",
    horizontal: 1.4 ,
    vertical: 0.5,
    execute(player, weaponType, mode, weapon) {
        const cooldown = this.cooldown
        player.runCommand("scoreboard players remove @s exhaust 40")
        player.playAnimation(`animation.minced.${weaponType}.ability_power_up`)
        let statuser = JSON.parse(player.getDynamicProperty("resetingStatus"))
        statuser["Boost"] = statuser.Boost + 0.15
        player.setDynamicProperty("resetingStatus", JSON.stringify(statuser))
        player.setProperty("aura:color", 3)
        system.runTimeout(()=>{
            player.setProperty("aura:color", 0)         
        },40)
        player.runCommandAsync("tag @s remove attack")
        player.runCommandAsync("inputpermission set @s movement enabled")
        cooldowns(player,this.name,cooldown,10)
    },
    resetStats(player) {
        let statuser = JSON.parse(player.getDynamicProperty("resetingStatus"))
        statuser["Boost"] = statuser.Boost - 0.15
        player.setDynamicProperty("resetingStatus", JSON.stringify(statuser))
        player.setProperty("aura:color", 0)
    }
}

export default ability