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.
17 lines (12 loc) • 605 B
text/typescript
import { Result, ShowCoordinates } from '@scrabble-solver/types';
import { getCoordinate } from './getCoordinate';
export const getCoordinates = (result: Result, showCoordinates: ShowCoordinates): string => {
if (showCoordinates === 'hidden') {
return '';
}
const firstCell = result.cells[0];
const isHorizontal = firstCell.x !== result.cells[1].x;
const x = getCoordinate(firstCell.x, showCoordinates === 'original' ? 'letter' : 'number');
const y = getCoordinate(firstCell.y, showCoordinates === 'original' ? 'number' : 'letter');
return isHorizontal ? `${y}${x}` : `${x}${y}`;
};