"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPatternScore = void 0;
const types_1 = require("@scrabble-solver/types");
const getCellsScore_1 = require("./getCellsScore");
const getPatternScore = (config, pattern) => {
    const areAllTilesUsed = pattern.getEmptyCellsCount() === config.rackSize;
    const baseScore = (0, getCellsScore_1.getCellsScore)(config, pattern.cells);
    const collisionsScore = pattern
        .getCollisions()
        .reduce((sum, collision) => sum + (0, getCellsScore_1.getCellsScore)(config, collision.cells), 0);
    if (areAllTilesUsed) {
        if ((0, types_1.isScoreBingo)(config.bingo)) {
            return baseScore + collisionsScore + config.bingo.score;
        }
        if ((0, types_1.isMultiplierBingo)(config.bingo)) {
            return baseScore * config.bingo.multiplier + collisionsScore;
        }
    }
    return baseScore + collisionsScore;
};
exports.getPatternScore = getPatternScore;
