@scrabble-solver/types 2.15.10 → 2.15.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/build/Bingo.d.ts +10 -0
  2. package/build/Bingo.js +16 -0
  3. package/build/Board.d.ts +1 -1
  4. package/build/Board.js +40 -14
  5. package/build/BoardJson.d.ts +1 -1
  6. package/build/Bonus.d.ts +4 -4
  7. package/build/Cell.d.ts +1 -1
  8. package/build/CellJson.d.ts +1 -1
  9. package/build/CharacterBonus.d.ts +2 -2
  10. package/build/Collision.d.ts +1 -1
  11. package/build/CollisionJson.d.ts +1 -1
  12. package/build/Config.d.ts +11 -9
  13. package/build/Config.js +5 -2
  14. package/build/ConfigJson.d.ts +6 -5
  15. package/build/Dictionary.d.ts +1 -1
  16. package/build/Game.d.ts +1 -0
  17. package/build/Game.js +1 -0
  18. package/build/Pattern.d.ts +4 -4
  19. package/build/PatternJson.d.ts +1 -1
  20. package/build/Result.d.ts +4 -2
  21. package/build/Result.js +6 -0
  22. package/build/ResultJson.d.ts +2 -2
  23. package/build/Tile.d.ts +1 -1
  24. package/build/TileConfig.d.ts +1 -1
  25. package/build/WordBonus.d.ts +1 -1
  26. package/build/WordDefinition.d.ts +1 -1
  27. package/build/index.d.ts +1 -0
  28. package/build/index.js +5 -1
  29. package/package.json +3 -3
  30. package/src/Bingo.ts +19 -0
  31. package/src/Board.ts +49 -20
  32. package/src/BoardJson.ts +1 -1
  33. package/src/Bonus.ts +4 -4
  34. package/src/Cell.ts +1 -1
  35. package/src/CellJson.ts +1 -1
  36. package/src/CharacterBonus.ts +2 -2
  37. package/src/Collision.ts +1 -1
  38. package/src/CollisionJson.ts +1 -1
  39. package/src/Config.ts +15 -10
  40. package/src/ConfigJson.ts +6 -5
  41. package/src/Dictionary.ts +1 -1
  42. package/src/Game.ts +1 -0
  43. package/src/Pattern.ts +4 -4
  44. package/src/PatternJson.ts +1 -1
  45. package/src/Result.ts +10 -2
  46. package/src/ResultJson.ts +2 -2
  47. package/src/Tile.ts +1 -1
  48. package/src/TileConfig.ts +1 -1
  49. package/src/WordBonus.ts +1 -1
  50. package/src/WordDefinition.ts +1 -1
  51. package/src/index.ts +1 -0
@@ -0,0 +1,10 @@
1
+ export type MultiplierBingo = {
2
+ multiplier: number;
3
+ };
4
+ export type ScoreBingo = {
5
+ score: number;
6
+ };
7
+ export type Bingo = MultiplierBingo | ScoreBingo;
8
+ export declare const isBingo: (value: unknown) => value is Bingo;
9
+ export declare const isScoreBingo: (value: unknown) => value is ScoreBingo;
10
+ export declare const isMultiplierBingo: (value: unknown) => value is MultiplierBingo;
package/build/Bingo.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMultiplierBingo = exports.isScoreBingo = exports.isBingo = void 0;
4
+ const isObject_1 = require("./isObject");
5
+ const isBingo = (value) => {
6
+ return (0, exports.isScoreBingo)(value) || (0, exports.isMultiplierBingo)(value);
7
+ };
8
+ exports.isBingo = isBingo;
9
+ const isScoreBingo = (value) => {
10
+ return (0, isObject_1.isObject)(value) && 'score' in value && typeof value.score === 'number';
11
+ };
12
+ exports.isScoreBingo = isScoreBingo;
13
+ const isMultiplierBingo = (value) => {
14
+ return (0, isObject_1.isObject)(value) && 'multiplier' in value && typeof value.multiplier === 'number';
15
+ };
16
+ exports.isMultiplierBingo = isMultiplierBingo;
package/build/Board.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BoardJson } from './BoardJson';
1
+ import { type BoardJson } from './BoardJson';
2
2
  import { Cell } from './Cell';
