UNPKG

scrabble-solver

Version:

Scrabble Solver 2 - Free, open-source, cross-platform, multi-language analysis tool for Scrabble, Scrabble Duel, Super Scrabble, Letter League, Literaki, and Kelimelik. Quickly find the top-scoring words using the given board and tiles.

19 lines (18 loc) 878 B
"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;