"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TimewarpedBristler = void 0;
const reference_data_1 = require("@firestone-hs/reference-data");
const utils_1 = require("../../../services/utils");
const blood_gems_1 = require("../../../simulation/blood-gems");
const stats_1 = require("../../../simulation/stats");
const utils_2 = require("../../../utils");
exports.TimewarpedBristler = {
    cardIds: ["BG34_Giant_104", "BG34_Giant_104_G"],
    deathrattleSpawn: (minion, input) => {
        var _a, _b;
        let bloodGemAttack = 0;
        let bloodGemHealth = 0;
        let bloodGemEnchantments = minion.enchantments.filter((e) => e.cardId === "BG20_GEMe2");
        if (!!(bloodGemEnchantments === null || bloodGemEnchantments === void 0 ? void 0 : bloodGemEnchantments.length)) {
            const lastEnchantment = bloodGemEnchantments[bloodGemEnchantments.length - 1];
            bloodGemAttack = (_a = lastEnchantment.tagScriptDataNum1) !== null && _a !== void 0 ? _a : 0;
            bloodGemHealth = (_b = lastEnchantment.tagScriptDataNum2) !== null && _b !== void 0 ? _b : 0;
        }
        else {
            bloodGemEnchantments = minion.enchantments.filter((e) => e.cardId === "BG20_GEMe");
            bloodGemAttack = bloodGemEnchantments.map((e) => { var _a; return (_a = e.tagScriptDataNum1) !== null && _a !== void 0 ? _a : 0; }).reduce((a, b) => a + b, 0);
            bloodGemHealth = bloodGemEnchantments.map((e) => { var _a; return (_a = e.tagScriptDataNum2) !== null && _a !== void 0 ? _a : 0; }).reduce((a, b) => a + b, 0);
        }
        const candidates = input.boardWithDeadEntity.filter((e) => (0, utils_2.hasCorrectTribe)(e, input.boardWithDeadEntityHero, reference_data_1.Race.QUILBOAR, input.gameState.anomalies, input.gameState.allCards));
        const mult = minion.cardId === "BG34_Giant_104_G" ? 2 : 1;
        for (let i = 0; i < mult; i++) {
            const targets = (0, utils_1.pickMultipleRandom)(candidates, 2);
            for (const target of targets) {
                (0, blood_gems_1.applyBloodGemEnchantment)("BG20_GEMe2", target, minion, 1, bloodGemAttack, bloodGemHealth);
                (0, blood_gems_1.applyBloodGemEnchantment)("BG20_GEMe", target, minion, 1, bloodGemAttack, bloodGemHealth);
                (0, stats_1.modifyStats)(target, minion, bloodGemAttack, bloodGemHealth, input.boardWithDeadEntity, input.boardWithDeadEntityHero, input.gameState, false);
            }
        }
        return [];
    },
};
//# sourceMappingURL=timewarped-bristler.js.map