3
3
  export declare class Board {
4
4
  static create: (width: number, height: number) => Board;
package/build/Board.js CHANGED
@@ -70,20 +70,9 @@ class Board {
70
70
  }, 0);
71
71
  }
72
72
  getWords() {
73
- const columns = [];
74
- for (let x = 0; x < this.columnsCount; ++x) {
75
- const column = [];
76
- for (let y = 0; y < this.rowsCount; ++y) {
77
- column.push(this.rows[y][x]);
78
- }
79
- columns.push(column);
80
- }
81
- const columnsBoard = new Board({ rows: columns });
82
- const lines = this.toString().split('\n').concat(columnsBoard.toString().split('\n'));
83
- const words = lines
84
- .flatMap((line) => line.replaceAll(/\s+/g, constants_1.EMPTY_CELL).split(' '))
85
- .filter((word) => word.length > 1);
86
- return words;
73
+ const horizontalWords = getHorizontalWords(this.rows);
74
+ const verticalWords = getHorizontalWords(transpose(this.rows));
75
+ return [...horizontalWords, ...verticalWords];
87
76
  }
88
77
  isEmpty() {
89
78
  return this.rows.every((row) => row.every(({ isEmpty }) => isEmpty));
@@ -113,3 +102,40 @@ Board.fromJson = (json) => {
113
102
  rows: json.map((row) => row.map(Cell_1.Cell.fromJson)),
114
103
  });
115
104
  };
105
+ const transpose = (array) => {
106
+ const rows = array.length;
107
+ const cols = array[0].length;
108
+ const transposed = Array(cols)
109
+ .fill(null)
110
+ .map(() => Array(rows));
111
+ for (let y = 0; y < rows; ++y) {
112
+ for (let x = 0; x < cols; ++x) {
113
+ transposed[x][y] = array[y][x];
114
+ }
115
+ }
116
+ return transposed;
117
+ };
118
+ const getHorizontalWords = (cells) => {
119
+ const words = [];
120
+ for (const row of cells) {
121
+ let currentWord = [];
122
+ for (const cell of row) {
123
+ if (!cell.isEmpty) {
124
+ currentWord.push(cell);
125
+ }
126
+ else if (currentWord.length > 0) {
127
+ if (currentWord.length > 1) {
128
+ words.push(wordToString(currentWord));
129
+ }
130
+ currentWord = [];
131
+ }
132
+ }
133
+ if (currentWord.length > 1) {
134
+ words.push(wordToString(currentWord));
135
+ }
136
+ }
137
+ return words;
138
+ };
139
+ const wordToString = (currentWord) => {
140
+ return currentWord.map((cell) => cell.tile.character).join('');
141
+ };
@@ -1,3 +1,3 @@
1
- import { CellJson } from './CellJson';
1
+ import { type CellJson } from './CellJson';
2
2
  export type BoardJson = CellJson[][];
3
3
  export declare const isBoardJson: (value: unknown) => value is BoardJson;
package/build/Bonus.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { BONUS_CHARACTER, BONUS_WORD } from '@scrabble-solver/constants';
2
- import { BonusJson } from './BonusJson';
3
- import { BonusValue } from './BonusValue';
4
- import { Cell } from './Cell';
1
+ import { type BONUS_CHARACTER, type BONUS_WORD } from '@scrabble-solver/constants';
2
+ import { type BonusJson } from './BonusJson';
3
+ import { type BonusValue } from './BonusValue';
4
+ import { type Cell } from './Cell';
5
5
  import { type Config } from './Config';
6
6
  export declare abstract class Bonus {
7
7
  readonly multiplier: number;
package/build/Cell.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CellJson } from './CellJson';
1
+ import { type CellJson } from './CellJson';
2
2
  import { Tile } from './Tile';
