"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCellsScore = void 0;
const constants_1 = require("@scrabble-solver/constants");
const getCellsScore = (config, cells) => {
    const total = cells.reduce(({ multiplier, score }, cell) => {
        const bonus = config.getCellBonus(cell);
        const { characterMultiplier, wordMultiplier } = bonus && bonus.canApply(config, cell) ? bonus.value : constants_1.NO_BONUS;
        const characterScore = config.pointsMap[cell.tile.character] || 0;
        const tileScore = cell.tile.isBlank ? config.blankScore : characterScore;
        return {
            multiplier: multiplier * wordMultiplier,
            score: score + tileScore * characterMultiplier,
        };
    }, { multiplier: 1, score: 0 });
    return total.score * total.multiplier;
};
exports.getCellsScore = getCellsScore;
