@scrabble-solver/solver
Version:
Scrabble Solver 2 - Solver
16 lines (11 loc) • 535 B
text/typescript
import { Config, Pattern } from '@scrabble-solver/types';
import getCellsScore from './getCellsScore';
const getPatternScore = (config: Config, pattern: Pattern) => {
const areAllTilesUsed = pattern.getEmptyCellsCount() === config.rackSize;
const bonusScore = areAllTilesUsed ? config.bingoScore : 0;
const score = pattern
.getCollisions()
.reduce((sum, collision) => sum + getCellsScore(config, collision.cells), getCellsScore(config, pattern.cells));
return score + bonusScore;
};
export default getPatternScore;