local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__ArraySome = ____lualib.__TS__ArraySome
local ____exports = {}
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
local StageID = ____isaac_2Dtypescript_2Ddefinitions.StageID
local ____cachedEnumValues = require("arrays.cachedEnumValues")
local DOOR_SLOT_VALUES = ____cachedEnumValues.DOOR_SLOT_VALUES
local ____cachedClasses = require("core.cachedClasses")
local game = ____cachedClasses.game
local ____array = require("functions.array")
local filterMap = ____array.filterMap
local ____levelGrid = require("functions.levelGrid")
local getRoomDescriptorsForType = ____levelGrid.getRoomDescriptorsForType
local isDoorSlotValidAtGridIndexForRedRoom = ____levelGrid.isDoorSlotValidAtGridIndexForRedRoom
local ____rooms = require("functions.rooms")
local getNumRooms = ____rooms.getNumRooms
local getRoomsInsideGrid = ____rooms.getRoomsInsideGrid
--- Helper function to fill every possible level grid square with a red room.
function ____exports.fillLevelWithRedRooms(self)
    local level = game:GetLevel()
    local numRoomsInGrid
    repeat
        do
            local roomsInGrid = getRoomsInsideGrid(nil)
            numRoomsInGrid = #roomsInGrid
            for ____, roomDescriptor in ipairs(roomsInGrid) do
                for ____, doorSlot in ipairs(DOOR_SLOT_VALUES) do
                    if isDoorSlotValidAtGridIndexForRedRoom(nil, doorSlot, roomDescriptor.GridIndex) then
                        level:MakeRedRoomDoor(roomDescriptor.GridIndex, doorSlot)
                    end
                end
            end
        end
    until not (numRoomsInGrid ~= getNumRooms(nil))
end
--- Helper function to get the boss IDs of all of the Boss Rooms on this floor. (This is equivalent
-- to the sub-type of the room data.)
-- 
-- Note that this will only look at Boss Rooms inside of the grid, so e.g. Reverse Emperor card
-- rooms will not count.
function ____exports.getLevelBossIDs(self)
    local roomsInsideGrid = getRoomsInsideGrid(nil)
    return filterMap(
        nil,
        roomsInsideGrid,
        function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomDescriptor.Data.Type == RoomType.BOSS and roomDescriptor.Data.StageID == StageID.SPECIAL_ROOMS and roomDescriptor.Data.Subtype or nil end
    )
end
--- Helper function to check if the current floor has a Boss Room that matches the boss ID provided.
-- 
-- This function is variadic, meaning that you can pass as many boss IDs as you want to check for.
-- It will return true if one or more of the boss IDs are matched.
function ____exports.levelHasBossID(self, ...)
    local bossIDs = {...}
    local levelBossIDs = ____exports.getLevelBossIDs(nil)
    local levelBossIDsSet = __TS__New(Set, levelBossIDs)
    return __TS__ArraySome(
        bossIDs,
        function(____, bossID) return levelBossIDsSet:has(bossID) end
    )
end
--- Helper function to check to see if the current floor has one or more of a specific room type in
-- it.
-- 
-- This function is variadic, meaning that you can pass as many room types as you want to check for.
-- This function will return true if any of the room types are found.
function ____exports.levelHasRoomType(self, ...)
    local roomDescriptors = getRoomDescriptorsForType(nil, ...)
    return #roomDescriptors > 0
end
return ____exports
