@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.
- package/dist/Action.d.ts +25 -25
- package/dist/Action.js +45 -55
- package/dist/Action.js.map +1 -1
- package/dist/ApplyAutomaticMoves.d.ts +2 -2
- package/dist/ApplyAutomaticMoves.js +18 -24
- package/dist/ApplyAutomaticMoves.js.map +1 -1
- package/dist/Competitive.d.ts +6 -6
- package/dist/Competitive.js +3 -7
- package/dist/Competitive.js.map +1 -1
- package/dist/Dummy.d.ts +7 -7
- package/dist/Dummy.js +22 -25
- package/dist/Dummy.js.map +1 -1
- package/dist/Eliminations.d.ts +5 -5
- package/dist/Eliminations.js +4 -8
- package/dist/Eliminations.js.map +1 -1
- package/dist/IncompleteInformation.d.ts +14 -14
- package/dist/IncompleteInformation.js +30 -37
- package/dist/IncompleteInformation.js.map +1 -1
- package/dist/LoopWithFuse.d.ts +4 -4
- package/dist/LoopWithFuse.js +10 -14
- package/dist/LoopWithFuse.js.map +1 -1
- package/dist/RandomMove.d.ts +7 -7
- package/dist/RandomMove.js +7 -12
- package/dist/RandomMove.js.map +1 -1
- package/dist/Robot.d.ts +2 -2
- package/dist/Robot.js +1 -2
- package/dist/Rules.d.ts +14 -14
- package/dist/Rules.js +63 -74
- package/dist/Rules.js.map +1 -1
- package/dist/RulesCreator.d.ts +5 -5
- package/dist/RulesCreator.js +1 -2
- package/dist/TimeLimit.d.ts +18 -18
- package/dist/TimeLimit.js +8 -12
- package/dist/TimeLimit.js.map +1 -1
- package/dist/Undo.d.ts +6 -6
- package/dist/Undo.js +4 -8
- package/dist/Undo.js.map +1 -1
- package/dist/index.d.ts +22 -22
- package/dist/index.js +13 -37
- package/dist/index.js.map +1 -1
- package/dist/options/EnumOption.d.ts +7 -7
- package/dist/options/EnumOption.js +3 -7
- package/dist/options/EnumOption.js.map +1 -1
- package/dist/options/Option.d.ts +9 -9
- package/dist/options/Option.js +1 -2
- package/dist/options/OptionSpecOf.d.ts +4 -4
- package/dist/options/OptionSpecOf.js +1 -2
- package/dist/options/OptionsSpec.d.ts +10 -10
- package/dist/options/OptionsSpec.js +1 -2
- package/dist/options/OptionsValidationError.d.ts +4 -4
- package/dist/options/OptionsValidationError.js +7 -28
- package/dist/options/OptionsValidationError.js.map +1 -1
- package/dist/options/PlayerIdSpec.d.ts +8 -8
- package/dist/options/PlayerIdSpec.js +12 -17
- package/dist/options/PlayerIdSpec.js.map +1 -1
- package/dist/options/PlayersOptionsSpec.d.ts +8 -8
- package/dist/options/PlayersOptionsSpec.js +1 -2
- package/dist/options/WithIdOption.d.ts +4 -4
- package/dist/options/WithIdOption.js +1 -2
- package/dist/options/WithPlayerOptionsSpec.d.ts +5 -5
- package/dist/options/WithPlayerOptionsSpec.js +1 -2
- package/dist/options/WithPlayersOptions.d.ts +4 -4
- package/dist/options/WithPlayersOptions.js +1 -2
- package/dist/options/getFallbackPlayerName.d.ts +4 -4
- package/dist/options/getFallbackPlayerName.js +9 -15
- package/dist/options/getFallbackPlayerName.js.map +1 -1
- package/dist/options/index.d.ts +13 -13
- package/dist/options/index.js +5 -29
- package/dist/options/index.js.map +1 -1
- package/dist/options/isWithPlayerIdOptions.d.ts +4 -4
- package/dist/options/isWithPlayerIdOptions.js +7 -10
- package/dist/options/isWithPlayerIdOptions.js.map +1 -1
- package/dist/options/providePlayerIds.d.ts +6 -6
- package/dist/options/providePlayerIds.js +22 -37
- package/dist/options/providePlayerIds.js.map +1 -1
- package/dist/utils/EnumUtils.d.ts +1 -1
- package/dist/utils/EnumUtils.js +3 -7
- package/dist/utils/EnumUtils.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -17
- package/dist/utils/index.js.map +1 -1
- 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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"Rules.js","sourceRoot":"","sources":["../src/Rules.ts"],"names":[],"mappings":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AAK,SAAS,CAAA;QAC7C,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF"}
|
package/dist/RulesCreator.d.ts
CHANGED
|
@@ -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
|
+
}
|
package/dist/RulesCreator.js
CHANGED
package/dist/TimeLimit.d.ts
CHANGED
|
@@ -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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
package/dist/TimeLimit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeLimit.js","sourceRoot":"","sources":["../src/TimeLimit.ts"],"names":[],"mappings":"
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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":"
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
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":"
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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":"
|
|
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"}
|
package/dist/options/Option.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { TFunction } from 'i18next';
|
|
2
|
-
|
|
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;
|
package/dist/options/Option.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import EnumOption from './EnumOption';
|
|
2
|
-
import Option from './Option';
|
|
3
|
-
|
|
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,10 +1,10 @@
|
|
|
1
|
-
import { TFunction } from 'i18next';
|
|
2
|
-
import OptionSpecOf from './OptionSpecOf';
|
|
3
|
-
import WithPlayerOptionsSpec from './WithPlayerOptionsSpec';
|
|
4
|
-
import WithPlayersOptions from './WithPlayersOptions';
|
|
5
|
-
|
|
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,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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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":"
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|