"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KarmicChameleon = void 0;
const golden_1 = require("../../../simulation/utils/golden");
const utils_1 = require("../../../utils");
const card_interface_1 = require("../../card.interface");
const _card_mappings_1 = require("../_card-mappings");
exports.KarmicChameleon = {
    cardIds: ["BG31_802", "BG31_802_G"],
    baseAvengeValue: (cardId) => 5,
    avenge: (minion, input) => {
        const board = input.board.filter((e) => e.health > 0 && !e.definitelyDead);
        const chameleonIndex = input.board.findIndex((entity) => entity.entityId === minion.entityId);
        if (chameleonIndex > 0) {
            const minionToTheLeft = board[chameleonIndex - 1];
            if (!!minionToTheLeft) {
                const clone = {
                    ...(0, utils_1.copyEntity)(minionToTheLeft),
                    entityId: input.gameState.sharedState.currentEntityId++,
                };
                if (minion.cardId === "BG31_802_G") {
                    (0, golden_1.makeMinionGolden)(clone, minion, input.board, input.hero, input.otherBoard, input.otherHero, input.gameState);
                }
                input.board.splice(chameleonIndex, 1, clone);
                input.gameState.spectator.registerPowerTarget(minion, minionToTheLeft, input.board, input.hero, input.otherHero);
                const onSpawnedImpl = _card_mappings_1.cardMappings[clone.cardId];
                if ((0, card_interface_1.hasOnSpawned)(onSpawnedImpl)) {
                    onSpawnedImpl.onSpawned(clone, {
                        hero: input.hero,
                        board: board,
                        gameState: input.gameState,
                        applyAttackAuras: true,
                        applyHealthAuras: true,
                    });
                }
            }
        }
    },
};
//# sourceMappingURL=karmic-chameleon.js.map