"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTavernSpellEffectRepeatCount = void 0;
const reference_data_1 = require("@firestone-hs/reference-data");
const getTavernSpellEffectRepeatCount = (input) => {
    var _a, _b;
    if (input.source !== input.hero) {
        return 1;
    }
    let repeats = 1;
    const hasGoldenBalinda = input.board.some((e) => e.cardId === "BG35_883_G");
    const hasNormalBalinda = input.board.some((e) => e.cardId === "BG35_883");
    if ((hasGoldenBalinda || hasNormalBalinda) &&
        input.target &&
        input.board.some((e) => e.entityId === input.target.entityId)) {
        repeats = hasGoldenBalinda ? 3 : 2;
    }
    const maelstromExtra = input.board.filter((e) => e.cardId === "BG34_922").length +
        2 * input.board.filter((e) => e.cardId === "BG34_922_G").length;
    repeats += maelstromExtra;
    const spellCard = input.gameState.allCards.getCard(input.spellCardId);
    const isBountySpell = (_a = spellCard === null || spellCard === void 0 ? void 0 : spellCard.mechanics) === null || _a === void 0 ? void 0 : _a.includes('BACON_BOUNTY');
    if (isBountySpell && input.source === input.hero) {
        const proudPrivateerExtra = input.board.filter((e) => e.cardId === "BG33_825").length +
            2 * input.board.filter((e) => e.cardId === "BG33_825_G").length;
        repeats += proudPrivateerExtra;
    }
    const cathedrals = input.hero.trinkets.filter((t) => {
        var _a, _b;
        return t.cardId === "BG30_MagicItem_434" &&
            t.scriptDataNum1 > 0 &&
            ((_b = (_a = t.tags) === null || _a === void 0 ? void 0 : _a[reference_data_1.GameTag.TRIGGER_VISUAL]) !== null && _b !== void 0 ? _b : 0) > 0;
    });
    repeats += cathedrals.length;
    for (const cathedral of cathedrals) {
        cathedral.tags = (_b = cathedral.tags) !== null && _b !== void 0 ? _b : {};
        cathedral.tags[reference_data_1.GameTag.TRIGGER_VISUAL] = 0;
    }
    return repeats;
};
exports.getTavernSpellEffectRepeatCount = getTavernSpellEffectRepeatCount;
//# sourceMappingURL=tavern-spell-repeat.js.map