@scrabble-solver/types 2.5.0 → 2.7.0

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/Config.d.ts CHANGED
@@ -10,17 +10,19 @@ declare class Config {
10
10
  readonly config: ConfigJson;
11
11
  readonly pointsMap: Record<string, number>;
12
12
  constructor(config: ConfigJson);
13
- get allCharacters(): string;
14
13
  get allTilesBonusScore(): number;
15
14
  get alphabet(): string[];
16
15
  get blankScore(): number;
17
16
  get boardHeight(): number;
18
17
  get boardWidth(): number;
18
+ get twoCharacterTiles(): string[];
19
19
  getCellBonus(cell: Cell): Bonus | undefined;
20
20
  getCellBonusValue(cell: Cell): BonusValue;
21
21
  getCharacterPoints(character: string | null): number | undefined;
22
+ getTwoCharacterTileByPrefix(character: string): string | undefined;
22
23
  getTilePoints(tile: Tile | null): number | undefined;
23
24
  hasCharacter(character: string): boolean;
25
+ isTwoCharacterTilePrefix(character: string): boolean;
24
26
  get maximumNumberOfCharacters(): number;
25
27
  get numberOfBlanks(): number;
26
28
  get tiles(): TileConfig[];
package/build/Config.js CHANGED
@@ -26,13 +26,6 @@ var Config = /** @class */ (function () {
26
26
  Config.fromJson = function (json) {
27
27
  return new Config(json);
28
28
  };
29
- Object.defineProperty(Config.prototype, "allCharacters", {
30
- get: function () {
31
- return getAllCharacters(this.config);
32
- },
33
- enumerable: false,
34
- configurable: true
35
- });
36
29
  Object.defineProperty(Config.prototype, "allTilesBonusScore", {
37
30
  get: function () {
38
31
  return this.config.allTilesBonusScore;
@@ -68,6 +61,13 @@ var Config = /** @class */ (function () {
68
61
  enumerable: false,
69
62
  configurable: true
70
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
71
  Config.prototype.getCellBonus = function (cell) {
72
72
  return this.bonuses.find(function (bonus) { return bonus.matchesCellCoordinates(cell); });
73
73
  };
@@ -84,6 +84,12 @@ var Config = /** @class */ (function () {
84
84
  }
85
85
  return this.pointsMap[character];
86
86
  };
87
+ Config.prototype.getTwoCharacterTileByPrefix = function (character) {
88
+ if (character.length !== 1) {
89
+ return undefined;
90
+ }
91
+ return this.twoCharacterTiles.find(function (characters) { return characters.startsWith(character); });
92
+ };
87
93
  Config.prototype.getTilePoints = function (tile) {
88
94
  if (tile === null) {
89
95
  return undefined;
@@ -93,6 +99,9 @@ var Config = /** @class */ (function () {
93
99
  Config.prototype.hasCharacter = function (character) {
94
100
  return this.alphabet.includes(character);
95
101
  };
102
+ Config.prototype.isTwoCharacterTilePrefix = function (character) {
103
+ return typeof this.getTwoCharacterTileByPrefix(character) !== 'undefined';
104
+ };
96
105
  Object.defineProperty(Config.prototype, "maximumNumberOfCharacters", {
97
106
  get: function () {
98
107
  return this.config.maximumNumberOfCharacters;
@@ -130,12 +139,6 @@ var getBonuses = function (config) {
130
139
  throw new Error("Unsupported Bonus type: \"" + bonus.type + "\"");
131
140
  });
132
141
  };
133
- var getAllCharacters = function (config) {
134
- return config.tiles.reduce(function (allCharacters, _a) {
135
- var character = _a.character, count = _a.count;
136
- return allCharacters + Array(count).fill(character).join('');
137
- }, Array(config.numberOfBlanks).fill(constants_1.BLANK).join(''));
138
- };
139
142
  var getAlphabet = function (config) { return config.tiles.map(function (_a) {
140
143
  var character = _a.character;
141
144
  return character;
package/build/Locale.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  declare enum Locale {
2
2
  EN_GB = "en-GB",
3
3
  EN_US = "en-US",
4
+ ES_ES = "es-ES",
4
5
  FR_FR = "fr-FR",
5
- PL_PL = "pl-PL"
6
+ PL_PL = "pl-PL",
7
+ DE_DE = "de-DE"
6
8
  }
7
9
  export default Locale;
package/build/Locale.js CHANGED
@@ -5,7 +5,9 @@ var Locale;
5
5
  (function (Locale) {
6
6
  Locale["EN_GB"] = "en-GB";
7
7
  Locale["EN_US"] = "en-US";
8
+ Locale["ES_ES"] = "es-ES";
8
9
  Locale["FR_FR"] = "fr-FR";
9
10
  Locale["PL_PL"] = "pl-PL";
11
+ Locale["DE_DE"] = "de-DE";
10
12
  })(Locale || (Locale = {}));
11
13
  exports.default = Locale;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrabble-solver/types",
3
- "version": "2.5.0",
3
+ "version": "2.7.0",
4
4
  "description": "Scrabble Solver 2 - Types",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  "author": {
12
12
  "name": "Kamil Mielnik",
13
13
  "email": "kamil.adam.mielnik@gmail.com",
14
- "url": "http://kamilmielnik.com/"
14
+ "url": "https://kamilmielnik.com/"
15
15
  },
16
16
  "license": "CC-BY-NC-ND-4.0",
17
17
  "bugs": {
@@ -24,7 +24,7 @@
24
24
  "clean:force": "npm run clean && rimraf package-lock.json"
25
25
  },
26
26
  "dependencies": {
27
- "@scrabble-solver/constants": "^2.5.0"
27
+ "@scrabble-solver/constants": "^2.7.0"
28
28
  },
29
- "gitHead": "e698e6466c1872c2c325cfce1585f3e22892e633"
29
+ "gitHead": "db0e2eab74ee597f70df456444312241f2646f9e"
30
30
  }
package/src/Config.ts CHANGED
@@ -26,10 +26,6 @@ class Config {
26
26
  this.pointsMap = getPointsMap(this.config);
27
27
  }
28
28
 
29
- public get allCharacters(): string {
30
- return getAllCharacters(this.config);
31
- }
32
-
33
29
  public get allTilesBonusScore(): number {
34
30
  return this.config.allTilesBonusScore;
35
31
  }
@@ -50,6 +46,10 @@ class Config {
50
46
  return this.config.boardWidth;
51
47
  }
52
48
 
49
+ public get twoCharacterTiles(): string[] {
50
+ return this.config.tiles.filter((tile) => tile.character.length === 2).map((tile) => tile.character);
51
+ }
52
+
53
53
  public getCellBonus(cell: Cell): Bonus | undefined {
54
54
  return this.bonuses.find((bonus) => bonus.matchesCellCoordinates(cell));
55
55
  }
@@ -70,6 +70,14 @@ class Config {
70
70
  return this.pointsMap[character];
71
71
  }
72
72
 
73
+ public getTwoCharacterTileByPrefix(character: string): string | undefined {
74
+ if (character.length !== 1) {
75
+ return undefined;
76
+ }
77
+
78
+ return this.twoCharacterTiles.find((characters) => characters.startsWith(character));
79
+ }
80
+
73
81
  public getTilePoints(tile: Tile | null): number | undefined {
74
82
  if (tile === null) {
75
83
  return undefined;
@@ -82,6 +90,10 @@ class Config {
82
90
  return this.alphabet.includes(character);
83
91
  }
84
92
 
93
+ public isTwoCharacterTilePrefix(character: string): boolean {
94
+ return typeof this.getTwoCharacterTileByPrefix(character) !== 'undefined';
95
+ }
96
+
85
97
  public get maximumNumberOfCharacters(): number {
86
98
  return this.config.maximumNumberOfCharacters;
87
99
  }
@@ -113,12 +125,6 @@ const getBonuses = (config: ConfigJson): Bonus[] => {
113
125
  });
114
126
  };
115
127
 
116
- const getAllCharacters = (config: ConfigJson) =>
117
- config.tiles.reduce(
118
- (allCharacters, { character, count }) => allCharacters + Array(count).fill(character).join(''),
119
- Array(config.numberOfBlanks).fill(BLANK).join(''),
120
- );
121
-
122
128
  const getAlphabet = (config: ConfigJson): string[] => config.tiles.map(({ character }) => character);
123
129
 
124
130
  const getPointsMap = (config: ConfigJson): Record<string, number> =>
package/src/Locale.ts CHANGED
@@ -2,8 +2,10 @@
2
2
  enum Locale {
3
3
  EN_GB = 'en-GB',
4
4
  EN_US = 'en-US',
5
+ ES_ES = 'es-ES',
5
6
  FR_FR = 'fr-FR',
6
7
  PL_PL = 'pl-PL',
8
+ DE_DE = 'de-DE',
7
9
  }
8
10
 
9
11
  export default Locale;