@scrabble-solver/types 2.15.9 → 2.15.10
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.
- package/build/Board.d.ts +5 -6
- package/build/Board.js +17 -16
- package/build/BoardJson.d.ts +2 -3
- package/build/Bonus.d.ts +5 -6
- package/build/Bonus.js +2 -1
- package/build/BonusJson.d.ts +1 -2
- package/build/BonusValue.d.ts +1 -2
- package/build/Cell.d.ts +4 -5
- package/build/Cell.js +13 -15
- package/build/CellJson.d.ts +2 -3
- package/build/CellJson.js +2 -5
- package/build/CharacterBonus.d.ts +5 -6
- package/build/CharacterBonus.js +4 -6
- package/build/Collision.d.ts +2 -3
- package/build/CollisionJson.d.ts +2 -3
- package/build/Config.d.ts +12 -12
- package/build/Config.js +14 -13
- package/build/ConfigJson.d.ts +7 -7
- package/build/Dictionary.d.ts +2 -3
- package/build/FinalPattern.d.ts +2 -3
- package/build/FinalPattern.js +4 -6
- package/build/Game.d.ts +2 -2
- package/build/Game.js +3 -3
- package/build/HorizontalPattern.d.ts +2 -3
- package/build/HorizontalPattern.js +5 -7
- package/build/Locale.d.ts +1 -2
- package/build/Locale.js +2 -3
- package/build/Pattern.d.ts +5 -6
- package/build/Pattern.js +2 -1
- package/build/PatternJson.d.ts +2 -3
- package/build/Result.d.ts +6 -6
- package/build/Result.js +11 -13
- package/build/ResultJson.d.ts +3 -4
- package/build/ShowCoordinates.d.ts +1 -2
- package/build/Tile.d.ts +3 -4
- package/build/Tile.js +11 -10
- package/build/TileConfig.d.ts +1 -2
- package/build/TileJson.d.ts +1 -2
- package/build/TileJson.js +2 -5
- package/build/VerticalPattern.d.ts +2 -3
- package/build/VerticalPattern.js +5 -7
- package/build/WordBonus.d.ts +3 -4
- package/build/WordBonus.js +4 -6
- package/build/WordDefinition.d.ts +3 -4
- package/build/WordDefinition.js +13 -12
- package/build/WordDefinitionJson.d.ts +1 -2
- package/build/index.d.ts +31 -31
- package/build/index.js +20 -23
- package/build/isError.d.ts +1 -2
- package/build/isError.js +4 -6
- package/build/isObject.d.ts +1 -2
- package/build/isObject.js +2 -1
- package/package.json +3 -3
- package/src/Board.ts +14 -13
- package/src/BoardJson.ts +2 -4
- package/src/Bonus.ts +5 -7
- package/src/BonusJson.ts +1 -3
- package/src/BonusValue.ts +1 -3
- package/src/Cell.ts +5 -7
- package/src/CellJson.ts +3 -5
- package/src/CharacterBonus.ts +5 -7
- package/src/Collision.ts +2 -4
- package/src/CollisionJson.ts +2 -4
- package/src/Config.ts +20 -18
- package/src/ConfigJson.ts +7 -8
- package/src/Dictionary.ts +2 -4
- package/src/FinalPattern.ts +2 -4
- package/src/Game.ts +2 -3
- package/src/HorizontalPattern.ts +2 -4
- package/src/Locale.ts +1 -3
- package/src/Pattern.ts +5 -7
- package/src/PatternJson.ts +2 -4
- package/src/Result.ts +6 -8
- package/src/ResultJson.ts +3 -5
- package/src/ShowCoordinates.ts +1 -3
- package/src/Tile.ts +4 -6
- package/src/TileConfig.ts +1 -3
- package/src/TileJson.ts +2 -4
- package/src/VerticalPattern.ts +2 -4
- package/src/WordBonus.ts +3 -5
- package/src/WordDefinition.ts +4 -6
- package/src/WordDefinitionJson.ts +1 -3
- package/src/index.ts +31 -31
- package/src/isError.ts +2 -4
- package/src/isObject.ts +1 -3
package/build/Board.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import BoardJson from './BoardJson';
|
|
2
|
-
import Cell from './Cell';
|
|
3
|
-
declare class Board {
|
|
4
|
-
static create(
|
|
5
|
-
static fromJson(json: BoardJson)
|
|
1
|
+
import { BoardJson } from './BoardJson';
|
|
2
|
+
import { Cell } from './Cell';
|
|
3
|
+
export declare class Board {
|
|
4
|
+
static create: (width: number, height: number) => Board;
|
|
5
|
+
static fromJson: (json: BoardJson) => Board;
|
|
6
6
|
static fromStringArray(stringArray: string[]): Board;
|
|
7
7
|
readonly columnsCount: number;
|
|
8
8
|
readonly rows: Cell[][];
|
|
@@ -29,4 +29,3 @@ declare class Board {
|
|
|
29
29
|
updateCell(x: number, y: number, updateCell: (cell: Cell) => Cell): void;
|
|
30
30
|
updateRow(y: number, updateRow: (cells: Cell[]) => Cell[]): void;
|
|
31
31
|
}
|
|
32
|
-
export default Board;
|
package/build/Board.js
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Board = void 0;
|
|
6
4
|
const constants_1 = require("@scrabble-solver/constants");
|
|
7
|
-
const Cell_1 =
|
|
8
|
-
const Tile_1 =
|
|
5
|
+
const Cell_1 = require("./Cell");
|
|
6
|
+
const Tile_1 = require("./Tile");
|
|
9
7
|
class Board {
|
|
10
|
-
static create(size) {
|
|
11
|
-
return Board.fromStringArray(Array(size).fill(Array(size).fill(' ').join('')));
|
|
12
|
-
}
|
|
13
|
-
static fromJson(json) {
|
|
14
|
-
return new Board({
|
|
15
|
-
rows: json.map((row) => row.map(Cell_1.default.fromJson)),
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
8
|
static fromStringArray(stringArray) {
|
|
19
9
|
return new Board({
|
|
20
|
-
rows: stringArray.map((row, y) => row.split('').map((character, x) => new Cell_1.
|
|
10
|
+
rows: stringArray.map((row, y) => row.split('').map((character, x) => new Cell_1.Cell({
|
|
21
11
|
isEmpty: !character || character === constants_1.EMPTY_CELL,
|
|
22
|
-
tile: character === constants_1.EMPTY_CELL ? Tile_1.
|
|
12
|
+
tile: character === constants_1.EMPTY_CELL ? Tile_1.Tile.Null : new Tile_1.Tile({ character }),
|
|
23
13
|
x,
|
|
24
14
|
y,
|
|
25
15
|
}))),
|
|
@@ -111,4 +101,15 @@ class Board {
|
|
|
111
101
|
this.rows[y] = updateRow(this.rows[y]);
|
|
112
102
|
}
|
|
113
103
|
}
|
|
114
|
-
exports.
|
|
104
|
+
exports.Board = Board;
|
|
105
|
+
Board.create = (width, height) => {
|
|
106
|
+
const rows = Array(height);
|
|
107
|
+
const emptyRow = Array(width).fill(' ').join('');
|
|
108
|
+
const emptyRows = rows.fill(emptyRow);
|
|
109
|
+
return Board.fromStringArray(emptyRows);
|
|
110
|
+
};
|
|
111
|
+
Board.fromJson = (json) => {
|
|
112
|
+
return new Board({
|
|
113
|
+
rows: json.map((row) => row.map(Cell_1.Cell.fromJson)),
|
|
114
|
+
});
|
|
115
|
+
};
|
package/build/BoardJson.d.ts
CHANGED
package/build/Bonus.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
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';
|
|
5
|
-
import type Config from './Config';
|
|
6
|
-
declare abstract class Bonus {
|
|
2
|
+
import { BonusJson } from './BonusJson';
|
|
3
|
+
import { BonusValue } from './BonusValue';
|
|
4
|
+
import { Cell } from './Cell';
|
|
5
|
+
import { type Config } from './Config';
|
|
6
|
+
export declare abstract class Bonus {
|
|
7
7
|
readonly multiplier: number;
|
|
8
8
|
readonly score: number | undefined;
|
|
9
9
|
abstract readonly type: typeof BONUS_CHARACTER | typeof BONUS_WORD;
|
|
@@ -20,4 +20,3 @@ declare abstract class Bonus {
|
|
|
20
20
|
toJson(): BonusJson;
|
|
21
21
|
get value(): BonusValue;
|
|
22
22
|
}
|
|
23
|
-
export default Bonus;
|
package/build/Bonus.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Bonus = void 0;
|
|
3
4
|
class Bonus {
|
|
4
5
|
constructor({ multiplier, score, x, y }) {
|
|
5
6
|
this.multiplier = multiplier;
|
|
@@ -29,4 +30,4 @@ class Bonus {
|
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
exports.
|
|
33
|
+
exports.Bonus = Bonus;
|
package/build/BonusJson.d.ts
CHANGED
package/build/BonusValue.d.ts
CHANGED
package/build/Cell.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import CellJson from './CellJson';
|
|
2
|
-
import Tile from './Tile';
|
|
3
|
-
declare class Cell {
|
|
4
|
-
static fromJson(json: CellJson)
|
|
1
|
+
import { CellJson } from './CellJson';
|
|
2
|
+
import { Tile } from './Tile';
|
|
3
|
+
export declare class Cell {
|
|
4
|
+
static fromJson: (json: CellJson) => Cell;
|
|
5
5
|
readonly isEmpty: boolean;
|
|
6
6
|
tile: Tile;
|
|
7
7
|
readonly x: number;
|
|
@@ -19,4 +19,3 @@ declare class Cell {
|
|
|
19
19
|
toJson(): CellJson;
|
|
20
20
|
toString(): string;
|
|
21
21
|
}
|
|
22
|
-
export default Cell;
|
package/build/Cell.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
3
|
+
exports.Cell = void 0;
|
|
4
|
+
const Tile_1 = require("./Tile");
|
|
7
5
|
class Cell {
|
|
8
|
-
|
|
9
|
-
return new Cell({
|
|
10
|
-
isEmpty: json.isEmpty,
|
|
11
|
-
tile: Tile_1.default.fromJson(json.tile),
|
|
12
|
-
x: json.x,
|
|
13
|
-
y: json.y,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
constructor({ isEmpty = true, tile = Tile_1.default.Null, x, y }) {
|
|
6
|
+
constructor({ isEmpty = true, tile = Tile_1.Tile.Null, x, y }) {
|
|
17
7
|
this.isEmpty = isEmpty;
|
|
18
8
|
this.tile = tile;
|
|
19
9
|
this.x = x;
|
|
@@ -31,7 +21,7 @@ class Cell {
|
|
|
31
21
|
return this.x === other.x && this.y === other.y && this.isEmpty === other.isEmpty && this.tile.equals(other.tile);
|
|
32
22
|
}
|
|
33
23
|
hasTile() {
|
|
34
|
-
return this.tile !== Tile_1.
|
|
24
|
+
return this.tile !== Tile_1.Tile.Null;
|
|
35
25
|
}
|
|
36
26
|
isCandidate() {
|
|
37
27
|
return this.isEmpty && this.hasTile();
|
|
@@ -48,4 +38,12 @@ class Cell {
|
|
|
48
38
|
return this.tile.toString();
|
|
49
39
|
}
|
|
50
40
|
}
|
|
51
|
-
exports.
|
|
41
|
+
exports.Cell = Cell;
|
|
42
|
+
Cell.fromJson = (json) => {
|
|
43
|
+
return new Cell({
|
|
44
|
+
isEmpty: json.isEmpty,
|
|
45
|
+
tile: Tile_1.Tile.fromJson(json.tile),
|
|
46
|
+
x: json.x,
|
|
47
|
+
y: json.y,
|
|
48
|
+
});
|
|
49
|
+
};
|
package/build/CellJson.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import TileJson from './TileJson';
|
|
2
|
-
interface CellJson {
|
|
1
|
+
import { TileJson } from './TileJson';
|
|
2
|
+
export interface CellJson {
|
|
3
3
|
isEmpty: boolean;
|
|
4
4
|
tile: TileJson | null;
|
|
5
5
|
x: number;
|
|
6
6
|
y: number;
|
|
7
7
|
}
|
|
8
8
|
export declare const isCellJson: (value: unknown) => value is CellJson;
|
|
9
|
-
export default CellJson;
|
package/build/CellJson.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.isCellJson = void 0;
|
|
7
|
-
const isObject_1 =
|
|
4
|
+
const isObject_1 = require("./isObject");
|
|
8
5
|
const TileJson_1 = require("./TileJson");
|
|
9
6
|
const isCellJson = (value) => {
|
|
10
|
-
return ((0, isObject_1.
|
|
7
|
+
return ((0, isObject_1.isObject)(value) &&
|
|
11
8
|
typeof value.isEmpty === 'boolean' &&
|
|
12
9
|
((0, TileJson_1.isTileJson)(value.tile) || value.tile === null) &&
|
|
13
10
|
typeof value.x === 'number' &&
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import Bonus from './Bonus';
|
|
2
|
-
import BonusValue from './BonusValue';
|
|
3
|
-
import Cell from './Cell';
|
|
4
|
-
import type Config from './Config';
|
|
5
|
-
declare class CharacterBonus extends Bonus {
|
|
1
|
+
import { Bonus } from './Bonus';
|
|
2
|
+
import { BonusValue } from './BonusValue';
|
|
3
|
+
import { Cell } from './Cell';
|
|
4
|
+
import { type Config } from './Config';
|
|
5
|
+
export declare class CharacterBonus extends Bonus {
|
|
6
6
|
readonly type = "BONUS_CHARACTER";
|
|
7
7
|
canApply(config: Config, cell: Cell): boolean;
|
|
8
8
|
matchesCellTileScore(config: Config, cell: Cell): boolean;
|
|
9
9
|
get value(): BonusValue;
|
|
10
10
|
}
|
|
11
|
-
export default CharacterBonus;
|
package/build/CharacterBonus.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CharacterBonus = void 0;
|
|
6
4
|
const constants_1 = require("@scrabble-solver/constants");
|
|
7
|
-
const Bonus_1 =
|
|
8
|
-
class CharacterBonus extends Bonus_1.
|
|
5
|
+
const Bonus_1 = require("./Bonus");
|
|
6
|
+
class CharacterBonus extends Bonus_1.Bonus {
|
|
9
7
|
constructor() {
|
|
10
8
|
super(...arguments);
|
|
11
9
|
this.type = constants_1.BONUS_CHARACTER;
|
|
@@ -26,4 +24,4 @@ class CharacterBonus extends Bonus_1.default {
|
|
|
26
24
|
};
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
|
-
exports.
|
|
27
|
+
exports.CharacterBonus = CharacterBonus;
|
package/build/Collision.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import Cell from './Cell';
|
|
2
|
-
type Collision = Cell[];
|
|
3
|
-
export default Collision;
|
|
1
|
+
import { Cell } from './Cell';
|
|
2
|
+
export type Collision = Cell[];
|
package/build/CollisionJson.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import CellJson from './CellJson';
|
|
2
|
-
type CollisionJson = CellJson[];
|
|
3
|
-
export default CollisionJson;
|
|
1
|
+
import { CellJson } from './CellJson';
|
|
2
|
+
export type CollisionJson = CellJson[];
|
package/build/Config.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
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';
|
|
9
|
-
declare class Config {
|
|
10
|
-
static fromJson(json: ConfigJson)
|
|
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';
|
|
9
|
+
export declare class Config {
|
|
10
|
+
static fromJson: (json: ConfigJson) => Config;
|
|
11
11
|
readonly bonuses: Bonus[];
|
|
12
12
|
readonly config: ConfigJson;
|
|
13
13
|
readonly pointsMap: Record<string, number>;
|
|
@@ -16,7 +16,8 @@ declare class Config {
|
|
|
16
16
|
get bingoScore(): number;
|
|
17
17
|
get blankScore(): number;
|
|
18
18
|
get blanksCount(): number;
|
|
19
|
-
get
|
|
19
|
+
get boardHeight(): number;
|
|
20
|
+
get boardWidth(): number;
|
|
20
21
|
get game(): Game;
|
|
21
22
|
get locale(): Locale;
|
|
22
23
|
get twoCharacterTiles(): string[];
|
|
@@ -31,4 +32,3 @@ declare class Config {
|
|
|
31
32
|
get tiles(): TileConfig[];
|
|
32
33
|
toJson(): ConfigJson;
|
|
33
34
|
}
|
|
34
|
-
export default Config;
|
package/build/Config.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Config = void 0;
|
|
6
4
|
const constants_1 = require("@scrabble-solver/constants");
|
|
7
|
-
const CharacterBonus_1 =
|
|
8
|
-
const WordBonus_1 =
|
|
5
|
+
const CharacterBonus_1 = require("./CharacterBonus");
|
|
6
|
+
const WordBonus_1 = require("./WordBonus");
|
|
9
7
|
class Config {
|
|
10
|
-
static fromJson(json) {
|
|
11
|
-
return new Config(json);
|
|
12
|
-
}
|
|
13
8
|
constructor(config) {
|
|
14
9
|
this.bonuses = getBonuses(config);
|
|
15
10
|
this.config = config;
|
|
@@ -27,8 +22,11 @@ class Config {
|
|
|
27
22
|
get blanksCount() {
|
|
28
23
|
return this.config.blanksCount;
|
|
29
24
|
}
|
|
30
|
-
get
|
|
31
|
-
return this.config.
|
|
25
|
+
get boardHeight() {
|
|
26
|
+
return this.config.boardHeight;
|
|
27
|
+
}
|
|
28
|
+
get boardWidth() {
|
|
29
|
+
return this.config.boardWidth;
|
|
32
30
|
}
|
|
33
31
|
get game() {
|
|
34
32
|
return this.config.game;
|
|
@@ -82,13 +80,17 @@ class Config {
|
|
|
82
80
|
return this.config;
|
|
83
81
|
}
|
|
84
82
|
}
|
|
83
|
+
exports.Config = Config;
|
|
84
|
+
Config.fromJson = (json) => {
|
|
85
|
+
return new Config(json);
|
|
86
|
+
};
|
|
85
87
|
const getBonuses = (config) => {
|
|
86
88
|
return config.bonuses.map((bonus) => {
|
|
87
89
|
if (bonus.type === constants_1.BONUS_CHARACTER) {
|
|
88
|
-
return new CharacterBonus_1.
|
|
90
|
+
return new CharacterBonus_1.CharacterBonus(bonus);
|
|
89
91
|
}
|
|
90
92
|
if (bonus.type === constants_1.BONUS_WORD) {
|
|
91
|
-
return new WordBonus_1.
|
|
93
|
+
return new WordBonus_1.WordBonus(bonus);
|
|
92
94
|
}
|
|
93
95
|
throw new Error(`Unsupported Bonus type: "${bonus.type}"`);
|
|
94
96
|
});
|
|
@@ -98,4 +100,3 @@ const getPointsMap = (config) => config.tiles.reduce((pointsMap, { character, sc
|
|
|
98
100
|
...pointsMap,
|
|
99
101
|
[character]: score,
|
|
100
102
|
}), {});
|
|
101
|
-
exports.default = Config;
|
package/build/ConfigJson.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import BonusJson from './BonusJson';
|
|
2
|
-
import Game from './Game';
|
|
3
|
-
import Locale from './Locale';
|
|
4
|
-
import TileConfig from './TileConfig';
|
|
5
|
-
interface ConfigJson {
|
|
1
|
+
import { BonusJson } from './BonusJson';
|
|
2
|
+
import { Game } from './Game';
|
|
3
|
+
import { Locale } from './Locale';
|
|
4
|
+
import { TileConfig } from './TileConfig';
|
|
5
|
+
export interface ConfigJson {
|
|
6
6
|
bingoScore: number;
|
|
7
7
|
blankScore: number;
|
|
8
8
|
blanksCount: number;
|
|
9
|
-
|
|
9
|
+
boardHeight: number;
|
|
10
|
+
boardWidth: number;
|
|
10
11
|
bonuses: BonusJson[];
|
|
11
12
|
game: Game;
|
|
12
13
|
locale: Locale;
|
|
@@ -14,4 +15,3 @@ interface ConfigJson {
|
|
|
14
15
|
rackSize: number;
|
|
15
16
|
tiles: TileConfig[];
|
|
16
17
|
}
|
|
17
|
-
export default ConfigJson;
|
package/build/Dictionary.d.ts
CHANGED
package/build/FinalPattern.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import Pattern from './Pattern';
|
|
2
|
-
declare class FinalPattern extends Pattern {
|
|
1
|
+
import { Pattern } from './Pattern';
|
|
2
|
+
export declare class FinalPattern extends Pattern {
|
|
3
3
|
private readonly collisions;
|
|
4
4
|
constructor(pattern: Pattern);
|
|
5
5
|
getCollisions(): Pattern[];
|
|
6
6
|
}
|
|
7
|
-
export default FinalPattern;
|
package/build/FinalPattern.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
exports.FinalPattern = void 0;
|
|
4
|
+
const Pattern_1 = require("./Pattern");
|
|
5
|
+
class FinalPattern extends Pattern_1.Pattern {
|
|
8
6
|
constructor(pattern) {
|
|
9
7
|
super(pattern.board, pattern.cells);
|
|
10
8
|
this.collisions = pattern.getCollisions();
|
|
@@ -13,4 +11,4 @@ class FinalPattern extends Pattern_1.default {
|
|
|
13
11
|
return this.collisions;
|
|
14
12
|
}
|
|
15
13
|
}
|
|
16
|
-
exports.
|
|
14
|
+
exports.FinalPattern = FinalPattern;
|
package/build/Game.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
declare enum Game {
|
|
1
|
+
export declare enum Game {
|
|
2
2
|
Kelimelik = "kelimelik",
|
|
3
3
|
Literaki = "literaki",
|
|
4
4
|
Scrabble = "scrabble",
|
|
5
|
+
ScrabbleDuel = "scrabble-duel",
|
|
5
6
|
SuperScrabble = "super-scrabble"
|
|
6
7
|
}
|
|
7
8
|
export declare const isGame: (locale: unknown) => locale is Game;
|
|
8
|
-
export default Game;
|
package/build/Game.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isGame = void 0;
|
|
3
|
+
exports.isGame = exports.Game = void 0;
|
|
4
4
|
var Game;
|
|
5
5
|
(function (Game) {
|
|
6
6
|
Game["Kelimelik"] = "kelimelik";
|
|
7
7
|
Game["Literaki"] = "literaki";
|
|
8
8
|
Game["Scrabble"] = "scrabble";
|
|
9
|
+
Game["ScrabbleDuel"] = "scrabble-duel";
|
|
9
10
|
Game["SuperScrabble"] = "super-scrabble";
|
|
10
|
-
})(Game || (Game = {}));
|
|
11
|
+
})(Game || (exports.Game = Game = {}));
|
|
11
12
|
const games = Object.values(Game);
|
|
12
13
|
const isGame = (locale) => games.includes(locale);
|
|
13
14
|
exports.isGame = isGame;
|
|
14
|
-
exports.default = Game;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import Pattern from './Pattern';
|
|
2
|
-
declare class HorizontalPattern extends Pattern {
|
|
1
|
+
import { Pattern } from './Pattern';
|
|
2
|
+
export declare class HorizontalPattern extends Pattern {
|
|
3
3
|
clone(): Pattern;
|
|
4
4
|
getCollisions(): Pattern[];
|
|
5
5
|
}
|
|
6
|
-
export default HorizontalPattern;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
exports.HorizontalPattern = void 0;
|
|
4
|
+
const Pattern_1 = require("./Pattern");
|
|
5
|
+
class HorizontalPattern extends Pattern_1.Pattern {
|
|
8
6
|
clone() {
|
|
9
7
|
return new HorizontalPattern(this.board, this.cells.map((cell) => cell.clone()));
|
|
10
8
|
}
|
|
@@ -26,11 +24,11 @@ class HorizontalPattern extends Pattern_1.default {
|
|
|
26
24
|
const nextCells = column.slice(cell.y + 1, y);
|
|
27
25
|
const cells = [...previousCells, cell, ...nextCells];
|
|
28
26
|
if (cells.length > 1) {
|
|
29
|
-
const pattern = new Pattern_1.
|
|
27
|
+
const pattern = new Pattern_1.Pattern(this.board, cells);
|
|
30
28
|
collisions.push(pattern);
|
|
31
29
|
}
|
|
32
30
|
});
|
|
33
31
|
return collisions;
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
|
-
exports.
|
|
34
|
+
exports.HorizontalPattern = HorizontalPattern;
|
package/build/Locale.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @see https://en.wikipedia.org/wiki/IETF_language_tag
|
|
4
4
|
* @see https://en.wikipedia.org/wiki/ISO_3166-1
|
|
5
5
|
*/
|
|
6
|
-
declare enum Locale {
|
|
6
|
+
export declare enum Locale {
|
|
7
7
|
DE_DE = "de-DE",
|
|
8
8
|
EN_GB = "en-GB",
|
|
9
9
|
EN_US = "en-US",
|
|
@@ -15,4 +15,3 @@ declare enum Locale {
|
|
|
15
15
|
TR_TR = "tr-TR"
|
|
16
16
|
}
|
|
17
17
|
export declare const isLocale: (locale: unknown) => locale is Locale;
|
|
18
|
-
export default Locale;
|
package/build/Locale.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isLocale = void 0;
|
|
3
|
+
exports.isLocale = exports.Locale = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Locales are defined using IETF language tags
|
|
6
6
|
* @see https://en.wikipedia.org/wiki/IETF_language_tag
|
|
@@ -17,8 +17,7 @@ var Locale;
|
|
|
17
17
|
Locale["PL_PL"] = "pl-PL";
|
|
18
18
|
Locale["RO_RO"] = "ro-RO";
|
|
19
19
|
Locale["TR_TR"] = "tr-TR";
|
|
20
|
-
})(Locale || (Locale = {}));
|
|
20
|
+
})(Locale || (exports.Locale = Locale = {}));
|
|
21
21
|
const locales = Object.values(Locale);
|
|
22
22
|
const isLocale = (locale) => locales.includes(locale);
|
|
23
23
|
exports.isLocale = isLocale;
|
|
24
|
-
exports.default = Locale;
|
package/build/Pattern.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import Board from './Board';
|
|
2
|
-
import Cell from './Cell';
|
|
3
|
-
import Config from './Config';
|
|
4
|
-
import PatternJson from './PatternJson';
|
|
5
|
-
declare class Pattern {
|
|
1
|
+
import { Board } from './Board';
|
|
2
|
+
import { Cell } from './Cell';
|
|
3
|
+
import { Config } from './Config';
|
|
4
|
+
import { PatternJson } from './PatternJson';
|
|
5
|
+
export declare class Pattern {
|
|
6
6
|
readonly board: Board;
|
|
7
7
|
readonly cells: Cell[];
|
|
8
8
|
constructor(board: Board, cells: Cell[]);
|
|
@@ -18,4 +18,3 @@ declare class Pattern {
|
|
|
18
18
|
toJson(): PatternJson;
|
|
19
19
|
toString(): string;
|
|
20
20
|
}
|
|
21
|
-
export default Pattern;
|
package/build/Pattern.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pattern = void 0;
|
|
3
4
|
class Pattern {
|
|
4
5
|
constructor(board, cells) {
|
|
5
6
|
this.board = board;
|
|
@@ -46,4 +47,4 @@ class Pattern {
|
|
|
46
47
|
return this.cells.reduce((result, cell) => result + cell.toString(), '');
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
exports.
|
|
50
|
+
exports.Pattern = Pattern;
|
package/build/PatternJson.d.ts
CHANGED
package/build/Result.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Cell from './Cell';
|
|
2
|
-
import ResultJson from './ResultJson';
|
|
3
|
-
import Tile from './Tile';
|
|
1
|
+
import { Cell } from './Cell';
|
|
2
|
+
import { ResultJson } from './ResultJson';
|
|
3
|
+
import { Tile } from './Tile';
|
|
4
4
|
type Collision = Cell[];
|
|
5
|
-
declare class Result {
|
|
6
|
-
static fromJson(json: ResultJson)
|
|
5
|
+
export declare class Result {
|
|
6
|
+
static fromJson: (json: ResultJson) => Result;
|
|
7
7
|
readonly blanksCount: number;
|
|
8
8
|
readonly cells: Cell[];
|
|
9
9
|
readonly collisions: Collision[];
|
|
@@ -26,4 +26,4 @@ declare class Result {
|
|
|
26
26
|
});
|
|
27
27
|
toJson(): ResultJson;
|
|
28
28
|
}
|
|
29
|
-
export
|
|
29
|
+
export {};
|
package/build/Result.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Result = void 0;
|
|
6
4
|
const constants_1 = require("@scrabble-solver/constants");
|
|
7
|
-
const Cell_1 =
|
|
5
|
+
const Cell_1 = require("./Cell");
|
|
8
6
|
class Result {
|
|
9
|
-
static fromJson(json) {
|
|
10
|
-
return new Result({
|
|
11
|
-
id: json.id,
|
|
12
|
-
cells: json.cells.map(Cell_1.default.fromJson),
|
|
13
|
-
collisions: json.collisions.map((collision) => collision.map(Cell_1.default.fromJson)),
|
|
14
|
-
points: json.points,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
7
|
constructor({ cells, id, collisions, points, }) {
|
|
18
8
|
const tiles = getTiles(cells);
|
|
19
9
|
this.blanksCount = getBlanks(tiles).length;
|
|
@@ -40,6 +30,15 @@ class Result {
|
|
|
40
30
|
};
|
|
41
31
|
}
|
|
42
32
|
}
|
|
33
|
+
exports.Result = Result;
|
|
34
|
+
Result.fromJson = (json) => {
|
|
35
|
+
return new Result({
|
|
36
|
+
id: json.id,
|
|
37
|
+
cells: json.cells.map(Cell_1.Cell.fromJson),
|
|
38
|
+
collisions: json.collisions.map((collision) => collision.map(Cell_1.Cell.fromJson)),
|
|
39
|
+
points: json.points,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
43
42
|
const getBlanks = (tiles) => tiles.filter(({ isBlank }) => isBlank);
|
|
44
43
|
const getConsonants = (tiles) => tiles.filter(isConsonant);
|
|
45
44
|
const getVowels = (tiles) => tiles.filter(isVowel);
|
|
@@ -49,4 +48,3 @@ const getWord = (cells) => cells.reduce((word, cell) => word + cell.toString(),
|
|
|
49
48
|
const getWords = (cells, collisions) => [cells, ...collisions].map(getWord);
|
|
50
49
|
const isConsonant = ({ character, isBlank }) => constants_1.CONSONANTS.includes(character) && !isBlank;
|
|
51
50
|
const isVowel = ({ character, isBlank }) => constants_1.VOWELS.includes(character) && !isBlank;
|
|
52
|
-
exports.default = Result;
|