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


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

const ability = {
    name: 'A2',
    display_name: "Accelerate",
    button_icon: "textures/items/diamond",
    registry_name: "accelerate",
    description: 'speed up',
    level: "basic",
    cooldown: 5,
    damages: 10,
    charge_type: "continuous",
    charge_count: 3,
    charge_interval: 10,
    canSwitch : true,
    filters: ["pistol", "dagger", "katar"],
    slots: ["ability"],
    execute(player, weaponType, mode, weapon) {
        switch(mode){
            default: {
                player.playAnimation(`animation.minced.${weaponType}.ability_accelerate`,
                {
                    blendOutTime: 0.1,
                    stopExpression: "query.all_animations_finished",
                    nextState: `animation.minced.${weaponType}.combat_stance`
                })
                const cooldown = this.cooldown
                player.runCommand("scoreboard players remove @s exhaust 40")
                player.setProperty("aura:color", 7)
                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)
                player.addEffect("speed", 100, { amplifier: 1, showParticles: false })
            } break;
        }
    },
    resetStats(player) {
        player.removeEffect("speed")
    }
}

export default ability