scrabble-solver
Version:
Scrabble Solver 2 - Free, open-source, cross-platform, multi-language analysis tool for Scrabble, Scrabble Duel, Super Scrabble, Letter League, Crossplay, Literaki, and Kelimelik. Quickly find the top-scoring words using the given board and tiles.
23 lines (22 loc) • 985 B
JavaScript
;
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;