var _a;
import { EquipmentSlot, system, world } from "@minecraft/server";
import { Effect, getPlayerEquipment } from "../utils/my_API";
import { parameterNames, Settings } from "nps_mot/utils/scoreboard";
system.runInterval(() => {
    if (Settings.getValue(parameterNames.armorEffects)) {
        for (const player of world.getPlayers()) {
            ArmorSet.applyArmorEffects(player);
        }
    }
}, 50); //2.5s
// Definition of the Armor class
class Armor {
    // Constructor
    constructor(type, bonus) {
        this.type = type;
        this.bonus = bonus;
    }
    applyArmorEffects(player) {
        const playerEquipment = getPlayerEquipment(player);
        const armorPieces = {
            "Feet": playerEquipment.getEquipment(EquipmentSlot.Feet),
            "Legs": playerEquipment.getEquipment(EquipmentSlot.Legs),
            "Chest": playerEquipment.getEquipment(EquipmentSlot.Chest),
            "Head": playerEquipment.getEquipment(EquipmentSlot.Head)
        };
        const fullArmor = Object.values(armorPieces).every(piece => piece !== undefined && piece.typeId.includes(this.type));
        if (fullArmor) {
            this.applyArmorBonus(player);
        }
    }
    applyArmorBonus(player) {
        for (const effect of this.bonus) {
            player.runCommand(`effect @s ${effect.id} ${effect.duration} ${effect.amplifier} ${effect.hideParticles}`);
        }
    }
}
// Definition of the ArmorSet class
class ArmorSet {
    static applyArmorEffects(player) {
        this.armors.forEach(armor => {
            armor.applyArmorEffects(player);
        });
    }
}
_a = ArmorSet;
// Create effects
ArmorSet.fireResistanceEffect = new Effect("fire_resistance");
ArmorSet.strengthEffect = new Effect("strength");
ArmorSet.speedEffect = new Effect("speed");
ArmorSet.slowFallingEffect = new Effect("slow_falling");
ArmorSet.regenerationEffect = new Effect("regeneration");
ArmorSet.resistanceEffect = new Effect("resistance");
ArmorSet.hasteEffect = new Effect("haste");
ArmorSet.conduitPowerEffect = new Effect("conduit_power");
ArmorSet.nightVisionEffect = new Effect("night_vision", 15);
ArmorSet.jumpBoostEffect = new Effect("jump_boost");
ArmorSet.waterBreathingEffect = new Effect("water_breathing");
ArmorSet.villageHeroEffect = new Effect("village_hero");
ArmorSet.badOmenEffect = new Effect("bad_omen");
ArmorSet.saturationEffect = new Effect("saturation");
ArmorSet.armors = [
    new Armor("nps_mot:adamantite", [_a.fireResistanceEffect, _a.resistanceEffect]),
    new Armor("nps_mot:osmium", [_a.regenerationEffect, _a.strengthEffect]),
    new Armor("nps_mot:red_diamond", [_a.regenerationEffect, _a.strengthEffect, _a.saturationEffect]),
    new Armor("nps_mot:green_diamond", [_a.waterBreathingEffect, _a.conduitPowerEffect, _a.nightVisionEffect]),
    new Armor("nps_mot:purple_diamond", [_a.waterBreathingEffect, _a.nightVisionEffect]),
    new Armor("nps_mot:orange_diamond", [_a.nightVisionEffect, _a.speedEffect]),
    new Armor("nps_mot:pink_diamond", [_a.nightVisionEffect, _a.regenerationEffect]),
    new Armor("nps_mot:black_diamond", [_a.nightVisionEffect, _a.hasteEffect]),
    new Armor("nps_mot:yellow_diamond", [_a.nightVisionEffect, _a.resistanceEffect]),
    new Armor("nps_mot:ruby", [_a.hasteEffect]),
    new Armor("nps_mot:sapphire", [_a.hasteEffect]),
    new Armor("nps_mot:iridium", [_a.fireResistanceEffect, _a.resistanceEffect]),
    new Armor("nps_mot:ruthenium", [_a.resistanceEffect]),
    new Armor("nps_mot:orichalc", [_a.speedEffect, _a.hasteEffect, _a.slowFallingEffect, _a.jumpBoostEffect]),
    new Armor("nps_mot:platinum", [_a.resistanceEffect]),
    new Armor("nps_mot:tungsten", [_a.resistanceEffect]),
    new Armor("nps_mot:titanium", [_a.resistanceEffect]),
    new Armor("nps_mot:aluminium", [_a.speedEffect]),
    new Armor("nps_mot:emerald", [_a.villageHeroEffect, _a.resistanceEffect]),
    new Armor("nps_mot:obsidian", [_a.badOmenEffect, _a.hasteEffect, _a.fireResistanceEffect]),
    new Armor("nps_mot:black_opal", [_a.speedEffect, _a.hasteEffect]),
    new Armor("nps_mot:amethyst", [_a.speedEffect]),
    new Armor("nps_mot:rhodium", [_a.nightVisionEffect]),
    new Armor("nps_mot:palladium", [_a.resistanceEffect])
];
