@scrabble-solver/scrabble-solver 2.9.1 → 2.9.2

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 (49) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +7 -7
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/eslint/.cache_8dgz12 +1 -1
  5. package/.next/cache/next-server.js.nft.json +1 -1
  6. package/.next/cache/webpack/client-production/0.pack +0 -0
  7. package/.next/cache/webpack/client-production/index.pack +0 -0
  8. package/.next/cache/webpack/edge-server-production/0.pack +0 -0
  9. package/.next/cache/webpack/edge-server-production/index.pack +0 -0
  10. package/.next/cache/webpack/server-production/0.pack +0 -0
  11. package/.next/cache/webpack/server-production/index.pack +0 -0
  12. package/.next/next-server.js.nft.json +1 -1
  13. package/.next/prerender-manifest.json +1 -1
  14. package/.next/required-server-files.json +1 -1
  15. package/.next/routes-manifest.json +1 -1
  16. package/.next/server/chunks/413.js +6 -2
  17. package/.next/server/chunks/44.js +894 -3
  18. package/.next/server/chunks/515.js +10 -3
  19. package/.next/server/middleware-build-manifest.js +1 -1
  20. package/.next/server/pages/404.html +2 -2
  21. package/.next/server/pages/404.js.nft.json +1 -1
  22. package/.next/server/pages/500.html +2 -2
  23. package/.next/server/pages/_app.js.nft.json +1 -1
  24. package/.next/server/pages/api/dictionary/[locale]/[word].js +121 -65
  25. package/.next/server/pages/api/dictionary/[locale]/[word].js.nft.json +1 -1
  26. package/.next/server/pages/api/dictionary/[locale].js +1 -1
  27. package/.next/server/pages/api/dictionary/[locale].js.nft.json +1 -1
  28. package/.next/server/pages/api/solve.js +1 -1
  29. package/.next/server/pages/api/solve.js.nft.json +1 -1
  30. package/.next/server/pages/api/verify.js +1 -1
  31. package/.next/server/pages/api/verify.js.nft.json +1 -1
  32. package/.next/server/pages/index.html +2 -2
  33. package/.next/server/pages/index.js.nft.json +1 -1
  34. package/.next/server/pages/index.json +1 -1
  35. package/.next/static/{Oki2Ia4sgLw021iM7byAe → Ntg-ilwD7GqTIFwRpSaTQ}/_buildManifest.js +1 -1
  36. package/.next/static/{Oki2Ia4sgLw021iM7byAe → Ntg-ilwD7GqTIFwRpSaTQ}/_ssgManifest.js +0 -0
  37. package/.next/static/chunks/{317-e7d5d859f1f95938.js → 317-5e5334962dd7c681.js} +1 -1
  38. package/.next/static/chunks/pages/{_app-10893b318367f97c.js → _app-183f598b1d4d480b.js} +1 -1
  39. package/.next/static/css/e8de67ad5ea35427.css +1 -0
  40. package/.next/trace +52 -52
  41. package/LICENSE +1 -1
  42. package/package.json +11 -11
  43. package/src/components/Dictionary/Dictionary.module.scss +1 -0
  44. package/src/components/Dictionary/Dictionary.tsx +7 -2
  45. package/src/i18n/en.json +2 -2
  46. package/src/pages/api/dictionary/[locale]/[word].ts +3 -1
  47. package/.next/server/chunks/452.js +0 -894
  48. package/.next/static/css/e3d218f4ea72c5fb.css +0 -1
  49. package/public/robots.txt +0 -4
