scrabble-solver 2.8.2 → 2.8.3
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/.eslintrc.js +1 -1
- package/lerna.json +1 -1
- package/package.json +1 -1
- package/packages/configs/build/getConfig.js +6 -12
- package/packages/configs/build/getLocaleConfig.js +2 -2
- package/packages/configs/build/isConfigId.js +5 -8
- package/packages/configs/build/literaki/bonuses.js +2 -2
- package/packages/configs/build/literaki/literaki.js +14 -27
- package/packages/configs/build/literaki/tiles/tilesDe.js +1 -1
- package/packages/configs/build/literaki/tiles/tilesEn.js +1 -1
- package/packages/configs/build/literaki/tiles/tilesEs.js +1 -1
- package/packages/configs/build/literaki/tiles/tilesFr.js +1 -1
- package/packages/configs/build/literaki/tiles/tilesPl.js +1 -1
- package/packages/configs/build/scrabble/bonuses.js +2 -2
- package/packages/configs/build/scrabble/scrabble.js +14 -27
- package/packages/configs/build/scrabble/tiles/tilesDe.js +1 -1
- package/packages/configs/build/scrabble/tiles/tilesEn.js +1 -1
- package/packages/configs/build/scrabble/tiles/tilesEs.js +1 -1
- package/packages/configs/build/scrabble/tiles/tilesFr.js +1 -1
- package/packages/configs/build/scrabble/tiles/tilesPl.js +1 -1
- package/packages/configs/package.json +3 -3
- package/packages/constants/package.json +1 -1
- package/packages/dictionaries/build/Dictionaries.js +37 -110
- package/packages/dictionaries/build/constants/index.js +2 -2
- package/packages/dictionaries/build/index.js +1 -1
- package/packages/dictionaries/build/lib/DiskCache.js +31 -91
- package/packages/dictionaries/build/lib/LayeredCache.js +37 -101
- package/packages/dictionaries/build/lib/MemoryCache.js +16 -17
- package/packages/dictionaries/build/lib/createAsyncProxy.js +14 -58
- package/packages/dictionaries/build/lib/createCacheTimestampComparator.js +4 -4
- package/packages/dictionaries/build/lib/downloadDictionary.js +10 -54
- package/packages/dictionaries/build/lib/getDictionaryFilepath.js +4 -4
- package/packages/dictionaries/build/lib/readFile.js +12 -50
- package/packages/dictionaries/build/lib/writeFile.js +12 -50
- package/packages/dictionaries/package-lock.json +2 -2
- package/packages/dictionaries/package.json +4 -4
- package/packages/dictionaries/src/lib/LayeredCache.ts +17 -8
- package/packages/logger/build/constants.js +2 -2
- package/packages/logger/build/logger.js +4 -4
- package/packages/logger/package-lock.json +2 -2
- package/packages/logger/package.json +1 -1
- package/packages/scrabble-solver/.next/BUILD_ID +1 -1
- package/packages/scrabble-solver/.next/build-manifest.json +5 -5
- package/packages/scrabble-solver/.next/cache/.tsbuildinfo +1 -1
- package/packages/scrabble-solver/.next/cache/eslint/.cache_8dgz12 +1 -1
- package/packages/scrabble-solver/.next/cache/next-server.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/cache/webpack/client-production/0.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/client-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/0.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/next-server.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/prerender-manifest.json +1 -1
- package/packages/scrabble-solver/.next/routes-manifest.json +1 -1
- package/packages/scrabble-solver/.next/server/chunks/413.js +391 -673
- package/packages/scrabble-solver/.next/server/chunks/515.js +414 -500
- package/packages/scrabble-solver/.next/server/chunks/907.js +397 -679
- package/packages/scrabble-solver/.next/server/middleware-build-manifest.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/404.html +1 -1
- package/packages/scrabble-solver/.next/server/pages/404.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/500.html +2 -2
- package/packages/scrabble-solver/.next/server/pages/_app.js +7 -10
- package/packages/scrabble-solver/.next/server/pages/_app.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/_document.js +0 -3
- package/packages/scrabble-solver/.next/server/pages/_error.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale]/[word].js +114 -171
- package/packages/scrabble-solver/.next/server/pages/api/solve.js +428 -1164
- package/packages/scrabble-solver/.next/server/pages/index.html +1 -1
- package/packages/scrabble-solver/.next/server/pages/index.js +2 -2
- package/packages/scrabble-solver/.next/server/pages/index.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/index.json +1 -1
- package/packages/scrabble-solver/.next/static/OhUvTNKwyrrzmNwKBnpUU/_buildManifest.js +1 -0
- package/packages/scrabble-solver/.next/static/{nXSSCVI5pGlS_NxEidxkS → OhUvTNKwyrrzmNwKBnpUU}/_ssgManifest.js +0 -0
- package/packages/scrabble-solver/.next/static/chunks/{195-fcadef5c6eed8338.js → 195-4b75c9c697b7b455.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/pages/_app-72522bfb306a8aef.js +1 -0
- package/packages/scrabble-solver/.next/trace +42 -42
- package/packages/scrabble-solver/package-lock.json +2 -2
- package/packages/scrabble-solver/package.json +8 -8
- package/packages/scrabble-solver/src/components/Board/Board.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/BoardPure.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/components/Cell/Button.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/components/Cell/Cell.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/components/Cell/CellPure.tsx +1 -1
- package/packages/scrabble-solver/src/components/Button/Button.tsx +1 -1
- package/packages/scrabble-solver/src/components/Checkbox/Checkbox.tsx +1 -1
- package/packages/scrabble-solver/src/components/Dictionary/Dictionary.tsx +1 -1
- package/packages/scrabble-solver/src/components/DictionaryInput/DictionaryInput.tsx +1 -1
- package/packages/scrabble-solver/src/components/EmptyState/EmptyState.tsx +1 -1
- package/packages/scrabble-solver/src/components/Key/Key.tsx +1 -1
- package/packages/scrabble-solver/src/components/KeyMap/KeyMap.tsx +1 -1
- package/packages/scrabble-solver/src/components/KeyMap/components/Mapping/Mapping.tsx +1 -1
- package/packages/scrabble-solver/src/components/Loading/Loading.tsx +1 -1
- package/packages/scrabble-solver/src/components/Logo/Logo.tsx +1 -1
- package/packages/scrabble-solver/src/components/NavButtons/NavButtons.tsx +1 -1
- package/packages/scrabble-solver/src/components/NotFound/NotFound.tsx +1 -1
- package/packages/scrabble-solver/src/components/PlainTiles/PlainTiles.tsx +1 -1
- package/packages/scrabble-solver/src/components/PlainTiles/Tile.tsx +1 -1
- package/packages/scrabble-solver/src/components/Rack/Rack.tsx +1 -1
- package/packages/scrabble-solver/src/components/Rack/RackTile.tsx +1 -1
- package/packages/scrabble-solver/src/components/Radio/Radio.tsx +1 -1
- package/packages/scrabble-solver/src/components/RemainingTiles/Character.tsx +1 -1
- package/packages/scrabble-solver/src/components/RemainingTiles/RemainingTiles.tsx +1 -1
- package/packages/scrabble-solver/src/components/Results/Cell.tsx +1 -1
- package/packages/scrabble-solver/src/components/Results/HeaderButton.tsx +1 -1
- package/packages/scrabble-solver/src/components/Results/Result.tsx +1 -1
- package/packages/scrabble-solver/src/components/Results/Results.tsx +1 -1
- package/packages/scrabble-solver/src/components/Results/SolveButton.tsx +1 -1
- package/packages/scrabble-solver/src/components/ResultsInput/ResultsInput.tsx +1 -1
- package/packages/scrabble-solver/src/components/Screen/Screen.tsx +1 -1
- package/packages/scrabble-solver/src/components/Settings/Settings.tsx +1 -1
- package/packages/scrabble-solver/src/components/Settings/components/AutoGroupTilesSetting/AutoGroupTilesSetting.tsx +1 -1
- package/packages/scrabble-solver/src/components/Settings/components/ConfigSetting/ConfigSetting.tsx +1 -1
- package/packages/scrabble-solver/src/components/Settings/components/LocaleSetting/LocaleSetting.tsx +1 -1
- package/packages/scrabble-solver/src/components/Sidebar/Sidebar.tsx +1 -1
- package/packages/scrabble-solver/src/components/Sidebar/components/Section/Section.tsx +1 -1
- package/packages/scrabble-solver/src/components/Splash/Splash.tsx +1 -1
- package/packages/scrabble-solver/src/components/SquareButton/Link.tsx +1 -1
- package/packages/scrabble-solver/src/components/SquareButton/SquareButton.tsx +1 -1
- package/packages/scrabble-solver/src/components/Tile/Tile.tsx +1 -1
- package/packages/scrabble-solver/src/components/Tile/TilePure.tsx +1 -1
- package/packages/scrabble-solver/src/components/Tooltip/useTooltip.tsx +1 -1
- package/packages/scrabble-solver/src/components/Well/Well.tsx +1 -1
- package/packages/scrabble-solver/src/hooks/usePortal.tsx +19 -9
- package/packages/scrabble-solver/src/lib/memoize.ts +1 -1
- package/packages/scrabble-solver/src/pages/_app.tsx +1 -1
- package/packages/scrabble-solver/src/pages/_document.tsx +1 -1
- package/packages/scrabble-solver/src/pages/index.tsx +1 -1
- package/packages/solver/build/PatternsFiller.js +37 -67
- package/packages/solver/build/PatternsGenerator.js +42 -75
- package/packages/solver/build/ScoresCalculator.js +20 -24
- package/packages/solver/build/Solver.js +19 -23
- package/packages/solver/package-lock.json +2 -2
- package/packages/solver/package.json +5 -5
- package/packages/solver/src/PatternsFiller.ts +3 -2
- package/packages/types/build/Board.js +68 -85
- package/packages/types/build/Bonus.js +15 -21
- package/packages/types/build/Cell.js +30 -32
- package/packages/types/build/CharacterBonus.js +18 -40
- package/packages/types/build/Config.js +62 -117
- package/packages/types/build/HorizontalPattern.js +17 -63
- package/packages/types/build/Pattern.js +36 -40
- package/packages/types/build/Result.js +23 -46
- package/packages/types/build/Tile.js +22 -24
- package/packages/types/build/VerticalPattern.js +17 -63
- package/packages/types/build/WordBonus.js +13 -35
- package/packages/types/build/WordDefinition.js +13 -15
- package/packages/types/package.json +2 -2
- package/packages/word-definitions/build/crawl/crawl.js +15 -16
- package/packages/word-definitions/build/crawl/crawlEnglish.js +3 -3
- package/packages/word-definitions/build/crawl/crawlFrench.js +3 -3
- package/packages/word-definitions/build/crawl/crawlGerman.js +3 -3
- package/packages/word-definitions/build/crawl/crawlPolish.js +3 -3
- package/packages/word-definitions/build/crawl/crawlSpanish.js +3 -3
- package/packages/word-definitions/build/getWordDefinition.js +9 -52
- package/packages/word-definitions/build/lib/normalizeDefinition.js +15 -15
- package/packages/word-definitions/build/lib/request.js +8 -20
- package/packages/word-definitions/build/lib/unique.js +1 -1
- package/packages/word-definitions/build/parse/parse.js +18 -19
- package/packages/word-definitions/build/parse/parseEnglish.js +5 -5
- package/packages/word-definitions/build/parse/parseFrench.js +5 -5
- package/packages/word-definitions/build/parse/parseGerman.js +6 -6
- package/packages/word-definitions/build/parse/parsePolish.js +6 -6
- package/packages/word-definitions/build/parse/parseSpanish.js +9 -9
- package/packages/word-definitions/package-lock.json +8 -8
- package/packages/word-definitions/package.json +2 -2
- package/packages/word-lists/build/getDeDeWordList.js +5 -43
- package/packages/word-lists/build/getEnGbWordList.js +5 -43
- package/packages/word-lists/build/getEnUsWordList.js +5 -43
- package/packages/word-lists/build/getEsEsWordList.js +7 -50
- package/packages/word-lists/build/getFrFrWordList.js +9 -50
- package/packages/word-lists/build/getPlPlWordList.js +34 -91
- package/packages/word-lists/build/getWordList.js +16 -17
- package/packages/word-lists/build/lib/downloadFile.js +5 -5
- package/packages/word-lists/build/lib/downloadHtml.js +8 -8
- package/packages/word-lists/build/lib/extractWords.js +5 -5
- package/packages/word-lists/build/lib/findFirstWordIndex.js +6 -6
- package/packages/word-lists/build/lib/getHash.js +2 -5
- package/packages/word-lists/build/lib/getTempFilename.js +3 -3
- package/packages/word-lists/build/lib/getTxtWordList.js +12 -56
- package/packages/word-lists/package-lock.json +2 -2
- package/packages/word-lists/package.json +2 -2
- package/packages/word-lists/src/getFrFrWordList.ts +1 -0
- package/tsconfig.json +1 -1
- package/packages/scrabble-solver/.next/static/chunks/pages/_app-f4030148d742bcd2.js +0 -1
- package/packages/scrabble-solver/.next/static/nXSSCVI5pGlS_NxEidxkS/_buildManifest.js +0 -1
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var multiplier = _a.multiplier, score = _a.score, x = _a.x, y = _a.y;
|
|
3
|
+
class Bonus {
|
|
4
|
+
constructor({ multiplier, score, x, y }) {
|
|
6
5
|
this.multiplier = multiplier;
|
|
7
6
|
this.score = score;
|
|
8
7
|
this.x = x;
|
|
9
8
|
this.y = y;
|
|
10
9
|
}
|
|
11
|
-
|
|
10
|
+
canApply(_config, cell) {
|
|
12
11
|
return cell.isEmpty && this.matchesCellCoordinates(cell);
|
|
13
|
-
}
|
|
14
|
-
|
|
12
|
+
}
|
|
13
|
+
matchesCellCoordinates(cell) {
|
|
15
14
|
return this.x === cell.x && this.y === cell.y;
|
|
16
|
-
}
|
|
17
|
-
|
|
15
|
+
}
|
|
16
|
+
toJson() {
|
|
18
17
|
return {
|
|
19
18
|
multiplier: this.multiplier,
|
|
20
19
|
score: this.score,
|
|
@@ -22,17 +21,12 @@ var Bonus = /** @class */ (function () {
|
|
|
22
21
|
x: this.x,
|
|
23
22
|
y: this.y,
|
|
24
23
|
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
enumerable: false,
|
|
34
|
-
configurable: true
|
|
35
|
-
});
|
|
36
|
-
return Bonus;
|
|
37
|
-
}());
|
|
24
|
+
}
|
|
25
|
+
get value() {
|
|
26
|
+
return {
|
|
27
|
+
characterMultiplier: 1,
|
|
28
|
+
wordMultiplier: 1,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
38
32
|
exports.default = Bonus;
|
|
@@ -3,17 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const Tile_1 = __importDefault(require("./Tile"));
|
|
7
|
+
class Cell {
|
|
8
8
|
// eslint-disable-next-line no-undef
|
|
9
|
-
|
|
10
|
-
var _b = _a.isEmpty, isEmpty = _b === void 0 ? true : _b, _c = _a.tile, tile = _c === void 0 ? Tile_1.default.Null : _c, x = _a.x, y = _a.y;
|
|
9
|
+
constructor({ isEmpty = true, tile = Tile_1.default.Null, x, y }) {
|
|
11
10
|
this.isEmpty = isEmpty;
|
|
12
11
|
this.tile = tile;
|
|
13
12
|
this.x = x;
|
|
14
13
|
this.y = y;
|
|
15
14
|
}
|
|
16
|
-
|
|
15
|
+
static fromJson(json) {
|
|
17
16
|
if (!json) {
|
|
18
17
|
return Cell.Null;
|
|
19
18
|
}
|
|
@@ -23,47 +22,46 @@ var Cell = /** @class */ (function () {
|
|
|
23
22
|
x: json.x,
|
|
24
23
|
y: json.y,
|
|
25
24
|
});
|
|
26
|
-
}
|
|
27
|
-
|
|
25
|
+
}
|
|
26
|
+
clone() {
|
|
28
27
|
return new Cell({
|
|
29
28
|
isEmpty: this.isEmpty,
|
|
30
29
|
tile: this.tile.clone(),
|
|
31
30
|
x: this.x,
|
|
32
31
|
y: this.y,
|
|
33
32
|
});
|
|
34
|
-
}
|
|
35
|
-
|
|
33
|
+
}
|
|
34
|
+
equals(other) {
|
|
36
35
|
return this.x === other.x && this.y === other.y && this.isEmpty === other.isEmpty && this.tile.equals(other.tile);
|
|
37
|
-
}
|
|
38
|
-
|
|
36
|
+
}
|
|
37
|
+
hasTile() {
|
|
39
38
|
return this.tile !== Tile_1.default.Null;
|
|
40
|
-
}
|
|
41
|
-
|
|
39
|
+
}
|
|
40
|
+
isCandidate() {
|
|
42
41
|
return this.isEmpty && this.hasTile();
|
|
43
|
-
}
|
|
44
|
-
|
|
42
|
+
}
|
|
43
|
+
toJson() {
|
|
45
44
|
return {
|
|
46
45
|
isEmpty: this.isEmpty,
|
|
47
46
|
tile: this.tile.toJson(),
|
|
48
47
|
x: this.x,
|
|
49
48
|
y: this.y,
|
|
50
49
|
};
|
|
51
|
-
}
|
|
52
|
-
|
|
50
|
+
}
|
|
51
|
+
toString() {
|
|
53
52
|
return String(this.tile);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}());
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
Cell.Null = Object.freeze({
|
|
56
|
+
isEmpty: true,
|
|
57
|
+
tile: Tile_1.default.Null,
|
|
58
|
+
x: 0,
|
|
59
|
+
y: 0,
|
|
60
|
+
clone: () => Cell.Null,
|
|
61
|
+
equals: (other) => other === Cell.Null,
|
|
62
|
+
hasTile: () => false,
|
|
63
|
+
isCandidate: () => false,
|
|
64
|
+
toString: () => '',
|
|
65
|
+
toJson: () => null,
|
|
66
|
+
});
|
|
69
67
|
exports.default = Cell;
|
|
@@ -1,51 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
4
|
};
|
|
20
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
_this.type = constants_1.BONUS_CHARACTER;
|
|
28
|
-
return _this;
|
|
6
|
+
const constants_1 = require("@scrabble-solver/constants");
|
|
7
|
+
const Bonus_1 = __importDefault(require("./Bonus"));
|
|
8
|
+
class CharacterBonus extends Bonus_1.default {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.type = constants_1.BONUS_CHARACTER;
|
|
29
12
|
}
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
13
|
+
canApply(config, cell) {
|
|
14
|
+
return super.canApply(config, cell) && this.matchesCellTileScore(config, cell);
|
|
15
|
+
}
|
|
16
|
+
matchesCellTileScore(config, cell) {
|
|
34
17
|
if (typeof this.score === 'undefined') {
|
|
35
18
|
return true;
|
|
36
19
|
}
|
|
37
20
|
return this.score === config.pointsMap[cell.tile.character];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
enumerable: false,
|
|
47
|
-
configurable: true
|
|
48
|
-
});
|
|
49
|
-
return CharacterBonus;
|
|
50
|
-
}(Bonus_1.default));
|
|
21
|
+
}
|
|
22
|
+
get value() {
|
|
23
|
+
return {
|
|
24
|
+
characterMultiplier: this.multiplier,
|
|
25
|
+
wordMultiplier: 1,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
51
29
|
exports.default = CharacterBonus;
|
|
@@ -1,81 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
const constants_1 = require("@scrabble-solver/constants");
|
|
7
|
+
const CharacterBonus_1 = __importDefault(require("./CharacterBonus"));
|
|
8
|
+
const WordBonus_1 = __importDefault(require("./WordBonus"));
|
|
9
|
+
class Config {
|
|
10
|
+
constructor(config) {
|
|
22
11
|
this.bonuses = getBonuses(config);
|
|
23
12
|
this.config = config;
|
|
24
13
|
this.pointsMap = getPointsMap(this.config);
|
|
25
14
|
}
|
|
26
|
-
|
|
15
|
+
static fromJson(json) {
|
|
27
16
|
return new Config(json);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
enumerable: false,
|
|
55
|
-
configurable: true
|
|
56
|
-
});
|
|
57
|
-
Object.defineProperty(Config.prototype, "boardWidth", {
|
|
58
|
-
get: function () {
|
|
59
|
-
return this.config.boardWidth;
|
|
60
|
-
},
|
|
61
|
-
enumerable: false,
|
|
62
|
-
configurable: true
|
|
63
|
-
});
|
|
64
|
-
Object.defineProperty(Config.prototype, "twoCharacterTiles", {
|
|
65
|
-
get: function () {
|
|
66
|
-
return this.config.tiles.filter(function (tile) { return tile.character.length === 2; }).map(function (tile) { return tile.character; });
|
|
67
|
-
},
|
|
68
|
-
enumerable: false,
|
|
69
|
-
configurable: true
|
|
70
|
-
});
|
|
71
|
-
Config.prototype.getCellBonus = function (cell) {
|
|
72
|
-
return this.bonuses.find(function (bonus) { return bonus.matchesCellCoordinates(cell); });
|
|
73
|
-
};
|
|
74
|
-
Config.prototype.getCellBonusValue = function (cell) {
|
|
75
|
-
var _a;
|
|
76
|
-
return ((_a = this.getCellBonus(cell)) === null || _a === void 0 ? void 0 : _a.value) || constants_1.NO_BONUS;
|
|
77
|
-
};
|
|
78
|
-
Config.prototype.getCharacterPoints = function (character) {
|
|
17
|
+
}
|
|
18
|
+
get allTilesBonusScore() {
|
|
19
|
+
return this.config.allTilesBonusScore;
|
|
20
|
+
}
|
|
21
|
+
get alphabet() {
|
|
22
|
+
return getAlphabet(this.config);
|
|
23
|
+
}
|
|
24
|
+
get blankScore() {
|
|
25
|
+
return this.config.blankScore;
|
|
26
|
+
}
|
|
27
|
+
get boardHeight() {
|
|
28
|
+
return this.config.boardHeight;
|
|
29
|
+
}
|
|
30
|
+
get boardWidth() {
|
|
31
|
+
return this.config.boardWidth;
|
|
32
|
+
}
|
|
33
|
+
get twoCharacterTiles() {
|
|
34
|
+
return this.config.tiles.filter((tile) => tile.character.length === 2).map((tile) => tile.character);
|
|
35
|
+
}
|
|
36
|
+
getCellBonus(cell) {
|
|
37
|
+
return this.bonuses.find((bonus) => bonus.matchesCellCoordinates(cell));
|
|
38
|
+
}
|
|
39
|
+
getCellBonusValue(cell) {
|
|
40
|
+
return this.getCellBonus(cell)?.value || constants_1.NO_BONUS;
|
|
41
|
+
}
|
|
42
|
+
getCharacterPoints(character) {
|
|
79
43
|
if (character === null) {
|
|
80
44
|
return undefined;
|
|
81
45
|
}
|
|
@@ -83,71 +47,52 @@ var Config = /** @class */ (function () {
|
|
|
83
47
|
return this.blankScore;
|
|
84
48
|
}
|
|
85
49
|
return this.pointsMap[character];
|
|
86
|
-
}
|
|
87
|
-
|
|
50
|
+
}
|
|
51
|
+
getTwoCharacterTileByPrefix(character) {
|
|
88
52
|
if (character.length !== 1) {
|
|
89
53
|
return undefined;
|
|
90
54
|
}
|
|
91
|
-
return this.twoCharacterTiles.find(
|
|
92
|
-
}
|
|
93
|
-
|
|
55
|
+
return this.twoCharacterTiles.find((characters) => characters.startsWith(character));
|
|
56
|
+
}
|
|
57
|
+
getTilePoints(tile) {
|
|
94
58
|
if (tile === null) {
|
|
95
59
|
return undefined;
|
|
96
60
|
}
|
|
97
61
|
return tile.isBlank ? this.blankScore : this.getCharacterPoints(tile.character);
|
|
98
|
-
}
|
|
99
|
-
|
|
62
|
+
}
|
|
63
|
+
hasCharacter(character) {
|
|
100
64
|
return this.alphabet.includes(character);
|
|
101
|
-
}
|
|
102
|
-
|
|
65
|
+
}
|
|
66
|
+
isTwoCharacterTilePrefix(character) {
|
|
103
67
|
return typeof this.getTwoCharacterTileByPrefix(character) !== 'undefined';
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
enumerable: false,
|
|
117
|
-
configurable: true
|
|
118
|
-
});
|
|
119
|
-
Object.defineProperty(Config.prototype, "tiles", {
|
|
120
|
-
get: function () {
|
|
121
|
-
return this.config.tiles;
|
|
122
|
-
},
|
|
123
|
-
enumerable: false,
|
|
124
|
-
configurable: true
|
|
125
|
-
});
|
|
126
|
-
Config.prototype.toJson = function () {
|
|
68
|
+
}
|
|
69
|
+
get maximumNumberOfCharacters() {
|
|
70
|
+
return this.config.maximumNumberOfCharacters;
|
|
71
|
+
}
|
|
72
|
+
get numberOfBlanks() {
|
|
73
|
+
return this.config.numberOfBlanks;
|
|
74
|
+
}
|
|
75
|
+
get tiles() {
|
|
76
|
+
return this.config.tiles;
|
|
77
|
+
}
|
|
78
|
+
toJson() {
|
|
127
79
|
return this.config;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return config.bonuses.map(function (bonus) {
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const getBonuses = (config) => {
|
|
83
|
+
return config.bonuses.map((bonus) => {
|
|
133
84
|
if (bonus.type === constants_1.BONUS_CHARACTER) {
|
|
134
85
|
return new CharacterBonus_1.default(bonus);
|
|
135
86
|
}
|
|
136
87
|
if (bonus.type === constants_1.BONUS_WORD) {
|
|
137
88
|
return new WordBonus_1.default(bonus);
|
|
138
89
|
}
|
|
139
|
-
throw new Error(
|
|
90
|
+
throw new Error(`Unsupported Bonus type: "${bonus.type}"`);
|
|
140
91
|
});
|
|
141
92
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return config.tiles.reduce(function (pointsMap, _a) {
|
|
148
|
-
var _b;
|
|
149
|
-
var character = _a.character, score = _a.score;
|
|
150
|
-
return (__assign(__assign({}, pointsMap), (_b = {}, _b[character] = score, _b)));
|
|
151
|
-
}, {});
|
|
152
|
-
};
|
|
93
|
+
const getAlphabet = (config) => config.tiles.map(({ character }) => character);
|
|
94
|
+
const getPointsMap = (config) => config.tiles.reduce((pointsMap, { character, score }) => ({
|
|
95
|
+
...pointsMap,
|
|
96
|
+
[character]: score,
|
|
97
|
+
}), {});
|
|
153
98
|
exports.default = Config;
|
|
@@ -1,85 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
18
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
19
|
-
if (!m) return o;
|
|
20
|
-
var i = m.call(o), r, ar = [], e;
|
|
21
|
-
try {
|
|
22
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
23
|
-
}
|
|
24
|
-
catch (error) { e = { error: error }; }
|
|
25
|
-
finally {
|
|
26
|
-
try {
|
|
27
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
28
|
-
}
|
|
29
|
-
finally { if (e) throw e.error; }
|
|
30
|
-
}
|
|
31
|
-
return ar;
|
|
32
|
-
};
|
|
33
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
34
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
35
|
-
if (ar || !(i in from)) {
|
|
36
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
37
|
-
ar[i] = from[i];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
41
|
-
};
|
|
42
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
4
|
};
|
|
45
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
function HorizontalPattern() {
|
|
50
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
51
|
-
}
|
|
52
|
-
HorizontalPattern.prototype.clone = function () {
|
|
6
|
+
const Pattern_1 = __importDefault(require("./Pattern"));
|
|
7
|
+
class HorizontalPattern extends Pattern_1.default {
|
|
8
|
+
clone() {
|
|
53
9
|
return new HorizontalPattern({
|
|
54
10
|
board: this.board,
|
|
55
|
-
cells: this.cells.map(
|
|
11
|
+
cells: this.cells.map((cell) => cell.clone()),
|
|
56
12
|
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var collisions = [];
|
|
13
|
+
}
|
|
14
|
+
getCollisions() {
|
|
15
|
+
const collisions = [];
|
|
61
16
|
this.cells
|
|
62
|
-
.filter(
|
|
63
|
-
.forEach(
|
|
64
|
-
|
|
65
|
-
|
|
17
|
+
.filter((cell) => cell.isEmpty && (this.board.collidesUp(cell) || this.board.collidesDown(cell)))
|
|
18
|
+
.forEach((cell) => {
|
|
19
|
+
const column = this.board.getColumn(cell.x);
|
|
20
|
+
let y = cell.y - 1;
|
|
66
21
|
while (y >= 0 && column[y].hasTile()) {
|
|
67
22
|
--y;
|
|
68
23
|
}
|
|
69
|
-
|
|
24
|
+
const previousCells = column.slice(y + 1, cell.y);
|
|
70
25
|
y = cell.y + 1;
|
|
71
26
|
while (y < column.length && column[y].hasTile()) {
|
|
72
27
|
++y;
|
|
73
28
|
}
|
|
74
|
-
|
|
75
|
-
|
|
29
|
+
const nextCells = column.slice(cell.y + 1, y);
|
|
30
|
+
const cells = [...previousCells, cell, ...nextCells];
|
|
76
31
|
if (cells.length > 1) {
|
|
77
|
-
|
|
32
|
+
const pattern = new Pattern_1.default({ board: this.board, cells });
|
|
78
33
|
collisions.push(pattern);
|
|
79
34
|
}
|
|
80
35
|
});
|
|
81
36
|
return collisions;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
}(Pattern_1.default));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
85
39
|
exports.default = HorizontalPattern;
|
|
@@ -1,56 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var board = _a.board, cells = _a.cells;
|
|
3
|
+
class Pattern {
|
|
4
|
+
constructor({ board, cells }) {
|
|
6
5
|
this.board = board;
|
|
7
6
|
this.cells = cells;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
canBePlaced(config) {
|
|
9
|
+
const numberOfEmptyCells = this.getNumberOfEmptyCells();
|
|
10
|
+
const isNumberOfUsedCellsInRange = numberOfEmptyCells >= 1 && numberOfEmptyCells <= config.maximumNumberOfCharacters;
|
|
12
11
|
return (isNumberOfUsedCellsInRange &&
|
|
13
12
|
(this.hasAtLeast1NonEmptyCell() || this.collides() || (this.goesThroughBoardCenter() && this.board.isEmpty())));
|
|
14
|
-
}
|
|
15
|
-
|
|
13
|
+
}
|
|
14
|
+
clone() {
|
|
16
15
|
return new Pattern({
|
|
17
16
|
board: this.board,
|
|
18
|
-
cells: this.cells.map(
|
|
17
|
+
cells: this.cells.map((cell) => cell.clone()),
|
|
19
18
|
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
41
|
-
Pattern.prototype.getCollisions = function () {
|
|
19
|
+
}
|
|
20
|
+
collides() {
|
|
21
|
+
return this.cells.some((cell) => cell.isEmpty && this.board.collides(cell));
|
|
22
|
+
}
|
|
23
|
+
getIndexOfFirstCellWithoutTile() {
|
|
24
|
+
return this.cells.findIndex((cell) => !cell.hasTile());
|
|
25
|
+
}
|
|
26
|
+
getNumberOfEmptyCells() {
|
|
27
|
+
return this.cells.filter((cell) => cell.isEmpty).length;
|
|
28
|
+
}
|
|
29
|
+
goesThroughBoardCenter() {
|
|
30
|
+
return this.cells.some((cell) => cell.x === this.board.center.x && cell.y === this.board.center.y && cell.isEmpty);
|
|
31
|
+
}
|
|
32
|
+
hasAtLeast1EmptyCell() {
|
|
33
|
+
return this.cells.some((cell) => cell.isEmpty);
|
|
34
|
+
}
|
|
35
|
+
hasAtLeast1NonEmptyCell() {
|
|
36
|
+
return this.cells.some((cell) => !cell.isEmpty);
|
|
37
|
+
}
|
|
38
|
+
getCollisions() {
|
|
42
39
|
return [];
|
|
43
|
-
}
|
|
44
|
-
|
|
40
|
+
}
|
|
41
|
+
toJson() {
|
|
45
42
|
return {
|
|
46
|
-
cells: this.cells.map(
|
|
47
|
-
collisions: this.getCollisions().map(
|
|
43
|
+
cells: this.cells.map((cell) => cell.toJson()),
|
|
44
|
+
collisions: this.getCollisions().map((collision) => collision.toJson()),
|
|
48
45
|
word: this.toString(),
|
|
49
46
|
};
|
|
50
|
-
}
|
|
51
|
-
|
|
47
|
+
}
|
|
48
|
+
toString() {
|
|
52
49
|
return this.cells.map(String).join('');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
}());
|
|
50
|
+
}
|
|
51
|
+
}
|
|
56
52
|
exports.default = Pattern;
|