@gamepark/rules-api 5.23.2 → 5.24.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.
Files changed (82) hide show
  1. package/dist/Action.d.ts +25 -25
  2. package/dist/Action.js +45 -55
  3. package/dist/Action.js.map +1 -1
  4. package/dist/ApplyAutomaticMoves.d.ts +2 -2
  5. package/dist/ApplyAutomaticMoves.js +18 -24
  6. package/dist/ApplyAutomaticMoves.js.map +1 -1
  7. package/dist/Competitive.d.ts +6 -6
  8. package/dist/Competitive.js +3 -7
  9. package/dist/Competitive.js.map +1 -1
  10. package/dist/Dummy.d.ts +7 -7
  11. package/dist/Dummy.js +22 -25
  12. package/dist/Dummy.js.map +1 -1
  13. package/dist/Eliminations.d.ts +5 -5
  14. package/dist/Eliminations.js +4 -8
  15. package/dist/Eliminations.js.map +1 -1
  16. package/dist/IncompleteInformation.d.ts +14 -14
  17. package/dist/IncompleteInformation.js +30 -37
  18. package/dist/IncompleteInformation.js.map +1 -1
  19. package/dist/LoopWithFuse.d.ts +4 -4
  20. package/dist/LoopWithFuse.js +10 -14
  21. package/dist/LoopWithFuse.js.map +1 -1
  22. package/dist/RandomMove.d.ts +7 -7
  23. package/dist/RandomMove.js +7 -12
  24. package/dist/RandomMove.js.map +1 -1
  25. package/dist/Robot.d.ts +2 -2
  26. package/dist/Robot.js +1 -2
  27. package/dist/Rules.d.ts +14 -14
  28. package/dist/Rules.js +63 -74
  29. package/dist/Rules.js.map +1 -1
  30. package/dist/RulesCreator.d.ts +5 -5
  31. package/dist/RulesCreator.js +1 -2
  32. package/dist/TimeLimit.d.ts +18 -18
  33. package/dist/TimeLimit.js +8 -12
  34. package/dist/TimeLimit.js.map +1 -1
  35. package/dist/Undo.d.ts +6 -6
  36. package/dist/Undo.js +4 -8
  37. package/dist/Undo.js.map +1 -1
  38. package/dist/index.d.ts +22 -22
  39. package/dist/index.js +13 -37
  40. package/dist/index.js.map +1 -1
  41. package/dist/options/EnumOption.d.ts +7 -7
  42. package/dist/options/EnumOption.js +3 -7
  43. package/dist/options/EnumOption.js.map +1 -1
  44. package/dist/options/Option.d.ts +9 -9
  45. package/dist/options/Option.js +1 -2
  46. package/dist/options/OptionSpecOf.d.ts +4 -4
  47. package/dist/options/OptionSpecOf.js +1 -2
  48. package/dist/options/OptionsSpec.d.ts +10 -10
  49. package/dist/options/OptionsSpec.js +1 -2
  50. package/dist/options/OptionsValidationError.d.ts +4 -4
  51. package/dist/options/OptionsValidationError.js +7 -28
  52. package/dist/options/OptionsValidationError.js.map +1 -1
  53. package/dist/options/PlayerIdSpec.d.ts +8 -8
  54. package/dist/options/PlayerIdSpec.js +12 -17
  55. package/dist/options/PlayerIdSpec.js.map +1 -1
  56. package/dist/options/PlayersOptionsSpec.d.ts +8 -8
  57. package/dist/options/PlayersOptionsSpec.js +1 -2
  58. package/dist/options/WithIdOption.d.ts +4 -4
  59. package/dist/options/WithIdOption.js +1 -2
  60. package/dist/options/WithPlayerOptionsSpec.d.ts +5 -5
  61. package/dist/options/WithPlayerOptionsSpec.js +1 -2
  62. package/dist/options/WithPlayersOptions.d.ts +4 -4
  63. package/dist/options/WithPlayersOptions.js +1 -2
  64. package/dist/options/getFallbackPlayerName.d.ts +4 -4
  65. package/dist/options/getFallbackPlayerName.js +9 -15
  66. package/dist/options/getFallbackPlayerName.js.map +1 -1
  67. package/dist/options/index.d.ts +13 -13
  68. package/dist/options/index.js +5 -29
  69. package/dist/options/index.js.map +1 -1
  70. package/dist/options/isWithPlayerIdOptions.d.ts +4 -4
  71. package/dist/options/isWithPlayerIdOptions.js +7 -10
  72. package/dist/options/isWithPlayerIdOptions.js.map +1 -1
  73. package/dist/options/providePlayerIds.d.ts +6 -6
  74. package/dist/options/providePlayerIds.js +22 -37
  75. package/dist/options/providePlayerIds.js.map +1 -1
  76. package/dist/utils/EnumUtils.d.ts +1 -1
  77. package/dist/utils/EnumUtils.js +3 -7
  78. package/dist/utils/EnumUtils.js.map +1 -1
  79. package/dist/utils/index.d.ts +1 -1
  80. package/dist/utils/index.js +1 -17
  81. package/dist/utils/index.js.map +1 -1
  82. package/package.json +3 -2
