"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isHandMinionCandidate = exports.getHighestAttackHandMinions = void 0;
const reference_data_1 = require("@firestone-hs/reference-data");
const utils_1 = require("./utils");
const getHighestAttackHandMinions = (hand, count, isMinionInHand) => {
    if (!(hand === null || hand === void 0 ? void 0 : hand.length) || count <= 0) {
        return [];
    }
    const scored = hand.map((entity, index) => ({ entity, index })).filter(({ entity }) => isMinionInHand(entity));
    const randomized = (0, utils_1.shuffleArray)(scored);
    randomized.sort((a, b) => {
        var _a, _b;
        const atkDiff = ((_a = b.entity.attack) !== null && _a !== void 0 ? _a : 0) - ((_b = a.entity.attack) !== null && _b !== void 0 ? _b : 0);
        if (atkDiff !== 0) {
            return atkDiff;
        }
        return 0;
    });
    return randomized.slice(0, count).map((s) => s.entity);
};
exports.getHighestAttackHandMinions = getHighestAttackHandMinions;
const isHandMinionCandidate = (entity, cardTypeUpper) => {
    return !!(entity === null || entity === void 0 ? void 0 : entity.cardId) && !entity.locked && cardTypeUpper(entity.cardId) === reference_data_1.CardType[reference_data_1.CardType.MINION];
};
exports.isHandMinionCandidate = isHandMinionCandidate;
//# sourceMappingURL=hand-minion-priority.js.map