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.
11 lines (8 loc) • 532 B
text/typescript
import { Config } from '@scrabble-solver/types';
import { BOARD_CELL_BORDER_WIDTH, BOARD_TILE_SIZE_MAX } from 'parameters';
export const getCellSize = (config: Config, width: number, height: number): number => {
const maxWidth = (width - BOARD_CELL_BORDER_WIDTH) / config.boardWidth - BOARD_CELL_BORDER_WIDTH;
const maxHeight = (height - BOARD_CELL_BORDER_WIDTH) / config.boardHeight - BOARD_CELL_BORDER_WIDTH;
const cellSize = Math.min(maxWidth, maxHeight);
return Math.floor(Math.min(cellSize, BOARD_TILE_SIZE_MAX));
};