local ____lualib = require("lualib_bundle")
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local ____exports = {}
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local Challenge = ____isaac_2Dtypescript_2Ddefinitions.Challenge
local ____challengeBosses = require("objects.challengeBosses")
local CHALLENGE_BOSSES = ____challengeBosses.CHALLENGE_BOSSES
local DEFAULT_CHALLENGE_BOSS_ID = ____challengeBosses.DEFAULT_CHALLENGE_BOSS_ID
local ____challengeCharacters = require("objects.challengeCharacters")
local CHALLENGE_CHARACTERS = ____challengeCharacters.CHALLENGE_CHARACTERS
local DEFAULT_CHALLENGE_CHARACTER = ____challengeCharacters.DEFAULT_CHALLENGE_CHARACTER
local ____challengeCollectibleTypes = require("objects.challengeCollectibleTypes")
local CHALLENGE_COLLECTIBLE_TYPES = ____challengeCollectibleTypes.CHALLENGE_COLLECTIBLE_TYPES
local ____challengeNames = require("objects.challengeNames")
local CHALLENGE_NAMES = ____challengeNames.CHALLENGE_NAMES
local DEFAULT_CHALLENGE_NAME = ____challengeNames.DEFAULT_CHALLENGE_NAME
local ____challengeTrinketType = require("objects.challengeTrinketType")
local CHALLENGE_TRINKET_TYPE = ____challengeTrinketType.CHALLENGE_TRINKET_TYPE
local ____log = require("functions.log")
local log = ____log.log
--- Helper function to see if the player is playing any challenge.
function ____exports.onAnyChallenge(self)
    local challenge = Isaac.GetChallenge()
    return challenge ~= Challenge.NULL
end
--- Helper function to clear the current challenge, which will restart the run on a new random
-- non-challenge seed with the current character.
-- 
-- If the player is not in a challenge already, this function will do nothing.
-- 
-- Under the hood, this function executes the `challenge 0` console command.
function ____exports.clearChallenge(self)
    if ____exports.onAnyChallenge(nil) then
        local command = "challenge " .. tostring(Challenge.NULL)
        log("Restarting the run to clear the current challenge with a console command of: " .. command)
        Isaac.ExecuteCommand(command)
    end
end
--- Get the final boss of a challenge. This will only work for vanilla challenges.
-- 
-- For modded challenges, `BossID.MOM` (6) will be returned.
-- 
-- Note that for `Challenge.BACKASSWARDS` (31), this function will return `BossID.MEGA_SATAN` (55),
-- but this is not actually the final boss. (There is no final boss for this challenge.)
function ____exports.getChallengeBoss(self, challenge)
    local challengeBossID = CHALLENGE_BOSSES[challenge]
    return challengeBossID or DEFAULT_CHALLENGE_BOSS_ID
end
--- Get the starting character of a challenge. This will only work for vanilla challenges.
-- 
-- For modded challenges, `PlayerType.ISAAC` (0) will be returned.
function ____exports.getChallengeCharacter(self, challenge)
    local challengeCharacter = CHALLENGE_CHARACTERS[challenge]
    return challengeCharacter or DEFAULT_CHALLENGE_CHARACTER
end
--- Get the extra starting collectibles for a challenge. This will only work for vanilla challenges.
-- 
-- For modded challenges, an empty array will be returned.
function ____exports.getChallengeCollectibleTypes(self, challenge)
    return CHALLENGE_COLLECTIBLE_TYPES[challenge]
end
--- Get the proper name for a `Challenge` enum. This will only work for vanilla challenges.
-- 
-- For modded challenges, "Unknown" will be returned.
function ____exports.getChallengeName(self, challenge)
    local challengeName = CHALLENGE_NAMES[challenge]
    return challengeName or DEFAULT_CHALLENGE_NAME
end
--- Get the extra starting trinket for a challenge. This will only work for vanilla challenges.
-- 
-- If a challenge does not grant a starting trinket, `undefined` will be returned.
-- 
-- For modded challenges, `undefined` will be returned.
function ____exports.getChallengeTrinketType(self, challenge)
    return CHALLENGE_TRINKET_TYPE[challenge]
end
--- Helper function to check to see if the player is playing a particular challenge.
-- 
-- This function is variadic, meaning that you can specify as many challenges as you want to check
-- for.
function ____exports.onChallenge(self, ...)
    local challenges = {...}
    local challenge = Isaac.GetChallenge()
    return __TS__ArrayIncludes(challenges, challenge)
end
--- Helper function to restart the run on a particular challenge.
-- 
-- If the player is already in the particular challenge, this function will do nothing.
-- 
-- Under the hood, this function executes the `challenge 0` console command.
function ____exports.setChallenge(self, challenge)
    if not ____exports.onChallenge(nil, challenge) then
        local command = "challenge " .. tostring(challenge)
        log("Restarting the run to set a challenge with a console command of: " .. command)
        Isaac.ExecuteCommand(command)
    end
end
return ____exports
