import { system } from "@minecraft/server";

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

const ability = {
    name: 'A1',
    display_name: "Aim",
    button_icon: "textures/items/diamond",
    registry_name: "aim",
    description: 'Aims Weapon',
    level: "basic",
    cooldown: 2,
    damages: 10,
    charge_type: "continuous",
    charge_count: 3,
    charge_interval: 10,
    canSwitch : false,
    filters: ["pistol", "hand_cannon", "bow", "crossbow", "gun"],
    slots: ["charge"],
    execute(player, weaponType, mode, weapon) {
        let gauss = JSON.parse(player.getDynamicProperty("resetingStatus"))
        switch(mode){
            case "charge": {
                if(gauss.aiming != true) {
                    player.playAnimation(`animation.minced.${weaponType}.aim`,
                    {
                        stopExpression: "!query.is_using_item"
                    })
                    gauss["aiming"] = true
                    player.setDynamicProperty("resetingStatus", JSON.stringify(gauss))
                }
                player.addEffect("slowness", 5, { amplifier: 5, showParticles: false })
            } break;
        }
    },
    resetStats(player) {
        let gauss = JSON.parse(player.getDynamicProperty("resetingStatus"))
        gauss["aiming"] = false
        player.setDynamicProperty("resetingStatus", JSON.stringify(gauss))
        player.removeEffect("slowness")
    }
}

export default ability