UNPKG

@scrabble-solver/solver

Version:
16 lines (15 loc) 745 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const getCellsScore_1 = __importDefault(require("./getCellsScore")); const getPatternScore = (config, pattern) => { const areAllTilesUsed = pattern.getEmptyCellsCount() === config.rackSize; const bonusScore = areAllTilesUsed ? config.bingoScore : 0; const score = pattern .getCollisions() .reduce((sum, collision) => sum + (0, getCellsScore_1.default)(config, collision.cells), (0, getCellsScore_1.default)(config, pattern.cells)); return score + bonusScore; }; exports.default = getPatternScore;