@gamepark/rules-api 5.19.0 → 5.21.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 +5 -5
- package/dist/Action.js +19 -19
- package/dist/Action.js.map +1 -1
- package/dist/ApplyAutomaticMoves.d.ts +2 -0
- package/dist/ApplyAutomaticMoves.js +25 -0
- package/dist/ApplyAutomaticMoves.js.map +1 -0
- package/dist/Competitive.d.ts +1 -1
- package/dist/Dummy.d.ts +5 -5
- package/dist/Dummy.js.map +1 -1
- package/dist/Eliminations.d.ts +2 -3
- package/dist/Eliminations.js +3 -3
- package/dist/Eliminations.js.map +1 -1
- package/dist/IncompleteInformation.d.ts +8 -8
- package/dist/IncompleteInformation.js +18 -12
- package/dist/IncompleteInformation.js.map +1 -1
- package/dist/LoopWithFuse.d.ts +4 -0
- package/dist/LoopWithFuse.js +15 -0
- package/dist/LoopWithFuse.js.map +1 -0
- package/dist/RandomMove.d.ts +6 -6
- package/dist/RandomMove.js +5 -4
- package/dist/RandomMove.js.map +1 -1
- package/dist/Robot.d.ts +1 -1
- package/dist/Rules.d.ts +10 -6
- package/dist/Rules.js +47 -6
- package/dist/Rules.js.map +1 -1
- package/dist/RulesCreator.d.ts +3 -3
- package/dist/TimeLimit.d.ts +2 -2
- package/dist/TimeLimit.js.map +1 -1
- package/dist/Undo.d.ts +3 -4
- package/dist/Undo.js +3 -2
- package/dist/Undo.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/Game.d.ts +0 -10
- package/dist/Game.js +0 -35
- package/dist/Game.js.map +0 -1
- package/dist/GameCreator.d.ts +0 -4
- package/dist/GameCreator.js +0 -3
- package/dist/GameCreator.js.map +0 -1
- package/dist/SequentialGame.d.ts +0 -11
- package/dist/SequentialGame.js +0 -42
- package/dist/SequentialGame.js.map +0 -1
- package/dist/SimultaneousGame.d.ts +0 -11
- package/dist/SimultaneousGame.js +0 -34
- package/dist/SimultaneousGame.js.map +0 -1
package/dist/Action.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Game from './Game';
|
|
2
1
|
import { IncompleteInformation } from './index';
|
|
2
|
+
import Rules from './Rules';
|
|
3
3
|
declare type Action<Move = any, PlayerId = any> = {
|
|
4
4
|
id?: string;
|
|
5
5
|
playerId: PlayerId;
|
|
@@ -7,7 +7,7 @@ declare type Action<Move = any, PlayerId = any> = {
|
|
|
7
7
|
consequences: Move[];
|
|
8
8
|
};
|
|
9
9
|
export default Action;
|
|
10
|
-
export declare function playAction<
|
|
10
|
+
export declare function playAction<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>, move: Move, playerId: PlayerId, id?: string): Action<Move, PlayerId>;
|
|
11
11
|
export declare type ActionWithViews<Move = any, MoveView = Move, PlayerId = any> = {
|
|
12
12
|
action: Action<Move, PlayerId>;
|
|
13
13
|
views: ActionView<MoveView, PlayerId>[];
|
|
@@ -16,9 +16,9 @@ export declare type ActionView<MoveView = any, PlayerId = any> = {
|
|
|
16
16
|
recipient?: PlayerId;
|
|
17
17
|
action: Action<MoveView, PlayerId>;
|
|
18
18
|
};
|
|
19
|
-
export declare function playActionWithViews<
|
|
20
|
-
export declare function replayAction<
|
|
21
|
-
export declare function replayActions<
|
|
19
|
+
export declare function playActionWithViews<Game, View, Move, MoveView, PlayerId>(rules: Rules<Game, Move, PlayerId> & IncompleteInformation<View, Move, MoveView>, move: Move, playerId: PlayerId, recipients: PlayerId[], id?: string): ActionWithViews<Move, MoveView, PlayerId>;
|
|
20
|
+
export declare function replayAction<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>, action: Action<Move, PlayerId>): void;
|
|
21
|
+
export declare function replayActions<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>, actions: Action<Move, PlayerId>[]): void;
|
|
22
22
|
export declare type SecretAction<Move = any, MoveView = Move, PlayerId = any> = Action<Move, PlayerId> & {
|
|
23
23
|
secrets: ActionView<MoveView, PlayerId>[];
|
|
24
24
|
};
|
package/dist/Action.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isSecretAction = exports.replayActions = exports.replayAction = exports.playActionWithViews = exports.playAction = void 0;
|
|
4
|
-
var Game_1 = require("./Game");
|
|
5
4
|
var index_1 = require("./index");
|
|
6
5
|
var RandomMove_1 = require("./RandomMove");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
var ApplyAutomaticMoves_1 = require("./ApplyAutomaticMoves");
|
|
7
|
+
function playAction(rules, move, playerId, id) {
|
|
8
|
+
if ((0, RandomMove_1.hasRandomMove)(rules)) {
|
|
9
|
+
move = rules.randomize(move);
|
|
10
10
|
}
|
|
11
11
|
var action = { id: id, playerId: playerId, move: move, consequences: [] };
|
|
12
|
-
|
|
13
|
-
(0,
|
|
12
|
+
rules.play(JSON.parse(JSON.stringify(move)));
|
|
13
|
+
(0, ApplyAutomaticMoves_1.applyAutomaticMoves)(rules, function (move) { return action.consequences.push(move); });
|
|
14
14
|
return action;
|
|
15
15
|
}
|
|
16
16
|
exports.playAction = playAction;
|
|
17
|
-
function playActionWithViews(
|
|
18
|
-
if ((0, RandomMove_1.hasRandomMove)(
|
|
19
|
-
move =
|
|
17
|
+
function playActionWithViews(rules, move, playerId, recipients, id) {
|
|
18
|
+
if ((0, RandomMove_1.hasRandomMove)(rules)) {
|
|
19
|
+
move = rules.randomize(move);
|
|
20
20
|
}
|
|
21
21
|
var actionWithView = {
|
|
22
22
|
action: { id: id, playerId: playerId, move: move, consequences: [] },
|
|
@@ -25,28 +25,28 @@ function playActionWithViews(game, move, playerId, recipients, id) {
|
|
|
25
25
|
// Prepare action view for each player
|
|
26
26
|
for (var _i = 0, recipients_1 = recipients; _i < recipients_1.length; _i++) {
|
|
27
27
|
var recipient = recipients_1[_i];
|
|
28
|
-
actionWithView.views.push({ recipient: recipient, action: { id: id, playerId: playerId, move: (0, index_1.getMoveView)(
|
|
28
|
+
actionWithView.views.push({ recipient: recipient, action: { id: id, playerId: playerId, move: (0, index_1.getMoveView)(rules, move, recipient), consequences: [] } });
|
|
29
29
|
}
|
|
30
30
|
// Prepare action view for spectators
|
|
31
|
-
actionWithView.views.push({ action: { id: id, playerId: playerId, move: (0, index_1.getMoveView)(
|
|
32
|
-
|
|
33
|
-
(0,
|
|
31
|
+
actionWithView.views.push({ action: { id: id, playerId: playerId, move: (0, index_1.getMoveView)(rules, move), consequences: [] } });
|
|
32
|
+
rules.play(JSON.parse(JSON.stringify(move)));
|
|
33
|
+
(0, ApplyAutomaticMoves_1.applyAutomaticMoves)(rules, function (move) {
|
|
34
34
|
actionWithView.action.consequences.push(move);
|
|
35
35
|
for (var _i = 0, _a = actionWithView.views; _i < _a.length; _i++) {
|
|
36
36
|
var view = _a[_i];
|
|
37
|
-
view.action.consequences.push((0, index_1.getMoveView)(
|
|
37
|
+
view.action.consequences.push((0, index_1.getMoveView)(rules, move, view.recipient));
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
return actionWithView;
|
|
41
41
|
}
|
|
42
42
|
exports.playActionWithViews = playActionWithViews;
|
|
43
|
-
function replayAction(
|
|
44
|
-
|
|
45
|
-
action.consequences.forEach(function (move) { return
|
|
43
|
+
function replayAction(rules, action) {
|
|
44
|
+
rules.play(JSON.parse(JSON.stringify(action.move)));
|
|
45
|
+
action.consequences.forEach(function (move) { return rules.play(JSON.parse(JSON.stringify(move))); });
|
|
46
46
|
}
|
|
47
47
|
exports.replayAction = replayAction;
|
|
48
|
-
function replayActions(
|
|
49
|
-
actions.forEach(function (action) { return replayAction(
|
|
48
|
+
function replayActions(rules, actions) {
|
|
49
|
+
actions.forEach(function (action) { return replayAction(rules, action); });
|
|
50
50
|
}
|
|
51
51
|
exports.replayActions = replayActions;
|
|
52
52
|
function isSecretAction(action) {
|
package/dist/Action.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Action.js","sourceRoot":"","sources":["../src/Action.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"Action.js","sourceRoot":"","sources":["../src/Action.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyAutomaticMoves = void 0;
|
|
4
|
+
var RandomMove_1 = require("./RandomMove");
|
|
5
|
+
var LoopWithFuse_1 = require("./LoopWithFuse");
|
|
6
|
+
function applyAutomaticMoves(rules, preprocessMove) {
|
|
7
|
+
var moves = [];
|
|
8
|
+
(0, LoopWithFuse_1.loopWithFuse)(function () {
|
|
9
|
+
if (moves.length === 0 && rules.getAutomaticMoves) {
|
|
10
|
+
moves.push.apply(moves, (0, RandomMove_1.randomizeMoves)(rules, rules.getAutomaticMoves()));
|
|
11
|
+
}
|
|
12
|
+
var move = moves.shift();
|
|
13
|
+
if (move) {
|
|
14
|
+
if (preprocessMove)
|
|
15
|
+
preprocessMove(move);
|
|
16
|
+
rules.play(JSON.parse(JSON.stringify(move)));
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}, { errorFn: function () { return new Error("Infinite loop detected while applying move consequences: ".concat(JSON.stringify(rules.getAutomaticMoves()), ")")); } });
|
|
23
|
+
}
|
|
24
|
+
exports.applyAutomaticMoves = applyAutomaticMoves;
|
|
25
|
+
//# sourceMappingURL=ApplyAutomaticMoves.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplyAutomaticMoves.js","sourceRoot":"","sources":["../src/ApplyAutomaticMoves.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAC3C,+CAA2C;AAG3C,SAAgB,mBAAmB,CAAuB,KAAkC,EAAE,cAAqC;IACjI,IAAM,KAAK,GAAW,EAAE,CAAA;IACxB,IAAA,2BAAY,EAAC;QACX,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,iBAAiB,EAAE;YACjD,KAAK,CAAC,IAAI,OAAV,KAAK,EAAS,IAAA,2BAAc,EAAC,KAAK,EAAE,KAAK,CAAC,iBAAiB,EAAE,CAAC,EAAC;SAChE;QACD,IAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAA;QAC1B,IAAI,IAAI,EAAE;YACR,IAAI,cAAc;gBAAE,cAAc,CAAC,IAAI,CAAC,CAAA;YACxC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAC5C,OAAO,IAAI,CAAA;SACZ;aAAM;YACL,OAAO,KAAK,CAAA;SACb;IACH,CAAC,EAAE,EAAC,OAAO,EAAE,cAAM,OAAA,IAAI,KAAK,CAAC,mEAA4D,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,iBAAkB,EAAE,CAAC,MAAG,CAAC,EAApH,CAAoH,EAAC,CAAC,CAAA;AAC3I,CAAC;AAfD,kDAeC"}
|
package/dist/Competitive.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Rules from './Rules';
|
|
2
|
-
export default interface Competitive<
|
|
2
|
+
export default interface Competitive<Game, Move = string, PlayerId = number> extends Rules<Game, Move, PlayerId> {
|
|
3
3
|
rankPlayers(playerA: PlayerId, playerB: PlayerId): number;
|
|
4
4
|
getScore?(playerId: PlayerId): number;
|
|
5
5
|
}
|
package/dist/Dummy.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import RulesCreator from './RulesCreator';
|
|
2
|
-
export default class Dummy<
|
|
3
|
-
Rules: RulesCreator<
|
|
4
|
-
constructor(Rules: RulesCreator<
|
|
5
|
-
getRandomMove(state:
|
|
6
|
-
getLegalMoves(state:
|
|
2
|
+
export default class Dummy<Game, Move = string, PlayerId = number> {
|
|
3
|
+
Rules: RulesCreator<Game, Move, PlayerId>;
|
|
4
|
+
constructor(Rules: RulesCreator<Game, Move, PlayerId>);
|
|
5
|
+
getRandomMove(state: Game, playerId: PlayerId): Promise<Move[]>;
|
|
6
|
+
getLegalMoves(state: Game, playerId: PlayerId): Move[];
|
|
7
7
|
}
|
package/dist/Dummy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dummy.js","sourceRoot":"","sources":["../src/Dummy.ts"],"names":[],"mappings":";;AAEA;IAIE,eAAY,
|
|
1
|
+
{"version":3,"file":"Dummy.js","sourceRoot":"","sources":["../src/Dummy.ts"],"names":[],"mappings":";;AAEA;IAIE,eAAY,KAAyC;QACnD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,6BAAa,GAAb,UAAc,KAAW,EAAE,QAAkB;QAC3C,IAAI,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QAC/C,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAC7C,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3E,CAAC;IAED,6BAAa,GAAb,UAAc,KAAW,EAAE,QAAkB;QAC3C,IAAM,KAAK,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACnC,IAAI,KAAK,CAAC,aAAa,EAAE;YACvB,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;SACrC;aAAM;YACL,OAAO,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAA;YAC9E,OAAO,EAAE,CAAA;SACV;IACH,CAAC;IACH,YAAC;AAAD,CAAC,AAvBD,IAuBC"}
|
package/dist/Eliminations.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export default interface Eliminations<State, Move = string, PlayerId = number> extends Game<State, Move> {
|
|
1
|
+
export default interface Eliminations<Move = string, PlayerId = number> {
|
|
3
2
|
isEliminated(playerId: PlayerId): boolean;
|
|
4
3
|
giveUpMove?(playerId: PlayerId): Move | undefined;
|
|
5
4
|
}
|
|
6
|
-
export declare function hasEliminations<
|
|
5
|
+
export declare function hasEliminations<Move, PlayerId>(rules: Object): rules is Eliminations<Move, PlayerId>;
|
package/dist/Eliminations.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasEliminations = void 0;
|
|
4
|
-
function hasEliminations(
|
|
5
|
-
var
|
|
6
|
-
return typeof
|
|
4
|
+
function hasEliminations(rules) {
|
|
5
|
+
var test = rules;
|
|
6
|
+
return typeof test.isEliminated === 'function';
|
|
7
7
|
}
|
|
8
8
|
exports.hasEliminations = hasEliminations;
|
|
9
9
|
//# sourceMappingURL=Eliminations.js.map
|
package/dist/Eliminations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Eliminations.js","sourceRoot":"","sources":["../src/Eliminations.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Eliminations.js","sourceRoot":"","sources":["../src/Eliminations.ts"],"names":[],"mappings":";;;AAMA,SAAgB,eAAe,CAAiB,KAAa;IAC3D,IAAM,IAAI,GAAG,KAAqC,CAAA;IAClD,OAAO,OAAO,IAAI,CAAC,YAAY,KAAK,UAAU,CAAA;AAChD,CAAC;AAHD,0CAGC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import Rules from './Rules';
|
|
2
|
-
export default interface IncompleteInformation<
|
|
3
|
-
getView():
|
|
2
|
+
export default interface IncompleteInformation<GameView = any, Move = any, MoveView = any> {
|
|
3
|
+
getView(): GameView;
|
|
4
4
|
getMoveView(move: Move): MoveView;
|
|
5
5
|
}
|
|
6
|
-
export declare function hasIncompleteInformation<
|
|
7
|
-
export interface SecretInformation<
|
|
8
|
-
getPlayerView(playerId: PlayerId):
|
|
6
|
+
export declare function hasIncompleteInformation<GameView = any, Move = any, MoveView = any>(rules: Object): rules is IncompleteInformation<GameView, Move, MoveView>;
|
|
7
|
+
export interface SecretInformation<GameView = any, Move = any, MoveView = any, PlayerId = any> extends IncompleteInformation<GameView, Move, MoveView> {
|
|
8
|
+
getPlayerView(playerId: PlayerId): GameView;
|
|
9
9
|
getPlayerMoveView?(move: Move, playerId: PlayerId): MoveView;
|
|
10
10
|
keepMoveSecret?(move: Move, playerId: PlayerId): boolean;
|
|
11
11
|
}
|
|
12
|
-
export declare function hasSecretInformation<
|
|
13
|
-
export declare function getGameView<
|
|
14
|
-
export declare function getMoveView<
|
|
12
|
+
export declare function hasSecretInformation<GameView = any, Move = any, MoveView = any, PlayerId = any>(rules: Object): rules is SecretInformation<GameView, Move, MoveView, PlayerId>;
|
|
13
|
+
export declare function getGameView<Game, GameView, PlayerId>(rules: Rules<Game, any, PlayerId>, playerId?: PlayerId): GameView;
|
|
14
|
+
export declare function getMoveView<GameView, Move, MoveView, PlayerId>(rules: Rules<any, Move, PlayerId>, move: Move, playerId?: PlayerId): MoveView;
|
|
@@ -2,30 +2,36 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getMoveView = exports.getGameView = exports.hasSecretInformation = exports.hasIncompleteInformation = void 0;
|
|
4
4
|
function hasIncompleteInformation(rules) {
|
|
5
|
-
var
|
|
6
|
-
return typeof
|
|
5
|
+
var test = rules;
|
|
6
|
+
return typeof test.getView === 'function' && typeof test.getMoveView === 'function';
|
|
7
7
|
}
|
|
8
8
|
exports.hasIncompleteInformation = hasIncompleteInformation;
|
|
9
9
|
function hasSecretInformation(rules) {
|
|
10
|
-
var
|
|
11
|
-
return typeof
|
|
10
|
+
var test = rules;
|
|
11
|
+
return typeof test.getPlayerView === 'function';
|
|
12
12
|
}
|
|
13
13
|
exports.hasSecretInformation = hasSecretInformation;
|
|
14
|
-
function getGameView(
|
|
15
|
-
if (hasSecretInformation(
|
|
16
|
-
return
|
|
14
|
+
function getGameView(rules, playerId) {
|
|
15
|
+
if (hasSecretInformation(rules) && playerId !== undefined) {
|
|
16
|
+
return rules.getPlayerView(playerId);
|
|
17
|
+
}
|
|
18
|
+
else if (hasIncompleteInformation(rules)) {
|
|
19
|
+
return rules.getView();
|
|
17
20
|
}
|
|
18
21
|
else {
|
|
19
|
-
return game
|
|
22
|
+
return rules.game;
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
25
|
exports.getGameView = getGameView;
|
|
23
|
-
function getMoveView(
|
|
24
|
-
if (hasSecretInformation(
|
|
25
|
-
return JSON.parse(JSON.stringify(
|
|
26
|
+
function getMoveView(rules, move, playerId) {
|
|
27
|
+
if (hasSecretInformation(rules) && rules.getPlayerMoveView && playerId !== undefined) {
|
|
28
|
+
return JSON.parse(JSON.stringify(rules.getPlayerMoveView(move, playerId)));
|
|
29
|
+
}
|
|
30
|
+
else if (hasIncompleteInformation(rules)) {
|
|
31
|
+
return JSON.parse(JSON.stringify(rules.getMoveView(move)));
|
|
26
32
|
}
|
|
27
33
|
else {
|
|
28
|
-
return
|
|
34
|
+
return move;
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
37
|
exports.getMoveView = getMoveView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IncompleteInformation.js","sourceRoot":"","sources":["../src/IncompleteInformation.ts"],"names":[],"mappings":";;;AAQA,SAAgB,wBAAwB,CAA6C,
|
|
1
|
+
{"version":3,"file":"IncompleteInformation.js","sourceRoot":"","sources":["../src/IncompleteInformation.ts"],"names":[],"mappings":";;;AAQA,SAAgB,wBAAwB,CAA6C,KAAa;IAChG,IAAM,IAAI,GAAG,KAAwD,CAAA;IACrE,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,UAAU,CAAA;AACrF,CAAC;AAHD,4DAGC;AAUD,SAAgB,oBAAoB,CAA6D,KAAa;IAC5G,IAAM,IAAI,GAAG,KAA8D,CAAA;IAC3E,OAAO,OAAO,IAAI,CAAC,aAAa,KAAK,UAAU,CAAA;AACjD,CAAC;AAHD,oDAGC;AAED,SAAgB,WAAW,CAA2B,KAAiC,EAAE,QAAmB;IAC1G,IAAI,oBAAoB,CAA+B,KAAK,CAAC,IAAI,QAAQ,KAAK,SAAS,EAAE;QACvF,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;KACrC;SAAM,IAAI,wBAAwB,CAAW,KAAK,CAAC,EAAE;QACpD,OAAO,KAAK,CAAC,OAAO,EAAE,CAAA;KACvB;SAAM;QACL,OAAO,KAAK,CAAC,IAAuB,CAAA;KACrC;AACH,CAAC;AARD,kCAQC;AAED,SAAgB,WAAW,CAAqC,KAAiC,EAAE,IAAU,EAAE,QAAmB;IAChI,IAAI,oBAAoB,CAAqC,KAAK,CAAC,IAAI,KAAK,CAAC,iBAAiB,IAAI,QAAQ,KAAK,SAAS,EAAE;QACxH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;KAC3E;SAAM,IAAI,wBAAwB,CAA2B,KAAK,CAAC,EAAE;QACpE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAC3D;SAAM;QACL,OAAO,IAAuB,CAAA;KAC/B;AACH,CAAC;AARD,kCAQC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loopWithFuse = void 0;
|
|
4
|
+
function loopWithFuse(repeat, options) {
|
|
5
|
+
var attempts = (options === null || options === void 0 ? void 0 : options.attempts) || (process.env.NODE_ENV === 'development' ? 100 : 1000);
|
|
6
|
+
var errorFn = (options === null || options === void 0 ? void 0 : options.errorFn) || (function () { return new Error('Infinite loop detected'); });
|
|
7
|
+
while (repeat()) {
|
|
8
|
+
if (attempts == 0) {
|
|
9
|
+
throw errorFn();
|
|
10
|
+
}
|
|
11
|
+
attempts--;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.loopWithFuse = loopWithFuse;
|
|
15
|
+
//# sourceMappingURL=LoopWithFuse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoopWithFuse.js","sourceRoot":"","sources":["../src/LoopWithFuse.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAC,MAAqB,EAAE,OAAsD;IACxG,IAAI,QAAQ,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,KAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IACzF,IAAM,OAAO,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,KAAI,CAAC,cAAM,OAAA,IAAI,KAAK,CAAC,wBAAwB,CAAC,EAAnC,CAAmC,CAAC,CAAA;IAC/E,OAAO,MAAM,EAAE,EAAE;QACf,IAAI,QAAQ,IAAI,CAAC,EAAE;YACjB,MAAM,OAAO,EAAE,CAAA;SAChB;QACD,QAAQ,EAAE,CAAA;KACX;AACH,CAAC;AATD,oCASC"}
|
package/dist/RandomMove.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default interface RandomMove<
|
|
3
|
-
randomize(move: Move): Move &
|
|
4
|
-
play(move: Move &
|
|
1
|
+
import Rules from './Rules';
|
|
2
|
+
export default interface RandomMove<Move = string, RandomizedMove = string> {
|
|
3
|
+
randomize(move: Move): Move & RandomizedMove;
|
|
4
|
+
play(move: Move & RandomizedMove): void;
|
|
5
5
|
}
|
|
6
|
-
export declare function hasRandomMove<
|
|
7
|
-
export declare function randomizeMoves<
|
|
6
|
+
export declare function hasRandomMove<Game, Move, RandomizedMove>(rules: Rules<Game, Move>): rules is Rules<Game, Move> & RandomMove<Move, RandomizedMove>;
|
|
7
|
+
export declare function randomizeMoves<Game, Move, RandomizedMove = Move>(rules: Rules<Game, Move>, moves: Move[]): (Move & RandomizedMove)[];
|
package/dist/RandomMove.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.randomizeMoves = exports.hasRandomMove = void 0;
|
|
4
|
-
function hasRandomMove(
|
|
5
|
-
|
|
4
|
+
function hasRandomMove(rules) {
|
|
5
|
+
var test = rules;
|
|
6
|
+
return typeof test.randomize === 'function';
|
|
6
7
|
}
|
|
7
8
|
exports.hasRandomMove = hasRandomMove;
|
|
8
|
-
function randomizeMoves(
|
|
9
|
-
return hasRandomMove(
|
|
9
|
+
function randomizeMoves(rules, moves) {
|
|
10
|
+
return hasRandomMove(rules) ? moves.map(function (move) { return rules.randomize(move); }) : moves;
|
|
10
11
|
}
|
|
11
12
|
exports.randomizeMoves = randomizeMoves;
|
|
12
13
|
//# sourceMappingURL=RandomMove.js.map
|
package/dist/RandomMove.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RandomMove.js","sourceRoot":"","sources":["../src/RandomMove.ts"],"names":[],"mappings":";;;AAQA,SAAgB,aAAa,
|
|
1
|
+
{"version":3,"file":"RandomMove.js","sourceRoot":"","sources":["../src/RandomMove.ts"],"names":[],"mappings":";;;AAQA,SAAgB,aAAa,CAA6B,KAAwB;IAChF,IAAM,IAAI,GAAG,KAA6D,CAAA;IAC1E,OAAO,OAAO,IAAI,CAAC,SAAS,KAAK,UAAU,CAAA;AAC7C,CAAC;AAHD,sCAGC;AAED,SAAgB,cAAc,CAAoC,KAAwB,EAAE,KAAa;IACvG,OAAO,aAAa,CAA6B,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAA,IAAI,IAAI,OAAA,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAArB,CAAqB,CAAC,CAAC,CAAC,CAAE,KAAmC,CAAA;AAC3I,CAAC;AAFD,wCAEC"}
|
package/dist/Robot.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare type Robot<
|
|
1
|
+
declare type Robot<Game, Move = string, PlayerId = number> = (state: Game, playerId: PlayerId) => Promise<Move[]>;
|
|
2
2
|
export default Robot;
|
package/dist/Rules.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export default abstract class Rules<Game = any, Move = any, PlayerId = any> {
|
|
2
|
+
game: Game;
|
|
3
|
+
automaticMoves: Move[];
|
|
4
|
+
constructor(game: Game);
|
|
5
|
+
get state(): Game;
|
|
6
|
+
delegate(): Rules<Game, Move, PlayerId> | undefined;
|
|
7
|
+
delegates(): Rules<Game, Move, PlayerId>[];
|
|
5
8
|
isTurnToPlay(playerId: PlayerId): boolean;
|
|
6
9
|
getActivePlayer?(): PlayerId | undefined;
|
|
7
10
|
isLegalMove(playerId: PlayerId, move: Move): boolean;
|
|
8
|
-
getLegalMoves
|
|
9
|
-
|
|
11
|
+
getLegalMoves(playerId: PlayerId): Move[];
|
|
12
|
+
getAutomaticMoves(): Move[];
|
|
13
|
+
play(move: Move): void;
|
|
10
14
|
isOver(playerIds: PlayerId[]): boolean;
|
|
11
15
|
}
|
package/dist/Rules.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -7,17 +16,37 @@ var fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
|
7
16
|
var Eliminations_1 = require("./Eliminations");
|
|
8
17
|
var Rules = /** @class */ (function () {
|
|
9
18
|
function Rules(game) {
|
|
10
|
-
this.
|
|
19
|
+
this.automaticMoves = [];
|
|
20
|
+
this.game = game;
|
|
11
21
|
}
|
|
22
|
+
Object.defineProperty(Rules.prototype, "state", {
|
|
23
|
+
get: function () {
|
|
24
|
+
return this.game;
|
|
25
|
+
},
|
|
26
|
+
enumerable: false,
|
|
27
|
+
configurable: true
|
|
28
|
+
});
|
|
29
|
+
Rules.prototype.delegate = function () {
|
|
30
|
+
return;
|
|
31
|
+
};
|
|
32
|
+
Rules.prototype.delegates = function () {
|
|
33
|
+
var delegate = this.delegate();
|
|
34
|
+
return delegate ? [delegate] : [];
|
|
35
|
+
};
|
|
12
36
|
Rules.prototype.isTurnToPlay = function (playerId) {
|
|
13
|
-
|
|
14
|
-
|
|
37
|
+
var rules = this.delegates();
|
|
38
|
+
if (rules.some(function (rules) { return rules.isTurnToPlay(playerId); })) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
if (this.getActivePlayer) {
|
|
42
|
+
return playerId === this.getActivePlayer();
|
|
15
43
|
}
|
|
16
|
-
return
|
|
44
|
+
return false;
|
|
17
45
|
};
|
|
18
46
|
Rules.prototype.isLegalMove = function (playerId, move) {
|
|
19
|
-
|
|
20
|
-
|
|
47
|
+
var rules = this.delegates();
|
|
48
|
+
if (rules.some(function (rules) { return rules.isLegalMove(playerId, move); })) {
|
|
49
|
+
return true;
|
|
21
50
|
}
|
|
22
51
|
if (this.getLegalMoves(playerId).some(function (legalMove) { return (0, fast_deep_equal_1.default)(move, legalMove); })) {
|
|
23
52
|
return true;
|
|
@@ -27,6 +56,18 @@ var Rules = /** @class */ (function () {
|
|
|
27
56
|
}
|
|
28
57
|
return false;
|
|
29
58
|
};
|
|
59
|
+
Rules.prototype.getLegalMoves = function (playerId) {
|
|
60
|
+
return this.delegates().flatMap(function (rules) { return rules.getLegalMoves(playerId); });
|
|
61
|
+
};
|
|
62
|
+
Rules.prototype.getAutomaticMoves = function () {
|
|
63
|
+
return __spreadArray(__spreadArray([], this.automaticMoves, true), this.delegates().flatMap(function (rules) { return rules.getAutomaticMoves(); }), true);
|
|
64
|
+
};
|
|
65
|
+
Rules.prototype.play = function (move) {
|
|
66
|
+
for (var _i = 0, _a = this.delegates(); _i < _a.length; _i++) {
|
|
67
|
+
var rules = _a[_i];
|
|
68
|
+
rules.play(move);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
30
71
|
Rules.prototype.isOver = function (playerIds) {
|
|
31
72
|
var _this = this;
|
|
32
73
|
return !playerIds.some(function (playerId) { return _this.isTurnToPlay(playerId); });
|
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":";;;;;;;;;;;;;;AAAA,oEAAmC;AACnC,+CAA8C;AAE9C;IAIE,eAAY,IAAU;QAFtB,mBAAc,GAAW,EAAE,CAAA;QAGzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,sBAAI,wBAAK;aAAT;YACE,OAAO,IAAI,CAAC,IAAI,CAAA;QAClB,CAAC;;;OAAA;IAED,wBAAQ,GAAR;QACE,OAAM;IACR,CAAC;IAED,yBAAS,GAAT;QACE,IAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;QAChC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACnC,CAAC;IAED,4BAAY,GAAZ,UAAa,QAAkB;QAC7B,IAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAC9B,IAAI,KAAK,CAAC,IAAI,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,EAA5B,CAA4B,CAAC,EAAE;YACrD,OAAO,IAAI,CAAA;SACZ;QACD,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,OAAO,QAAQ,KAAK,IAAI,CAAC,eAAe,EAAE,CAAA;SAC3C;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAID,2BAAW,GAAX,UAAY,QAAkB,EAAE,IAAU;QACxC,IAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAC9B,IAAI,KAAK,CAAC,IAAI,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAjC,CAAiC,CAAC,EAAE;YAC1D,OAAO,IAAI,CAAA;SACZ;QACD,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAA,SAAS,IAAI,OAAA,IAAA,yBAAK,EAAC,IAAI,EAAE,SAAS,CAAC,EAAtB,CAAsB,CAAC,EAAE;YAC1E,OAAO,IAAI,CAAA;SACZ;QACD,IAAI,IAAA,8BAAe,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE;YAC5C,OAAO,IAAA,yBAAK,EAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAA;SAC9C;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,6BAAa,GAAb,UAAc,QAAkB;QAC9B,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,EAA7B,CAA6B,CAAC,CAAA;IACzE,CAAC;IAED,iCAAiB,GAAjB;QACE,uCAAW,IAAI,CAAC,cAAc,SAAK,IAAI,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,iBAAiB,EAAE,EAAzB,CAAyB,CAAC,QAAC;IAClG,CAAC;IAED,oBAAI,GAAJ,UAAK,IAAU;QACb,KAAoB,UAAgB,EAAhB,KAAA,IAAI,CAAC,SAAS,EAAE,EAAhB,cAAgB,EAAhB,IAAgB,EAAE;YAAjC,IAAM,KAAK,SAAA;YACd,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;SACjB;IACH,CAAC;IAED,sBAAM,GAAN,UAAO,SAAqB;QAA5B,iBAEC;QADC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,UAAA,QAAQ,IAAI,OAAA,KAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAA3B,CAA2B,CAAC,CAAA;IACjE,CAAC;IACH,YAAC;AAAD,CAAC,AAjED,IAiEC"}
|
package/dist/RulesCreator.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Rules from './Rules';
|
|
2
|
-
export default interface RulesCreator<
|
|
3
|
-
new (state:
|
|
4
|
-
new (options: Options): 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
5
|
}
|
package/dist/TimeLimit.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Rules from './Rules';
|
|
2
|
-
export default interface TimeLimit<
|
|
2
|
+
export default interface TimeLimit<Game, Move = string, PlayerId = number> extends Rules<Game, Move, PlayerId> {
|
|
3
3
|
/**
|
|
4
4
|
* Amount of time given to a player everytime it is their turn to play.
|
|
5
5
|
* @param playerId Id of the player, if you want to give different time depending of the id for asymmetric games.
|
|
@@ -11,7 +11,7 @@ export default interface TimeLimit<State, Move = string, PlayerId = number> exte
|
|
|
11
11
|
*/
|
|
12
12
|
startingTime?(playerId: PlayerId): number;
|
|
13
13
|
}
|
|
14
|
-
export declare function hasTimeLimit<
|
|
14
|
+
export declare function hasTimeLimit<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>): rules is TimeLimit<Game, Move, PlayerId>;
|
|
15
15
|
export declare enum GameSpeed {
|
|
16
16
|
Disabled = "Disabled",
|
|
17
17
|
RealTime = "RealTime"
|
package/dist/TimeLimit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeLimit.js","sourceRoot":"","sources":["../src/TimeLimit.ts"],"names":[],"mappings":";;;AAgBA,SAAgB,YAAY,
|
|
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"}
|
package/dist/Undo.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Action from './Action';
|
|
2
|
-
|
|
3
|
-
export default interface Undo<State, Move = string, PlayerId = number> extends Game<State, Move> {
|
|
2
|
+
export default interface Undo<Game, Move = string, PlayerId = number> {
|
|
4
3
|
canUndo(action: Action<Move, PlayerId>, consecutiveActions: Action<Move, PlayerId>[]): boolean;
|
|
5
|
-
restoreLocalMoves?(localState:
|
|
4
|
+
restoreLocalMoves?(localState: Game): void;
|
|
6
5
|
}
|
|
7
|
-
export declare function hasUndo<
|
|
6
|
+
export declare function hasUndo<Game, Move, PlayerId>(rules: Object): rules is Undo<Game, Move, PlayerId>;
|
package/dist/Undo.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasUndo = void 0;
|
|
4
|
-
function hasUndo(
|
|
5
|
-
|
|
4
|
+
function hasUndo(rules) {
|
|
5
|
+
var test = rules;
|
|
6
|
+
return typeof test.canUndo === 'function';
|
|
6
7
|
}
|
|
7
8
|
exports.hasUndo = hasUndo;
|
|
8
9
|
//# 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,SAAgB,OAAO,CAAuB,KAAa;IACzD,IAAM,IAAI,GAAG,KAAmC,CAAA;IAChD,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,CAAA;AAC3C,CAAC;AAHD,0BAGC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
export { default as Game } from './Game';
|
|
2
|
-
export * from './Game';
|
|
3
1
|
export { default as Rules } from './Rules';
|
|
4
|
-
export { default as GameCreator } from './GameCreator';
|
|
5
2
|
export { default as RulesCreator } from './RulesCreator';
|
|
6
3
|
export { default as Action } from './Action';
|
|
7
4
|
export * from './Action';
|
|
@@ -21,3 +18,5 @@ export { default as Robot } from './Robot';
|
|
|
21
18
|
export { default as Dummy } from './Dummy';
|
|
22
19
|
export * from './options';
|
|
23
20
|
export * from './utils';
|
|
21
|
+
export { applyAutomaticMoves } from './ApplyAutomaticMoves';
|
|
22
|
+
export { loopWithFuse } from './LoopWithFuse';
|
package/dist/index.js
CHANGED
|
@@ -17,8 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.Dummy = exports.Rules = void 0;
|
|
21
|
-
__exportStar(require("./Game"), exports);
|
|
20
|
+
exports.loopWithFuse = exports.applyAutomaticMoves = exports.Dummy = exports.Rules = void 0;
|
|
22
21
|
var Rules_1 = require("./Rules");
|
|
23
22
|
Object.defineProperty(exports, "Rules", { enumerable: true, get: function () { return __importDefault(Rules_1).default; } });
|
|
24
23
|
__exportStar(require("./Action"), exports);
|
|
@@ -32,4 +31,8 @@ var Dummy_1 = require("./Dummy");
|
|
|
32
31
|
Object.defineProperty(exports, "Dummy", { enumerable: true, get: function () { return __importDefault(Dummy_1).default; } });
|
|
33
32
|
__exportStar(require("./options"), exports);
|
|
34
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; } });
|
|
35
38
|
//# 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,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gamepark/rules-api",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.21.0",
|
|
4
4
|
"description": "API to implement the rules of a board game",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"i18next": ">=21.3.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "0caeae47e4d92831c1ed8191d35c5b9d8dfed9ce"
|
|
31
31
|
}
|
package/dist/Game.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export default interface Game<State, Move = string> {
|
|
2
|
-
state: State;
|
|
3
|
-
play(move: Move): void;
|
|
4
|
-
getAutomaticMoves?(): Move[];
|
|
5
|
-
}
|
|
6
|
-
export declare function applyAutomaticMoves<State, Move>(game: Game<State, Move>, preprocessMove?: (move: Move) => void): void;
|
|
7
|
-
export declare function loopWithFuse(repeat: () => boolean, options?: {
|
|
8
|
-
attempts?: number;
|
|
9
|
-
errorFn?: () => Error;
|
|
10
|
-
}): void;
|
package/dist/Game.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loopWithFuse = exports.applyAutomaticMoves = void 0;
|
|
4
|
-
var RandomMove_1 = require("./RandomMove");
|
|
5
|
-
function applyAutomaticMoves(game, preprocessMove) {
|
|
6
|
-
var moves = [];
|
|
7
|
-
loopWithFuse(function () {
|
|
8
|
-
if (moves.length === 0 && game.getAutomaticMoves) {
|
|
9
|
-
moves.push.apply(moves, (0, RandomMove_1.randomizeMoves)(game, game.getAutomaticMoves()));
|
|
10
|
-
}
|
|
11
|
-
var move = moves.shift();
|
|
12
|
-
if (move) {
|
|
13
|
-
if (preprocessMove)
|
|
14
|
-
preprocessMove(move);
|
|
15
|
-
game.play(JSON.parse(JSON.stringify(move)));
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
}, { errorFn: function () { return new Error("Infinite loop detected while applying move consequences: ".concat(JSON.stringify(game.getAutomaticMoves()), ")")); } });
|
|
22
|
-
}
|
|
23
|
-
exports.applyAutomaticMoves = applyAutomaticMoves;
|
|
24
|
-
function loopWithFuse(repeat, options) {
|
|
25
|
-
var attempts = (options === null || options === void 0 ? void 0 : options.attempts) || (process.env.NODE_ENV === 'development' ? 100 : 1000);
|
|
26
|
-
var errorFn = (options === null || options === void 0 ? void 0 : options.errorFn) || (function () { return new Error('Infinite loop detected'); });
|
|
27
|
-
while (repeat()) {
|
|
28
|
-
if (attempts == 0) {
|
|
29
|
-
throw errorFn();
|
|
30
|
-
}
|
|
31
|
-
attempts--;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.loopWithFuse = loopWithFuse;
|
|
35
|
-
//# sourceMappingURL=Game.js.map
|
package/dist/Game.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Game.js","sourceRoot":"","sources":["../src/Game.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAU3C,SAAgB,mBAAmB,CAAc,IAAuB,EAAE,cAAqC;IAC7G,IAAM,KAAK,GAAW,EAAE,CAAA;IACxB,YAAY,CAAC;QACX,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,iBAAiB,EAAE;YAChD,KAAK,CAAC,IAAI,OAAV,KAAK,EAAS,IAAA,2BAAc,EAAC,IAAI,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,EAAC;SAC9D;QACD,IAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAA;QAC1B,IAAI,IAAI,EAAE;YACR,IAAI,cAAc;gBAAE,cAAc,CAAC,IAAI,CAAC,CAAA;YACxC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAC3C,OAAO,IAAI,CAAA;SACZ;aAAM;YACL,OAAO,KAAK,CAAA;SACb;IACH,CAAC,EAAE,EAAC,OAAO,EAAE,cAAM,OAAA,IAAI,KAAK,CAAC,mEAA4D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAkB,EAAE,CAAC,MAAG,CAAC,EAAnH,CAAmH,EAAC,CAAC,CAAA;AAC1I,CAAC;AAfD,kDAeC;AAED,SAAgB,YAAY,CAAC,MAAqB,EAAE,OAAsD;IACxG,IAAI,QAAQ,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,KAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IACzF,IAAM,OAAO,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,KAAI,CAAC,cAAM,OAAA,IAAI,KAAK,CAAC,wBAAwB,CAAC,EAAnC,CAAmC,CAAC,CAAA;IAC/E,OAAO,MAAM,EAAE,EAAE;QACf,IAAI,QAAQ,IAAI,CAAC,EAAE;YACjB,MAAM,OAAO,EAAE,CAAA;SAChB;QACD,QAAQ,EAAE,CAAA;KACX;AACH,CAAC;AATD,oCASC"}
|
package/dist/GameCreator.d.ts
DELETED
package/dist/GameCreator.js
DELETED
package/dist/GameCreator.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GameCreator.js","sourceRoot":"","sources":["../src/GameCreator.ts"],"names":[],"mappings":""}
|
package/dist/SequentialGame.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import Rules from './Rules';
|
|
2
|
-
export default abstract class SequentialGame<State, Move = string, PlayerId = number> implements Rules<State, Move, PlayerId> {
|
|
3
|
-
state: State;
|
|
4
|
-
protected constructor(game: State);
|
|
5
|
-
abstract play(move: Move): void;
|
|
6
|
-
isLegalMove(playerId: PlayerId, move: Move): boolean;
|
|
7
|
-
getActivePlayer?(): PlayerId | undefined;
|
|
8
|
-
isTurnToPlay(playerId: PlayerId): boolean;
|
|
9
|
-
getLegalMoves?(): Move[];
|
|
10
|
-
isOver(): boolean;
|
|
11
|
-
}
|
package/dist/SequentialGame.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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 SequentialGame = /** @class */ (function () {
|
|
9
|
-
function SequentialGame(game) {
|
|
10
|
-
this.state = game;
|
|
11
|
-
}
|
|
12
|
-
SequentialGame.prototype.isLegalMove = function (playerId, move) {
|
|
13
|
-
if (!this.getLegalMoves || !this.getActivePlayer) {
|
|
14
|
-
throw new Error('You must either implement "isLegalMove" or ("getLegalMoves" and "getActivePlayer")');
|
|
15
|
-
}
|
|
16
|
-
if (playerId !== this.getActivePlayer()) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
if (this.getLegalMoves().some(function (legalMove) { return (0, fast_deep_equal_1.default)(move, legalMove); })) {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
if ((0, Eliminations_1.hasEliminations)(this) && this.giveUpMove) {
|
|
23
|
-
return (0, fast_deep_equal_1.default)(move, this.giveUpMove(playerId));
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
};
|
|
27
|
-
SequentialGame.prototype.isTurnToPlay = function (playerId) {
|
|
28
|
-
if (!this.getActivePlayer) {
|
|
29
|
-
throw new Error('You must either implement "isTurnToPlay" or "getActivePlayer"');
|
|
30
|
-
}
|
|
31
|
-
return playerId === this.getActivePlayer();
|
|
32
|
-
};
|
|
33
|
-
SequentialGame.prototype.isOver = function () {
|
|
34
|
-
if (!this.getActivePlayer) {
|
|
35
|
-
throw new Error('You must either implement "isOver" or "getActivePlayer"');
|
|
36
|
-
}
|
|
37
|
-
return this.getActivePlayer() === undefined;
|
|
38
|
-
};
|
|
39
|
-
return SequentialGame;
|
|
40
|
-
}());
|
|
41
|
-
exports.default = SequentialGame;
|
|
42
|
-
//# sourceMappingURL=SequentialGame.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SequentialGame.js","sourceRoot":"","sources":["../src/SequentialGame.ts"],"names":[],"mappings":";;;;;AAAA,oEAAmC;AACnC,+CAA8C;AAG9C;IAGE,wBAAsB,IAAW;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IACnB,CAAC;IAID,oCAAW,GAAX,UAAY,QAAkB,EAAE,IAAU;QACxC,IAAI,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YAChD,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAA;SACtG;QACD,IAAI,QAAQ,KAAK,IAAI,CAAC,eAAe,EAAE,EAAE;YACvC,OAAO,KAAK,CAAA;SACb;QACD,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,UAAA,SAAS,IAAI,OAAA,IAAA,yBAAK,EAAC,IAAI,EAAE,SAAS,CAAC,EAAtB,CAAsB,CAAC,EAAE;YAClE,OAAO,IAAI,CAAA;SACZ;QACD,IAAI,IAAA,8BAAe,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE;YAC5C,OAAO,IAAA,yBAAK,EAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAA;SAC9C;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAID,qCAAY,GAAZ,UAAa,QAAkB;QAC7B,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;SACjF;QACD,OAAO,QAAQ,KAAK,IAAI,CAAC,eAAe,EAAE,CAAA;IAC5C,CAAC;IAID,+BAAM,GAAN;QACE,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAA;SAC3E;QACD,OAAO,IAAI,CAAC,eAAe,EAAE,KAAK,SAAS,CAAA;IAC7C,CAAC;IACH,qBAAC;AAAD,CAAC,AA1CD,IA0CC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import Rules from './Rules';
|
|
2
|
-
export default abstract class SimultaneousGame<State, Move = string, PlayerId = number> implements Rules<State, Move, PlayerId> {
|
|
3
|
-
state: State;
|
|
4
|
-
protected constructor(game: State);
|
|
5
|
-
abstract play(move: Move): void;
|
|
6
|
-
isLegalMove(playerId: PlayerId, move: Move): boolean;
|
|
7
|
-
abstract isTurnToPlay(playerId: PlayerId): boolean;
|
|
8
|
-
getLegalMoves?(playerId: PlayerId): Move[];
|
|
9
|
-
getPlayerIds?(): PlayerId[];
|
|
10
|
-
isOver(): boolean;
|
|
11
|
-
}
|
package/dist/SimultaneousGame.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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 SimultaneousGame = /** @class */ (function () {
|
|
9
|
-
function SimultaneousGame(game) {
|
|
10
|
-
this.state = game;
|
|
11
|
-
}
|
|
12
|
-
SimultaneousGame.prototype.isLegalMove = function (playerId, move) {
|
|
13
|
-
if (typeof this.getLegalMoves === 'undefined') {
|
|
14
|
-
throw new Error('You must either implement "isLegalMove" or "getLegalMoves');
|
|
15
|
-
}
|
|
16
|
-
if (this.getLegalMoves(playerId).some(function (legalMove) { return (0, fast_deep_equal_1.default)(move, legalMove); })) {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
if ((0, Eliminations_1.hasEliminations)(this) && this.giveUpMove) {
|
|
20
|
-
return (0, fast_deep_equal_1.default)(move, this.giveUpMove(playerId));
|
|
21
|
-
}
|
|
22
|
-
return false;
|
|
23
|
-
};
|
|
24
|
-
SimultaneousGame.prototype.isOver = function () {
|
|
25
|
-
var _this = this;
|
|
26
|
-
if (!this.getPlayerIds) {
|
|
27
|
-
throw new Error('You must either implement "isOver" or "getPlayerIds"');
|
|
28
|
-
}
|
|
29
|
-
return !this.getPlayerIds().some(function (playerId) { return _this.isTurnToPlay(playerId); });
|
|
30
|
-
};
|
|
31
|
-
return SimultaneousGame;
|
|
32
|
-
}());
|
|
33
|
-
exports.default = SimultaneousGame;
|
|
34
|
-
//# sourceMappingURL=SimultaneousGame.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SimultaneousGame.js","sourceRoot":"","sources":["../src/SimultaneousGame.ts"],"names":[],"mappings":";;;;;AAAA,oEAAmC;AACnC,+CAA8C;AAG9C;IAGE,0BAAsB,IAAW;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IACnB,CAAC;IAID,sCAAW,GAAX,UAAY,QAAkB,EAAE,IAAU;QACxC,IAAI,OAAO,IAAI,CAAC,aAAa,KAAK,WAAW,EAAE;YAC7C,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAA;SAC7E;QACD,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAA,SAAS,IAAI,OAAA,IAAA,yBAAK,EAAC,IAAI,EAAE,SAAS,CAAC,EAAtB,CAAsB,CAAC,EAAE;YAC1E,OAAO,IAAI,CAAA;SACZ;QACD,IAAI,IAAA,8BAAe,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE;YAC5C,OAAO,IAAA,yBAAK,EAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAA;SAC9C;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAQD,iCAAM,GAAN;QAAA,iBAKC;QAJC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;SACxE;QACD,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,UAAA,QAAQ,IAAI,OAAA,KAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAA3B,CAA2B,CAAC,CAAA;IAC3E,CAAC;IACH,uBAAC;AAAD,CAAC,AAlCD,IAkCC"}
|