"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StompingStegodonEnchantment = void 0;
const reference_data_1 = require("@firestone-hs/reference-data");
const stats_1 = require("../../../simulation/stats");
const utils_1 = require("../../../utils");
const stomping_stegodon_1 = require("./stomping-stegodon");
exports.StompingStegodonEnchantment = {
    cardIds: [
        "BG33_840e2",
        "BG33_840_Ge2",
    ],
    rally: (enchantment, input) => {
        var _a, _b;
        const mult = enchantment.cardId === "BG33_840_Ge2" ? 2 : 1;
        const nbOfTriggers = (_a = enchantment.repeats) !== null && _a !== void 0 ? _a : 1;
        const enchantmentCardIdToAdd = enchantment.cardId === "BG33_840_Ge2"
            ? "BG33_840_Ge2"
            : "BG33_840e2";
        const candidates = input.attackingBoard.filter((e) => e !== input.attacker &&
            (0, utils_1.hasCorrectTribe)(e, input.attackingHero, reference_data_1.Race.BEAST, input.gameState.anomalies, input.gameState.allCards));
        for (const candidate of candidates) {
            (0, stats_1.modifyStats)(candidate, input.attacker, stomping_stegodon_1.stompingStegodonAttack * nbOfTriggers * mult, stomping_stegodon_1.stompingStegodonHealth * nbOfTriggers * mult, input.attackingBoard, input.attackingHero, input.gameState);
            let existingEnchantment = candidate.enchantments.find((e) => e.cardId === enchantmentCardIdToAdd);
            if (!existingEnchantment) {
                existingEnchantment = {
                    cardId: enchantmentCardIdToAdd,
                    originEntityId: input.attacker.entityId,
                    timing: input.gameState.sharedState.currentEntityId++,
                    repeats: 0,
                };
                candidate.enchantments.push(existingEnchantment);
            }
            existingEnchantment.repeats = ((_b = existingEnchantment.repeats) !== null && _b !== void 0 ? _b : 0) + nbOfTriggers;
        }
        return { dmgDoneByAttacker: 0, dmgDoneByDefender: 0 };
    },
};
//# sourceMappingURL=stomping-stegodon-enchantment.js.map