package/dist/Rules.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- export default abstract class Rules<Game = any, Move = any, PlayerId = any> {
2
- game: Game;
3
- constructor(game: Game);
4
- get state(): Game;
5
- delegate(): Rules<Game, Move, PlayerId> | undefined;
6
- delegates(): Rules<Game, Move, PlayerId>[];
7
- isTurnToPlay(playerId: PlayerId): boolean;
8
- getActivePlayer?(): PlayerId | undefined;
9
- isLegalMove(playerId: PlayerId, move: Move): boolean;
10
- getLegalMoves(playerId: PlayerId): Move[];
11
- getAutomaticMoves(): Move[];
12
- play(move: Move): Move[];
13
- isOver(playerIds?: PlayerId[]): boolean;
14
- }
1
+ export default abstract class Rules<Game = any, Move = any, PlayerId = any> {
2
+ game: Game;
3
+ constructor(game: Game);
4
+ get state(): Game;
5
+ delegate(): Rules<Game, Move, PlayerId> | undefined;
6
+ delegates(): Rules<Game, Move, PlayerId>[];
7
+ isTurnToPlay(playerId: PlayerId): boolean;
8
+ getActivePlayer?(): PlayerId | undefined;
9
+ isLegalMove(playerId: PlayerId, move: Move): boolean;
10
+ getLegalMoves(playerId: PlayerId): Move[];
11
+ getAutomaticMoves(): Move[];
12
+ play(move: Move): Move[];
13
+ isOver(playerIds?: PlayerId[]): boolean;
14
+ }
package/dist/Rules.js CHANGED
@@ -1,75 +1,64 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
7
- var Eliminations_1 = require("./Eliminations");
8
- var Rules = /** @class */ (function () {
9
- function Rules(game) {
10
- this.game = game;
11
- }
12
- Object.defineProperty(Rules.prototype, "state", {
13
- get: function () {
14
- return this.game;
15
- },
16
- enumerable: false,
17
- configurable: true
18
- });
19
- Rules.prototype.delegate = function () {
20
- return;
21
- };
22
- Rules.prototype.delegates = function () {
23
- var delegate = this.delegate();
24
- return delegate ? [delegate] : [];
25
- };
26
- Rules.prototype.isTurnToPlay = function (playerId) {
27
- var rules = this.delegates();
28
- if (rules.some(function (rules) { return rules.isTurnToPlay(playerId); })) {
29
- return true;
30
- }
31
- if (this.getActivePlayer) {
32
- return playerId === this.getActivePlayer();
33
- }
34
- return false;
35
- };
36
- Rules.prototype.isLegalMove = function (playerId, move) {
37
- var rules = this.delegates();
38
- if (rules.some(function (rules) { return rules.isLegalMove(playerId, move); })) {
39
- return true;
40
- }
41
- if (this.getLegalMoves(playerId).some(function (legalMove) { return (0, fast_deep_equal_1.default)(move, legalMove); })) {
42
- return true;
43
- }
44
- if ((0, Eliminations_1.hasEliminations)(this) && this.giveUpMove) {
45
- return (0, fast_deep_equal_1.default)(move, this.giveUpMove(playerId));
46
- }
47
- return false;
48
- };
49
- Rules.prototype.getLegalMoves = function (playerId) {
50
- return this.delegates().flatMap(function (rules) { return rules.getLegalMoves(playerId); });
51
- };
52
- Rules.prototype.getAutomaticMoves = function () {
53
- return this.delegates().flatMap(function (rules) { return rules.getAutomaticMoves(); });
54
- };
55
- Rules.prototype.play = function (move) {
56
- return this.delegates().flatMap(function (rules) { return rules.play(move); });
57
- };
58
- Rules.prototype.isOver = function (playerIds) {
59
- var _this = this;
60
- var delegates = this.delegates();
61
- if (delegates.length > 0 && delegates.every(function (delegate) { return delegate.isOver(playerIds); })) {
62
- return true;
63
- }
64
- if (playerIds) {
65
- return !playerIds.some(function (playerId) { return _this.isTurnToPlay(playerId); });
66
- }
67
- if (this.getActivePlayer) {
68
- return this.getActivePlayer() === undefined;
69
- }
70
- return false;
71
- };
72
- return Rules;
73
- }());
74
- exports.default = Rules;
1
+ import equal from 'fast-deep-equal';
2
+ import { hasEliminations } from './Eliminations';
3
+ export default class Rules {
4
+ game;
5
+ constructor(game) {
6
+ this.game = game;
7
+ }
8
+ get state() {
9
+ return this.game;
10
+ }
11
+ delegate() {
12
+ return;
13
+ }
14
+ delegates() {
15
+ const delegate = this.delegate();
16
+ return delegate ? [delegate] : [];
17
+ }
18
+ isTurnToPlay(playerId) {
19
+ const rules = this.delegates();
20
+ if (rules.some(rules => rules.isTurnToPlay(playerId))) {
21
+ return true;
22
+ }
23
+ if (this.getActivePlayer) {
24
+ return playerId === this.getActivePlayer();
25
+ }
26
+ return false;
27
+ }
28
+ isLegalMove(playerId, move) {
29
+ const rules = this.delegates();
30
+ if (rules.some(rules => rules.isLegalMove(playerId, move))) {
31
+ return true;
32
+ }
33
+ if (this.getLegalMoves(playerId).some(legalMove => equal(move, legalMove))) {
34
+ return true;
35
+ }
36
+ if (hasEliminations(this) && this.giveUpMove) {
37
+ return equal(move, this.giveUpMove(playerId));
38
+ }
39
+ return false;
40
+ }
41
+ getLegalMoves(playerId) {
42
+ return this.delegates().flatMap(rules => rules.getLegalMoves(playerId));
43
+ }
44
+ getAutomaticMoves() {
45
+ return this.delegates().flatMap(rules => rules.getAutomaticMoves());
46
+ }
47
+ play(move) {
48
+ return this.delegates().flatMap(rules => rules.play(move));
49
+ }
50
+ isOver(playerIds) {
51
+ const delegates = this.delegates();
52
+ if (delegates.length > 0 && delegates.every(delegate => delegate.isOver(playerIds))) {
53
+ return true;
54
+ }
55
+ if (playerIds) {
56
+ return !playerIds.some(playerId => this.isTurnToPlay(playerId));
57
+ }
58
+ if (this.getActivePlayer) {
59
+ return this.getActivePlayer() === undefined;
60
+ }
61
+ return false;
62
+ }
63
+ }
75
64
  //# sourceMappingURL=Rules.js.map