3
3
  export declare class Cell {
4
4
  static fromJson: (json: CellJson) => Cell;
@@ -1,4 +1,4 @@
1
- import { TileJson } from './TileJson';
1
+ import { type TileJson } from './TileJson';
2
2
  export interface CellJson {
3
3
  isEmpty: boolean;
4
4
  tile: TileJson | null;
@@ -1,6 +1,6 @@
1
1
  import { Bonus } from './Bonus';
2
- import { BonusValue } from './BonusValue';
3
- import { Cell } from './Cell';
2
+ import { type BonusValue } from './BonusValue';
3
+ import { type Cell } from './Cell';
4
4
  import { type Config } from './Config';
5
5
  export declare class CharacterBonus extends Bonus {
6
6
  readonly type = "BONUS_CHARACTER";
@@ -1,2 +1,2 @@
1
- import { Cell } from './Cell';
1
+ import { type Cell } from './Cell';
2
2
  export type Collision = Cell[];
@@ -1,2 +1,2 @@
1
- import { CellJson } from './CellJson';
1
+ import { type CellJson } from './CellJson';
2
2
  export type CollisionJson = CellJson[];
package/build/Config.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- import { Bonus } from './Bonus';
2
- import { BonusValue } from './BonusValue';
3
- import { Cell } from './Cell';
4
- import { ConfigJson } from './ConfigJson';
5
- import { Game } from './Game';
6
- import { Locale } from './Locale';
7
- import { Tile } from './Tile';
8
- import { TileConfig } from './TileConfig';
1
+ import { type Bingo } from './Bingo';
2
+ import { type Bonus } from './Bonus';
3
+ import { type BonusValue } from './BonusValue';
4
+ import { type Cell } from './Cell';
5
+ import { type ConfigJson } from './ConfigJson';
6
+ import { type Game } from './Game';
7
+ import { type Locale } from './Locale';
8
+ import { type Tile } from './Tile';
9
+ import { type TileConfig } from './TileConfig';
9
10
  export declare class Config {
10
11
  static fromJson: (json: ConfigJson) => Config;
11
12
  readonly bonuses: Bonus[];
@@ -13,7 +14,7 @@ export declare class Config {
13
14
  readonly pointsMap: Record<string, number>;
14
15
  constructor(config: ConfigJson);
15
16
  get alphabet(): string[];
16
- get bingoScore(): number;
17
+ get bingo(): Bingo;
17
18
  get blankScore(): number;
18
19
  get blanksCount(): number;
19
20
  get boardHeight(): number;
@@ -29,6 +30,7 @@ export declare class Config {
29
30
  hasCharacter(character: string): boolean;
30
31
  isTwoCharacterTilePrefix(character: string): boolean;
31
32
  get rackSize(): number;
33
+ get supportsRemainingTiles(): boolean;
32
34
  get tiles(): TileConfig[];
33
35
  toJson(): ConfigJson;
34
36
  }
package/build/Config.js CHANGED
@@ -13,8 +13,8 @@ class Config {
13
13
  get alphabet() {
14
14
  return getAlphabet(this.config);
15
15
  }
16
- get bingoScore() {
17
- return this.config.bingoScore;
16
+ get bingo() {
17
+ return this.config.bingo;
18
18
  }
19
19
  get blankScore() {
20
20
  return this.config.blankScore;
@@ -73,6 +73,9 @@ class Config {
73
73
  get rackSize() {
74
74
  return this.config.rackSize;
75
75
  }
76
+ get supportsRemainingTiles() {
77
+ return this.tiles.every((tile) => typeof tile.count === 'number');
78
+ }
76
79
  get tiles() {
77
80
  return this.config.tiles;
78
81
  }
@@ -1,9 +1,10 @@
1
- import { BonusJson } from './BonusJson';
2
- import { Game } from './Game';
3
- import { Locale } from './Locale';
4
- import { TileConfig } from './TileConfig';
1
+ import { type Bingo } from './Bingo';
2
+ import { type BonusJson } from './BonusJson';
3
+ import { type Game } from './Game';
4
+ import { type Locale } from './Locale';
5
+ import { type TileConfig } from './TileConfig';
5
6
  export interface ConfigJson {
6
- bingoScore: number;
7
+ bingo: Bingo;
7
8
  blankScore: number;
8
9
  blanksCount: number;
9
10
  boardHeight: number;
@@ -1,4 +1,4 @@
1
- import { Locale } from './Locale';
1
+ import { type Locale } from './Locale';
2
2
  export interface Dictionary {
3
3
  description: string;
4
4
  locale: Locale;
package/build/Game.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export declare enum Game {
2
2
  Kelimelik = "kelimelik",
3
+ LetterLeague = "letter-league",
3
4
  Literaki = "literaki",
4
5
  Scrabble = "scrabble",
5
6
  ScrabbleDuel = "scrabble-duel",
package/build/Game.js CHANGED
@@ -4,6 +4,7 @@ exports.isGame = exports.Game = void 0;
4
4
  var Game;
5
5
  (function (Game) {
6
6
  Game["Kelimelik"] = "kelimelik";
7
+ Game["LetterLeague"] = "letter-league";
7
8
  Game["Literaki"] = "literaki";
8
9
  Game["Scrabble"] = "scrabble";
9
10
  Game["ScrabbleDuel"] = "scrabble-duel";
@@ -1,7 +1,7 @@
1
- import { Board } from './Board';
2
- import { Cell } from './Cell';
3
- import { Config } from './Config';
4
- import { PatternJson } from './PatternJson';
1
+ import { type Board } from './Board';
2
+ import { type Cell } from './Cell';
3
+ import { type Config } from './Config';
4
+ import { type PatternJson } from './PatternJson';
5
5
  export declare class Pattern {
6
6
  readonly board: Board;
7
7
  readonly cells: Cell[];
@@ -1,4 +1,4 @@
1
- import { CellJson } from './CellJson';
1
+ import { type CellJson } from './CellJson';
2
2
  export interface PatternJson {
3
3
  cells: CellJson[];
4
4
  collisions: PatternJson[];
package/build/Result.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Cell } from './Cell';
2
- import { ResultJson } from './ResultJson';
3
- import { Tile } from './Tile';
2
+ import { type ResultJson } from './ResultJson';
3
+ import { type Tile } from './Tile';
4
4
  type Collision = Cell[];
5
5
  export declare class Result {
6
6
  static fromJson: (json: ResultJson) => Result;
@@ -25,5 +25,7 @@ export declare class Result {
25
25
  points: number;
26
26
  });
27
27
  toJson(): ResultJson;
28
+ isHorizontal(): boolean;
29
+ isVertical(): boolean;
28
30
  }
29
31
  export {};
package/build/Result.js CHANGED
@@ -29,6 +29,12 @@ class Result {
29
29
  points: this.points,
30
30
  };
31
31
  }
32
+ isHorizontal() {
33
+ return this.cells[0].y === this.cells[1].y;
34
+ }
35
+ isVertical() {
36
+ return this.cells[0].x === this.cells[1].x;
37
+ }
32
38
  }
33
39
  exports.Result = Result;
34
40
  Result.fromJson = (json) => {
@@ -1,5 +1,5 @@
1
- import { CellJson } from './CellJson';
2
- import { CollisionJson } from './CollisionJson';
1
+ import { type CellJson } from './CellJson';
2
+ import { type CollisionJson } from './CollisionJson';
3
3
  export interface ResultJson {
4
4
  cells: CellJson[];
5
5
  collisions: CollisionJson[];
package/build/Tile.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { TileJson } from './TileJson';
1
+ import { type TileJson } from './TileJson';
2
2
  export declare class Tile {
3
3
  static fromJson: (json: TileJson | null) => Tile;
4
4
  static readonly Null: Tile;
@@ -1,5 +1,5 @@
1
1
  export interface TileConfig {
2
2
  character: string;
3
- count: number;
3
+ count?: number;
4
4
  score: number;
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import { Bonus } from './Bonus';
2
- import { BonusValue } from './BonusValue';
2
+ import { type BonusValue } from './BonusValue';
3
3
  export declare class WordBonus extends Bonus {
4
4
  readonly type = "BONUS_WORD";
5
5
  get value(): BonusValue;
@@ -1,4 +1,4 @@
1
- import { WordDefinitionJson } from './WordDefinitionJson';
1
+ import { type WordDefinitionJson } from './WordDefinitionJson';
2
2
  export declare class WordDefinition {
3
3
  static fromJson: (json: WordDefinitionJson | null) => WordDefinition;
4
4
  static readonly Null: WordDefinition;
package/build/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { Bingo, isBingo, isMultiplierBingo, isScoreBingo } from './Bingo';
1
2
  export { Board } from './Board';
2
3
  export { BoardJson, isBoardJson } from './BoardJson';
3
4
  export { Bonus } from './Bonus';
package/build/index.js CHANGED
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WordDefinition = exports.WordBonus = exports.VerticalPattern = exports.isTileJson = exports.Tile = exports.Result = exports.Pattern = exports.Locale = exports.isLocale = exports.isObject = exports.isError = exports.HorizontalPattern = exports.isGame = exports.Game = exports.FinalPattern = exports.Config = exports.CharacterBonus = exports.isCellJson = exports.Cell = exports.Bonus = exports.isBoardJson = exports.Board = void 0;
3
+ exports.WordDefinition = exports.WordBonus = exports.VerticalPattern = exports.isTileJson = exports.Tile = exports.Result = exports.Pattern = exports.Locale = exports.isLocale = exports.isObject = exports.isError = exports.HorizontalPattern = exports.isGame = exports.Game = exports.FinalPattern = exports.Config = exports.CharacterBonus = exports.isCellJson = exports.Cell = exports.Bonus = exports.isBoardJson = exports.Board = exports.isScoreBingo = exports.isMultiplierBingo = exports.isBingo = void 0;
4
+ var Bingo_1 = require("./Bingo");
5
+ Object.defineProperty(exports, "isBingo", { enumerable: true, get: function () { return Bingo_1.isBingo; } });
6
+ Object.defineProperty(exports, "isMultiplierBingo", { enumerable: true, get: function () { return Bingo_1.isMultiplierBingo; } });
7
+ Object.defineProperty(exports, "isScoreBingo", { enumerable: true, get: function () { return Bingo_1.isScoreBingo; } });
4
8
  var Board_1 = require("./Board");
5
9
  Object.defineProperty(exports, "Board", { enumerable: true, get: function () { return Board_1.Board; } });
6
10
  var BoardJson_1 = require("./BoardJson");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrabble-solver/types",
3
- "version": "2.15.10",
3
+ "version": "2.15.12",
4
4
  "description": "Scrabble Solver 2 - Types",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "clean": "rimraf build/"
24
24
  },
25
25
  "dependencies": {
26
- "@scrabble-solver/constants": "^2.15.10"
26
+ "@scrabble-solver/constants": "^2.15.12"
27
27
  },
28
- "gitHead": "dab5a817c1bde1a3ebf8e8907215adf12af5cb27"
28
+ "gitHead": "1eeef2b2975e63b195885dd2636c53624d300c6b"
29
29
  }
package/src/Bingo.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { isObject } from './isObject';
2
+
3
+ export type MultiplierBingo = { multiplier: number };
4
+
5
+ export type ScoreBingo = { score: number };
6
+
7
+ export type Bingo = MultiplierBingo | ScoreBingo;
8
+
9
+ export const isBingo = (value: unknown): value is Bingo => {
10
+ return isScoreBingo(value) || isMultiplierBingo(value);
11
+ };
12
+
13
+ export const isScoreBingo = (value: unknown): value is ScoreBingo => {
14
+ return isObject(value) && 'score' in value && typeof value.score === 'number';
15
+ };
16
+
17
+ export const isMultiplierBingo = (value: unknown): value is MultiplierBingo => {
18
+ return isObject(value) && 'multiplier' in value && typeof value.multiplier === 'number';
19
+ };
package/src/Board.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EMPTY_CELL } from '@scrabble-solver/constants';
2
2
 
3
- import { BoardJson } from './BoardJson';
3
+ import { type BoardJson } from './BoardJson';
4
4
  import { Cell } from './Cell';
5
5
  import { Tile } from './Tile';
6
6
 
@@ -110,25 +110,9 @@ export class Board {
110
110
  }
111
111
 
112
112
  public getWords(): string[] {
113
- const columns: Cell[][] = [];
114
-
115
- for (let x = 0; x < this.columnsCount; ++x) {
116
- const column: Cell[] = [];
117
-
118
- for (let y = 0; y < this.rowsCount; ++y) {
119
- column.push(this.rows[y][x]);
120
- }
121
-
122
- columns.push(column);
123
- }
124
-
125
- const columnsBoard = new Board({ rows: columns });
126
- const lines = this.toString().split('\n').concat(columnsBoard.toString().split('\n'));
127
- const words = lines
128
- .flatMap((line) => line.replaceAll(/\s+/g, EMPTY_CELL).split(' '))
129
- .filter((word) => word.length > 1);
130
-
131
- return words;
113
+ const horizontalWords = getHorizontalWords(this.rows);
114
+ const verticalWords = getHorizontalWords(transpose(this.rows));
115
+ return [...horizontalWords, ...verticalWords];
132
116
  }
133
117
 
134
118
  public isEmpty(): boolean {
@@ -151,3 +135,48 @@ export class Board {
151
135
  this.rows[y] = updateRow(this.rows[y]);
152
136
  }
153
137
  }
138
+
139
+ const transpose = <T>(array: T[][]): T[][] => {
140
+ const rows = array.length;
141
+ const cols = array[0].length;
142
+ const transposed: T[][] = Array(cols)
143
+ .fill(null)
144
+ .map(() => Array(rows));
145
+
146
+ for (let y = 0; y < rows; ++y) {
147
+ for (let x = 0; x < cols; ++x) {
148
+ transposed[x][y] = array[y][x];
149
+ }
150
+ }
151
+
152
+ return transposed;
153
+ };
154
+
155
+ const getHorizontalWords = (cells: Cell[][]): string[] => {
156
+ const words: string[] = [];
157
+
158
+ for (const row of cells) {
159
+ let currentWord: Cell[] = [];
160
+
161
+ for (const cell of row) {
162
+ if (!cell.isEmpty) {
163
+ currentWord.push(cell);
164
+ } else if (currentWord.length > 0) {
165
+ if (currentWord.length > 1) {
166
+ words.push(wordToString(currentWord));
167
+ }
168
+ currentWord = [];
169
+ }
170
+ }
171
+
172
+ if (currentWord.length > 1) {
173
+ words.push(wordToString(currentWord));
174
+ }
175
+ }
176
+
177
+ return words;
178
+ };
179
+
180
+ const wordToString = (currentWord: Cell[]): string => {
181
+ return currentWord.map((cell) => cell.tile.character).join('');
182
+ };
package/src/BoardJson.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CellJson, isCellJson } from './CellJson';
1
+ import { type CellJson, isCellJson } from './CellJson';
2
2
 
3
3
  export type BoardJson = CellJson[][];
4
4
 
package/src/Bonus.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { BONUS_CHARACTER, BONUS_WORD } from '@scrabble-solver/constants';
1
+ import { type BONUS_CHARACTER, type BONUS_WORD } from '@scrabble-solver/constants';
2
2
 
3
- import { BonusJson } from './BonusJson';
4
- import { BonusValue } from './BonusValue';
5
- import { Cell } from './Cell';
3
+ import { type BonusJson } from './BonusJson';
4
+ import { type BonusValue } from './BonusValue';
5
+ import { type Cell } from './Cell';
6
6
  import { type Config } from './Config';
7
7
 
8
8
  export abstract class Bonus {
package/src/Cell.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CellJson } from './CellJson';
1
+ import { type CellJson } from './CellJson';
2
2
  import { Tile } from './Tile';
3
3
 
4
4
  export class Cell {
package/src/CellJson.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isObject } from './isObject';
2
- import { isTileJson, TileJson } from './TileJson';
2
+ import { isTileJson, type TileJson } from './TileJson';
3
3
 
4
4
  export interface CellJson {
5
5
  isEmpty: boolean;
@@ -1,8 +1,8 @@
1
1
  import { BONUS_CHARACTER } from '@scrabble-solver/constants';
2
2
 
3
3
  import { Bonus } from './Bonus';
4
- import { BonusValue } from './BonusValue';
5
- import { Cell } from './Cell';
4
+ import { type BonusValue } from './BonusValue';
5
+ import { type Cell } from './Cell';
6
6
  import { type Config } from './Config';
7
7
 
8
8
  export class CharacterBonus extends Bonus {
package/src/Collision.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { Cell } from './Cell';
1
+ import { type Cell } from './Cell';
2
2
 
3
3
  export type Collision = Cell[];
@@ -1,3 +1,3 @@
1
- import { CellJson } from './CellJson';
1
+ import { type CellJson } from './CellJson';
2
2
 
3
3
  export type CollisionJson = CellJson[];
package/src/Config.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import { BLANK, BONUS_CHARACTER, BONUS_WORD, NO_BONUS } from '@scrabble-solver/constants';
2
2
 
3
- import { Bonus } from './Bonus';
4
- import { BonusValue } from './BonusValue';
5
- import { Cell } from './Cell';
3
+ import { type Bingo } from './Bingo';
4
+ import { type Bonus } from './Bonus';
5
+ import { type BonusValue } from './BonusValue';
6
+ import { type Cell } from './Cell';
6
7
  import { CharacterBonus } from './CharacterBonus';
7
- import { ConfigJson } from './ConfigJson';
8
- import { Game } from './Game';
9
- import { Locale } from './Locale';
10
- import { Tile } from './Tile';
11
- import { TileConfig } from './TileConfig';
8
+ import { type ConfigJson } from './ConfigJson';
9
+ import { type Game } from './Game';
10
+ import { type Locale } from './Locale';
11
+ import { type Tile } from './Tile';
12
+ import { type TileConfig } from './TileConfig';
12
13
  import { WordBonus } from './WordBonus';
13
14
 
14
15
  export class Config {
@@ -32,8 +33,8 @@ export class Config {
32
33
  return getAlphabet(this.config);
33
34
  }
34
35
 
35
- public get bingoScore(): number {
36
- return this.config.bingoScore;
36
+ public get bingo(): Bingo {
37
+ return this.config.bingo;
37
38
  }
38
39
 
39
40
  public get blankScore(): number {
@@ -112,6 +113,10 @@ export class Config {
112
113
  return this.config.rackSize;
113
114
  }
114
115
 
116
+ public get supportsRemainingTiles(): boolean {
117
+ return this.tiles.every((tile) => typeof tile.count === 'number');
118
+ }
119
+
115
120
  public get tiles(): TileConfig[] {
116
121
  return this.config.tiles;
117
122
  }
package/src/ConfigJson.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { BonusJson } from './BonusJson';
2
- import { Game } from './Game';
3
- import { Locale } from './Locale';
4
- import { TileConfig } from './TileConfig';
1
+ import { type Bingo } from './Bingo';
2
+ import { type BonusJson } from './BonusJson';
3
+ import { type Game } from './Game';
4
+ import { type Locale } from './Locale';
5
+ import { type TileConfig } from './TileConfig';
5
6
 
6
7
  export interface ConfigJson {
7
- bingoScore: number;
8
+ bingo: Bingo;
8
9
  blankScore: number;
9
10
  blanksCount: number;
10
11
  boardHeight: number;
package/src/Dictionary.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Locale } from './Locale';
1
+ import { type Locale } from './Locale';
2
2
 
3
3
  export interface Dictionary {
4
4
  description: string;
package/src/Game.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export enum Game {
2
2
  Kelimelik = 'kelimelik',
3
+ LetterLeague = 'letter-league',
3
4
  Literaki = 'literaki',
4
5
  Scrabble = 'scrabble',
5
6
  ScrabbleDuel = 'scrabble-duel',
package/src/Pattern.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Board } from './Board';
2
- import { Cell } from './Cell';
3
- import { Config } from './Config';
4
- import { PatternJson } from './PatternJson';
1
+ import { type Board } from './Board';
2
+ import { type Cell } from './Cell';
3
+ import { type Config } from './Config';
4
+ import { type PatternJson } from './PatternJson';
5
5
 
6
6
  export class Pattern {
7
7
  public readonly board: Board;
@@ -1,4 +1,4 @@
1
- import { CellJson } from './CellJson';
1
+ import { type CellJson } from './CellJson';
2
2
 
3
3
  export interface PatternJson {
4
4
  cells: CellJson[];
package/src/Result.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { CONSONANTS, VOWELS } from '@scrabble-solver/constants';
2
2
 
3
3
  import { Cell } from './Cell';
4
- import { ResultJson } from './ResultJson';
5
- import { Tile } from './Tile';
4
+ import { type ResultJson } from './ResultJson';
5
+ import { type Tile } from './Tile';
6
6
 
7
7
  type Collision = Cell[];
8
8
 
@@ -80,6 +80,14 @@ export class Result {
80
80
  points: this.points,
81
81
  };
82
82
  }
83
+
84
+ public isHorizontal(): boolean {
85
+ return this.cells[0].y === this.cells[1].y;
86
+ }
87
+
88
+ public isVertical(): boolean {
89
+ return this.cells[0].x === this.cells[1].x;
90
+ }
83
91
  }
84
92
 
85
93
  const getBlanks = (tiles: Tile[]): Tile[] => tiles.filter(({ isBlank }) => isBlank);
package/src/ResultJson.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { CellJson } from './CellJson';
2
- import { CollisionJson } from './CollisionJson';
1
+ import { type CellJson } from './CellJson';
2
+ import { type CollisionJson } from './CollisionJson';
3
3
 
4
4
  export interface ResultJson {
5
5
  cells: CellJson[];
package/src/Tile.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EMPTY_CELL } from '@scrabble-solver/constants';
2
2
 
3
- import { TileJson } from './TileJson';
3
+ import { type TileJson } from './TileJson';
4
4
 
5
5
  export class Tile {
6
6
  public static fromJson = (json: TileJson | null): Tile => {
package/src/TileConfig.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export interface TileConfig {
2
2
  character: string;
3
- count: number;
3
+ count?: number;
4
4
  score: number;
5
5
  }
package/src/WordBonus.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { BONUS_WORD } from '@scrabble-solver/constants';
2
2
 
3
3
  import { Bonus } from './Bonus';
4
- import { BonusValue } from './BonusValue';
4
+ import { type BonusValue } from './BonusValue';
5
5
 
6
6
  export class WordBonus extends Bonus {
7
7
  public readonly type = BONUS_WORD;
@@ -1,4 +1,4 @@
1
- import { WordDefinitionJson } from './WordDefinitionJson';
1
+ import { type WordDefinitionJson } from './WordDefinitionJson';
2
2
 
3
3
  export class WordDefinition {
4
4
  public static fromJson = (json: WordDefinitionJson | null): WordDefinition => {
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { Bingo, isBingo, isMultiplierBingo, isScoreBingo } from './Bingo';
1
2
  export { Board } from './Board';
2
3
  export { BoardJson, isBoardJson } from './BoardJson';
3
4
  export { Bonus } from './Bonus';