UNPKG

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.

26 lines (18 loc) 528 B
import { type CellJson, type Config } from '@scrabble-solver/types'; import { isCharacterValid } from './isCharacterValid'; export const isCellValid = (cell: CellJson, config: Config): boolean => { const { isEmpty, tile, x, y } = cell; if (x < 0 || x >= config.boardWidth) { return false; } if (y < 0 || y >= config.boardHeight) { return false; } if (isEmpty && tile !== null) { return false; } if (tile !== null && !isCharacterValid(tile.character)) { return false; } return true; };