@gamepark/rules-api 5.23.2 → 6.0.1-alpha.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 +4 -5
- package/dist/Action.js +6 -6
- package/dist/Action.js.map +1 -1
- package/dist/ApplyAutomaticMoves.d.ts +1 -1
- package/dist/ApplyAutomaticMoves.js +1 -1
- package/dist/ApplyAutomaticMoves.js.map +1 -1
- package/dist/Competitive.d.ts +2 -2
- package/dist/Dummy.d.ts +2 -2
- package/dist/Dummy.js +2 -1
- package/dist/Dummy.js.map +1 -1
- package/dist/Eliminations.d.ts +1 -1
- package/dist/IncompleteInformation.d.ts +2 -2
- package/dist/RandomMove.d.ts +2 -2
- package/dist/RandomMove.js +4 -2
- package/dist/RandomMove.js.map +1 -1
- package/dist/Robot.d.ts +1 -2
- package/dist/Rules.d.ts +2 -1
- package/dist/Rules.js +2 -1
- package/dist/Rules.js.map +1 -1
- package/dist/RulesCreator.d.ts +2 -2
- package/dist/TimeLimit.d.ts +2 -2
- package/dist/Undo.d.ts +2 -2
- package/dist/UnpredictableMove.d.ts +12 -0
- package/dist/UnpredictableMove.js +43 -0
- package/dist/UnpredictableMove.js.map +1 -0
- package/dist/index.d.ts +13 -18
- package/dist/index.js +13 -17
- package/dist/index.js.map +1 -1
- package/dist/material/HiddenMaterialRules.d.ts +19 -0
- package/dist/material/HiddenMaterialRules.js +138 -0
- package/dist/material/HiddenMaterialRules.js.map +1 -0
- package/dist/material/MaterialGame.d.ts +11 -0
- package/dist/material/MaterialGame.js +3 -0
- package/dist/material/MaterialGame.js.map +1 -0
- package/dist/material/MaterialRules.d.ts +32 -0
- package/dist/material/MaterialRules.js +216 -0
- package/dist/material/MaterialRules.js.map +1 -0
- package/dist/material/SecretMaterialRules.d.ts +12 -0
- package/dist/material/SecretMaterialRules.js +52 -0
- package/dist/material/SecretMaterialRules.js.map +1 -0
- package/dist/material/helper/MaterialMoveBuilder.d.ts +9 -0
- package/dist/material/helper/MaterialMoveBuilder.js +28 -0
- package/dist/material/helper/MaterialMoveBuilder.js.map +1 -0
- package/dist/material/helper/MaterialSearchHelper.d.ts +18 -0
- package/dist/material/helper/MaterialSearchHelper.js +62 -0
- package/dist/material/helper/MaterialSearchHelper.js.map +1 -0
- package/dist/material/helper/index.d.ts +2 -0
- package/dist/material/helper/index.js +19 -0
- package/dist/material/helper/index.js.map +1 -0
- package/dist/material/index.d.ts +9 -0
- package/dist/material/index.js +26 -0
- package/dist/material/index.js.map +1 -0
- package/dist/material/items/Material.d.ts +30 -0
- package/dist/material/items/Material.js +149 -0
- package/dist/material/items/Material.js.map +1 -0
- package/dist/material/items/MaterialItem.d.ts +10 -0
- package/dist/material/items/MaterialItem.js +3 -0
- package/dist/material/items/MaterialItem.js.map +1 -0
- package/dist/material/items/MaterialOperation.d.ts +20 -0
- package/dist/material/items/MaterialOperation.js +147 -0
- package/dist/material/items/MaterialOperation.js.map +1 -0
- package/dist/material/items/index.d.ts +3 -0
- package/dist/material/items/index.js +20 -0
- package/dist/material/items/index.js.map +1 -0
- package/dist/material/location/Location.d.ts +14 -0
- package/dist/material/location/Location.js +12 -0
- package/dist/material/location/Location.js.map +1 -0
- package/dist/material/location/index.d.ts +2 -0
- package/dist/material/location/index.js +19 -0
- package/dist/material/location/index.js.map +1 -0
- package/dist/material/location/strategy/LocationStrategy.d.ts +5 -0
- package/dist/material/location/strategy/LocationStrategy.js +3 -0
- package/dist/material/location/strategy/LocationStrategy.js.map +1 -0
- package/dist/material/location/strategy/PositiveSequenceStrategy.d.ts +11 -0
- package/dist/material/location/strategy/PositiveSequenceStrategy.js +42 -0
- package/dist/material/location/strategy/PositiveSequenceStrategy.js.map +1 -0
- package/dist/material/location/strategy/index.d.ts +2 -0
- package/dist/material/location/strategy/index.js +19 -0
- package/dist/material/location/strategy/index.js.map +1 -0
- package/dist/material/moves/CreateItem.d.ts +7 -0
- package/dist/material/moves/CreateItem.js +3 -0
- package/dist/material/moves/CreateItem.js.map +1 -0
- package/dist/material/moves/CustomMove.d.ts +6 -0
- package/dist/material/moves/CustomMove.js +3 -0
- package/dist/material/moves/CustomMove.js.map +1 -0
- package/dist/material/moves/DeleteItem.d.ts +7 -0
- package/dist/material/moves/DeleteItem.js +3 -0
- package/dist/material/moves/DeleteItem.js.map +1 -0
- package/dist/material/moves/MaterialMove.d.ts +11 -0
- package/dist/material/moves/MaterialMove.js +3 -0
- package/dist/material/moves/MaterialMove.js.map +1 -0
- package/dist/material/moves/MaterialMoveType.d.ts +6 -0
- package/dist/material/moves/MaterialMoveType.js +11 -0
- package/dist/material/moves/MaterialMoveType.js.map +1 -0
- package/dist/material/moves/MaterialMovesBuilder.d.ts +8 -0
- package/dist/material/moves/MaterialMovesBuilder.js +34 -0
- package/dist/material/moves/MaterialMovesBuilder.js.map +1 -0
- package/dist/material/moves/MaterialRulesMove.d.ts +6 -0
- package/dist/material/moves/MaterialRulesMove.js +3 -0
- package/dist/material/moves/MaterialRulesMove.js.map +1 -0
- package/dist/material/moves/MoveItem.d.ts +17 -0
- package/dist/material/moves/MoveItem.js +54 -0
- package/dist/material/moves/MoveItem.js.map +1 -0
- package/dist/material/moves/MoveKind.d.ts +6 -0
- package/dist/material/moves/MoveKind.js +11 -0
- package/dist/material/moves/MoveKind.js.map +1 -0
- package/dist/material/moves/Shuffle.d.ts +9 -0
- package/dist/material/moves/Shuffle.js +3 -0
- package/dist/material/moves/Shuffle.js.map +1 -0
- package/dist/material/moves/index.d.ts +11 -0
- package/dist/material/moves/index.js +28 -0
- package/dist/material/moves/index.js.map +1 -0
- package/dist/material/moves/local/LocalMove.d.ts +6 -0
- package/dist/material/moves/local/LocalMove.js +9 -0
- package/dist/material/moves/local/LocalMove.js.map +1 -0
- package/dist/material/moves/local/RulesDisplay.d.ts +32 -0
- package/dist/material/moves/local/RulesDisplay.js +26 -0
- package/dist/material/moves/local/RulesDisplay.js.map +1 -0
- package/dist/material/moves/local/index.d.ts +2 -0
- package/dist/material/moves/local/index.js +19 -0
- package/dist/material/moves/local/index.js.map +1 -0
- package/dist/material/moves/rules/EndGame.d.ts +4 -0
- package/dist/material/moves/rules/EndGame.js +3 -0
- package/dist/material/moves/rules/EndGame.js.map +1 -0
- package/dist/material/moves/rules/RuleMove.d.ts +16 -0
- package/dist/material/moves/rules/RuleMove.js +19 -0
- package/dist/material/moves/rules/RuleMove.js.map +1 -0
- package/dist/material/moves/rules/StartPlayerTurn.d.ts +7 -0
- package/dist/material/moves/rules/StartPlayerTurn.js +3 -0
- package/dist/material/moves/rules/StartPlayerTurn.js.map +1 -0
- package/dist/material/moves/rules/StartRule.d.ts +7 -0
- package/dist/material/moves/rules/StartRule.js +3 -0
- package/dist/material/moves/rules/StartRule.js.map +1 -0
- package/dist/material/moves/rules/index.d.ts +4 -0
- package/dist/material/moves/rules/index.js +21 -0
- package/dist/material/moves/rules/index.js.map +1 -0
- package/dist/material/rules/MaterialRulesMovesBuilder.d.ts +10 -0
- package/dist/material/rules/MaterialRulesMovesBuilder.js +35 -0
- package/dist/material/rules/MaterialRulesMovesBuilder.js.map +1 -0
- package/dist/material/rules/MaterialStepRules.d.ts +22 -0
- package/dist/material/rules/MaterialStepRules.js +101 -0
- package/dist/material/rules/MaterialStepRules.js.map +1 -0
- package/dist/material/rules/PlayerTurnRule.d.ts +10 -0
- package/dist/material/rules/PlayerTurnRule.js +53 -0
- package/dist/material/rules/PlayerTurnRule.js.map +1 -0
- package/dist/material/rules/RuleStep.d.ts +6 -0
- package/dist/material/rules/RuleStep.js +3 -0
- package/dist/material/rules/RuleStep.js.map +1 -0
- package/dist/material/rules/index.d.ts +3 -0
- package/dist/material/rules/index.js +20 -0
- package/dist/material/rules/index.js.map +1 -0
- package/dist/options/EnumOption.d.ts +2 -3
- package/dist/options/EnumOption.js.map +1 -1
- package/dist/options/Option.d.ts +1 -2
- package/dist/options/OptionSpecOf.d.ts +3 -4
- package/dist/options/OptionsSpec.d.ts +4 -5
- package/dist/options/OptionsValidationError.d.ts +1 -1
- package/dist/options/OptionsValidationError.js +2 -1
- package/dist/options/OptionsValidationError.js.map +1 -1
- package/dist/options/PlayerIdSpec.d.ts +2 -3
- package/dist/options/PlayerIdSpec.js.map +1 -1
- package/dist/options/PlayersOptionsSpec.d.ts +3 -4
- package/dist/options/WithIdOption.d.ts +1 -2
- package/dist/options/WithPlayerOptionsSpec.d.ts +2 -3
- package/dist/options/WithPlayersOptions.d.ts +1 -2
- package/dist/options/getFallbackPlayerName.d.ts +3 -3
- package/dist/options/getFallbackPlayerName.js +4 -6
- package/dist/options/getFallbackPlayerName.js.map +1 -1
- package/dist/options/index.d.ts +12 -12
- package/dist/options/index.js +12 -12
- package/dist/options/index.js.map +1 -1
- package/dist/options/isWithPlayerIdOptions.d.ts +4 -4
- package/dist/options/isWithPlayerIdOptions.js +2 -1
- package/dist/options/isWithPlayerIdOptions.js.map +1 -1
- package/dist/options/providePlayerIds.d.ts +6 -6
- package/dist/options/providePlayerIds.js +5 -7
- package/dist/options/providePlayerIds.js.map +1 -1
- package/package.json +9 -3
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.MaterialStepRules = void 0;
|
|
30
|
+
var Rules_1 = require("../../Rules");
|
|
31
|
+
var items_1 = require("../items");
|
|
32
|
+
var MaterialRulesMovesBuilder_1 = require("./MaterialRulesMovesBuilder");
|
|
33
|
+
var MaterialStepRules = /** @class */ (function (_super) {
|
|
34
|
+
__extends(MaterialStepRules, _super);
|
|
35
|
+
function MaterialStepRules() {
|
|
36
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
37
|
+
}
|
|
38
|
+
MaterialStepRules.prototype.material = function (type) {
|
|
39
|
+
var _a;
|
|
40
|
+
return new items_1.Material(type, Array.from(((_a = this.game.items[type]) !== null && _a !== void 0 ? _a : []).entries()).filter(function (entry) { return entry[1].quantity !== 0; }));
|
|
41
|
+
};
|
|
42
|
+
MaterialStepRules.prototype.beforeMaterialMove = function (_move) {
|
|
43
|
+
return [];
|
|
44
|
+
};
|
|
45
|
+
MaterialStepRules.prototype.afterMaterialMove = function (_move) {
|
|
46
|
+
return [];
|
|
47
|
+
};
|
|
48
|
+
MaterialStepRules.prototype.onRuleStart = function (_move, _previousRule) {
|
|
49
|
+
return [];
|
|
50
|
+
};
|
|
51
|
+
MaterialStepRules.prototype.onRuleEnd = function (_move) {
|
|
52
|
+
return [];
|
|
53
|
+
};
|
|
54
|
+
MaterialStepRules.prototype.onCustomMove = function (_move) {
|
|
55
|
+
return [];
|
|
56
|
+
};
|
|
57
|
+
MaterialStepRules.prototype.rules = function () {
|
|
58
|
+
return new MaterialRulesMovesBuilder_1.MaterialRulesMovesBuilder(this.game);
|
|
59
|
+
};
|
|
60
|
+
MaterialStepRules.prototype.getMemory = function (player) {
|
|
61
|
+
var _a, _b, _c;
|
|
62
|
+
if (player !== undefined) {
|
|
63
|
+
return ((_b = (_a = this.game.rule.playersMemory) === null || _a === void 0 ? void 0 : _a[player]) !== null && _b !== void 0 ? _b : {});
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return ((_c = this.game.rule.memory) !== null && _c !== void 0 ? _c : {});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
MaterialStepRules.prototype.memorize = function (memory, player) {
|
|
70
|
+
if (player !== undefined) {
|
|
71
|
+
if (!this.game.rule.playersMemory)
|
|
72
|
+
this.game.rule.playersMemory = {};
|
|
73
|
+
this.game.rule.playersMemory[player] = __assign(__assign({}, this.game.rule.playersMemory[player]), memory);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
this.game.rule.memory = __assign(__assign({}, this.game.rule.memory), memory);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
MaterialStepRules.prototype.getGameMemory = function (player) {
|
|
80
|
+
var _a, _b, _c;
|
|
81
|
+
if (player !== undefined) {
|
|
82
|
+
return ((_b = (_a = this.game.playersMemory) === null || _a === void 0 ? void 0 : _a[player]) !== null && _b !== void 0 ? _b : {});
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return ((_c = this.game.memory) !== null && _c !== void 0 ? _c : {});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
MaterialStepRules.prototype.memorizeOnGame = function (memory, player) {
|
|
89
|
+
if (player !== undefined) {
|
|
90
|
+
if (!this.game.playersMemory)
|
|
91
|
+
this.game.playersMemory = {};
|
|
92
|
+
this.game.playersMemory[player] = __assign(__assign({}, this.game.playersMemory[player]), memory);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
this.game.memory = __assign(__assign({}, this.game.memory), memory);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
return MaterialStepRules;
|
|
99
|
+
}(Rules_1.Rules));
|
|
100
|
+
exports.MaterialStepRules = MaterialStepRules;
|
|
101
|
+
//# sourceMappingURL=MaterialStepRules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaterialStepRules.js","sourceRoot":"","sources":["../../../src/material/rules/MaterialStepRules.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MaterialStepRules } from './MaterialStepRules';
|
|
2
|
+
import { MaterialRulesMove } from '../moves';
|
|
3
|
+
export declare abstract class PlayerTurnRule<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends MaterialStepRules<Player, MaterialType, LocationType> {
|
|
4
|
+
get player(): Player;
|
|
5
|
+
get nextPlayer(): Player;
|
|
6
|
+
getActivePlayer(): Player;
|
|
7
|
+
initializeMoves(): MaterialRulesMove<Player, MaterialType, LocationType>[];
|
|
8
|
+
getLegalMoves(player: Player): MaterialRulesMove<Player, MaterialType, LocationType>[];
|
|
9
|
+
abstract getPlayerMoves(): MaterialRulesMove<Player, MaterialType, LocationType>[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
exports.PlayerTurnRule = void 0;
|
|
19
|
+
var MaterialStepRules_1 = require("./MaterialStepRules");
|
|
20
|
+
var PlayerTurnRule = /** @class */ (function (_super) {
|
|
21
|
+
__extends(PlayerTurnRule, _super);
|
|
22
|
+
function PlayerTurnRule() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(PlayerTurnRule.prototype, "player", {
|
|
26
|
+
get: function () {
|
|
27
|
+
return this.game.rule.player;
|
|
28
|
+
},
|
|
29
|
+
enumerable: false,
|
|
30
|
+
configurable: true
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(PlayerTurnRule.prototype, "nextPlayer", {
|
|
33
|
+
get: function () {
|
|
34
|
+
return this.game.players[(this.game.players.indexOf(this.player) + 1) % this.game.players.length];
|
|
35
|
+
},
|
|
36
|
+
enumerable: false,
|
|
37
|
+
configurable: true
|
|
38
|
+
});
|
|
39
|
+
PlayerTurnRule.prototype.getActivePlayer = function () {
|
|
40
|
+
return this.player;
|
|
41
|
+
};
|
|
42
|
+
PlayerTurnRule.prototype.initializeMoves = function () {
|
|
43
|
+
return [];
|
|
44
|
+
};
|
|
45
|
+
PlayerTurnRule.prototype.getLegalMoves = function (player) {
|
|
46
|
+
if (player !== this.getActivePlayer())
|
|
47
|
+
return [];
|
|
48
|
+
return this.getPlayerMoves();
|
|
49
|
+
};
|
|
50
|
+
return PlayerTurnRule;
|
|
51
|
+
}(MaterialStepRules_1.MaterialStepRules));
|
|
52
|
+
exports.PlayerTurnRule = PlayerTurnRule;
|
|
53
|
+
//# sourceMappingURL=PlayerTurnRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlayerTurnRule.js","sourceRoot":"","sources":["../../../src/material/rules/PlayerTurnRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,yDAAuD;AAGvD;IACU,kCAAqD;IAD/D;;IAyBA,CAAC;IAtBC,sBAAI,kCAAM;aAAV;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAK,CAAC,MAAO,CAAA;QAChC,CAAC;;;OAAA;IAED,sBAAI,sCAAU;aAAd;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACnG,CAAC;;;OAAA;IAED,wCAAe,GAAf;QACE,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED,wCAAe,GAAf;QACE,OAAO,EAAE,CAAA;IACX,CAAC;IAED,sCAAa,GAAb,UAAc,MAAc;QAC1B,IAAI,MAAM,KAAK,IAAI,CAAC,eAAe,EAAE;YAAE,OAAO,EAAE,CAAA;QAChD,OAAO,IAAI,CAAC,cAAc,EAAE,CAAA;IAC9B,CAAC;IAGH,qBAAC;AAAD,CAAC,AAzBD,CACU,qCAAiB,GAwB1B;AAzBqB,wCAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RuleStep.js","sourceRoot":"","sources":["../../../src/material/rules/RuleStep.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./RuleStep"), exports);
|
|
18
|
+
__exportStar(require("./MaterialStepRules"), exports);
|
|
19
|
+
__exportStar(require("./PlayerTurnRule"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/material/rules/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,sDAAmC;AACnC,mDAAgC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import Option from './Option';
|
|
2
|
-
declare type EnumOption<T = any> = Option & {
|
|
1
|
+
import { Option } from './Option';
|
|
2
|
+
export declare type EnumOption<T = any> = Option & {
|
|
3
3
|
values: T[];
|
|
4
4
|
valueSpec: (value: T) => Option;
|
|
5
5
|
};
|
|
6
|
-
export default EnumOption;
|
|
7
6
|
export declare function isEnumOption<T = any>(option: Option): option is EnumOption<T>;
|
|
@@ -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":";;;AAOA,SAAgB,YAAY,CAAU,MAAc;IAClD,OAAO,KAAK,CAAC,OAAO,CAAE,MAAqB,CAAC,MAAM,CAAC,CAAA;AACrD,CAAC;AAFD,oCAEC"}
|
package/dist/options/Option.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { TFunction } from 'i18next';
|
|
2
|
-
declare type Option = {
|
|
2
|
+
export declare type Option = {
|
|
3
3
|
label: (t: TFunction) => string;
|
|
4
4
|
help?: (t: TFunction) => string;
|
|
5
5
|
warn?: (t: TFunction) => string;
|
|
6
6
|
subscriberRequired?: boolean;
|
|
7
7
|
competitiveDisabled?: boolean;
|
|
8
8
|
};
|
|
9
|
-
export default Option;
|
|
@@ -1,4 +1,3 @@
|
|
|
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
|
+
export declare type OptionSpecOf<T> = [T] extends [boolean] ? Option : EnumOption<T>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
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> : {}) & {
|
|
2
|
+
import { OptionSpecOf } from './OptionSpecOf';
|
|
3
|
+
import { WithPlayerOptionsSpec } from './WithPlayerOptionsSpec';
|
|
4
|
+
import { WithPlayersOptions } from './WithPlayersOptions';
|
|
5
|
+
export declare type OptionsSpec<Options> = (Options extends WithPlayersOptions<infer P> ? WithPlayerOptionsSpec<P> : {}) & {
|
|
6
6
|
[key in keyof Omit<Options, 'players'>]: OptionSpecOf<Options[key]>;
|
|
7
7
|
} & {
|
|
8
8
|
validate?: (options: Partial<Options>, t: TFunction) => void;
|
|
9
9
|
};
|
|
10
|
-
export default OptionsSpec;
|
|
@@ -15,6 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.OptionsValidationError = void 0;
|
|
18
19
|
var OptionsValidationError = /** @class */ (function (_super) {
|
|
19
20
|
__extends(OptionsValidationError, _super);
|
|
20
21
|
function OptionsValidationError(message, fields) {
|
|
@@ -25,5 +26,5 @@ var OptionsValidationError = /** @class */ (function (_super) {
|
|
|
25
26
|
}
|
|
26
27
|
return OptionsValidationError;
|
|
27
28
|
}(Error));
|
|
28
|
-
exports.
|
|
29
|
+
exports.OptionsValidationError = OptionsValidationError;
|
|
29
30
|
//# 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;IAA4C,0CAAK;IAG/C,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,CAA4C,KAAK,GAOhD;AAPY,wDAAsB"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import EnumOption from './EnumOption';
|
|
2
|
-
declare type PlayerIdSpec<Id> = EnumOption<Id> & {
|
|
1
|
+
import { EnumOption } from './EnumOption';
|
|
2
|
+
export declare type PlayerIdSpec<Id> = EnumOption<Id> & {
|
|
3
3
|
mandatory?: (players: number) => Id[];
|
|
4
4
|
unavailable?: (players: number) => Id[];
|
|
5
5
|
};
|
|
6
|
-
export default PlayerIdSpec;
|
|
7
6
|
export declare function getMandatoryIds<Id>(spec: PlayerIdSpec<Id>, players: number): Id[];
|
|
8
7
|
export declare function getAvailableIds<Id>(spec: PlayerIdSpec<Id>, players: number): Id[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlayerIdSpec.js","sourceRoot":"","sources":["../../src/options/PlayerIdSpec.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"PlayerIdSpec.js","sourceRoot":"","sources":["../../src/options/PlayerIdSpec.ts"],"names":[],"mappings":";;;AAOA,SAAgB,eAAe,CAAK,IAAsB,EAAE,OAAe;IACzE,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AACtD,CAAC;AAFD,0CAEC;AAED,SAAgB,eAAe,CAAK,IAAsB,EAAE,OAAe;IACzE,IAAI,IAAI,CAAC,WAAW,EAAE;QACpB,IAAM,gBAAc,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAChD,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAA,EAAE,IAAI,OAAA,CAAC,gBAAc,CAAC,QAAQ,CAAC,EAAE,CAAC,EAA5B,CAA4B,CAAC,CAAA;KAC9D;SAAM;QACL,OAAO,IAAI,CAAC,MAAM,CAAA;KACnB;AACH,CAAC;AAPD,0CAOC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import PlayerIdSpec from './PlayerIdSpec';
|
|
2
|
-
import WithIdOption from './WithIdOption';
|
|
3
|
-
declare type PlayersOptionsSpec<Options> = (Options extends WithIdOption<infer Id> ? {
|
|
1
|
+
import { PlayerIdSpec } from './PlayerIdSpec';
|
|
2
|
+
import { WithIdOption } from './WithIdOption';
|
|
3
|
+
export declare type PlayersOptionsSpec<Options> = (Options extends WithIdOption<infer Id> ? {
|
|
4
4
|
id: PlayerIdSpec<Id>;
|
|
5
5
|
} : {}) & {
|
|
6
6
|
[key in keyof Omit<Options, 'id'>]: any;
|
|
7
7
|
};
|
|
8
|
-
export default PlayersOptionsSpec;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import PlayersOptionsSpec from './PlayersOptionsSpec';
|
|
2
|
-
declare type WithPlayerOptionsSpec<P> = {
|
|
1
|
+
import { PlayersOptionsSpec } from './PlayersOptionsSpec';
|
|
2
|
+
export declare type WithPlayerOptionsSpec<P> = {
|
|
3
3
|
players: PlayersOptionsSpec<P>;
|
|
4
4
|
};
|
|
5
|
-
export default WithPlayerOptionsSpec;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { TFunction } from 'i18next';
|
|
2
|
-
import OptionsSpec from './OptionsSpec';
|
|
3
|
-
import WithIdOption from './WithIdOption';
|
|
4
|
-
export
|
|
2
|
+
import { OptionsSpec } from './OptionsSpec';
|
|
3
|
+
import { WithIdOption } from './WithIdOption';
|
|
4
|
+
export declare function getFallbackPlayerName<Id, P extends WithIdOption<Id>, Options>(id: Id, t: TFunction, optionsSpec?: OptionsSpec<Options>): string;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
3
|
+
exports.getFallbackPlayerName = void 0;
|
|
4
|
+
var isWithPlayerIdOptions_1 = require("./isWithPlayerIdOptions");
|
|
7
5
|
function getFallbackPlayerName(id, t, optionsSpec) {
|
|
8
|
-
if (optionsSpec && (0, isWithPlayerIdOptions_1.
|
|
6
|
+
if (optionsSpec && (0, isWithPlayerIdOptions_1.isWithPlayerIdOptions)(optionsSpec)) {
|
|
9
7
|
return optionsSpec.players.id.valueSpec(id).label(t);
|
|
10
8
|
}
|
|
11
9
|
else {
|
|
12
10
|
return t('Player {number}', { number: id });
|
|
13
11
|
}
|
|
14
12
|
}
|
|
15
|
-
exports.
|
|
13
|
+
exports.getFallbackPlayerName = getFallbackPlayerName;
|
|
16
14
|
//# sourceMappingURL=getFallbackPlayerName.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFallbackPlayerName.js","sourceRoot":"","sources":["../../src/options/getFallbackPlayerName.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getFallbackPlayerName.js","sourceRoot":"","sources":["../../src/options/getFallbackPlayerName.ts"],"names":[],"mappings":";;;AACA,iEAA+D;AAI/D,SAAgB,qBAAqB,CAA0C,EAAM,EAAE,CAAY,EAAE,WAAkC;IACrI,IAAI,WAAW,IAAI,IAAA,6CAAqB,EAAiB,WAAW,CAAC,EAAE;QACrE,OAAO,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;KACrD;SAAM;QACL,OAAO,CAAC,CAAC,iBAAiB,EAAE,EAAC,MAAM,EAAE,EAAE,EAAC,CAAC,CAAA;KAC1C;AACH,CAAC;AAND,sDAMC"}
|
package/dist/options/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { default as OptionsSpec } from './OptionsSpec';
|
|
2
|
-
export { default as OptionSpecOf } from './OptionSpecOf';
|
|
3
|
-
export { default as Option } from './Option';
|
|
4
|
-
export { default as EnumOption } from './EnumOption';
|
|
5
1
|
export * from './EnumOption';
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
2
|
+
export * from './getFallbackPlayerName';
|
|
3
|
+
export * from './isWithPlayerIdOptions';
|
|
4
|
+
export * from './Option';
|
|
5
|
+
export * from './OptionSpecOf';
|
|
6
|
+
export * from './OptionsSpec';
|
|
7
|
+
export * from './OptionsValidationError';
|
|
8
|
+
export * from './PlayerIdSpec';
|
|
9
|
+
export * from './PlayersOptionsSpec';
|
|
10
|
+
export * from './providePlayerIds';
|
|
11
|
+
export * from './WithIdOption';
|
|
12
|
+
export * from './WithPlayerOptionsSpec';
|
|
13
|
+
export * from './WithPlayersOptions';
|
package/dist/options/index.js
CHANGED
|
@@ -13,18 +13,18 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.OptionsValidationError = exports.getFallbackPlayerName = exports.isWithPlayerIdOptions = exports.providePlayerIds = void 0;
|
|
21
17
|
__exportStar(require("./EnumOption"), exports);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
__exportStar(require("./getFallbackPlayerName"), exports);
|
|
19
|
+
__exportStar(require("./isWithPlayerIdOptions"), exports);
|
|
20
|
+
__exportStar(require("./Option"), exports);
|
|
21
|
+
__exportStar(require("./OptionSpecOf"), exports);
|
|
22
|
+
__exportStar(require("./OptionsSpec"), exports);
|
|
23
|
+
__exportStar(require("./OptionsValidationError"), exports);
|
|
24
|
+
__exportStar(require("./PlayerIdSpec"), exports);
|
|
25
|
+
__exportStar(require("./PlayersOptionsSpec"), exports);
|
|
26
|
+
__exportStar(require("./providePlayerIds"), exports);
|
|
27
|
+
__exportStar(require("./WithIdOption"), exports);
|
|
28
|
+
__exportStar(require("./WithPlayerOptionsSpec"), exports);
|
|
29
|
+
__exportStar(require("./WithPlayersOptions"), exports);
|
|
30
30
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/options/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/options/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,0DAAuC;AACvC,0DAAuC;AACvC,2CAAwB;AACxB,iDAA8B;AAC9B,gDAA6B;AAC7B,2DAAwC;AACxC,iDAA8B;AAC9B,uDAAoC;AACpC,qDAAkC;AAClC,iDAA8B;AAC9B,0DAAuC;AACvC,uDAAoC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import OptionsSpec from './OptionsSpec';
|
|
2
|
-
import WithIdOption from './WithIdOption';
|
|
3
|
-
import WithPlayerOptionsSpec from './WithPlayerOptionsSpec';
|
|
4
|
-
export
|
|
1
|
+
import { OptionsSpec } from './OptionsSpec';
|
|
2
|
+
import { WithIdOption } from './WithIdOption';
|
|
3
|
+
import { WithPlayerOptionsSpec } from './WithPlayerOptionsSpec';
|
|
4
|
+
export declare function isWithPlayerIdOptions<Id, P extends WithIdOption<Id>, Options>(optionsSpec: OptionsSpec<Options>): optionsSpec is OptionsSpec<Options> & WithPlayerOptionsSpec<P>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isWithPlayerIdOptions = void 0;
|
|
3
4
|
function isWithPlayerIdOptions(optionsSpec) {
|
|
4
5
|
var playersOptions = optionsSpec.players;
|
|
5
6
|
if (!playersOptions)
|
|
@@ -7,5 +8,5 @@ function isWithPlayerIdOptions(optionsSpec) {
|
|
|
7
8
|
var idOptions = playersOptions.id;
|
|
8
9
|
return !!idOptions;
|
|
9
10
|
}
|
|
10
|
-
exports.
|
|
11
|
+
exports.isWithPlayerIdOptions = isWithPlayerIdOptions;
|
|
11
12
|
//# sourceMappingURL=isWithPlayerIdOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isWithPlayerIdOptions.js","sourceRoot":"","sources":["../../src/options/isWithPlayerIdOptions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isWithPlayerIdOptions.js","sourceRoot":"","sources":["../../src/options/isWithPlayerIdOptions.ts"],"names":[],"mappings":";;;AAKA,SAAgB,qBAAqB,CAA0C,WAAiC;IAC9G,IAAM,cAAc,GAAI,WAA+D,CAAC,OAAO,CAAA;IAC/F,IAAI,CAAC,cAAc;QAAE,OAAO,KAAK,CAAA;IACjC,IAAM,SAAS,GAAI,cAA2D,CAAC,EAAE,CAAA;IACjF,OAAO,CAAC,CAAC,SAAS,CAAA;AACpB,CAAC;AALD,sDAKC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import WithIdOption from './WithIdOption';
|
|
2
|
-
import WithPlayersOptions from './WithPlayersOptions';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
1
|
+
import { WithIdOption } from './WithIdOption';
|
|
2
|
+
import { WithPlayersOptions } from './WithPlayersOptions';
|
|
3
|
+
export declare function providePlayerIds(players: number): number[];
|
|
4
|
+
export declare function providePlayerIds<Options>(players: number, options: Options): number[];
|
|
5
|
+
export declare function providePlayerIds<Id, Player extends WithIdOption<Id>, Options extends WithPlayersOptions<Player>>(players: number, options: Options): Id[];
|
|
6
|
+
export declare function providePlayerIds<Id, Player extends WithIdOption<Id>, Options extends WithPlayersOptions<Player>>(players: (Id | null)[], options: Options): Id[];
|
|
@@ -8,23 +8,21 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
8
8
|
}
|
|
9
9
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
|
|
12
|
+
exports.providePlayerIds = void 0;
|
|
13
|
+
var isWithPlayerIdOptions_1 = require("./isWithPlayerIdOptions");
|
|
16
14
|
var PlayerIdSpec_1 = require("./PlayerIdSpec");
|
|
17
15
|
function providePlayerIds(players, optionsSpec) {
|
|
18
16
|
var result = typeof players === 'number' ? Array(players).fill(null) : __spreadArray([], players, true);
|
|
19
17
|
var numberOfPlayers = typeof players === 'number' ? players : players.length;
|
|
20
|
-
var mandatoryIds = optionsSpec && (0, isWithPlayerIdOptions_1.
|
|
18
|
+
var mandatoryIds = optionsSpec && (0, isWithPlayerIdOptions_1.isWithPlayerIdOptions)(optionsSpec) ? (0, PlayerIdSpec_1.getMandatoryIds)(optionsSpec.players.id, numberOfPlayers) : [];
|
|
21
19
|
while (mandatoryIds.some(function (id) { return !result.includes(id); })) {
|
|
22
20
|
var mandatoryId = mandatoryIds.find(function (id) { return !result.includes(id); });
|
|
23
21
|
var potentialIndexes = result.map(function (id, index) { return ({ id: id, index: index }); }).filter(function (r) { return !mandatoryIds.includes(r.id); }).map(function (r) { return r.index; });
|
|
24
22
|
var index = potentialIndexes[Math.floor(Math.random() * potentialIndexes.length)];
|
|
25
23
|
result[index] = mandatoryId;
|
|
26
24
|
}
|
|
27
|
-
var potentialIds = (optionsSpec && (0, isWithPlayerIdOptions_1.
|
|
25
|
+
var potentialIds = (optionsSpec && (0, isWithPlayerIdOptions_1.isWithPlayerIdOptions)(optionsSpec) ? (0, PlayerIdSpec_1.getAvailableIds)(optionsSpec.players.id, numberOfPlayers)
|
|
28
26
|
: Array.from(Array(numberOfPlayers).keys()).map(function (id) { return id + 1; }));
|
|
29
27
|
var remainingIds = potentialIds.filter(function (id) { return !result.includes(id); });
|
|
30
28
|
for (var i = 0; i < result.length; i++) {
|
|
@@ -34,5 +32,5 @@ function providePlayerIds(players, optionsSpec) {
|
|
|
34
32
|
}
|
|
35
33
|
return result;
|
|
36
34
|
}
|
|
37
|
-
exports.
|
|
35
|
+
exports.providePlayerIds = providePlayerIds;
|
|
38
36
|
//# sourceMappingURL=providePlayerIds.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providePlayerIds.js","sourceRoot":"","sources":["../../src/options/providePlayerIds.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"providePlayerIds.js","sourceRoot":"","sources":["../../src/options/providePlayerIds.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAA+D;AAE/D,+CAAiE;AASjE,SAAgB,gBAAgB,CAAc,OAA+B,EAAE,WAA8B;IAC3G,IAAM,MAAM,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAK,OAAO,OAAC,CAAA;IAErF,IAAM,eAAe,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAA;IAE9E,IAAM,YAAY,GAAG,WAAW,IAAI,IAAA,6CAAqB,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAA,8BAAe,EAAC,WAAW,CAAC,OAAO,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACtI,OAAO,YAAY,CAAC,IAAI,CAAC,UAAA,EAAE,IAAI,OAAA,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAApB,CAAoB,CAAC,EAAE;QACpD,IAAM,WAAW,GAAG,YAAY,CAAC,IAAI,CAAC,UAAA,EAAE,IAAI,OAAA,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAApB,CAAoB,CAAE,CAAA;QAClE,IAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,UAAC,EAAE,EAAE,KAAK,IAAK,OAAA,CAAC,EAAC,EAAE,IAAA,EAAE,KAAK,OAAA,EAAC,CAAC,EAAb,CAAa,CAAC,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAA5B,CAA4B,CAAC,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,KAAK,EAAP,CAAO,CAAC,CAAA;QAC7H,IAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAA;QACnF,MAAM,CAAC,KAAK,CAAC,GAAG,WAAW,CAAA;KAC5B;IAED,IAAM,YAAY,GAAG,CAAC,WAAW,IAAI,IAAA,6CAAqB,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAA,8BAAe,EAAC,WAAW,CAAC,OAAO,CAAC,EAAE,EAAE,eAAe,CAAC;QAChI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,UAAA,EAAE,IAAI,OAAA,EAAE,GAAG,CAAC,EAAN,CAAM,CAAC,CAAS,CAAA;IACxE,IAAM,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,UAAA,EAAE,IAAI,OAAA,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAApB,CAAoB,CAAC,CAAA;IACpE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;YAC3D,MAAM,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;SACvF;KACF;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAvBD,4CAuBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gamepark/rules-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1-alpha.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",
|
|
@@ -19,13 +19,19 @@
|
|
|
19
19
|
"author": "Romain Fromi <romain@game-park.com> (https://game-park.com/)",
|
|
20
20
|
"license": "ISC",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"fast-deep-equal": "^3.1.3"
|
|
22
|
+
"fast-deep-equal": "^3.1.3",
|
|
23
|
+
"lodash.mapvalues": "^4.6.0",
|
|
24
|
+
"lodash.maxby": "^4.6.0",
|
|
25
|
+
"lodash.minby": "^4.6.0"
|
|
23
26
|
},
|
|
24
27
|
"publishConfig": {
|
|
25
28
|
"access": "public"
|
|
26
29
|
},
|
|
27
30
|
"devDependencies": {
|
|
31
|
+
"@types/lodash.mapvalues": "^4.6.7",
|
|
32
|
+
"@types/lodash.maxby": "^4.6.7",
|
|
33
|
+
"@types/lodash.minby": "^4.6.7",
|
|
28
34
|
"i18next": ">=21.3.0"
|
|
29
35
|
},
|
|
30
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "6743256139b4328bcdd2436f03ddc3b3cacecb71"
|
|
31
37
|
}
|