package/dist/Rules.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Rules.js","sourceRoot":"","sources":["../src/Rules.ts"],"names":[],"mappings":";;;;;AAAA,oEAAmC;AACnC,+CAA8C;AAE9C;IAGE,eAAY,IAAU;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,sBAAI,wBAAK;aAAT;YACE,OAAO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EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,eAAe,EAAE,KAAK,SAAS,CAAA;QAC7C,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF"}
@@ -1,5 +1,5 @@
1
- import Rules from './Rules';
2
- export default interface RulesCreator<Game = any, Move = any, PlayerId = number, Options = any> {
3
- new (state: Game): Rules<Game, Move, PlayerId>;
4
- new (options: Options): Rules<Game, Move, PlayerId>;
5
- }
1
+ import Rules from './Rules';
2
+ export default interface RulesCreator<Game = any, Move = any, PlayerId = number, Options = any> {
3
+ new (state: Game): Rules<Game, Move, PlayerId>;
4
+ new (options: Options): Rules<Game, Move, PlayerId>;
5
+ }
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=RulesCreator.js.map
@@ -1,18 +1,18 @@
1
- import Rules from './Rules';
2
- export default interface TimeLimit<Game, Move = string, PlayerId = number> extends Rules<Game, Move, PlayerId> {
3
- /**
4
- * Amount of time given to a player everytime it is their turn to play.
5
- * @param playerId Id of the player, if you want to give different time depending of the id for asymmetric games.
6
- */
7
- giveTime(playerId: PlayerId): number;
8
- /**
9
- * Amount of time given to a player before the game begins. Default value is 2 minutes.
10
- * @param playerId Id of the player, if you want to give different time depending of the id for asymmetric games.
11
- */
12
- startingTime?(playerId: PlayerId): number;
13
- }
14
- export declare function hasTimeLimit<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>): rules is TimeLimit<Game, Move, PlayerId>;
15
- export declare enum GameSpeed {
16
- Disabled = "Disabled",
17
- RealTime = "RealTime"
18
- }
1
+ import Rules from './Rules';
2
+ export default interface TimeLimit<Game, Move = string, PlayerId = number> extends Rules<Game, Move, PlayerId> {
3
+ /**
4
+ * Amount of time given to a player everytime it is their turn to play.
5
+ * @param playerId Id of the player, if you want to give different time depending of the id for asymmetric games.
6
+ */
7
+ giveTime(playerId: PlayerId): number;
8
+ /**
9
+ * Amount of time given to a player before the game begins. Default value is 2 minutes.
10
+ * @param playerId Id of the player, if you want to give different time depending of the id for asymmetric games.
11
+ */
12
+ startingTime?(playerId: PlayerId): number;
13
+ }
14
+ export declare function hasTimeLimit<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>): rules is TimeLimit<Game, Move, PlayerId>;
15
+ export declare enum GameSpeed {
16
+ Disabled = "Disabled",
17
+ RealTime = "RealTime"
18
+ }
package/dist/TimeLimit.js CHANGED
@@ -1,13 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GameSpeed = exports.hasTimeLimit = void 0;
4
- function hasTimeLimit(rules) {
5
- return typeof rules.giveTime === 'function';
6
- }
7
- exports.hasTimeLimit = hasTimeLimit;
8
- var GameSpeed;
9
- (function (GameSpeed) {
10
- GameSpeed["Disabled"] = "Disabled";
11
- GameSpeed["RealTime"] = "RealTime";
12
- })(GameSpeed = exports.GameSpeed || (exports.GameSpeed = {}));
1
+ export function hasTimeLimit(rules) {
2
+ return typeof rules.giveTime === 'function';
3
+ }
4
+ export var GameSpeed;
5
+ (function (GameSpeed) {
6
+ GameSpeed["Disabled"] = "Disabled";
7
+ GameSpeed["RealTime"] = "RealTime";
8
+ })(GameSpeed || (GameSpeed = {}));
13
9
  //# sourceMappingURL=TimeLimit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeLimit.js","sourceRoot":"","sources":["../src/TimeLimit.ts"],"names":[],"mappings":";;;AAgBA,SAAgB,YAAY,CAAuB,KAAkC;IACnF,OAAO,OAAQ,KAAyC,CAAC,QAAQ,KAAK,UAAU,CAAA;AAClF,CAAC;AAFD,oCAEC;AAED,IAAY,SAAwD;AAApE,WAAY,SAAS;IAAE,kCAAqB,CAAA;IAAE,kCAAqB,CAAA;AAAA,CAAC,EAAxD,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAA+C"}
