"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NaturalBlessing = void 0;
const reference_data_1 = require("@firestone-hs/reference-data");
const utils_1 = require("../../../services/utils");
const stats_1 = require("../../../simulation/stats");
const utils_2 = require("../../../utils");
exports.NaturalBlessing = {
    cardIds: ["BG28_845"],
    castTavernSpell: (spellCardId, input) => {
        var _a, _b, _c, _d;
        const baseAttack = input.gameState.allCards.getCard(spellCardId).tags[reference_data_1.GameTag[reference_data_1.GameTag.TAG_SCRIPT_DATA_NUM_1]];
        const baseHealth = input.gameState.allCards.getCard(spellCardId).tags[reference_data_1.GameTag[reference_data_1.GameTag.TAG_SCRIPT_DATA_NUM_2]];
        const { attack, health } = (0, utils_2.withTavernSpellStatBuff)(input.hero, baseAttack, baseHealth, input.gameState.allCards, input.spellCardId);
        const allMinions = [...input.board, ...input.otherBoard];
        const target = (0, utils_1.pickRandom)(allMinions);
        const minionsSharingType = allMinions.filter((e) => doMinionsShareType(e, target, input.gameState.allCards));
        for (const minion of minionsSharingType) {
            (0, stats_1.modifyStats)(minion, input.source, attack, health, input.board, input.hero, input.gameState);
        }
        const hasPortrait = (_a = input.hero.trinkets) === null || _a === void 0 ? void 0 : _a.some((t) => t.cardId === "BG32_MagicItem_894");
        if (hasPortrait) {
            for (const handCard of (_b = input.hero.hand) !== null && _b !== void 0 ? _b : []) {
                if (doMinionsShareType(handCard, target, input.gameState.allCards)) {
                    handCard.attack = ((_c = handCard.attack) !== null && _c !== void 0 ? _c : 0) + attack;
                    handCard.health = ((_d = handCard.health) !== null && _d !== void 0 ? _d : 0) + health;
                }
            }
        }
    },
};
const doMinionsShareType = (minion, target, allCards) => {
    var _a, _b;
    const minionTypes = (_a = allCards.getCard(minion.cardId).races) !== null && _a !== void 0 ? _a : [];
    const targetTypes = (_b = allCards.getCard(target.cardId).races) !== null && _b !== void 0 ? _b : [];
    return minionTypes.some((type) => targetTypes.includes(type));
};
//# sourceMappingURL=natural-blessing.js.map