"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExpertAviator = void 0;
const hand_minion_priority_1 = require("../../../services/hand-minion-priority");
const deathrattle_spawns_1 = require("../../../simulation/deathrattle-spawns");
const spawns_1 = require("../../../simulation/spawns");
const utils_1 = require("../../../utils");
exports.ExpertAviator = {
    cardIds: ["BG34_140", "BG34_140_G"],
    rally: (minion, input) => {
        const mult = minion.cardId === "BG34_140_G" ? 2 : 1;
        const allCards = input.gameState.allCards;
        const targets = (0, hand_minion_priority_1.getHighestAttackHandMinions)(input.attackingHero.hand, mult, (e) => !!e.maxHealth && (0, hand_minion_priority_1.isHandMinionCandidate)(e, (id) => { var _a; return (_a = allCards.getCard(id).type) === null || _a === void 0 ? void 0 : _a.toUpperCase(); }));
        for (const target of targets) {
            if (target.locked) {
                continue;
            }
            target.locked = true;
            const clone = (0, utils_1.copyEntity)(target);
            const spawnInput = {
                boardWithDeadEntity: input.attackingBoard,
                boardWithDeadEntityHero: input.attackingHero,
                gameState: input.gameState,
                deadEntity: minion,
                otherBoard: input.defendingBoard,
                otherBoardHero: input.defendingHero,
            };
            const spawns = (0, deathrattle_spawns_1.simplifiedSpawnEntities)(clone.cardId, 1, spawnInput, clone);
            for (const s of spawns) {
                s.onCanceledSummon = () => (target.locked = false);
            }
            (0, spawns_1.performEntitySpawns)(spawns, spawnInput.boardWithDeadEntity, spawnInput.boardWithDeadEntityHero, minion, input.attackingBoard.length - input.attackingBoard.indexOf(minion) - 1, spawnInput.otherBoard, spawnInput.otherBoardHero, input.gameState);
        }
        return {
            dmgDoneByAttacker: 0,
            dmgDoneByDefender: 0,
        };
    },
};
//# sourceMappingURL=expert-aviator.js.map