1
+ {"version":3,"file":"TimeLimit.js","sourceRoot":"","sources":["../src/TimeLimit.ts"],"names":[],"mappings":"AAgBA,MAAM,UAAU,YAAY,CAAuB,KAAkC;IACnF,OAAO,OAAQ,KAAyC,CAAC,QAAQ,KAAK,UAAU,CAAA;AAClF,CAAC;AAED,MAAM,CAAN,IAAY,SAAwD;AAApE,WAAY,SAAS;IAAE,kCAAqB,CAAA;IAAE,kCAAqB,CAAA;AAAA,CAAC,EAAxD,SAAS,KAAT,SAAS,QAA+C"}
package/dist/Undo.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import Action from './Action';
2
- export default interface Undo<Game, Move = string, PlayerId = number> {
3
- canUndo(action: Action<Move, PlayerId>, consecutiveActions: Action<Move, PlayerId>[]): boolean;
4
- restoreLocalMoves?(localState: Game): void;
5
- }
6
- export declare function hasUndo<Game, Move, PlayerId>(rules: Object): rules is Undo<Game, Move, PlayerId>;
1
+ import Action from './Action';
2
+ export default interface Undo<Game, Move = string, PlayerId = number> {
3
+ canUndo(action: Action<Move, PlayerId>, consecutiveActions: Action<Move, PlayerId>[]): boolean;
4
+ restoreLocalMoves?(localState: Game): void;
5
+ }
6
+ export declare function hasUndo<Game, Move, PlayerId>(rules: Object): rules is Undo<Game, Move, PlayerId>;
package/dist/Undo.js CHANGED
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasUndo = void 0;
4
- function hasUndo(rules) {
5
- var test = rules;
6
- return typeof test.canUndo === 'function';
7
- }
8
- exports.hasUndo = hasUndo;
1
+ export function hasUndo(rules) {
2
+ const test = rules;
3
+ return typeof test.canUndo === 'function';
4
+ }
9
5
  //# sourceMappingURL=Undo.js.map
