"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.shouldWhoreOfBabylonBeActive = exports.getEffectsList = exports.anyPlayerHasTrinketEffect = exports.anyPlayerHasNullEffect = exports.anyPlayerHasCollectibleEffect = void 0;
const isaac_typescript_definitions_1 = require("isaac-typescript-definitions");
const playerIndex_1 = require("./playerIndex");
const players_1 = require("./players");
/** Helper function to check to see if any player has a temporary collectible effect. */
function anyPlayerHasCollectibleEffect(collectibleType) {
    const players = (0, playerIndex_1.getAllPlayers)();
    return players.some((player) => {
        const effects = player.GetEffects();
        return effects.HasCollectibleEffect(collectibleType);
    });
}
exports.anyPlayerHasCollectibleEffect = anyPlayerHasCollectibleEffect;
/** Helper function to check to see if any player has a temporary null effect. */
function anyPlayerHasNullEffect(nullItemID) {
    const players = (0, playerIndex_1.getAllPlayers)();
    return players.some((player) => {
        const effects = player.GetEffects();
        return effects.HasNullEffect(nullItemID);
    });
}
exports.anyPlayerHasNullEffect = anyPlayerHasNullEffect;
/** Helper function to check to see if any player has a temporary trinket effect. */
function anyPlayerHasTrinketEffect(trinketType) {
    const players = (0, playerIndex_1.getAllPlayers)();
    return players.some((player) => {
        const effects = player.GetEffects();
        return effects.HasTrinketEffect(trinketType);
    });
}
exports.anyPlayerHasTrinketEffect = anyPlayerHasTrinketEffect;
/**
 * 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 getEffectsList(player) {
    const effects = player.GetEffects();
    const effectsList = effects.GetEffectsList();
    const effectArray = [];
    for (let i = 0; i < effectsList.Size; i++) {
        const effect = effectsList.Get(i);
        if (effect !== undefined) {
            effectArray.push(effect);
        }
    }
    return effectArray;
}
exports.getEffectsList = getEffectsList;
/**
 * 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 shouldWhoreOfBabylonBeActive(player) {
    const redHearts = player.GetHearts();
    const threshold = (0, players_1.isCharacter)(player, isaac_typescript_definitions_1.PlayerType.EVE) ? 2 : 1;
    return redHearts <= threshold;
}
exports.shouldWhoreOfBabylonBeActive = shouldWhoreOfBabylonBeActive;
