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.
26 lines (21 loc) • 778 B
text/typescript
import { CreatePlainTilesOptions, PlainTile } from '../types';
import { createPlainTile } from './createPlainTile';
export const createPlainTiles = ({ color, content, showPoints }: CreatePlainTilesOptions): PlainTile[] => {
const rows = content.map((words, rowIndex) => {
return words.map((word, wordIndex) => {
const cellOffset = words.slice(0, wordIndex).reduce((result, { length }) => result + length + ' '.length, 0);
const characters = word.split('');
return characters.map((character, cellIndex) => {
return createPlainTile({
cellIndex: cellOffset + cellIndex,
character,
color,
rowIndex,
showPoints,
});
});
});
});
const tiles = rows.flat(2);
return tiles;
};