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

const weaponBoost = new Map([
        ["saber", 3],
        ["scythe", 5.5],
        ["scissors", 2.5],
    ])

const ability = {
    name: 'C1',
    display_name: "Counter",
    button_icon: "textures/items/diamond",
    registry_name: "counter",
    description: 'Counter Attacks',
    indexNum: 27,
    level: "advanced",
    cooldown: 5,
    damages: 15,
    charge_type: "charge_till_end",
    charge_count: 3,
    charge_interval: 10,
    canSwitch : false,
    filters: ["spear", "longsword", "saber"],
    slots: ["ability"],
    coodname: "ctcd",
    horizontal: 0.5,
    vertical: 0,
    execute(player, weaponType, mode, weapon) {
        const cooldown = this.cooldown
        player.runCommand("scoreboard players remove @s exhaust 40")
        let statuser = JSON.parse(player.getDynamicProperty("resetingStatus"))
        statuser["counter"] = statuser.counter + 1
        player.setDynamicProperty("resetingStatus", JSON.stringify(statuser))
        player.setProperty("aura:color", 5)
        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["counter"] = statuser.counter - 1
        player.setDynamicProperty("resetingStatus", JSON.stringify(statuser))
        player.setProperty("aura:color", 0)
    }
}

export default ability