@@ -1,894 +0,0 @@
1
- "use strict";
2
- exports.id = 452;
3
- exports.ids = [452];
4
- exports.modules = {
5
-
6
- /***/ 83017:
7
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
8
-
9
-
10
- var __importDefault = (this && this.__importDefault) || function (mod) {
11
- return (mod && mod.__esModule) ? mod : { "default": mod };
12
- };
13
- Object.defineProperty(exports, "__esModule", ({ value: true }));
14
- const constants_1 = __webpack_require__(38436);
15
- const Cell_1 = __importDefault(__webpack_require__(70902));
16
- const Tile_1 = __importDefault(__webpack_require__(580));
17
- class Board {
18
- constructor({ rows }) {
19
- this.rows = rows;
20
- this.columnsCount = rows[0].length;
21
- this.rowsCount = rows.length;
22
- }
23
- static create(width, height) {
24
- return Board.fromStringArray(Array(height).fill(Array(width).fill(' ').join('')));
25
- }
26
- static fromJson(json) {
27
- return new Board({
28
- rows: json.map((row) => row.map(Cell_1.default.fromJson)),
29
- });
30
- }
31
- static fromStringArray(stringArray) {
32
- return new Board({
33
- rows: stringArray.map((row, y) => row.split('').map((character, x) => new Cell_1.default({
34
- isEmpty: !character || character === constants_1.EMPTY_CELL,
35
- tile: character === constants_1.EMPTY_CELL ? Tile_1.default.Null : new Tile_1.default({ character }),
36
- x,
37
- y,
38
- }))),
39
- });
40
- }
41
- get center() {
42
- const x = Math.floor(this.columnsCount / 2);
43
- const y = Math.floor(this.rowsCount / 2);
44
- return this.rows[y][x];
45
- }
46
- clone() {
47
- const rows = this.rows.map((row) => row.map((cell) => cell.clone()));
48
- return new Board({ rows });
49
- }
50
- collides(cell) {
51
- return this.collidesUp(cell) || this.collidesDown(cell) || this.collidesLeft(cell) || this.collidesRight(cell);
52
- }
53
- collidesDown({ x, y }) {
54
- return y < this.rowsCount - 1 && !this.rows[y + 1][x].isEmpty;
55
- }
56
- collidesLeft({ x, y }) {
57
- return x > 0 && !this.rows[y][x - 1].isEmpty;
58
- }
59
- collidesRight({ x, y }) {
60
- return x < this.columnsCount - 1 && !this.rows[y][x + 1].isEmpty;
61
- }
62
- collidesUp({ x, y }) {
63
- return y > 0 && !this.rows[y - 1][x].isEmpty;
64
- }
65
- equals(other) {
66
- return (this.columnsCount === other.columnsCount &&
67
- this.rowsCount === other.rowsCount &&
68
- this.rows.every((row, rowIndex) => {
69
- return row.every((cell, cellIndex) => {
70
- return cell.equals(other.rows[rowIndex][cellIndex]);
71
- });
72
- }));
73
- }
74
- getBlanksCount() {
75
- return this.rows.reduce((count, row) => {
76
- return count + row.reduce((rowCount, cell) => rowCount + (cell.tile.isBlank ? 1 : 0), 0);
77
- }, 0);
78
- }
79
- getColumn(index) {
80
- return this.rows.map((row) => row[index]);
81
- }
82
- getRow(index) {
83
- return this.rows[index];
84
- }
85
- getTilesCount() {
86
- return this.rows.reduce((count, row) => {
87
- return count + row.reduce((rowCount, cell) => rowCount + (cell.hasTile() ? 1 : 0), 0);
88
- }, 0);
89
- }
90
- getWords() {
91
- const columns = [];
92
- for (let x = 0; x < this.columnsCount; ++x) {
93
- const column = [];
94
- for (let y = 0; y < this.rowsCount; ++y) {
95
- column.push(this.rows[y][x]);
96
- }
97
- columns.push(column);
98
- }
99
- const columnsBoard = new Board({ rows: columns });
100
- const lines = this.toString().split('\n').concat(columnsBoard.toString().split('\n'));
101
- const words = lines
102
- .flatMap((line) => line.replaceAll(/\s+/g, constants_1.EMPTY_CELL).split(' '))
103
- .filter((word) => word.length > 1);
104
- return words;
105
- }
106
- isEmpty() {
107
- return this.rows.every((row) => row.every(({ isEmpty }) => isEmpty));
108
- }
109
- toJson() {
110
- return this.rows.map((row) => row.map((cell) => cell.toJson()));
111
- }
112
- toString() {
113
- return this.rows.map((row) => row.map(String).join('')).join('\n');
114
- }
115
- updateCell(x, y, updateCell) {
116
- this.rows[y][x] = updateCell(this.rows[y][x]);
117
- }
118
- updateRow(y, updateRow) {
119
- this.rows[y] = updateRow(this.rows[y]);
120
- }
121
- }
122
- exports["default"] = Board;
123
-
124
-
125
- /***/ }),
126
-
127
- /***/ 28508:
128
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
129
-
130
-
131
- Object.defineProperty(exports, "__esModule", ({ value: true }));
132
- exports.isBoardJson = void 0;
133
- const CellJson_1 = __webpack_require__(56508);
134
- const isBoardJson = (value) => {
135
- if (!Array.isArray(value)) {
136
- return false;
137
- }
138
- for (const row of value) {
139
- if (!Array.isArray(value)) {
140
- return false;
141
- }
142
- for (const cell of row) {
143
- if (!(0, CellJson_1.isCellJson)(cell)) {
144
- return false;
145
- }
146
- }
147
- }
148
- return true;
149
- };
150
- exports.isBoardJson = isBoardJson;
151
-
152
-
153
- /***/ }),
154
-
155
- /***/ 80769:
156
- /***/ ((__unused_webpack_module, exports) => {
157
-
158
-
159
- Object.defineProperty(exports, "__esModule", ({ value: true }));
160
- class Bonus {
161
- constructor({ multiplier, score, x, y }) {
162
- this.multiplier = multiplier;
163
- this.score = score;
164
- this.x = x;
165
- this.y = y;
166
- }
167
- canApply(_config, cell) {
168
- return cell.isEmpty && this.matchesCellCoordinates(cell);
169
- }
170
- matchesCellCoordinates(cell) {
171
- return this.x === cell.x && this.y === cell.y;
172
- }
173
- toJson() {
174
- return {
175
- multiplier: this.multiplier,
176
- score: this.score,
177
- type: this.type,
178
- x: this.x,
179
- y: this.y,
180
- };
181
- }
182
- get value() {
183
- return {
184
- characterMultiplier: 1,
185
- wordMultiplier: 1,
186
- };
187
- }
188
- }
189
- exports["default"] = Bonus;
190
-
191
-
192
- /***/ }),
193
-
194
- /***/ 70902:
195
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
196
-
197
-
198
- var __importDefault = (this && this.__importDefault) || function (mod) {
199
- return (mod && mod.__esModule) ? mod : { "default": mod };
200
- };
201
- Object.defineProperty(exports, "__esModule", ({ value: true }));
202
- const Tile_1 = __importDefault(__webpack_require__(580));
203
- class Cell {
204
- // eslint-disable-next-line no-undef
205
- constructor({ isEmpty = true, tile = Tile_1.default.Null, x, y }) {
206
- this.isEmpty = isEmpty;
207
- this.tile = tile;
208
- this.x = x;
209
- this.y = y;
210
- }
211
- static fromJson(json) {
212
- return new Cell({
213
- isEmpty: json.isEmpty,
214
- tile: Tile_1.default.fromJson(json.tile),
215
- x: json.x,
216
- y: json.y,
217
- });
218
- }
219
- clone() {
220
- return new Cell({
221
- isEmpty: this.isEmpty,
222
- tile: this.tile.clone(),
223
- x: this.x,
224
- y: this.y,
225
- });
226
- }
227
- equals(other) {
228
- return this.x === other.x && this.y === other.y && this.isEmpty === other.isEmpty && this.tile.equals(other.tile);
229
- }
230
- hasTile() {
231
- return this.tile !== Tile_1.default.Null;
232
- }
233
- isCandidate() {
234
- return this.isEmpty && this.hasTile();
235
- }
236
- toJson() {
237
- return {
238
- isEmpty: this.isEmpty,
239
- tile: this.tile.toJson(),
240
- x: this.x,
241
- y: this.y,
242
- };
243
- }
244
- toString() {
245
- return this.tile.toString();
246
- }
247
- }
248
- exports["default"] = Cell;
249
-
250
-
251
- /***/ }),
252
-
253
- /***/ 56508:
254
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
255
-
256
-
257
- var __importDefault = (this && this.__importDefault) || function (mod) {
258
- return (mod && mod.__esModule) ? mod : { "default": mod };
259
- };
260
- Object.defineProperty(exports, "__esModule", ({ value: true }));
261
- exports.isCellJson = void 0;
262
- const isObject_1 = __importDefault(__webpack_require__(93518));
263
- const TileJson_1 = __webpack_require__(92298);
264
- const isCellJson = (value) => {
265
- return ((0, isObject_1.default)(value) &&
266
- typeof value.isEmpty === 'boolean' &&
267
- ((0, TileJson_1.isTileJson)(value.tile) || value.tile === null) &&
268
- typeof value.x === 'number' &&
269
- typeof value.y === 'number');
270
- };
271
- exports.isCellJson = isCellJson;
272
-
273
-
274
- /***/ }),
275
-
276
- /***/ 95699:
277
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
278
-
279
-
280
- var __importDefault = (this && this.__importDefault) || function (mod) {
281
- return (mod && mod.__esModule) ? mod : { "default": mod };
282
- };
283
- Object.defineProperty(exports, "__esModule", ({ value: true }));
284
- const constants_1 = __webpack_require__(38436);
285
- const Bonus_1 = __importDefault(__webpack_require__(80769));
286
- class CharacterBonus extends Bonus_1.default {
287
- constructor() {
288
- super(...arguments);
289
- this.type = constants_1.BONUS_CHARACTER;
290
- }
291
- canApply(config, cell) {
292
- return super.canApply(config, cell) && this.matchesCellTileScore(config, cell);
293
- }
294
- matchesCellTileScore(config, cell) {
295
- if (typeof this.score === 'undefined') {
296
- return true;
297
- }
298
- return this.score === config.pointsMap[cell.tile.character];
299
- }
300
- get value() {
301
- return {
302
- characterMultiplier: this.multiplier,
303
- wordMultiplier: 1,
304
- };
305
- }
306
- }
307
- exports["default"] = CharacterBonus;
308
-
309
-
310
- /***/ }),
311
-
312
- /***/ 68725:
313
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
314
-
315
-
316
- var __importDefault = (this && this.__importDefault) || function (mod) {
317
- return (mod && mod.__esModule) ? mod : { "default": mod };
318
- };
319
- Object.defineProperty(exports, "__esModule", ({ value: true }));
320
- const constants_1 = __webpack_require__(38436);
321
- const CharacterBonus_1 = __importDefault(__webpack_require__(95699));
322
- const WordBonus_1 = __importDefault(__webpack_require__(39667));
323
- class Config {
324
- constructor(config) {
325
- this.bonuses = getBonuses(config);
326
- this.config = config;
327
- this.pointsMap = getPointsMap(this.config);
328
- }
329
- static fromJson(json) {
330
- return new Config(json);
331
- }
332
- get allTilesBonusScore() {
333
- return this.config.allTilesBonusScore;
334
- }
335
- get alphabet() {
336
- return getAlphabet(this.config);
337
- }
338
- get blankScore() {
339
- return this.config.blankScore;
340
- }
341
- get blanksCount() {
342
- return this.config.blanksCount;
343
- }
344
- get boardHeight() {
345
- return this.config.boardHeight;
346
- }
347
- get boardWidth() {
348
- return this.config.boardWidth;
349
- }
350
- get twoCharacterTiles() {
351
- return this.config.tiles.filter((tile) => tile.character.length === 2).map((tile) => tile.character);
352
- }
353
- getCellBonus(cell) {
354
- return this.bonuses.find((bonus) => bonus.matchesCellCoordinates(cell));
355
- }
356
- getCellBonusValue(cell) {
357
- return this.getCellBonus(cell)?.value || constants_1.NO_BONUS;
358
- }
359
- getCharacterPoints(character) {
360
- if (character === null) {
361
- return undefined;
362
- }
363
- if (character === constants_1.BLANK) {
364
- return this.blankScore;
365
- }
366
- return this.pointsMap[character];
367
- }
368
- getTwoCharacterTileByPrefix(character) {
369
- if (character.length !== 1) {
370
- return undefined;
371
- }
372
- return this.twoCharacterTiles.find((characters) => characters.startsWith(character));
373
- }
374
- getTilePoints(tile) {
375
- if (tile === null) {
376
- return undefined;
377
- }
378
- return tile.isBlank ? this.blankScore : this.getCharacterPoints(tile.character);
379
- }
380
- hasCharacter(character) {
381
- return character in this.pointsMap;
382
- }
383
- isTwoCharacterTilePrefix(character) {
384
- return typeof this.getTwoCharacterTileByPrefix(character) !== 'undefined';
385
- }
386
- get maximumCharactersCount() {
387
- return this.config.maximumCharactersCount;
388
- }
389
- get tiles() {
390
- return this.config.tiles;
391
- }
392
- toJson() {
393
- return this.config;
394
- }
395
- }
396
- const getBonuses = (config) => {
397
- return config.bonuses.map((bonus) => {
398
- if (bonus.type === constants_1.BONUS_CHARACTER) {
399
- return new CharacterBonus_1.default(bonus);
400
- }
401
- if (bonus.type === constants_1.BONUS_WORD) {
402
- return new WordBonus_1.default(bonus);
403
- }
404
- throw new Error(`Unsupported Bonus type: "${bonus.type}"`);
405
- });
406
- };
407
- const getAlphabet = (config) => config.tiles.map(({ character }) => character);
408
- const getPointsMap = (config) => config.tiles.reduce((pointsMap, { character, score }) => ({
409
- ...pointsMap,
410
- [character]: score,
411
- }), {});
412
- exports["default"] = Config;
413
-
414
-
415
- /***/ }),
416
-
417
- /***/ 79238:
418
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
419
-
420
-
421
- var __importDefault = (this && this.__importDefault) || function (mod) {
422
- return (mod && mod.__esModule) ? mod : { "default": mod };
423
- };
424
- Object.defineProperty(exports, "__esModule", ({ value: true }));
425
- const Pattern_1 = __importDefault(__webpack_require__(43600));
426
- class FinalPattern extends Pattern_1.default {
427
- constructor(pattern) {
428
- super(pattern.board, pattern.cells);
429
- this.collisions = pattern.getCollisions();
430
- }
431
- getCollisions() {
432
- return this.collisions;
433
- }
434
- }
435
- exports["default"] = FinalPattern;
436
-
437
-
438
- /***/ }),
439
-
440
- /***/ 44405:
441
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
442
-
443
-
444
- var __importDefault = (this && this.__importDefault) || function (mod) {
445
- return (mod && mod.__esModule) ? mod : { "default": mod };
446
- };
447
- Object.defineProperty(exports, "__esModule", ({ value: true }));
448
- const Pattern_1 = __importDefault(__webpack_require__(43600));
449
- class HorizontalPattern extends Pattern_1.default {
450
- clone() {
451
- return new HorizontalPattern(this.board, this.cells.map((cell) => cell.clone()));
452
- }
453
- getCollisions() {
454
- const collisions = [];
455
- this.cells
456
- .filter((cell) => cell.isEmpty && (this.board.collidesUp(cell) || this.board.collidesDown(cell)))
457
- .forEach((cell) => {
458
- const column = this.board.getColumn(cell.x);
459
- let y = cell.y - 1;
460
- while (y >= 0 && column[y].hasTile()) {
461
- --y;
462
- }
463
- const previousCells = column.slice(y + 1, cell.y);
464
- y = cell.y + 1;
465
- while (y < column.length && column[y].hasTile()) {
466
- ++y;
467
- }
468
- const nextCells = column.slice(cell.y + 1, y);
469
- const cells = [...previousCells, cell, ...nextCells];
470
- if (cells.length > 1) {
471
- const pattern = new Pattern_1.default(this.board, cells);
472
- collisions.push(pattern);
473
- }
474
- });
475
- return collisions;
476
- }
477
- }
478
- exports["default"] = HorizontalPattern;
479
-
480
-
481
- /***/ }),
482
-
483
- /***/ 28044:
484
- /***/ ((__unused_webpack_module, exports) => {
485
-
486
-
487
- Object.defineProperty(exports, "__esModule", ({ value: true }));
488
- exports.isLocale = void 0;
489
- // eslint-disable-next-line no-shadow
490
- var Locale;
491
- (function (Locale) {
492
- Locale["DE_DE"] = "de-DE";
493
- Locale["EN_GB"] = "en-GB";
494
- Locale["EN_US"] = "en-US";
495
- Locale["ES_ES"] = "es-ES";
496
- Locale["FR_FR"] = "fr-FR";
497
- Locale["PL_PL"] = "pl-PL";
498
- })(Locale || (Locale = {}));
499
- const locales = Object.values(Locale);
500
- const isLocale = (locale) => locales.includes(locale);
501
- exports.isLocale = isLocale;
502
- exports["default"] = Locale;
503
-
504
-
505
- /***/ }),
506
-
507
- /***/ 43600:
508
- /***/ ((__unused_webpack_module, exports) => {
509
-
510
-
511
- Object.defineProperty(exports, "__esModule", ({ value: true }));
512
- class Pattern {
513
- constructor(board, cells) {
514
- this.board = board;
515
- this.cells = cells;
516
- }
517
- canBePlaced(config) {
518
- const emptyCellsCount = this.getEmptyCellsCount();
519
- const isUsedCellsCountInRange = emptyCellsCount >= 1 && emptyCellsCount <= config.maximumCharactersCount;
520
- return (isUsedCellsCountInRange &&
521
- (this.hasAtLeast1NonEmptyCell() || this.collides() || (this.goesThroughBoardCenter() && this.board.isEmpty())));
522
- }
523
- clone() {
524
- return new Pattern(this.board, this.cells.map((cell) => cell.clone()));
525
- }
526
- collides() {
527
- return this.cells.some((cell) => cell.isEmpty && this.board.collides(cell));
528
- }
529
- getIndexOfFirstCellWithoutTile() {
530
- return this.cells.findIndex((cell) => !cell.hasTile());
531
- }
532
- getEmptyCellsCount() {
533
- return this.cells.filter((cell) => cell.isEmpty).length;
534
- }
535
- goesThroughBoardCenter() {
536
- return this.cells.some((cell) => cell.x === this.board.center.x && cell.y === this.board.center.y && cell.isEmpty);
537
- }
538
- hasAtLeast1EmptyCell() {
539
- return this.cells.some((cell) => cell.isEmpty);
540
- }
541
- hasAtLeast1NonEmptyCell() {
542
- return this.cells.some((cell) => !cell.isEmpty);
543
- }
544
- getCollisions() {
545
- return [];
546
- }
547
- toJson() {
548
- return {
549
- cells: this.cells.map((cell) => cell.toJson()),
550
- collisions: this.getCollisions().map((collision) => collision.toJson()),
551
- word: this.toString(),
552
- };
553
- }
554
- toString() {
555
- return this.cells.reduce((result, cell) => result + cell.toString(), '');
556
- }
557
- }
558
- exports["default"] = Pattern;
559
-
560
-
561
- /***/ }),
562
-
563
- /***/ 28211:
564
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
565
-
566
-
567
- var __importDefault = (this && this.__importDefault) || function (mod) {
568
- return (mod && mod.__esModule) ? mod : { "default": mod };
569
- };
570
- Object.defineProperty(exports, "__esModule", ({ value: true }));
571
- const constants_1 = __webpack_require__(38436);
572
- const Cell_1 = __importDefault(__webpack_require__(70902));
573
- class Result {
574
- constructor({ cells, id, collisions, points, }) {
575
- const tiles = getTiles(cells);
576
- this.blanksCount = getBlanks(tiles).length;
577
- this.cells = cells;
578
- this.collisions = collisions;
579
- this.consonantsCount = getConsonants(tiles).length;
580
- this.id = id;
581
- this.length = cells.length;
582
- this.points = points;
583
- this.pointsRatio = getPointsRatio(tiles, points);
584
- this.tiles = tiles;
585
- this.tilesCharacters = getTilesCharacters(tiles);
586
- this.tilesCount = tiles.length;
587
- this.vowelsCount = getVowels(tiles).length;
588
- this.word = getWord(cells);
589
- this.words = getWords(cells, collisions);
590
- this.wordsCount = 1 + this.collisions.length;
591
- }
592
- static fromJson(json) {
593
- return new Result({
594
- id: json.id,
595
- cells: json.cells.map(Cell_1.default.fromJson),
596
- collisions: json.collisions.map((collision) => collision.map(Cell_1.default.fromJson)),
597
- points: json.points,
598
- });
599
- }
600
- toJson() {
601
- return {
602
- cells: this.cells.map((cell) => cell.toJson()),
603
- id: this.id,
604
- collisions: this.collisions.map((collision) => collision.map((cell) => cell.toJson())),
605
- points: this.points,
606
- };
607
- }
608
- }
609
- const charactersComparator = (a, b) => a.localeCompare(b);
610
- const getBlanks = (tiles) => tiles.filter(({ isBlank }) => isBlank);
611
- const getConsonants = (tiles) => tiles.filter(isConsonant);
612
- const getVowels = (tiles) => tiles.filter(isVowel);
613
- const getNonBlankCharacters = (tiles) => getNonBlanks(tiles).map(({ character }) => character);
614
- const getNonBlanks = (tiles) => tiles.filter(({ isBlank }) => !isBlank);
615
- const getPointsRatio = (tiles, points) => points / tiles.length;
616
- const getTiles = (cells) => cells.filter(({ isEmpty }) => isEmpty).map(({ tile }) => tile);
617
- const getTilesCharacters = (tiles) => getNonBlankCharacters(tiles).sort(charactersComparator).join('');
618
- // eslint-disable-next-line prefer-template
619
- const getWord = (cells) => cells.reduce((word, cell) => word + cell.toString(), '');
620
- const getWords = (cells, collisions) => [cells, ...collisions].map(getWord);
621
- const isConsonant = ({ character, isBlank }) => constants_1.CONSONANTS.includes(character) && !isBlank;
622
- const isVowel = ({ character, isBlank }) => constants_1.VOWELS.includes(character) && !isBlank;
623
- exports["default"] = Result;
624
-
625
-
626
- /***/ }),
627
-
628
- /***/ 580:
629
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
630
-
631
-
632
- Object.defineProperty(exports, "__esModule", ({ value: true }));
633
- const constants_1 = __webpack_require__(38436);
634
- class Tile {
635
- constructor({ character, isBlank = false }) {
636
- this.character = character;
637
- this.isBlank = isBlank;
638
- }
639
- static fromJson(json) {
640
- if (!json) {
641
- return Tile.Null;
642
- }
643
- return new Tile({
644
- character: json.character,
645
- isBlank: json.isBlank,
646
- });
647
- }
648
- clone() {
649
- return new Tile({
650
- character: this.character,
651
- isBlank: this.isBlank,
652
- });
653
- }
654
- equals(other) {
655
- return this.character === other.character && this.isBlank === other.isBlank;
656
- }
657
- toJson() {
658
- return {
659
- character: this.character,
660
- isBlank: this.isBlank,
661
- };
662
- }
663
- toString() {
664
- return this.character;
665
- }
666
- }
667
- Tile.Null = Object.freeze({
668
- character: constants_1.EMPTY_CELL,
669
- isBlank: false,
670
- clone: () => Tile.Null,
671
- equals: (other) => other === Tile.Null,
672
- toJson: () => null,
673
- toString: () => constants_1.EMPTY_CELL,
674
- });
675
- exports["default"] = Tile;
676
-
677
-
678
- /***/ }),
679
-
680
- /***/ 92298:
681
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
682
-
683
-
684
- var __importDefault = (this && this.__importDefault) || function (mod) {
685
- return (mod && mod.__esModule) ? mod : { "default": mod };
686
- };
687
- Object.defineProperty(exports, "__esModule", ({ value: true }));
688
- exports.isTileJson = void 0;
689
- const isObject_1 = __importDefault(__webpack_require__(93518));
690
- const isTileJson = (value) => {
691
- return (0, isObject_1.default)(value) && typeof value.character === 'string' && typeof value.isBlank === 'boolean';
692
- };
693
- exports.isTileJson = isTileJson;
694
-
695
-
696
- /***/ }),
697
-
698
- /***/ 36161:
699
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
700
-
701
-
702
- var __importDefault = (this && this.__importDefault) || function (mod) {
703
- return (mod && mod.__esModule) ? mod : { "default": mod };
704
- };
705
- Object.defineProperty(exports, "__esModule", ({ value: true }));
706
- const Pattern_1 = __importDefault(__webpack_require__(43600));
707
- class VerticalPattern extends Pattern_1.default {
708
- clone() {
709
- return new VerticalPattern(this.board, this.cells.map((cell) => cell.clone()));
710
- }
711
- getCollisions() {
712
- const collisions = [];
713
- this.cells
714
- .filter((cell) => cell.isEmpty && (this.board.collidesLeft(cell) || this.board.collidesRight(cell)))
715
- .forEach((cell) => {
716
- const row = this.board.getRow(cell.y);
717
- let x = cell.x - 1;
718
- while (x >= 0 && row[x].hasTile()) {
719
- --x;
720
- }
721
- const previousCells = row.slice(x + 1, cell.x);
722
- x = cell.x + 1;
723
- while (x < row.length && row[x].hasTile()) {
724
- ++x;
725
- }
726
- const nextCells = row.slice(cell.x + 1, x);
727
- const cells = [...previousCells, cell, ...nextCells];
728
- if (cells.length > 1) {
729
- const pattern = new Pattern_1.default(this.board, cells);
730
- collisions.push(pattern);
731
- }
732
- });
733
- return collisions;
734
- }
735
- }
736
- exports["default"] = VerticalPattern;
737
-
738
-
739
- /***/ }),
740
-
741
- /***/ 39667:
742
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
743
-
744
-
745
- var __importDefault = (this && this.__importDefault) || function (mod) {
746
- return (mod && mod.__esModule) ? mod : { "default": mod };
747
- };
748
- Object.defineProperty(exports, "__esModule", ({ value: true }));
749
- const constants_1 = __webpack_require__(38436);
750
- const Bonus_1 = __importDefault(__webpack_require__(80769));
751
- class WordBonus extends Bonus_1.default {
752
- constructor() {
753
- super(...arguments);
754
- this.type = constants_1.BONUS_WORD;
755
- }
756
- get value() {
757
- return {
758
- characterMultiplier: 1,
759
- wordMultiplier: this.multiplier,
760
- };
761
- }
762
- }
763
- exports["default"] = WordBonus;
764
-
765
-
766
- /***/ }),
767
-
768
- /***/ 43184:
769
- /***/ ((__unused_webpack_module, exports) => {
770
-
771
-
772
- Object.defineProperty(exports, "__esModule", ({ value: true }));
773
- class WordDefinition {
774
- constructor({ definitions, isAllowed, word }) {
775
- this.definitions = definitions;
776
- this.isAllowed = isAllowed;
777
- this.word = word;
778
- }
779
- static fromJson(json) {
780
- if (!json) {
781
- return WordDefinition.Null;
782
- }
783
- return new WordDefinition({
784
- definitions: json.definitions,
785
- isAllowed: json.isAllowed,
786
- word: json.word,
787
- });
788
- }
789
- toJson() {
790
- return {
791
- definitions: this.definitions,
792
- isAllowed: this.isAllowed,
793
- word: this.word,
794
- };
795
- }
796
- }
797
- WordDefinition.Null = Object.freeze({
798
- definitions: [],
799
- isAllowed: false,
800
- word: '',
801
- toJson: () => null,
802
- });
803
- exports["default"] = WordDefinition;
804
-
805
-
806
- /***/ }),
807
-
808
- /***/ 46452:
809
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
810
-
811
-
812
- var __importDefault = (this && this.__importDefault) || function (mod) {
813
- return (mod && mod.__esModule) ? mod : { "default": mod };
814
- };
815
- Object.defineProperty(exports, "__esModule", ({ value: true }));
816
- exports.WordDefinition = exports.WordBonus = exports.VerticalPattern = exports.isTileJson = exports.Tile = exports.Result = exports.Pattern = exports.isLocale = exports.Locale = exports.isObject = exports.isError = exports.HorizontalPattern = exports.FinalPattern = exports.Config = exports.CharacterBonus = exports.isCellJson = exports.Cell = exports.Bonus = exports.isBoardJson = exports.Board = void 0;
817
- var Board_1 = __webpack_require__(83017);
818
- Object.defineProperty(exports, "Board", ({ enumerable: true, get: function () { return __importDefault(Board_1).default; } }));
819
- var BoardJson_1 = __webpack_require__(28508);
820
- Object.defineProperty(exports, "isBoardJson", ({ enumerable: true, get: function () { return BoardJson_1.isBoardJson; } }));
821
- var Bonus_1 = __webpack_require__(80769);
822
- Object.defineProperty(exports, "Bonus", ({ enumerable: true, get: function () { return __importDefault(Bonus_1).default; } }));
823
- var Cell_1 = __webpack_require__(70902);
824
- Object.defineProperty(exports, "Cell", ({ enumerable: true, get: function () { return __importDefault(Cell_1).default; } }));
825
- var CellJson_1 = __webpack_require__(56508);
826
- Object.defineProperty(exports, "isCellJson", ({ enumerable: true, get: function () { return CellJson_1.isCellJson; } }));
827
- var CharacterBonus_1 = __webpack_require__(95699);
828
- Object.defineProperty(exports, "CharacterBonus", ({ enumerable: true, get: function () { return __importDefault(CharacterBonus_1).default; } }));
829
- var Config_1 = __webpack_require__(68725);
830
- Object.defineProperty(exports, "Config", ({ enumerable: true, get: function () { return __importDefault(Config_1).default; } }));
831
- var FinalPattern_1 = __webpack_require__(79238);
832
- Object.defineProperty(exports, "FinalPattern", ({ enumerable: true, get: function () { return __importDefault(FinalPattern_1).default; } }));
833
- var HorizontalPattern_1 = __webpack_require__(44405);
834
- Object.defineProperty(exports, "HorizontalPattern", ({ enumerable: true, get: function () { return __importDefault(HorizontalPattern_1).default; } }));
835
- var isError_1 = __webpack_require__(24075);
836
- Object.defineProperty(exports, "isError", ({ enumerable: true, get: function () { return __importDefault(isError_1).default; } }));
837
- var isObject_1 = __webpack_require__(93518);
838
- Object.defineProperty(exports, "isObject", ({ enumerable: true, get: function () { return __importDefault(isObject_1).default; } }));
839
- var Locale_1 = __webpack_require__(28044);
840
- Object.defineProperty(exports, "Locale", ({ enumerable: true, get: function () { return __importDefault(Locale_1).default; } }));
841
- Object.defineProperty(exports, "isLocale", ({ enumerable: true, get: function () { return Locale_1.isLocale; } }));
842
- var Pattern_1 = __webpack_require__(43600);
843
- Object.defineProperty(exports, "Pattern", ({ enumerable: true, get: function () { return __importDefault(Pattern_1).default; } }));
844
- var Result_1 = __webpack_require__(28211);
845
- Object.defineProperty(exports, "Result", ({ enumerable: true, get: function () { return __importDefault(Result_1).default; } }));
846
- var Tile_1 = __webpack_require__(580);
847
- Object.defineProperty(exports, "Tile", ({ enumerable: true, get: function () { return __importDefault(Tile_1).default; } }));
848
- var TileJson_1 = __webpack_require__(92298);
849
- Object.defineProperty(exports, "isTileJson", ({ enumerable: true, get: function () { return TileJson_1.isTileJson; } }));
850
- var VerticalPattern_1 = __webpack_require__(36161);
851
- Object.defineProperty(exports, "VerticalPattern", ({ enumerable: true, get: function () { return __importDefault(VerticalPattern_1).default; } }));
852
- var WordBonus_1 = __webpack_require__(39667);
853
- Object.defineProperty(exports, "WordBonus", ({ enumerable: true, get: function () { return __importDefault(WordBonus_1).default; } }));
854
- var WordDefinition_1 = __webpack_require__(43184);
855
- Object.defineProperty(exports, "WordDefinition", ({ enumerable: true, get: function () { return __importDefault(WordDefinition_1).default; } }));
856
-
857
-
858
- /***/ }),
859
-
860
- /***/ 24075:
861
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
862
-
863
-
864
- var __importDefault = (this && this.__importDefault) || function (mod) {
865
- return (mod && mod.__esModule) ? mod : { "default": mod };
866
- };
867
- Object.defineProperty(exports, "__esModule", ({ value: true }));
868
- const isObject_1 = __importDefault(__webpack_require__(93518));
869
- const isError = (value) => {
870
- if (!(0, isObject_1.default)(value)) {
871
- return false;
872
- }
873
- return typeof value.message === 'string';
874
- };
875
- exports["default"] = isError;
876
-
877
-
878
- /***/ }),
879
-
880
- /***/ 93518:
881
- /***/ ((__unused_webpack_module, exports) => {
882
-
883
-
884
- Object.defineProperty(exports, "__esModule", ({ value: true }));
885
- const isObject = (value) => {
886
- return typeof value === 'object' && value !== null;
887
- };
888
- exports["default"] = isObject;
889
-
890
-
891
- /***/ })
892
-
893
- };
894
- ;