local ____lualib = require("lualib_bundle")
local __TS__ArraySome = ____lualib.__TS__ArraySome
local ____exports = {}
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
local ____playerIndex = require("functions.playerIndex")
local getAllPlayers = ____playerIndex.getAllPlayers
local ____players = require("functions.players")
local isCharacter = ____players.isCharacter
--- Helper function to check to see if any player has a temporary collectible effect.
function ____exports.anyPlayerHasCollectibleEffect(self, collectibleType)
    local players = getAllPlayers(nil)
    return __TS__ArraySome(
        players,
        function(____, player)
            local effects = player:GetEffects()
            return effects:HasCollectibleEffect(collectibleType)
        end
    )
end
--- Helper function to check to see if any player has a temporary null effect.
function ____exports.anyPlayerHasNullEffect(self, nullItemID)
    local players = getAllPlayers(nil)
    return __TS__ArraySome(
        players,
        function(____, player)
            local effects = player:GetEffects()
            return effects:HasNullEffect(nullItemID)
        end
    )
end
--- Helper function to check to see if any player has a temporary trinket effect.
function ____exports.anyPlayerHasTrinketEffect(self, trinketType)
    local players = getAllPlayers(nil)
    return __TS__ArraySome(
        players,
        function(____, player)
            local effects = player:GetEffects()
            return effects:HasTrinketEffect(trinketType)
        end
    )
end
--- Helper function to get an array of temporary effects for a player. This is helpful so that you
-- don't have to manually create an array from an `EffectsList` object.
function ____exports.getEffectsList(self, player)
    local effects = player:GetEffects()
    local effectsList = effects:GetEffectsList()
    local effectArray = {}
    do
        local i = 0
        while i < effectsList.Size do
            local effect = effectsList:Get(i)
            if effect ~= nil then
                effectArray[#effectArray + 1] = effect
            end
            i = i + 1
        end
    end
    return effectArray
end
--- Helper function to check if a player should have Whore of Babylon active at their current health
-- level.
-- 
-- - For most characters, Whore of Babylon activates when the red hearts are at 1/2 or less.
-- - For Eve, Whore of Babylon activates when the red hearts are at 1 or less.
function ____exports.shouldWhoreOfBabylonBeActive(self, player)
    local redHearts = player:GetHearts()
    local threshold = isCharacter(nil, player, PlayerType.EVE) and 2 or 1
    return redHearts <= threshold
end
return ____exports
