import { world, system, EquipmentSlot } from "@minecraft/server"
import { bossArmorItems } from "./boss_armor"

const sets = [
    bossArmorItems
]

system.runInterval(() => {
    const players = world.getAllPlayers()
    players.forEach(player => {
        const set = [
            player.getComponent('minecraft:equippable').getEquipment(EquipmentSlot.Head),
            player.getComponent('minecraft:equippable').getEquipment(EquipmentSlot.Chest),
            player.getComponent('minecraft:equippable').getEquipment(EquipmentSlot.Legs),
            player.getComponent('minecraft:equippable').getEquipment(EquipmentSlot.Feet)
        ]

        const findSet = sets.find(element => element.items.every(every => set.some(some => some != undefined && some.typeId == every)))

        findSet && findSet.callback(player)
    })
})