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

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

const ability = {
    name: 'P4',
    display_name: "Pull",
    button_icon: "textures/items/diamond",
    registry_name: "pull",
    description: 'Pull enemies towards yourself',
    indexNum: 12,
    level: "intermediate",
    cooldown: 12,
    damages: 10,
    charge_type: "charge_till_end",
    charge_count: 3,
    charge_interval: 10,
    canSwitch : false,
    filters: ["all"],
    slots: ["ability"],
    horizontal: 1.4 ,
    vertical: 0.5,
    execute(player, weaponType, mode, weapon) {
        const cooldown = this.cooldown
        switch(mode) {
            case "ultimate": {} break;
            default: {
                let knockback = [-2,0.25]
                player.playAnimation(`animation.minced.${weaponType}.ability_pull`)
                let effects = "slash"
                let stun = "medium"
                let ranger = 3
                let distil = 2
                let tgtnm = 3
                let NAT = 4
                let hitCount = 1
                attackPlayerMeikyu(player, ranger, (2 * weaponBoost.get(weaponType)), 10, 2, 10, distil, tgtnm, "line_target", attackEffect, knockback, stun, "", effects, 0, 10, NAT, true, "no cooldown", weapon, hitCount, true)
                cooldowns(player,this.name,cooldown,10)
            } break;
        }
        
    },
    resetStats(player) {
        let statuser = JSON.parse(player.getDynamicProperty("resetingStatus"))
        statuser["Boost"] = statuser.Boost - 0.2
        player.setDynamicProperty("resetingStatus", JSON.stringify(statuser))
        player.setProperty("aura:color", 0)
    }
}

export default ability