"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeTrinketFromPools = exports.removeCollectibleFromPools = exports.isCollectibleTypeInDefaultItemPool = exports.getRandomItemPool = exports.getItemPoolName = exports.getDefaultItemPoolsForCollectibleType = exports.getDefaultCollectibleTypesInItemPool = void 0;
const isaac_typescript_definitions_1 = require("isaac-typescript-definitions");
const cachedEnumValues_1 = require("../arrays/cachedEnumValues");
const cachedClasses_1 = require("../core/cachedClasses");
const itemPoolTypeToItemPoolName_1 = require("../maps/itemPoolTypeToItemPoolName");
const itemPoolTypeToCollectibleTypesSet_1 = require("../objects/itemPoolTypeToCollectibleTypesSet");
const array_1 = require("./array");
const NORMAL_MODE_ONLY_ITEM_POOL_TYPES = [
    isaac_typescript_definitions_1.ItemPoolType.TREASURE,
    isaac_typescript_definitions_1.ItemPoolType.BOSS,
    isaac_typescript_definitions_1.ItemPoolType.SHOP,
    isaac_typescript_definitions_1.ItemPoolType.DEVIL,
    isaac_typescript_definitions_1.ItemPoolType.ANGEL,
    isaac_typescript_definitions_1.ItemPoolType.CURSE,
    isaac_typescript_definitions_1.ItemPoolType.SECRET, // 5
];
const GREED_MODE_ONLY_ITEM_POOL_TYPES = [
    isaac_typescript_definitions_1.ItemPoolType.GREED_TREASURE,
    isaac_typescript_definitions_1.ItemPoolType.GREED_BOSS,
    isaac_typescript_definitions_1.ItemPoolType.GREED_SHOP,
    isaac_typescript_definitions_1.ItemPoolType.GREED_DEVIL,
    isaac_typescript_definitions_1.ItemPoolType.GREED_ANGEL,
    isaac_typescript_definitions_1.ItemPoolType.GREED_CURSE,
    isaac_typescript_definitions_1.ItemPoolType.GREED_SECRET, // 22
];
const FAKE_ITEM_POOL_TYPES = [isaac_typescript_definitions_1.ItemPoolType.SHELL_GAME];
const NORMAL_MODE_ITEM_POOL_TYPES = (0, array_1.arrayRemove)(cachedEnumValues_1.ITEM_POOL_TYPE_VALUES, ...GREED_MODE_ONLY_ITEM_POOL_TYPES, ...FAKE_ITEM_POOL_TYPES);
const GREED_MODE_ITEM_POOL_TYPES = (0, array_1.arrayRemove)(cachedEnumValues_1.ITEM_POOL_TYPE_VALUES, ...NORMAL_MODE_ONLY_ITEM_POOL_TYPES, ...FAKE_ITEM_POOL_TYPES);
/**
 * Helper function to get the collectibles that are in a particular item pool at the beginning of a
 * vanilla run.
 */
function getDefaultCollectibleTypesInItemPool(itemPoolType) {
    return itemPoolTypeToCollectibleTypesSet_1.ITEM_POOL_TYPE_TO_COLLECTIBLE_TYPES_SET[itemPoolType];
}
exports.getDefaultCollectibleTypesInItemPool = getDefaultCollectibleTypesInItemPool;
/**
 * Helper function to get the item pools that a particular collectible starts in at the beginning of
 * a vanilla run.
 *
 * This function will automatically account for Greed Mode. In other words, it will not return the
 * "normal" item pools when playing in Greed Mode.
 */
function getDefaultItemPoolsForCollectibleType(collectibleType) {
    const collectibleItemPoolTypes = [];
    const itemPoolTypes = cachedClasses_1.game.IsGreedMode()
        ? GREED_MODE_ITEM_POOL_TYPES
        : NORMAL_MODE_ITEM_POOL_TYPES;
    for (const itemPoolType of itemPoolTypes) {
        const collectibleTypesSet = itemPoolTypeToCollectibleTypesSet_1.ITEM_POOL_TYPE_TO_COLLECTIBLE_TYPES_SET[itemPoolType];
        if (collectibleTypesSet.has(collectibleType)) {
            collectibleItemPoolTypes.push(itemPoolType);
        }
    }
    return collectibleItemPoolTypes;
}
exports.getDefaultItemPoolsForCollectibleType = getDefaultItemPoolsForCollectibleType;
/**
 * Helper function to get the name for an item pool type as it appears in the "itempools.xml" file.
 */
function getItemPoolName(itemPoolType) {
    return itemPoolTypeToItemPoolName_1.ITEM_POOL_TYPE_TO_ITEM_POOL_NAME[itemPoolType];
}
exports.getItemPoolName = getItemPoolName;
/**
 * Helper function to get a random item pool. This is not as simple as getting a random value from
 * the `ItemPoolType` enum, since `ItemPoolType.SHELL_GAME` (7) is not a real item pool and the
 * Greed Mode item pools should be excluded if not playing in Greed Mode.
 *
 * If you want to get an unseeded item pool, you must explicitly pass `undefined` to the `seedOrRNG`
 * parameter.
 *
 * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
 *                  `RNG.Next` method will be called. If `undefined` is provided, it will default to
 *                  a random seed.
 */
function getRandomItemPool(seedOrRNG) {
    const itemPoolTypes = cachedClasses_1.game.IsGreedMode()
        ? GREED_MODE_ITEM_POOL_TYPES
        : NORMAL_MODE_ITEM_POOL_TYPES;
    return (0, array_1.getRandomArrayElement)(itemPoolTypes, seedOrRNG);
}
exports.getRandomItemPool = getRandomItemPool;
/**
 * Helper function to check if a particular collectibles is in a particular item pool at the
 * beginning of a vanilla run.
 */
function isCollectibleTypeInDefaultItemPool(collectibleType, itemPoolType) {
    const collectibleTypesSet = itemPoolTypeToCollectibleTypesSet_1.ITEM_POOL_TYPE_TO_COLLECTIBLE_TYPES_SET[itemPoolType];
    return collectibleTypesSet.has(collectibleType);
}
exports.isCollectibleTypeInDefaultItemPool = isCollectibleTypeInDefaultItemPool;
/**
 * Helper function to remove one or more collectibles from all item pools.
 *
 * This function is variadic, meaning you can pass as many collectible types as you want to remove.
 */
function removeCollectibleFromPools(...collectibleTypes) {
    const itemPool = cachedClasses_1.game.GetItemPool();
    for (const collectibleType of collectibleTypes) {
        itemPool.RemoveCollectible(collectibleType);
    }
}
exports.removeCollectibleFromPools = removeCollectibleFromPools;
/**
 * Helper function to remove one or more trinkets from all item pools.
 *
 * This function is variadic, meaning you can pass as many trinket types as you want to remove.
 */
function removeTrinketFromPools(...trinketTypes) {
    const itemPool = cachedClasses_1.game.GetItemPool();
    for (const trinketType of trinketTypes) {
        itemPool.RemoveTrinket(trinketType);
    }
}
exports.removeTrinketFromPools = removeTrinketFromPools;
