import { world} from "@minecraft/server";
import { launchPlayer } from "../../util/movements.js";
import { attackMobHumanoidMeikyu } from "../../util/attackMethods.js";

const animations =[
    [
        {
            animation: "minced.vindicator.attack_sprint",
            knockback: [-0.5,2],
            Player_Knockback: [2,0.25],
            type: "blunt",
            attack_speed: 8,
            stun_type: "short",
            hit_number: 1,
            range: 5,
            distance: 2,
            targetNum: 1,
            damage_multiplier: 1,
            stun_damage_multiplier: 1,
            next_attack_time: 4,
            Unbreakable: false
        },
        {
            animation: "minced.pillager.attack0",
            knockback: [1,0],
            Player_Knockback: [1,0],
            type: "slash",
            attack_speed: 9,
            stun_type: "short",
            hit_number: 1,
            range: 5,
            distance: 1,
            targetNum: 1,
            damage_multiplier: 1,
            stun_damage_multiplier: 1,
            next_attack_time: 10,
            Unbreakable: false
        },
        {
            animation: "minced.pillager.attack1",
            knockback: [1,0],
            Player_Knockback: [1,0],
            type: "slash",
            attack_speed: 9,
            stun_type: "short",
            hit_number: 1,
            range: 5,
            distance: 1,
            targetNum: 1,
            damage_multiplier: 1,
            stun_damage_multiplier: 1,
            next_attack_time: 10,
            Unbreakable: false
        },
        {
            animation: "minced.pillager.attack2",
            knockback: [1,0],
            Player_Knockback: [1,0],
            type: "slash",
            attack_speed: 13,
            stun_type: "short",
            hit_number: 1,
            range: 5,
            distance: 1,
            targetNum: 1,
            damage_multiplier: 2,
            stun_damage_multiplier: 1,
            next_attack_time: 20,
            Unbreakable: false
        }
    ]
]

const mob = {
    name: 'unidentified',
    display_name: "Unidentified",
    can_block: true,
    stun_meter_ticks: 40,
    block_damage: 5,
    block_power: 30,
    clash_power: 10,
    available_moves: [],
    cd: 1,
    execute(player, effect, mode, damage, stunDamage, damagetyper) {
        const cd = this.cd
        const blckdmg = this.block_damage
        let atkspd
        let lavander = damage
        let critChance = Math.floor(Math.random()*9)
        let critDamage = 0
        critChance != 2 ? critDamage = 0 : critDamage = Math.floor(Math.random() * lavander)
        let animChecker = 1
        switch(mode) {
            case "sprint": {
                player.playAnimation(`animation.${animations[0][0]}`)
                let stundamage = stunDamage
                let propCheck = {
                    animation: "minced.unarmed.attack",
                    knockback: [1,0.25],
                    Player_Knockback: [3,0],
                    type: "blunt",
                    attack_speed: 8,
                    stun_type: "short",
                    hit_number: 1,
                    range: 2,
                    distance: 1.5,
                    targetNum: 1,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    next_attack_time: 10,
                    Unbreakable: true
                }
                let knockback = propCheck.knockback
                player.playAnimation(`animation.${propCheck.animation}`)
                atkspd = propCheck.attack_speed
                let Pknockback = propCheck.Player_Knockback
                launchPlayer(player, Pknockback[0], Pknockback[1])
                let effects = propCheck.type
                let stun = propCheck.stun_type
                let ranger = propCheck.range
                let distil = propCheck.distance
                let tgtnm = propCheck.targetNum
                let NAT = propCheck.next_attack_time
                let breakable = propCheck.Unbreakable
                let hitNum = propCheck.hit_number
                attackMobHumanoidMeikyu(player, ranger, (lavander * propCheck.damage_multiplier), blckdmg, cd, atkspd, distil, tgtnm, "line_target", effect, knockback, stun, "knock_player", effects, 1, stundamage, NAT, breakable, "no_cooldown", "", hitNum)
            } break;
            default: {
                player.playAnimation(`animation.${animations[0][1]}`)
                let stundamage = stunDamage
                let propCheck = animations[0][animChecker]
                let knockback = propCheck.knockback
                atkspd = 1
                let stun = propCheck.stun_type
                let ranger = propCheck.range
                let distil = propCheck.distance
                let tgtnm = propCheck.targetNum
                let NAT = 1
                let breakable = propCheck.Unbreakable
                let hitNum = propCheck.hit_number
                attackMobHumanoidMeikyu(player, ranger, (lavander * propCheck.damage_multiplier), blckdmg, cd, atkspd, distil, tgtnm, "line_target", effect, knockback, stun, "", damagetyper, 1, stundamage, NAT, breakable, "no_cooldown", "", hitNum)
            } break;
        }
    }
}

export default mob