package/dist/Undo.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Undo.js","sourceRoot":"","sources":["../src/Undo.ts"],"names":[],"mappings":";;;AAOA,SAAgB,OAAO,CAAuB,KAAa;IACzD,IAAM,IAAI,GAAG,KAAmC,CAAA;IAChD,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,CAAA;AAC3C,CAAC;AAHD,0BAGC"}
1
+ {"version":3,"file":"Undo.js","sourceRoot":"","sources":["../src/Undo.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,OAAO,CAAuB,KAAa;IACzD,MAAM,IAAI,GAAG,KAAmC,CAAA;IAChD,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,CAAA;AAC3C,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,22 +1,22 @@
1
- export { default as Rules } from './Rules';
2
- export { default as RulesCreator } from './RulesCreator';
3
- export { default as Action } from './Action';
4
- export * from './Action';
5
- export { default as IncompleteInformation } from './IncompleteInformation';
6
- export * from './IncompleteInformation';
7
- export { default as Undo } from './Undo';
8
- export * from './Undo';
9
- export { default as Competitive } from './Competitive';
10
- export * from './Competitive';
11
- export { default as Eliminations } from './Eliminations';
12
- export * from './Eliminations';
13
- export { default as RandomMove } from './RandomMove';
14
- export * from './Eliminations';
15
- export { default as TimeLimit } from './TimeLimit';
16
- export * from './TimeLimit';
17
- export { default as Robot } from './Robot';
18
- export { default as Dummy } from './Dummy';
19
- export * from './options';
20
- export * from './utils';
21
- export { applyAutomaticMoves } from './ApplyAutomaticMoves';
22
- export { loopWithFuse } from './LoopWithFuse';
1
+ export { default as Rules } from './Rules';
2
+ export { default as RulesCreator } from './RulesCreator';
3
+ export { default as Action } from './Action';
4
+ export * from './Action';
5
+ export { default as IncompleteInformation } from './IncompleteInformation';
6
+ export * from './IncompleteInformation';
7
+ export { default as Undo } from './Undo';
8
+ export * from './Undo';
9
+ export { default as Competitive } from './Competitive';
10
+ export * from './Competitive';
11
+ export { default as Eliminations } from './Eliminations';
12
+ export * from './Eliminations';
13
+ export { default as RandomMove } from './RandomMove';
14
+ export * from './Eliminations';
15
+ export { default as TimeLimit } from './TimeLimit';
16
+ export * from './TimeLimit';
17
+ export { default as Robot } from './Robot';
18
+ export { default as Dummy } from './Dummy';
19
+ export * from './options';
20
+ export * from './utils';
21
+ export { applyAutomaticMoves } from './ApplyAutomaticMoves';
22
+ export { loopWithFuse } from './LoopWithFuse';
package/dist/index.js CHANGED
@@ -1,38 +1,14 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.loopWithFuse = exports.applyAutomaticMoves = exports.Dummy = exports.Rules = void 0;
21
- var Rules_1 = require("./Rules");
22
- Object.defineProperty(exports, "Rules", { enumerable: true, get: function () { return __importDefault(Rules_1).default; } });
23
- __exportStar(require("./Action"), exports);
24
- __exportStar(require("./IncompleteInformation"), exports);
25
- __exportStar(require("./Undo"), exports);
26
- __exportStar(require("./Competitive"), exports);
27
- __exportStar(require("./Eliminations"), exports);
28
- __exportStar(require("./Eliminations"), exports);
29
- __exportStar(require("./TimeLimit"), exports);
30
- var Dummy_1 = require("./Dummy");
31
- Object.defineProperty(exports, "Dummy", { enumerable: true, get: function () { return __importDefault(Dummy_1).default; } });
32
- __exportStar(require("./options"), exports);
33
- __exportStar(require("./utils"), exports);
34
- var ApplyAutomaticMoves_1 = require("./ApplyAutomaticMoves");
35
- Object.defineProperty(exports, "applyAutomaticMoves", { enumerable: true, get: function () { return ApplyAutomaticMoves_1.applyAutomaticMoves; } });
36
- var LoopWithFuse_1 = require("./LoopWithFuse");
37
- Object.defineProperty(exports, "loopWithFuse", { enumerable: true, get: function () { return LoopWithFuse_1.loopWithFuse; } });
1
+ export { default as Rules } from './Rules';
2
+ export * from './Action';
3
+ export * from './IncompleteInformation';
4
+ export * from './Undo';
5
+ export * from './Competitive';
6
+ export * from './Eliminations';
7
+ export * from './Eliminations';
8
+ export * from './TimeLimit';
9
+ export { default as Dummy } from './Dummy';
10
+ export * from './options';
11
+ export * from './utils';
12
+ export { applyAutomaticMoves } from './ApplyAutomaticMoves';
13
+ export { loopWithFuse } from './LoopWithFuse';
38
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,iCAAwC;AAAhC,+GAAA,OAAO,OAAS;AAIxB,2CAAwB;AAGxB,0DAAuC;AAGvC,yCAAsB;AAGtB,gDAA6B;AAG7B,iDAA8B;AAG9B,iDAA8B;AAG9B,8CAA2B;AAG3B,iCAAwC;AAAhC,+GAAA,OAAO,OAAS;AAExB,4CAAyB;AACzB,0CAAuB;AACvB,6DAAyD;AAAjD,0HAAA,mBAAmB,OAAA;AAC3B,+CAA2C;AAAnC,4GAAA,YAAY,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,SAAS,CAAA;AAIxC,cAAc,UAAU,CAAA;AAGxB,cAAc,yBAAyB,CAAA;AAGvC,cAAc,QAAQ,CAAA;AAGtB,cAAc,eAAe,CAAA;AAG7B,cAAc,gBAAgB,CAAA;AAG9B,cAAc,gBAAgB,CAAA;AAG9B,cAAc,aAAa,CAAA;AAG3B,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,SAAS,CAAA;AAExC,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA"}
@@ -1,7 +1,7 @@
1
- import Option from './Option';
2
- declare type EnumOption<T = any> = Option & {
3
- values: T[];
4
- valueSpec: (value: T) => Option;
5
- };
6
- export default EnumOption;
7
- export declare function isEnumOption<T = any>(option: Option): option is EnumOption<T>;
1
+ import Option from './Option';
2
+ type EnumOption<T = any> = Option & {
3
+ values: T[];
4
+ valueSpec: (value: T) => Option;
5
+ };
6
+ export default EnumOption;
7
+ export declare function isEnumOption<T = any>(option: Option): option is EnumOption<T>;
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEnumOption = void 0;
4
- function isEnumOption(option) {
5
- return Array.isArray(option.values);
6
- }
7
- exports.isEnumOption = isEnumOption;
1
+ export function isEnumOption(option) {
2
+ return Array.isArray(option.values);
3
+ }
8
4
  //# sourceMappingURL=EnumOption.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EnumOption.js","sourceRoot":"","sources":["../../src/options/EnumOption.ts"],"names":[],"mappings":";;;AASA,SAAgB,YAAY,CAAU,MAAc;IAClD,OAAO,KAAK,CAAC,OAAO,CAAE,MAAqB,CAAC,MAAM,CAAC,CAAA;AACrD,CAAC;AAFD,oCAEC"}
1
+ {"version":3,"file":"EnumOption.js","sourceRoot":"","sources":["../../src/options/EnumOption.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,YAAY,CAAU,MAAc;IAClD,OAAO,KAAK,CAAC,OAAO,CAAE,MAAqB,CAAC,MAAM,CAAC,CAAA;AACrD,CAAC"}
@@ -1,9 +1,9 @@
1
- import { TFunction } from 'i18next';
2
- declare type Option = {
3
- label: (t: TFunction) => string;
4
- help?: (t: TFunction) => string;
5
- warn?: (t: TFunction) => string;
6
- subscriberRequired?: boolean;
7
- competitiveDisabled?: boolean;
8
- };
9
- export default Option;
1
+ import { TFunction } from 'i18next';
2
+ type Option = {
3
+ label: (t: TFunction) => string;
4
+ help?: (t: TFunction) => string;
5
+ warn?: (t: TFunction) => string;
6
+ subscriberRequired?: boolean;
7
+ competitiveDisabled?: boolean;
8
+ };
9
+ export default Option;
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=Option.js.map
@@ -1,4 +1,4 @@
1
- import EnumOption from './EnumOption';
2
- import Option from './Option';
3
- declare type OptionSpecOf<T> = [T] extends [boolean] ? Option : EnumOption<T>;
4
- export default OptionSpecOf;
1
+ import EnumOption from './EnumOption';
2
+ import Option from './Option';
3
+ type OptionSpecOf<T> = [T] extends [boolean] ? Option : EnumOption<T>;
4
+ export default OptionSpecOf;
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=OptionSpecOf.js.map
@@ -1,10 +1,10 @@
1
- import { TFunction } from 'i18next';
2
- import OptionSpecOf from './OptionSpecOf';
3
- import WithPlayerOptionsSpec from './WithPlayerOptionsSpec';
4
- import WithPlayersOptions from './WithPlayersOptions';
5
- declare type OptionsSpec<Options> = (Options extends WithPlayersOptions<infer P> ? WithPlayerOptionsSpec<P> : {}) & {
6
- [key in keyof Omit<Options, 'players'>]: OptionSpecOf<Options[key]>;
7
- } & {
8
- validate?: (options: Partial<Options>, t: TFunction) => void;
9
- };
10
- export default OptionsSpec;
1
+ import { TFunction } from 'i18next';
2
+ import OptionSpecOf from './OptionSpecOf';
3
+ import WithPlayerOptionsSpec from './WithPlayerOptionsSpec';
4
+ import WithPlayersOptions from './WithPlayersOptions';
5
+ type OptionsSpec<Options> = (Options extends WithPlayersOptions<infer P> ? WithPlayerOptionsSpec<P> : {}) & {
6
+ [key in keyof Omit<Options, 'players'>]: OptionSpecOf<Options[key]>;
7
+ } & {
8
+ validate?: (options: Partial<Options>, t: TFunction) => void;
9
+ };
10
+ export default OptionsSpec;
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=OptionsSpec.js.map
@@ -1,4 +1,4 @@
1
- export default class OptionsValidationError extends Error {
2
- fields: string[];
3
- constructor(message: string, fields?: string[]);
4
- }
1
+ export default class OptionsValidationError extends Error {
2
+ fields: string[];
3
+ constructor(message: string, fields?: string[]);
4
+ }
@@ -1,29 +1,8 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
18
- var OptionsValidationError = /** @class */ (function (_super) {
19
- __extends(OptionsValidationError, _super);
20
- function OptionsValidationError(message, fields) {
21
- if (fields === void 0) { fields = []; }
22
- var _this = _super.call(this, message) || this;
23
- _this.fields = fields;
24
- return _this;
25
- }
26
- return OptionsValidationError;
27
- }(Error));
28
- exports.default = OptionsValidationError;
1
+ export default class OptionsValidationError extends Error {
2
+ fields;
3
+ constructor(message, fields = []) {
4
+ super(message);
5
+ this.fields = fields;
6
+ }
7
+ }
29
8
  //# sourceMappingURL=OptionsValidationError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OptionsValidationError.js","sourceRoot":"","sources":["../../src/options/OptionsValidationError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;IAAoD,0CAAK;IAGvD,gCAAY,OAAe,EAAE,MAAqB;QAArB,uBAAA,EAAA,WAAqB;QAAlD,YACE,kBAAM,OAAO,CAAC,SAEf;QADC,KAAI,CAAC,MAAM,GAAG,MAAM,CAAA;;IACtB,CAAC;IACH,6BAAC;AAAD,CAAC,AAPD,CAAoD,KAAK,GAOxD"}
1
+ {"version":3,"file":"OptionsValidationError.js","sourceRoot":"","sources":["../../src/options/OptionsValidationError.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,KAAK;IACvD,MAAM,CAAU;IAEhB,YAAY,OAAe,EAAE,SAAmB,EAAE;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;CACF"}
@@ -1,8 +1,8 @@
1
- import EnumOption from './EnumOption';
2
- declare type PlayerIdSpec<Id> = EnumOption<Id> & {
3
- mandatory?: (players: number) => Id[];
4
- unavailable?: (players: number) => Id[];
5
- };
6
- export default PlayerIdSpec;
7
- export declare function getMandatoryIds<Id>(spec: PlayerIdSpec<Id>, players: number): Id[];
8
- export declare function getAvailableIds<Id>(spec: PlayerIdSpec<Id>, players: number): Id[];
1
+ import EnumOption from './EnumOption';
2
+ type PlayerIdSpec<Id> = EnumOption<Id> & {
3
+ mandatory?: (players: number) => Id[];
4
+ unavailable?: (players: number) => Id[];
5
+ };
6
+ export default PlayerIdSpec;
7
+ export declare function getMandatoryIds<Id>(spec: PlayerIdSpec<Id>, players: number): Id[];
8
+ export declare function getAvailableIds<Id>(spec: PlayerIdSpec<Id>, players: number): Id[];
@@ -1,18 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAvailableIds = exports.getMandatoryIds = void 0;
4
- function getMandatoryIds(spec, players) {
5
- return spec.mandatory ? spec.mandatory(players) : [];
6
- }
7
- exports.getMandatoryIds = getMandatoryIds;
8
- function getAvailableIds(spec, players) {
9
- if (spec.unavailable) {
10
- var unavailableIds_1 = spec.unavailable(players);
11
- return spec.values.filter(function (id) { return !unavailableIds_1.includes(id); });
12
- }
13
- else {
14
- return spec.values;
15
- }
16
- }
17
- exports.getAvailableIds = getAvailableIds;
1
+ export function getMandatoryIds(spec, players) {
2
+ return spec.mandatory ? spec.mandatory(players) : [];
3
+ }
4
+ export function getAvailableIds(spec, players) {
5
+ if (spec.unavailable) {
6
+ const unavailableIds = spec.unavailable(players);
7
+ return spec.values.filter(id => !unavailableIds.includes(id));
8
+ }
9
+ else {
10
+ return spec.values;
11
+ }
12
+ }
18
13
  //# sourceMappingURL=PlayerIdSpec.js.map