"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.grantRandomBonusKeywords = exports.ApprenticeOfSefin = void 0;
const reference_data_1 = require("@firestone-hs/reference-data");
const divine_shield_1 = require("../../../keywords/divine-shield");
const reborn_1 = require("../../../keywords/reborn");
const stealth_1 = require("../../../keywords/stealth");
const taunt_1 = require("../../../keywords/taunt");
const venomous_1 = require("../../../keywords/venomous");
const windfury_1 = require("../../../keywords/windfury");
const utils_1 = require("../../../services/utils");
const stats_1 = require("../../../simulation/stats");
const cards_data_1 = require("../../cards-data");
exports.ApprenticeOfSefin = {
    cardIds: ["BG32_332", "BG32_332_G"],
    endOfTurn: (minion, input) => {
        const mult = minion.cardId === "BG32_332_G" ? 2 : 1;
        for (let i = 0; i < mult; i++) {
            (0, exports.grantRandomBonusKeywords)(minion, mult, input.board, input.hero, input.otherHero, input.gameState);
        }
        (0, stats_1.modifyStats)(minion, minion, 4 * mult, 4 * mult, input.board, input.hero, input.gameState);
        return true;
    },
};
const grantRandomBonusKeywords = (target, mult, board, hero, otherHero, gameState) => {
    let possibleKeywords = [...cards_data_1.validBonusKeywords];
    for (let i = 0; i < mult; i++) {
        if (target.divineShield) {
            possibleKeywords = possibleKeywords.filter((possibleKeyword) => possibleKeyword !== reference_data_1.GameTag.DIVINE_SHIELD);
        }
        if (target.taunt) {
            possibleKeywords = possibleKeywords.filter((possibleKeyword) => possibleKeyword !== reference_data_1.GameTag.TAUNT);
        }
        if (target.venomous) {
            possibleKeywords = possibleKeywords.filter((possibleKeyword) => possibleKeyword !== reference_data_1.GameTag.VENOMOUS);
        }
        if (target.windfury) {
            possibleKeywords = possibleKeywords.filter((possibleKeyword) => possibleKeyword !== reference_data_1.GameTag.WINDFURY);
        }
        if (target.stealth) {
            possibleKeywords = possibleKeywords.filter((possibleKeyword) => possibleKeyword !== reference_data_1.GameTag.STEALTH);
        }
        if (target.reborn) {
            possibleKeywords = possibleKeywords.filter((possibleKeyword) => possibleKeyword !== reference_data_1.GameTag.REBORN);
        }
        if (possibleKeywords.length === 0) {
            continue;
        }
        const targetKeyword = (0, utils_1.pickRandom)(possibleKeywords);
        possibleKeywords = possibleKeywords.filter((possibleKeyword) => possibleKeyword !== targetKeyword);
        switch (targetKeyword) {
            case reference_data_1.GameTag.DIVINE_SHIELD:
                (0, divine_shield_1.updateDivineShield)(target, board, hero, otherHero, true, gameState);
                break;
            case reference_data_1.GameTag.TAUNT:
                (0, taunt_1.updateTaunt)(target, true, board, hero, otherHero, gameState);
                break;
            case reference_data_1.GameTag.VENOMOUS:
                (0, venomous_1.updateVenomous)(target, true, board, hero, otherHero, gameState);
                break;
            case reference_data_1.GameTag.WINDFURY:
                (0, windfury_1.updateWindfury)(target, true, board, hero, otherHero, gameState);
                break;
            case reference_data_1.GameTag.STEALTH:
                (0, stealth_1.updateStealth)(target, true, board, hero, otherHero, gameState);
                break;
            case reference_data_1.GameTag.REBORN:
                (0, reborn_1.updateReborn)(target, true, board, hero, otherHero, gameState);
                break;
        }
    }
};
exports.grantRandomBonusKeywords = grantRandomBonusKeywords;
//# sourceMappingURL=apprentice-of-sefin.js.map