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

let resetingStatus = new JsonDatabase("resetingStatus")

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

const ability = {
    name: 'B1',
    display_name: "Battle Cry",
    button_icon: "textures/ui/abilities/battlecry",
    registry_name: "battlecry",
    description: 'Power Up yourself',
    level: "intermediate",
    cooldown: 15,
    damages: 10,
    charge_type: "charge_till_end",
    charge_count: 3,
    charge_interval: 10,
    canSwitch : true,
    filters: ["all"],
    slots: ["ability"],
    coodname: "B1",
    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_battle_cry`)
        let statuser = JSON.parse(player.getDynamicProperty("resetingStatus"))
        statuser["slashBoost"] = statuser.Boost + 0.2
        player.setDynamicProperty("resetingStatus", JSON.stringify(statuser))
        player.setProperty("aura:color", 8)
        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["slashBoost"] = statuser.Boost - 0.2
        player.setDynamicProperty("resetingStatus", JSON.stringify(statuser))
        player.setProperty("aura:color", 0)
    }
}

export default ability