@gamepark/rules-api 6.0.2-alpha.0 → 6.0.4-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/Rules.d.ts +1 -1
- package/dist/UnpredictableMove.d.ts +2 -1
- package/dist/UnpredictableMove.js +3 -2
- package/dist/UnpredictableMove.js.map +1 -1
- package/dist/material/HiddenMaterialRules.d.ts +15 -13
- package/dist/material/HiddenMaterialRules.js +60 -50
- package/dist/material/HiddenMaterialRules.js.map +1 -1
- package/dist/material/MaterialRules.d.ts +12 -11
- package/dist/material/MaterialRules.js +15 -19
- package/dist/material/MaterialRules.js.map +1 -1
- package/dist/material/SecretMaterialRules.d.ts +5 -5
- package/dist/material/SecretMaterialRules.js +1 -17
- package/dist/material/SecretMaterialRules.js.map +1 -1
- package/dist/material/items/Material.d.ts +3 -4
- package/dist/material/items/Material.js +13 -13
- package/dist/material/items/Material.js.map +1 -1
- package/dist/material/items/MaterialMutator.js +9 -5
- package/dist/material/items/MaterialMutator.js.map +1 -1
- package/dist/material/moves/CustomMove.d.ts +2 -0
- package/dist/material/moves/CustomMove.js +6 -0
- package/dist/material/moves/CustomMove.js.map +1 -1
- package/dist/material/moves/MaterialMove.d.ts +6 -11
- package/dist/material/moves/MoveItem.d.ts +3 -0
- package/dist/material/moves/MoveItem.js +5 -1
- package/dist/material/moves/MoveItem.js.map +1 -1
- package/dist/material/moves/MoveKind.d.ts +1 -1
- package/dist/material/moves/MoveKind.js +1 -1
- package/dist/material/moves/MoveKind.js.map +1 -1
- package/dist/material/moves/index.d.ts +1 -6
- package/dist/material/moves/index.js +1 -6
- package/dist/material/moves/index.js.map +1 -1
- package/dist/material/moves/items/CreateItem.d.ts +9 -0
- package/dist/material/moves/items/CreateItem.js +10 -0
- package/dist/material/moves/items/CreateItem.js.map +1 -0
- package/dist/material/moves/items/DeleteItem.d.ts +9 -0
- package/dist/material/moves/items/DeleteItem.js +10 -0
- package/dist/material/moves/items/DeleteItem.js.map +1 -0
- package/dist/material/moves/items/ItemMove.d.ts +11 -0
- package/dist/material/moves/{MaterialRulesMove.js → items/ItemMove.js} +1 -1
- package/dist/material/moves/items/ItemMove.js.map +1 -0
- package/dist/material/moves/items/ItemMoveType.d.ts +6 -0
- package/dist/material/moves/items/ItemMoveType.js +11 -0
- package/dist/material/moves/items/ItemMoveType.js.map +1 -0
- package/dist/material/moves/items/ItemMovesBuilder.d.ts +8 -0
- package/dist/material/moves/items/ItemMovesBuilder.js +34 -0
- package/dist/material/moves/items/ItemMovesBuilder.js.map +1 -0
- package/dist/material/moves/items/MoveItem.d.ts +16 -0
- package/dist/material/moves/items/MoveItem.js +14 -0
- package/dist/material/moves/items/MoveItem.js.map +1 -0
- package/dist/material/moves/items/Shuffle.d.ts +11 -0
- package/dist/material/moves/items/Shuffle.js +10 -0
- package/dist/material/moves/items/Shuffle.js.map +1 -0
- package/dist/material/moves/items/index.d.ts +7 -0
- package/dist/material/moves/items/index.js +24 -0
- package/dist/material/moves/items/index.js.map +1 -0
- package/dist/material/moves/rules/EndGame.d.ts +2 -0
- package/dist/material/moves/rules/EndGame.js +7 -0
- package/dist/material/moves/rules/EndGame.js.map +1 -1
- package/dist/material/moves/rules/StartPlayerTurn.d.ts +2 -0
- package/dist/material/moves/rules/StartPlayerTurn.js +7 -0
- package/dist/material/moves/rules/StartPlayerTurn.js.map +1 -1
- package/dist/material/moves/rules/StartRule.d.ts +2 -0
- package/dist/material/moves/rules/StartRule.js +7 -0
- package/dist/material/moves/rules/StartRule.js.map +1 -1
- package/dist/material/rules/MaterialStepRules.d.ts +10 -9
- package/dist/material/rules/MaterialStepRules.js +6 -9
- package/dist/material/rules/MaterialStepRules.js.map +1 -1
- package/dist/material/rules/PlayerTurnRule.d.ts +4 -4
- package/package.json +2 -2
- package/dist/material/moves/MaterialRulesMove.d.ts +0 -6
- package/dist/material/moves/MaterialRulesMove.js.map +0 -1
package/dist/Rules.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export declare abstract class Rules<Game = any, Move = any, PlayerId = any> {
|
|
|
11
11
|
getAutomaticMoves(): Move[];
|
|
12
12
|
play(move: Move): Move[];
|
|
13
13
|
isOver(playerIds?: PlayerId[]): boolean;
|
|
14
|
-
isUnpredictableMove?(move: Move): boolean;
|
|
14
|
+
isUnpredictableMove?(move: Move, player: PlayerId): boolean;
|
|
15
15
|
}
|
|
@@ -5,7 +5,8 @@ export declare type RulesWithUnpredictableMoves<G = any, M = any, P = any> = Rul
|
|
|
5
5
|
export declare const hasUnpredictableMoves: <G = any, M = any, P = any>(rules: Rules<G, M, P>) => rules is RulesWithUnpredictableMoves<G, M, P>;
|
|
6
6
|
export declare class UnpredictableMoveFilter<G = any, M = any, P = any> extends Rules<G, M, P> {
|
|
7
7
|
rules: RulesWithUnpredictableMoves<G, M, P>;
|
|
8
|
-
|
|
8
|
+
player: P;
|
|
9
|
+
constructor(rules: RulesWithUnpredictableMoves<G, M, P>, player: P);
|
|
9
10
|
play(move: M): M[];
|
|
10
11
|
getAutomaticMoves(): M[];
|
|
11
12
|
filterUnpredictableMoves(moves: M[]): M[];
|
|
@@ -21,9 +21,10 @@ var hasUnpredictableMoves = function (rules) { return typeof rules.isUnpredictab
|
|
|
21
21
|
exports.hasUnpredictableMoves = hasUnpredictableMoves;
|
|
22
22
|
var UnpredictableMoveFilter = /** @class */ (function (_super) {
|
|
23
23
|
__extends(UnpredictableMoveFilter, _super);
|
|
24
|
-
function UnpredictableMoveFilter(rules) {
|
|
24
|
+
function UnpredictableMoveFilter(rules, player) {
|
|
25
25
|
var _this = _super.call(this, rules.game) || this;
|
|
26
26
|
_this.rules = rules;
|
|
27
|
+
_this.player = player;
|
|
27
28
|
return _this;
|
|
28
29
|
}
|
|
29
30
|
UnpredictableMoveFilter.prototype.play = function (move) {
|
|
@@ -34,7 +35,7 @@ var UnpredictableMoveFilter = /** @class */ (function (_super) {
|
|
|
34
35
|
};
|
|
35
36
|
UnpredictableMoveFilter.prototype.filterUnpredictableMoves = function (moves) {
|
|
36
37
|
var _this = this;
|
|
37
|
-
var firstUnpredictableMoveIndex = moves.findIndex(function (move) { return !_this.rules.isUnpredictableMove(move); });
|
|
38
|
+
var firstUnpredictableMoveIndex = moves.findIndex(function (move) { return !_this.rules.isUnpredictableMove(move, _this.player); });
|
|
38
39
|
return (firstUnpredictableMoveIndex !== -1 ? moves.slice(0, firstUnpredictableMoveIndex) : moves);
|
|
39
40
|
};
|
|
40
41
|
return UnpredictableMoveFilter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnpredictableMove.js","sourceRoot":"","sources":["../src/UnpredictableMove.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iCAA+B;AAMxB,IAAM,qBAAqB,GAAG,UACnC,KAAqB,IAC6B,OAAA,OAAO,KAAK,CAAC,mBAAmB,KAAK,UAAU,EAA/C,CAA+C,CAAA;AAFtF,QAAA,qBAAqB,yBAEiE;AAEnG;IAAwE,2CAAc;
|
|
1
|
+
{"version":3,"file":"UnpredictableMove.js","sourceRoot":"","sources":["../src/UnpredictableMove.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iCAA+B;AAMxB,IAAM,qBAAqB,GAAG,UACnC,KAAqB,IAC6B,OAAA,OAAO,KAAK,CAAC,mBAAmB,KAAK,UAAU,EAA/C,CAA+C,CAAA;AAFtF,QAAA,qBAAqB,yBAEiE;AAEnG;IAAwE,2CAAc;IAIpF,iCAAY,KAA2C,EAAE,MAAS;QAAlE,YACE,kBAAM,KAAK,CAAC,IAAI,CAAC,SAGlB;QAFC,KAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,KAAI,CAAC,MAAM,GAAG,MAAM,CAAA;;IACtB,CAAC;IAED,sCAAI,GAAJ,UAAK,IAAO;QACV,OAAO,IAAI,CAAC,wBAAwB,CAAC,iBAAM,IAAI,YAAC,IAAI,CAAC,CAAC,CAAA;IACxD,CAAC;IAED,mDAAiB,GAAjB;QACE,OAAO,IAAI,CAAC,wBAAwB,CAAC,iBAAM,iBAAiB,WAAE,CAAC,CAAA;IACjE,CAAC;IAED,0DAAwB,GAAxB,UAAyB,KAAU;QAAnC,iBAGC;QAFC,IAAM,2BAA2B,GAAG,KAAK,CAAC,SAAS,CAAC,UAAA,IAAI,IAAI,OAAA,CAAC,KAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAI,EAAE,KAAI,CAAC,MAAM,CAAC,EAAlD,CAAkD,CAAC,CAAA;QAC/G,OAAO,CAAC,2BAA2B,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,2BAA2B,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IACnG,CAAC;IACH,8BAAC;AAAD,CAAC,AAtBD,CAAwE,aAAK,GAsB5E;AAtBY,0DAAuB"}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { IncompleteInformation } from '../IncompleteInformation';
|
|
2
2
|
import { MaterialRules } from './MaterialRules';
|
|
3
3
|
import { MaterialGame } from './MaterialGame';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
export declare abstract class HiddenMaterialRules<P extends number = number, M extends number = number, L extends number = number> extends MaterialRules<P, M, L> implements IncompleteInformation<MaterialGame<P, M, L>,
|
|
4
|
+
import { MaterialMove, MaterialRulesMoveRandomized } from './moves';
|
|
5
|
+
import { ItemPosition, Material } from './items';
|
|
6
|
+
export declare abstract class HiddenMaterialRules<P extends number = number, M extends number = number, L extends number = number> extends MaterialRules<P, M, L> implements IncompleteInformation<MaterialGame<P, M, L>, MaterialMove<P, M, L>, MaterialMove<P, M, L>> {
|
|
7
7
|
abstract hidingStrategies: Partial<Record<M, Partial<Record<L, HidingStrategy<P, L>>>>>;
|
|
8
|
+
material(type: M): Material<P, M, L>;
|
|
8
9
|
getItemTypeHidingStrategies(type: M): Partial<Record<L, HidingStrategy<P, L>>> | undefined;
|
|
9
|
-
isUnpredictableMove(move:
|
|
10
|
-
|
|
10
|
+
isUnpredictableMove(move: MaterialMove<P, M, L>, player: P): boolean;
|
|
11
|
+
moveBlocksUndo(move: MaterialMove<P, M, L>): boolean;
|
|
12
|
+
moveRevealsSomething(move: MaterialMove<P, M, L>): boolean;
|
|
11
13
|
getView(player?: P): any;
|
|
12
|
-
hideItem
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
14
|
+
private hideItem;
|
|
15
|
+
private getItemHiddenPaths;
|
|
16
|
+
getMoveView(move: MaterialRulesMoveRandomized<P, M, L>, player?: P): MaterialMove<P, M, L>;
|
|
17
|
+
private getMoveItemView;
|
|
18
|
+
private getMoveItemRevealedPath;
|
|
19
|
+
private moveItemWillRevealSomething;
|
|
18
20
|
private getShuffleItemsView;
|
|
19
21
|
}
|
|
20
|
-
export declare type HidingStrategy<P extends number = number, L extends number = number> = (item:
|
|
21
|
-
export declare const hideItemId:
|
|
22
|
+
export declare type HidingStrategy<P extends number = number, L extends number = number> = (item: ItemPosition<P, L>) => string[];
|
|
23
|
+
export declare const hideItemId: HidingStrategy;
|
|
@@ -45,38 +45,40 @@ var lodash_mapvalues_1 = __importDefault(require("lodash.mapvalues"));
|
|
|
45
45
|
var MaterialRules_1 = require("./MaterialRules");
|
|
46
46
|
var moves_1 = require("./moves");
|
|
47
47
|
var items_1 = require("./items");
|
|
48
|
+
var unset_1 = __importDefault(require("lodash/unset"));
|
|
49
|
+
var difference_1 = __importDefault(require("lodash/difference"));
|
|
50
|
+
var get_1 = __importDefault(require("lodash/get"));
|
|
51
|
+
var set_1 = __importDefault(require("lodash/set"));
|
|
48
52
|
var HiddenMaterialRules = /** @class */ (function (_super) {
|
|
49
53
|
__extends(HiddenMaterialRules, _super);
|
|
50
54
|
function HiddenMaterialRules() {
|
|
51
55
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
52
56
|
}
|
|
57
|
+
HiddenMaterialRules.prototype.material = function (type) {
|
|
58
|
+
var _this = this;
|
|
59
|
+
var _a;
|
|
60
|
+
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; }), function (move) {
|
|
61
|
+
if ((0, moves_1.isMoveItem)(move) && _this.game.players.some(function (player) { return _this.moveItemWillRevealSomething(move, player); })) {
|
|
62
|
+
move.reveal = true;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
};
|
|
53
66
|
HiddenMaterialRules.prototype.getItemTypeHidingStrategies = function (type) {
|
|
54
67
|
return this.hidingStrategies[type];
|
|
55
68
|
};
|
|
56
|
-
HiddenMaterialRules.prototype.isUnpredictableMove = function (move) {
|
|
57
|
-
if (
|
|
58
|
-
return
|
|
59
|
-
if (move.kind !== moves_1.MoveKind.MaterialMove)
|
|
60
|
-
return false;
|
|
61
|
-
if (move.type === moves_1.MaterialMoveType.Move) {
|
|
62
|
-
return move.reveal !== undefined;
|
|
69
|
+
HiddenMaterialRules.prototype.isUnpredictableMove = function (move, player) {
|
|
70
|
+
if ((0, moves_1.isMoveItem)(move)) {
|
|
71
|
+
return this.moveItemWillRevealSomething(move, player);
|
|
63
72
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
HiddenMaterialRules.prototype.randomize = function (move) {
|
|
67
|
-
if (move.kind === moves_1.MoveKind.MaterialMove && move.type === moves_1.MaterialMoveType.Move) {
|
|
68
|
-
// Hack the randomize function to flag any item movement that reveals something, thus making the action undoable
|
|
69
|
-
if (this.hidingStrategies /* TODO: can be undefined during setup because setup is called by constructor */) {
|
|
70
|
-
for (var _i = 0, _a = this.game.players; _i < _a.length; _i++) {
|
|
71
|
-
var player = _a[_i];
|
|
72
|
-
var moveView = this.getMoveItemView(move, player);
|
|
73
|
-
if (moveView.reveal) {
|
|
74
|
-
return _super.prototype.randomize.call(this, __assign(__assign({}, move), { reveal: {} }));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
73
|
+
else {
|
|
74
|
+
return _super.prototype.isUnpredictableMove.call(this, move, player);
|
|
78
75
|
}
|
|
79
|
-
|
|
76
|
+
};
|
|
77
|
+
HiddenMaterialRules.prototype.moveBlocksUndo = function (move) {
|
|
78
|
+
return _super.prototype.moveBlocksUndo.call(this, move) || this.moveRevealsSomething(move);
|
|
79
|
+
};
|
|
80
|
+
HiddenMaterialRules.prototype.moveRevealsSomething = function (move) {
|
|
81
|
+
return (0, moves_1.isMoveItem)(move) && !!move.reveal;
|
|
80
82
|
};
|
|
81
83
|
HiddenMaterialRules.prototype.getView = function (player) {
|
|
82
84
|
var _this = this;
|
|
@@ -89,43 +91,54 @@ var HiddenMaterialRules = /** @class */ (function (_super) {
|
|
|
89
91
|
}) });
|
|
90
92
|
};
|
|
91
93
|
HiddenMaterialRules.prototype.hideItem = function (type, item, player) {
|
|
92
|
-
var
|
|
93
|
-
if (!
|
|
94
|
-
return item;
|
|
95
|
-
var strategy = hidingStrategies[item.location.type];
|
|
96
|
-
if (!strategy)
|
|
94
|
+
var paths = this.getItemHiddenPaths(type, item, player);
|
|
95
|
+
if (!paths.length)
|
|
97
96
|
return item;
|
|
98
|
-
|
|
97
|
+
var hiddenItem = JSON.parse(JSON.stringify(item));
|
|
98
|
+
for (var _i = 0, paths_1 = paths; _i < paths_1.length; _i++) {
|
|
99
|
+
var path = paths_1[_i];
|
|
100
|
+
(0, unset_1.default)(hiddenItem, path);
|
|
101
|
+
}
|
|
102
|
+
return hiddenItem;
|
|
103
|
+
};
|
|
104
|
+
HiddenMaterialRules.prototype.getItemHiddenPaths = function (type, item, player) {
|
|
105
|
+
var _a;
|
|
106
|
+
var hidingStrategy = (_a = this.hidingStrategies[type]) === null || _a === void 0 ? void 0 : _a[item.location.type];
|
|
107
|
+
return hidingStrategy ? hidingStrategy(item, player) : [];
|
|
99
108
|
};
|
|
100
109
|
HiddenMaterialRules.prototype.getMoveView = function (move, player) {
|
|
101
|
-
if (move.kind === moves_1.MoveKind.
|
|
110
|
+
if (move.kind === moves_1.MoveKind.ItemMove && move.itemType in this.hidingStrategies) {
|
|
102
111
|
switch (move.type) {
|
|
103
|
-
case moves_1.
|
|
112
|
+
case moves_1.ItemMoveType.Move:
|
|
104
113
|
return this.getMoveItemView(move, player);
|
|
105
|
-
case moves_1.
|
|
106
|
-
return this.
|
|
107
|
-
case moves_1.
|
|
114
|
+
case moves_1.ItemMoveType.Create:
|
|
115
|
+
return __assign(__assign({}, move), { item: this.hideItem(move.itemType, move.item, player) });
|
|
116
|
+
case moves_1.ItemMoveType.Shuffle:
|
|
108
117
|
return this.getShuffleItemsView(move, player);
|
|
109
118
|
}
|
|
110
119
|
}
|
|
111
120
|
return move;
|
|
112
121
|
};
|
|
113
122
|
HiddenMaterialRules.prototype.getMoveItemView = function (move, player) {
|
|
114
|
-
var
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
var revealedPaths = this.getMoveItemRevealedPath(move, player);
|
|
124
|
+
if (!revealedPaths.length)
|
|
125
|
+
return move;
|
|
126
|
+
var item = this.material(move.itemType).getItem(move.itemIndex);
|
|
127
|
+
var moveView = __assign(__assign({}, move), { reveal: {} });
|
|
128
|
+
for (var _i = 0, revealedPaths_1 = revealedPaths; _i < revealedPaths_1.length; _i++) {
|
|
129
|
+
var path = revealedPaths_1[_i];
|
|
130
|
+
(0, set_1.default)(moveView.reveal, path, (0, get_1.default)(item, path));
|
|
131
|
+
}
|
|
132
|
+
return moveView;
|
|
122
133
|
};
|
|
123
|
-
HiddenMaterialRules.prototype.
|
|
124
|
-
var
|
|
125
|
-
|
|
134
|
+
HiddenMaterialRules.prototype.getMoveItemRevealedPath = function (move, player) {
|
|
135
|
+
var item = this.material(move.itemType).getItem(move.itemIndex);
|
|
136
|
+
var hiddenPathsBefore = this.getItemHiddenPaths(move.itemType, item, player);
|
|
137
|
+
var hiddenPathsAfter = this.getItemHiddenPaths(move.itemType, __assign(__assign({}, item), move.position), player);
|
|
138
|
+
return (0, difference_1.default)(hiddenPathsBefore, hiddenPathsAfter);
|
|
126
139
|
};
|
|
127
|
-
HiddenMaterialRules.prototype.
|
|
128
|
-
return
|
|
140
|
+
HiddenMaterialRules.prototype.moveItemWillRevealSomething = function (move, player) {
|
|
141
|
+
return this.getMoveItemRevealedPath(move, player).length > 0;
|
|
129
142
|
};
|
|
130
143
|
HiddenMaterialRules.prototype.getShuffleItemsView = function (move, _player) {
|
|
131
144
|
// TODO: if shuffling a player's hand, the player should see the result and get the new indexes
|
|
@@ -135,9 +148,6 @@ var HiddenMaterialRules = /** @class */ (function (_super) {
|
|
|
135
148
|
return HiddenMaterialRules;
|
|
136
149
|
}(MaterialRules_1.MaterialRules));
|
|
137
150
|
exports.HiddenMaterialRules = HiddenMaterialRules;
|
|
138
|
-
var hideItemId = function (
|
|
139
|
-
var id = item.id, hiddenItem = __rest(item, ["id"]);
|
|
140
|
-
return hiddenItem;
|
|
141
|
-
};
|
|
151
|
+
var hideItemId = function () { return ['id']; };
|
|
142
152
|
exports.hideItemId = hideItemId;
|
|
143
153
|
//# sourceMappingURL=HiddenMaterialRules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HiddenMaterialRules.js","sourceRoot":"","sources":["../../src/material/HiddenMaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sEAAwC;AACxC,iDAA+C;AAE/C,
|
|
1
|
+
{"version":3,"file":"HiddenMaterialRules.js","sourceRoot":"","sources":["../../src/material/HiddenMaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sEAAwC;AACxC,iDAA+C;AAE/C,iCAA6I;AAC7I,iCAA8D;AAE9D,uDAAgC;AAChC,iEAA0C;AAC1C,mDAA4B;AAC5B,mDAA4B;AAE5B;IACU,uCAAsB;IADhC;;IAwGA,CAA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
2
|
import { Rules } from '../Rules';
|
|
3
|
-
import {
|
|
3
|
+
import { MaterialMove, MaterialRulesMoveRandomized } from './moves';
|
|
4
4
|
import { Material, MaterialItem } from './items';
|
|
5
5
|
import { RandomMove } from '../RandomMove';
|
|
6
6
|
import { MaterialRulesStepCreator, MaterialStepRules } from './rules';
|
|
7
7
|
import { LocationStrategy } from './location';
|
|
8
8
|
import { Undo } from '../Undo';
|
|
9
9
|
import { Action } from '../Action';
|
|
10
|
-
export declare abstract class MaterialRules<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends Rules<MaterialGame<Player, MaterialType, LocationType>,
|
|
10
|
+
export declare abstract class MaterialRules<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends Rules<MaterialGame<Player, MaterialType, LocationType>, MaterialMove<Player, MaterialType, LocationType>, Player> implements RandomMove<MaterialMove<Player, MaterialType, LocationType>, MaterialRulesMoveRandomized<Player, MaterialType, LocationType>>, Undo<MaterialGame<Player, MaterialType, LocationType>, MaterialMove<Player, MaterialType, LocationType>, Player> {
|
|
11
11
|
constructor(state: MaterialGame<Player, MaterialType, LocationType>);
|
|
12
12
|
constructor(options: any);
|
|
13
13
|
items(type: MaterialType): MaterialItem<Player, LocationType>[];
|
|
@@ -20,14 +20,15 @@ export declare abstract class MaterialRules<Player extends number = number, Mate
|
|
|
20
20
|
getMemory<T>(player?: Player): T;
|
|
21
21
|
delegate(): MaterialStepRules<Player, MaterialType, LocationType> | undefined;
|
|
22
22
|
start<RuleId extends number = number>(id: RuleId, player?: Player, memory?: Record<string, any>): void;
|
|
23
|
-
randomize(move:
|
|
24
|
-
play(move:
|
|
25
|
-
isMoveTrigger(move:
|
|
26
|
-
canUndo(action: Action<
|
|
27
|
-
actionBlocksUndo(action: Action<
|
|
28
|
-
actionActivatesPlayer(action: Action<
|
|
29
|
-
moveBlocksUndo(move:
|
|
30
|
-
moveActivatesPlayer(move:
|
|
31
|
-
isUnpredictableMove(move:
|
|
23
|
+
randomize(move: MaterialMove<Player, MaterialType, LocationType>): MaterialMove<Player, MaterialType, LocationType> & MaterialRulesMoveRandomized<Player, MaterialType, LocationType>;
|
|
24
|
+
play(move: MaterialMove<Player, MaterialType, LocationType> & MaterialRulesMoveRandomized<Player, MaterialType, LocationType>): MaterialMove<Player, MaterialType, LocationType>[];
|
|
25
|
+
isMoveTrigger(move: MaterialMove<Player, MaterialType, LocationType>, predicate: (move: MaterialMove<Player, MaterialType, LocationType>) => boolean): boolean;
|
|
26
|
+
canUndo(action: Action<MaterialMove<Player, MaterialType, LocationType>, Player>, consecutiveActions: Action<MaterialMove<Player, MaterialType, LocationType>, Player>[]): boolean;
|
|
27
|
+
actionBlocksUndo(action: Action<MaterialMove<Player, MaterialType, LocationType>, Player>): boolean;
|
|
28
|
+
actionActivatesPlayer(action: Action<MaterialMove<Player, MaterialType, LocationType>, Player>): boolean;
|
|
29
|
+
moveBlocksUndo(move: MaterialMove<Player, MaterialType, LocationType>): boolean;
|
|
30
|
+
moveActivatesPlayer(move: MaterialMove<Player, MaterialType, LocationType>): boolean;
|
|
31
|
+
isUnpredictableMove(move: MaterialMove<Player, MaterialType, LocationType>, _player: Player): boolean;
|
|
32
|
+
isRandomMove(move: MaterialMove<Player, MaterialType, LocationType>): boolean;
|
|
32
33
|
restoreLocalMoves(game: MaterialGame<Player, MaterialType, LocationType>): void;
|
|
33
34
|
}
|
|
@@ -76,18 +76,19 @@ var MaterialRules = /** @class */ (function (_super) {
|
|
|
76
76
|
return __assign(__assign({}, this.game.memory), playerMemory);
|
|
77
77
|
};
|
|
78
78
|
MaterialRules.prototype.delegate = function () {
|
|
79
|
+
var _this = this;
|
|
79
80
|
if (!this.game.rule)
|
|
80
81
|
return;
|
|
81
82
|
var RulesStep = this.rulesSteps[this.game.rule.id];
|
|
82
|
-
return new RulesStep(this.game);
|
|
83
|
+
return new RulesStep(this.game, function (type) { return _this.material(type); });
|
|
83
84
|
};
|
|
84
85
|
MaterialRules.prototype.start = function (id, player, memory) {
|
|
85
86
|
this.game.rule = { id: id, player: player, memory: memory };
|
|
86
87
|
};
|
|
87
88
|
MaterialRules.prototype.randomize = function (move) {
|
|
88
|
-
if (move.kind === moves_1.MoveKind.
|
|
89
|
+
if (move.kind === moves_1.MoveKind.ItemMove) {
|
|
89
90
|
switch (move.type) {
|
|
90
|
-
case moves_1.
|
|
91
|
+
case moves_1.ItemMoveType.Shuffle:
|
|
91
92
|
return __assign(__assign({}, move), { newIndexes: (0, lodash_shuffle_1.default)(move.indexes) });
|
|
92
93
|
}
|
|
93
94
|
}
|
|
@@ -98,16 +99,16 @@ var MaterialRules = /** @class */ (function (_super) {
|
|
|
98
99
|
var consequences = [];
|
|
99
100
|
var delegate = this.delegate();
|
|
100
101
|
switch (move.kind) {
|
|
101
|
-
case moves_1.MoveKind.
|
|
102
|
+
case moves_1.MoveKind.ItemMove:
|
|
102
103
|
if (delegate) {
|
|
103
|
-
consequences.push.apply(consequences, delegate.
|
|
104
|
+
consequences.push.apply(consequences, delegate.beforeItemMove(move));
|
|
104
105
|
}
|
|
105
106
|
if (!this.game.items[move.itemType])
|
|
106
107
|
this.game.items[move.itemType] = [];
|
|
107
108
|
var mutator = new items_1.MaterialMutator(move.itemType, this.game.items[move.itemType], this.getLocationsStrategies()[move.itemType]);
|
|
108
109
|
mutator.applyMove(move);
|
|
109
110
|
if (delegate) {
|
|
110
|
-
consequences.push.apply(consequences, delegate.
|
|
111
|
+
consequences.push.apply(consequences, delegate.afterItemMove(move));
|
|
111
112
|
}
|
|
112
113
|
break;
|
|
113
114
|
case moves_1.MoveKind.RulesMove:
|
|
@@ -176,21 +177,16 @@ var MaterialRules = /** @class */ (function (_super) {
|
|
|
176
177
|
return this.moveActivatesPlayer(action.move);
|
|
177
178
|
};
|
|
178
179
|
MaterialRules.prototype.moveBlocksUndo = function (move) {
|
|
179
|
-
return this.moveActivatesPlayer(move) || this.
|
|
180
|
+
return this.moveActivatesPlayer(move) || this.isRandomMove(move);
|
|
180
181
|
};
|
|
181
182
|
MaterialRules.prototype.moveActivatesPlayer = function (move) {
|
|
182
|
-
return
|
|
183
|
-
};
|
|
184
|
-
MaterialRules.prototype.isUnpredictableMove = function (move) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
// case MaterialMoveType.ThrowDice:
|
|
190
|
-
return true;
|
|
191
|
-
default:
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
183
|
+
return (0, moves_1.isStartPlayerTurn)(move); // TODO: add StartSimultaneousTurns when implemented
|
|
184
|
+
};
|
|
185
|
+
MaterialRules.prototype.isUnpredictableMove = function (move, _player) {
|
|
186
|
+
return this.isRandomMove(move);
|
|
187
|
+
};
|
|
188
|
+
MaterialRules.prototype.isRandomMove = function (move) {
|
|
189
|
+
return (0, moves_1.isShuffle)(move); // TODO: || isThrowDice(move)
|
|
194
190
|
};
|
|
195
191
|
MaterialRules.prototype.restoreLocalMoves = function (game) {
|
|
196
192
|
this.game.rulesDisplay = game.rulesDisplay;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaterialRules.js","sourceRoot":"","sources":["../../src/material/MaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kCAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"MaterialRules.js","sourceRoot":"","sources":["../../src/material/MaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kCAAgC;AAChC,iCAAsJ;AACtJ,kEAAoC;AACpC,iCAAiE;AAOjE;IACU,iCAAiH;IAMzH,uBAAY,GAAQ;QAApB,iBAMC;QALC,IAAM,SAAS,GAAG,CAAE,GAAoB,CAAC,KAAK,CAAA;gBAC9C,kBAAM,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAClE,IAAI,SAAS,E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
|
|
|
1
1
|
import { SecretInformation } from '../IncompleteInformation';
|
|
2
2
|
import { HiddenMaterialRules } from './HiddenMaterialRules';
|
|
3
3
|
import { MaterialGame } from './MaterialGame';
|
|
4
|
-
import {
|
|
4
|
+
import { MaterialMove, MaterialRulesMoveRandomized } from './moves';
|
|
5
5
|
import { MaterialItem } from './items';
|
|
6
|
-
export declare abstract class SecretMaterialRules<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends HiddenMaterialRules<Player, MaterialType, LocationType> implements SecretInformation<MaterialGame,
|
|
6
|
+
export declare abstract class SecretMaterialRules<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends HiddenMaterialRules<Player, MaterialType, LocationType> implements SecretInformation<MaterialGame, MaterialMove<Player, MaterialType, LocationType>, MaterialMove<Player, MaterialType, LocationType>, Player> {
|
|
7
7
|
abstract hidingStrategies: Partial<Record<MaterialType, Partial<Record<LocationType, HidingSecretsStrategy<Player, LocationType>>>>>;
|
|
8
8
|
getPlayerView(player: Player): MaterialGame<Player, MaterialType, LocationType>;
|
|
9
|
-
getPlayerMoveView(move: MaterialRulesMoveRandomized<Player, MaterialType, LocationType>, player: Player):
|
|
9
|
+
getPlayerMoveView(move: MaterialRulesMoveRandomized<Player, MaterialType, LocationType>, player: Player): MaterialMove<Player, MaterialType, LocationType>;
|
|
10
10
|
}
|
|
11
|
-
export declare type HidingSecretsStrategy<P extends number = number, L extends number = number> = (item: MaterialItem<P, L>, player?: P) =>
|
|
12
|
-
export declare const hideItemIdToOthers: <P extends number = number, L extends number = number>(item: MaterialItem<P, L, any>, player?: P) =>
|
|
11
|
+
export declare type HidingSecretsStrategy<P extends number = number, L extends number = number> = (item: MaterialItem<P, L>, player?: P) => string[];
|
|
12
|
+
export declare const hideItemIdToOthers: <P extends number = number, L extends number = number>(item: MaterialItem<P, L, any>, player?: P) => string[];
|
|
@@ -14,17 +14,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
18
|
-
var t = {};
|
|
19
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
20
|
-
t[p] = s[p];
|
|
21
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
22
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
23
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
24
|
-
t[p[i]] = s[p[i]];
|
|
25
|
-
}
|
|
26
|
-
return t;
|
|
27
|
-
};
|
|
28
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
18
|
exports.hideItemIdToOthers = exports.SecretMaterialRules = void 0;
|
|
30
19
|
var HiddenMaterialRules_1 = require("./HiddenMaterialRules");
|
|
@@ -42,11 +31,6 @@ var SecretMaterialRules = /** @class */ (function (_super) {
|
|
|
42
31
|
return SecretMaterialRules;
|
|
43
32
|
}(HiddenMaterialRules_1.HiddenMaterialRules));
|
|
44
33
|
exports.SecretMaterialRules = SecretMaterialRules;
|
|
45
|
-
var hideItemIdToOthers = function (item, player) {
|
|
46
|
-
if (item.location.player === player)
|
|
47
|
-
return item;
|
|
48
|
-
var id = item.id, hiddenItem = __rest(item, ["id"]);
|
|
49
|
-
return hiddenItem;
|
|
50
|
-
};
|
|
34
|
+
var hideItemIdToOthers = function (item, player) { return item.location.player === player ? [] : ['id']; };
|
|
51
35
|
exports.hideItemIdToOthers = hideItemIdToOthers;
|
|
52
36
|
//# sourceMappingURL=SecretMaterialRules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecretMaterialRules.js","sourceRoot":"","sources":["../../src/material/SecretMaterialRules.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SecretMaterialRules.js","sourceRoot":"","sources":["../../src/material/SecretMaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,6DAA2D;AAK3D;IACU,uCAAuD;IADjE;;IAaA,CAAC;IAPC,2CAAa,GAAb,UAAc,MAAc;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC;IAED,+CAAiB,GAAjB,UAAkB,IAAqE,EAAE,MAAc;QACrG,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACvC,CAAC;IACH,0BAAC;AAAD,CAAC,AAbD,CACU,yCAAmB,GAY5B;AAbqB,kDAAmB;AAiBlC,IAAM,kBAAkB,GAAG,UAChC,IAAwB,EAAE,MAAU,IACvB,OAAA,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAA7C,CAA6C,CAAA;AAF/C,QAAA,kBAAkB,sBAE6B"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { ItemPosition, MaterialItem } from './MaterialItem';
|
|
2
2
|
import { Location } from '../location';
|
|
3
|
-
import { CreateItem,
|
|
4
|
-
import { DeleteItem } from '../moves/DeleteItem';
|
|
3
|
+
import { CreateItem, DeleteItem, MaterialMove, MoveItem, Shuffle } from '../moves';
|
|
5
4
|
declare type ItemEntry<P extends number = number, L extends number = number> = [number, MaterialItem<P, L>];
|
|
6
5
|
export declare class Material<P extends number = number, M extends number = number, L extends number = number> {
|
|
7
6
|
private readonly type;
|
|
8
7
|
private readonly entries;
|
|
9
|
-
private readonly
|
|
10
|
-
constructor(type: M, items: ItemEntry<P, L>[],
|
|
8
|
+
private readonly processMove?;
|
|
9
|
+
constructor(type: M, items: ItemEntry<P, L>[], processMove?: (move: MaterialMove<P, M, L>) => void);
|
|
11
10
|
private new;
|
|
12
11
|
getItems(): MaterialItem<P, L>[];
|
|
13
12
|
getItems<T>(mapFn: (item: MaterialItem<P, L>) => T): T[];
|
|
@@ -10,13 +10,13 @@ var minBy_1 = __importDefault(require("lodash/minBy"));
|
|
|
10
10
|
var maxBy_1 = __importDefault(require("lodash/maxBy"));
|
|
11
11
|
var orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
12
12
|
var Material = /** @class */ (function () {
|
|
13
|
-
function Material(type, items,
|
|
13
|
+
function Material(type, items, processMove) {
|
|
14
14
|
this.type = type;
|
|
15
15
|
this.entries = items;
|
|
16
|
-
this.
|
|
16
|
+
this.processMove = processMove;
|
|
17
17
|
}
|
|
18
18
|
Material.prototype.new = function (entries) {
|
|
19
|
-
return new Material(this.type, entries, this.
|
|
19
|
+
return new Material(this.type, entries, this.processMove);
|
|
20
20
|
};
|
|
21
21
|
Material.prototype.getItems = function (mapFn) {
|
|
22
22
|
return this.entries.map(function (entry) { return mapFn ? mapFn(entry[1]) : entry[1]; });
|
|
@@ -96,10 +96,10 @@ var Material = /** @class */ (function () {
|
|
|
96
96
|
return this.new(max ? [max] : []);
|
|
97
97
|
};
|
|
98
98
|
Material.prototype.process = function (moves) {
|
|
99
|
-
if (this.
|
|
99
|
+
if (this.processMove) {
|
|
100
100
|
for (var _i = 0, moves_2 = moves; _i < moves_2.length; _i++) {
|
|
101
101
|
var move = moves_2[_i];
|
|
102
|
-
this.
|
|
102
|
+
this.processMove(move);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
return moves;
|
|
@@ -110,8 +110,8 @@ var Material = /** @class */ (function () {
|
|
|
110
110
|
Material.prototype.createItems = function (items) {
|
|
111
111
|
var _this = this;
|
|
112
112
|
return this.process(items.map(function (item) { return ({
|
|
113
|
-
kind: moves_1.MoveKind.
|
|
114
|
-
type: moves_1.
|
|
113
|
+
kind: moves_1.MoveKind.ItemMove,
|
|
114
|
+
type: moves_1.ItemMoveType.Create,
|
|
115
115
|
itemType: _this.type,
|
|
116
116
|
item: item
|
|
117
117
|
}); }));
|
|
@@ -125,8 +125,8 @@ var Material = /** @class */ (function () {
|
|
|
125
125
|
var _this = this;
|
|
126
126
|
return this.process(this.entries.map(function (entry) {
|
|
127
127
|
var move = {
|
|
128
|
-
kind: moves_1.MoveKind.
|
|
129
|
-
type: moves_1.
|
|
128
|
+
kind: moves_1.MoveKind.ItemMove,
|
|
129
|
+
type: moves_1.ItemMoveType.Delete,
|
|
130
130
|
itemType: _this.type,
|
|
131
131
|
itemIndex: entry[0]
|
|
132
132
|
};
|
|
@@ -146,8 +146,8 @@ var Material = /** @class */ (function () {
|
|
|
146
146
|
delete position.rotation;
|
|
147
147
|
return this.process(this.entries.map(function (entry) {
|
|
148
148
|
var move = {
|
|
149
|
-
kind: moves_1.MoveKind.
|
|
150
|
-
type: moves_1.
|
|
149
|
+
kind: moves_1.MoveKind.ItemMove,
|
|
150
|
+
type: moves_1.ItemMoveType.Move,
|
|
151
151
|
itemType: _this.type,
|
|
152
152
|
itemIndex: entry[0],
|
|
153
153
|
position: position
|
|
@@ -159,8 +159,8 @@ var Material = /** @class */ (function () {
|
|
|
159
159
|
};
|
|
160
160
|
Material.prototype.shuffle = function () {
|
|
161
161
|
return this.process([{
|
|
162
|
-
kind: moves_1.MoveKind.
|
|
163
|
-
type: moves_1.
|
|
162
|
+
kind: moves_1.MoveKind.ItemMove,
|
|
163
|
+
type: moves_1.ItemMoveType.Shuffle,
|
|
164
164
|
itemType: this.type,
|
|
165
165
|
indexes: this.entries.map(function (entry) { return entry[0]; })
|
|
166
166
|
}])[0];
|