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

const weaponBoost = new Map([
        ["longsword", 3],
        ["saber", 2]
    ])

const ability = {
    name: 'F1',
    display_name: "Full Counter",
    button_icon: "textures/items/diamond",
    registry_name: "guard",
    description: 'Swings in front of.you to damage enemies',
    indexNum: 3,
    level: "advanced",
    cooldown: 100,
    damages: 15,
    charge_type: "charge_till_end",
    charge_count: 3,
    charge_interval: 10,
    canSwitch : false,
    filters: ["longsword", "saber"],
    slots: ["ability"],
    coodname: "grdcd",
    horizontal: 0.25,
    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["Alldamage"] = statuser.Alldamage + 0.2
        statuser["blunt"] = statuser.blunt + 0.3
        player.setDynamicProperty("resetingStatus", JSON.stringify(statuser))
        player.setProperty("aura:color", 5)
        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["Alldamage"] = statuser.Alldamage - 0.2
        statuser["blunt"] = statuser.blunt - 0.3
        player.setDynamicProperty("resetingStatus", JSON.stringify(statuser))
        player.setProperty("aura:color", 0)
    }
}

export default ability