@gamepark/rules-api 6.0.3-alpha.0 → 6.0.5-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 +14 -13
- package/dist/material/HiddenMaterialRules.js +58 -51
- package/dist/material/HiddenMaterialRules.js.map +1 -1
- package/dist/material/MaterialGame.d.ts +2 -1
- package/dist/material/MaterialRules.d.ts +11 -9
- package/dist/material/MaterialRules.js +31 -21
- package/dist/material/MaterialRules.js.map +1 -1
- package/dist/material/SecretMaterialRules.d.ts +2 -2
- package/dist/material/SecretMaterialRules.js +1 -17
- package/dist/material/SecretMaterialRules.js.map +1 -1
- package/dist/material/items/Material.d.ts +2 -2
- package/dist/material/items/Material.js +5 -5
- package/dist/material/items/Material.js.map +1 -1
- package/dist/material/items/MaterialMutator.d.ts +5 -4
- package/dist/material/items/MaterialMutator.js +27 -15
- package/dist/material/items/MaterialMutator.js.map +1 -1
- package/dist/material/moves/local/DisplayRules.d.ts +32 -0
- package/dist/material/moves/local/DisplayRules.js +26 -0
- package/dist/material/moves/local/DisplayRules.js.map +1 -0
- package/dist/material/moves/local/DropItem.d.ts +13 -0
- package/dist/material/moves/local/DropItem.js +10 -0
- package/dist/material/moves/local/DropItem.js.map +1 -0
- package/dist/material/moves/local/LocalMove.d.ts +5 -3
- package/dist/material/moves/local/LocalMove.js +1 -0
- package/dist/material/moves/local/LocalMove.js.map +1 -1
- package/dist/material/moves/local/index.d.ts +2 -1
- package/dist/material/moves/local/index.js +2 -1
- package/dist/material/moves/local/index.js.map +1 -1
- package/dist/material/rules/MaterialRulesPart.d.ts +23 -0
- package/dist/material/rules/MaterialRulesPart.js +98 -0
- package/dist/material/rules/MaterialRulesPart.js.map +1 -0
- package/dist/material/rules/MaterialStepRules.d.ts +3 -2
- package/dist/material/rules/MaterialStepRules.js +4 -7
- package/dist/material/rules/MaterialStepRules.js.map +1 -1
- package/dist/material/rules/PlayerTurnRule.d.ts +2 -2
- package/dist/material/rules/PlayerTurnRule.js +2 -2
- package/dist/material/rules/index.d.ts +1 -1
- package/dist/material/rules/index.js +1 -1
- package/package.json +4 -8
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,22 @@
|
|
|
1
1
|
import { IncompleteInformation } from '../IncompleteInformation';
|
|
2
2
|
import { MaterialRules } from './MaterialRules';
|
|
3
3
|
import { MaterialGame } from './MaterialGame';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { MaterialMove, MaterialRulesMoveRandomized } from './moves';
|
|
5
|
+
import { ItemPosition, Material } from './items';
|
|
6
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
|
-
abstract hidingStrategies: Partial<Record<M, Partial<Record<L, HidingStrategy<P, L>>>>>;
|
|
8
|
-
|
|
9
|
-
isUnpredictableMove(move: MaterialMove<P, M, L
|
|
10
|
-
|
|
7
|
+
abstract get hidingStrategies(): Partial<Record<M, Partial<Record<L, HidingStrategy<P, L>>>>>;
|
|
8
|
+
material(type: M): Material<P, M, L>;
|
|
9
|
+
isUnpredictableMove(move: MaterialMove<P, M, L>, player: P): boolean;
|
|
10
|
+
protected moveBlocksUndo(move: MaterialMove<P, M, L>): boolean;
|
|
11
|
+
protected moveRevealsSomething(move: MaterialMove<P, M, L>): boolean;
|
|
11
12
|
getView(player?: P): any;
|
|
12
|
-
hideItem
|
|
13
|
+
private hideItem;
|
|
14
|
+
private getItemHiddenPaths;
|
|
13
15
|
getMoveView(move: MaterialRulesMoveRandomized<P, M, L>, player?: P): MaterialMove<P, M, L>;
|
|
14
|
-
getMoveItemView
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
getCreateItemsView(move: CreateItem<P, M, L>, player?: P): CreateItem<P, M, L>;
|
|
16
|
+
private getMoveItemView;
|
|
17
|
+
private getMoveItemRevealedPath;
|
|
18
|
+
private moveItemWillRevealSomething;
|
|
18
19
|
private getShuffleItemsView;
|
|
19
20
|
}
|
|
20
|
-
export declare type HidingStrategy<P extends number = number, L extends number = number> = (item:
|
|
21
|
-
export declare const hideItemId:
|
|
21
|
+
export declare type HidingStrategy<P extends number = number, L extends number = number> = (item: ItemPosition<P, L>) => string[];
|
|
22
|
+
export declare const hideItemId: HidingStrategy;
|
|
@@ -41,61 +41,67 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
};
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
exports.hideItemId = exports.HiddenMaterialRules = void 0;
|
|
44
|
-
var
|
|
44
|
+
var 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
|
}
|
|
53
|
-
HiddenMaterialRules.prototype.
|
|
54
|
-
|
|
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
|
+
});
|
|
55
65
|
};
|
|
56
|
-
HiddenMaterialRules.prototype.isUnpredictableMove = function (move) {
|
|
57
|
-
if (
|
|
58
|
-
return
|
|
59
|
-
if (move.kind !== moves_1.MoveKind.ItemMove)
|
|
60
|
-
return false;
|
|
61
|
-
if (move.type === moves_1.ItemMoveType.Move) {
|
|
62
|
-
return move.reveal !== undefined;
|
|
66
|
+
HiddenMaterialRules.prototype.isUnpredictableMove = function (move, player) {
|
|
67
|
+
if ((0, moves_1.isMoveItem)(move)) {
|
|
68
|
+
return this.moveItemWillRevealSomething(move, player);
|
|
63
69
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
HiddenMaterialRules.prototype.randomize = function (move) {
|
|
67
|
-
if (move.kind === moves_1.MoveKind.ItemMove && move.type === moves_1.ItemMoveType.Move) {
|
|
68
|
-
if (this.hidingStrategies /* TODO: can be undefined during setup because setup is called by constructor */) {
|
|
69
|
-
for (var _i = 0, _a = this.game.players; _i < _a.length; _i++) {
|
|
70
|
-
var player = _a[_i];
|
|
71
|
-
var moveView = this.getMoveItemView(move, player);
|
|
72
|
-
if (moveView.reveal) {
|
|
73
|
-
// We flag the move in order to know that it revealed something to someone, which means it cannot be undone
|
|
74
|
-
return _super.prototype.randomize.call(this, __assign(__assign({}, move), { reveal: true }));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
70
|
+
else {
|
|
71
|
+
return _super.prototype.isUnpredictableMove.call(this, move, player);
|
|
78
72
|
}
|
|
79
|
-
|
|
73
|
+
};
|
|
74
|
+
HiddenMaterialRules.prototype.moveBlocksUndo = function (move) {
|
|
75
|
+
return _super.prototype.moveBlocksUndo.call(this, move) || this.moveRevealsSomething(move);
|
|
76
|
+
};
|
|
77
|
+
HiddenMaterialRules.prototype.moveRevealsSomething = function (move) {
|
|
78
|
+
return (0, moves_1.isMoveItem)(move) && !!move.reveal;
|
|
80
79
|
};
|
|
81
80
|
HiddenMaterialRules.prototype.getView = function (player) {
|
|
82
81
|
var _this = this;
|
|
83
|
-
return __assign(__assign({}, this.game), { items: (0,
|
|
82
|
+
return __assign(__assign({}, this.game), { items: (0, mapvalues_1.default)(this.game.items, function (items, stringType) {
|
|
84
83
|
var itemsType = parseInt(stringType);
|
|
85
|
-
var hidingStrategies = _this.
|
|
84
|
+
var hidingStrategies = _this.hidingStrategies[itemsType];
|
|
86
85
|
if (!hidingStrategies || !items)
|
|
87
86
|
return items;
|
|
88
87
|
return items.map(function (item) { return _this.hideItem(itemsType, item, player); });
|
|
89
88
|
}) });
|
|
90
89
|
};
|
|
91
90
|
HiddenMaterialRules.prototype.hideItem = function (type, item, player) {
|
|
92
|
-
var
|
|
93
|
-
if (!
|
|
94
|
-
return item;
|
|
95
|
-
var strategy = hidingStrategies[item.location.type];
|
|
96
|
-
if (!strategy)
|
|
91
|
+
var paths = this.getItemHiddenPaths(type, item, player);
|
|
92
|
+
if (!paths.length)
|
|
97
93
|
return item;
|
|
98
|
-
|
|
94
|
+
var hiddenItem = JSON.parse(JSON.stringify(item));
|
|
95
|
+
for (var _i = 0, paths_1 = paths; _i < paths_1.length; _i++) {
|
|
96
|
+
var path = paths_1[_i];
|
|
97
|
+
(0, unset_1.default)(hiddenItem, path);
|
|
98
|
+
}
|
|
99
|
+
return hiddenItem;
|
|
100
|
+
};
|
|
101
|
+
HiddenMaterialRules.prototype.getItemHiddenPaths = function (type, item, player) {
|
|
102
|
+
var _a;
|
|
103
|
+
var hidingStrategy = (_a = this.hidingStrategies[type]) === null || _a === void 0 ? void 0 : _a[item.location.type];
|
|
104
|
+
return hidingStrategy ? hidingStrategy(item, player) : [];
|
|
99
105
|
};
|
|
100
106
|
HiddenMaterialRules.prototype.getMoveView = function (move, player) {
|
|
101
107
|
if (move.kind === moves_1.MoveKind.ItemMove && move.itemType in this.hidingStrategies) {
|
|
@@ -103,7 +109,7 @@ var HiddenMaterialRules = /** @class */ (function (_super) {
|
|
|
103
109
|
case moves_1.ItemMoveType.Move:
|
|
104
110
|
return this.getMoveItemView(move, player);
|
|
105
111
|
case moves_1.ItemMoveType.Create:
|
|
106
|
-
return this.
|
|
112
|
+
return __assign(__assign({}, move), { item: this.hideItem(move.itemType, move.item, player) });
|
|
107
113
|
case moves_1.ItemMoveType.Shuffle:
|
|
108
114
|
return this.getShuffleItemsView(move, player);
|
|
109
115
|
}
|
|
@@ -111,21 +117,25 @@ var HiddenMaterialRules = /** @class */ (function (_super) {
|
|
|
111
117
|
return move;
|
|
112
118
|
};
|
|
113
119
|
HiddenMaterialRules.prototype.getMoveItemView = function (move, player) {
|
|
114
|
-
var
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
var revealedPaths = this.getMoveItemRevealedPath(move, player);
|
|
121
|
+
if (!revealedPaths.length)
|
|
122
|
+
return move;
|
|
123
|
+
var item = this.material(move.itemType).getItem(move.itemIndex);
|
|
124
|
+
var moveView = __assign(__assign({}, move), { reveal: {} });
|
|
125
|
+
for (var _i = 0, revealedPaths_1 = revealedPaths; _i < revealedPaths_1.length; _i++) {
|
|
126
|
+
var path = revealedPaths_1[_i];
|
|
127
|
+
(0, set_1.default)(moveView.reveal, path, (0, get_1.default)(item, path));
|
|
128
|
+
}
|
|
129
|
+
return moveView;
|
|
122
130
|
};
|
|
123
|
-
HiddenMaterialRules.prototype.
|
|
124
|
-
var
|
|
125
|
-
|
|
131
|
+
HiddenMaterialRules.prototype.getMoveItemRevealedPath = function (move, player) {
|
|
132
|
+
var item = this.material(move.itemType).getItem(move.itemIndex);
|
|
133
|
+
var hiddenPathsBefore = this.getItemHiddenPaths(move.itemType, item, player);
|
|
134
|
+
var hiddenPathsAfter = this.getItemHiddenPaths(move.itemType, __assign(__assign({}, item), move.position), player);
|
|
135
|
+
return (0, difference_1.default)(hiddenPathsBefore, hiddenPathsAfter);
|
|
126
136
|
};
|
|
127
|
-
HiddenMaterialRules.prototype.
|
|
128
|
-
return
|
|
137
|
+
HiddenMaterialRules.prototype.moveItemWillRevealSomething = function (move, player) {
|
|
138
|
+
return this.getMoveItemRevealedPath(move, player).length > 0;
|
|
129
139
|
};
|
|
130
140
|
HiddenMaterialRules.prototype.getShuffleItemsView = function (move, _player) {
|
|
131
141
|
// TODO: if shuffling a player's hand, the player should see the result and get the new indexes
|
|
@@ -135,9 +145,6 @@ var HiddenMaterialRules = /** @class */ (function (_super) {
|
|
|
135
145
|
return HiddenMaterialRules;
|
|
136
146
|
}(MaterialRules_1.MaterialRules));
|
|
137
147
|
exports.HiddenMaterialRules = HiddenMaterialRules;
|
|
138
|
-
var hideItemId = function (
|
|
139
|
-
var id = item.id, hiddenItem = __rest(item, ["id"]);
|
|
140
|
-
return hiddenItem;
|
|
141
|
-
};
|
|
148
|
+
var hideItemId = function () { return ['id']; };
|
|
142
149
|
exports.hideItemId = hideItemId;
|
|
143
150
|
//# sourceMappingURL=HiddenMaterialRules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HiddenMaterialRules.js","sourceRoot":"","sources":["../../src/material/HiddenMaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA
|
|
1
|
+
{"version":3,"file":"HiddenMaterialRules.js","sourceRoot":"","sources":["../../src/material/HiddenMaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+DAAwC;AACxC,iDAA+C;AAE/C,iCAA6I;AAC7I,iCAA8D;AAE9D,uDAAgC;AAChC,iEAA0C;AAC1C,mDAA4B;AAC5B,mDAA4B;AAE5B;IACU,uCAAsB;IADhC;;IAoGA,CAAC;IA9FU,sCAAQ,GAAjB,UAAkB,IAAO;QAAzB,iBAQC;;QAPC,OAAO,IAAI,gBAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,EAAvB,CAAuB,CAAC,EACpH,UAAA,IAAI;YACF,IAAI,IAAA,kBAAU,EAAC,IAAI,CAAC,IAAI,KAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,KAAI,CAAC,2BAA2B,CAAC,IAAI,EAAE,MAAM,CAAC,EAA9C,CAA8C,CAAC,EAAE;gBACxG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;aACnB;QACH,CAAC,CACF,CAAA;IACH,CAAC;IAED,iDAAmB,GAAnB,UAAoB,IAA2B,EAAE,MAAS;QACxD,IAAI,IAAA,kBA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EO,iDAAmB,GAA3B,UAA4B,IAA0B,EAAE,OAAW;QACjE,+FAA+F;QACvF,IAAA,UAAU,GAAkB,IAAI,WAAtB,EAAK,QAAQ,UAAK,IAAI,EAAlC,cAA2B,CAAF,CAAS;QACxC,OAAO,QAAQ,CAAA;IACjB,CAAC;IACH,0BAAC;AAAD,CAAC,AApGD,CACU,6BAAa,GAmGtB;AApGqB,kDAAmB;AAwGlC,IAAM,UAAU,GAAmB,cAAM,OAAA,CAAC,IAAI,CAAC,EAAN,CAAM,CAAA;AAAzC,QAAA,UAAU,cAA+B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MaterialItem } from './items';
|
|
2
2
|
import { RuleStep } from './rules';
|
|
3
|
-
import { RulesDisplay } from './moves';
|
|
3
|
+
import { DisplayedItem, RulesDisplay } from './moves';
|
|
4
4
|
export declare type MaterialGame<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> = {
|
|
5
5
|
players: Player[];
|
|
6
6
|
items: Partial<Record<MaterialType, MaterialItem<Player, LocationType>[]>>;
|
|
@@ -8,4 +8,5 @@ export declare type MaterialGame<Player extends number = number, MaterialType ex
|
|
|
8
8
|
memory?: Record<string, any>;
|
|
9
9
|
playersMemory?: Partial<Record<Player, Record<string, any>>>;
|
|
10
10
|
rulesDisplay?: RulesDisplay<Player, MaterialType, LocationType>;
|
|
11
|
+
droppedItem?: DisplayedItem<MaterialType>;
|
|
11
12
|
};
|
|
@@ -3,7 +3,7 @@ import { Rules } from '../Rules';
|
|
|
3
3
|
import { MaterialMove, MaterialRulesMoveRandomized } from './moves';
|
|
4
4
|
import { Material, MaterialItem } from './items';
|
|
5
5
|
import { RandomMove } from '../RandomMove';
|
|
6
|
-
import {
|
|
6
|
+
import { MaterialRulesPartCreator, MaterialRulesPart } from './rules';
|
|
7
7
|
import { LocationStrategy } from './location';
|
|
8
8
|
import { Undo } from '../Undo';
|
|
9
9
|
import { Action } from '../Action';
|
|
@@ -14,20 +14,22 @@ export declare abstract class MaterialRules<Player extends number = number, Mate
|
|
|
14
14
|
setupMaterial(type: MaterialType): Material<Player, MaterialType, LocationType>;
|
|
15
15
|
material(type: MaterialType): Material<Player, MaterialType, LocationType>;
|
|
16
16
|
abstract setup(options: any): void;
|
|
17
|
-
abstract get
|
|
18
|
-
|
|
17
|
+
abstract get rules(): Record<number, MaterialRulesPartCreator<Player, MaterialType, LocationType>>;
|
|
18
|
+
get locationsStrategies(): Partial<Record<MaterialType, Partial<Record<LocationType, LocationStrategy<Player, MaterialType, LocationType>>>>>;
|
|
19
19
|
get players(): Player[];
|
|
20
20
|
getMemory<T>(player?: Player): T;
|
|
21
|
-
delegate():
|
|
21
|
+
delegate(): MaterialRulesPart<Player, MaterialType, LocationType> | undefined;
|
|
22
22
|
start<RuleId extends number = number>(id: RuleId, player?: Player, memory?: Record<string, any>): void;
|
|
23
23
|
randomize(move: MaterialMove<Player, MaterialType, LocationType>): MaterialMove<Player, MaterialType, LocationType> & MaterialRulesMoveRandomized<Player, MaterialType, LocationType>;
|
|
24
24
|
play(move: MaterialMove<Player, MaterialType, LocationType> & MaterialRulesMoveRandomized<Player, MaterialType, LocationType>): MaterialMove<Player, MaterialType, LocationType>[];
|
|
25
25
|
isMoveTrigger(move: MaterialMove<Player, MaterialType, LocationType>, predicate: (move: MaterialMove<Player, MaterialType, LocationType>) => boolean): boolean;
|
|
26
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
|
|
27
|
+
protected actionBlocksUndo(action: Action<MaterialMove<Player, MaterialType, LocationType>, Player>): boolean;
|
|
28
|
+
protected actionActivatesPlayer(action: Action<MaterialMove<Player, MaterialType, LocationType>, Player>): boolean;
|
|
29
|
+
protected moveBlocksUndo(move: MaterialMove<Player, MaterialType, LocationType>): boolean;
|
|
30
|
+
protected moveActivatesPlayer(move: MaterialMove<Player, MaterialType, LocationType>): boolean;
|
|
31
|
+
isUnpredictableMove(move: MaterialMove<Player, MaterialType, LocationType>, _player: Player): boolean;
|
|
32
|
+
protected isRandomMove(move: MaterialMove<Player, MaterialType, LocationType>): boolean;
|
|
32
33
|
restoreLocalMoves(game: MaterialGame<Player, MaterialType, LocationType>): void;
|
|
34
|
+
isOver(playerIds?: Player[]): boolean;
|
|
33
35
|
}
|
|
@@ -32,7 +32,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
32
32
|
exports.MaterialRules = void 0;
|
|
33
33
|
var Rules_1 = require("../Rules");
|
|
34
34
|
var moves_1 = require("./moves");
|
|
35
|
-
var
|
|
35
|
+
var shuffle_1 = __importDefault(require("lodash/shuffle"));
|
|
36
36
|
var items_1 = require("./items");
|
|
37
37
|
var MaterialRules = /** @class */ (function (_super) {
|
|
38
38
|
__extends(MaterialRules, _super);
|
|
@@ -60,9 +60,13 @@ var MaterialRules = /** @class */ (function (_super) {
|
|
|
60
60
|
var _a;
|
|
61
61
|
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; }));
|
|
62
62
|
};
|
|
63
|
-
MaterialRules.prototype
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
Object.defineProperty(MaterialRules.prototype, "locationsStrategies", {
|
|
64
|
+
get: function () {
|
|
65
|
+
return {};
|
|
66
|
+
},
|
|
67
|
+
enumerable: false,
|
|
68
|
+
configurable: true
|
|
69
|
+
});
|
|
66
70
|
Object.defineProperty(MaterialRules.prototype, "players", {
|
|
67
71
|
get: function () {
|
|
68
72
|
return this.game.players;
|
|
@@ -76,10 +80,11 @@ var MaterialRules = /** @class */ (function (_super) {
|
|
|
76
80
|
return __assign(__assign({}, this.game.memory), playerMemory);
|
|
77
81
|
};
|
|
78
82
|
MaterialRules.prototype.delegate = function () {
|
|
83
|
+
var _this = this;
|
|
79
84
|
if (!this.game.rule)
|
|
80
85
|
return;
|
|
81
|
-
var RulesStep = this.
|
|
82
|
-
return new RulesStep(this.game);
|
|
86
|
+
var RulesStep = this.rules[this.game.rule.id];
|
|
87
|
+
return new RulesStep(this.game, function (type) { return _this.material(type); });
|
|
83
88
|
};
|
|
84
89
|
MaterialRules.prototype.start = function (id, player, memory) {
|
|
85
90
|
this.game.rule = { id: id, player: player, memory: memory };
|
|
@@ -88,7 +93,7 @@ var MaterialRules = /** @class */ (function (_super) {
|
|
|
88
93
|
if (move.kind === moves_1.MoveKind.ItemMove) {
|
|
89
94
|
switch (move.type) {
|
|
90
95
|
case moves_1.ItemMoveType.Shuffle:
|
|
91
|
-
return __assign(__assign({}, move), { newIndexes: (0,
|
|
96
|
+
return __assign(__assign({}, move), { newIndexes: (0, shuffle_1.default)(move.indexes) });
|
|
92
97
|
}
|
|
93
98
|
}
|
|
94
99
|
return move;
|
|
@@ -104,8 +109,12 @@ var MaterialRules = /** @class */ (function (_super) {
|
|
|
104
109
|
}
|
|
105
110
|
if (!this.game.items[move.itemType])
|
|
106
111
|
this.game.items[move.itemType] = [];
|
|
107
|
-
var mutator = new items_1.MaterialMutator(move.itemType, this.game.items[move.itemType], this.
|
|
112
|
+
var mutator = new items_1.MaterialMutator(move.itemType, this.game.items[move.itemType], this.locationsStrategies[move.itemType]);
|
|
108
113
|
mutator.applyMove(move);
|
|
114
|
+
if (this.game.droppedItem && ((0, moves_1.isMoveItem)(move) || (0, moves_1.isDeleteItem)(move))
|
|
115
|
+
&& this.game.droppedItem.type === move.itemType && move.itemIndex === this.game.droppedItem.index) {
|
|
116
|
+
delete this.game.droppedItem;
|
|
117
|
+
}
|
|
109
118
|
if (delegate) {
|
|
110
119
|
consequences.push.apply(consequences, delegate.afterItemMove(move));
|
|
111
120
|
}
|
|
@@ -142,6 +151,9 @@ var MaterialRules = /** @class */ (function (_super) {
|
|
|
142
151
|
case moves_1.LocalMoveType.CloseRulesDisplay:
|
|
143
152
|
delete this.game.rulesDisplay;
|
|
144
153
|
break;
|
|
154
|
+
case moves_1.LocalMoveType.DropItem:
|
|
155
|
+
this.game.droppedItem = move.item;
|
|
156
|
+
break;
|
|
145
157
|
}
|
|
146
158
|
}
|
|
147
159
|
return consequences;
|
|
@@ -176,25 +188,23 @@ var MaterialRules = /** @class */ (function (_super) {
|
|
|
176
188
|
return this.moveActivatesPlayer(action.move);
|
|
177
189
|
};
|
|
178
190
|
MaterialRules.prototype.moveBlocksUndo = function (move) {
|
|
179
|
-
return this.moveActivatesPlayer(move) || this.
|
|
191
|
+
return this.moveActivatesPlayer(move) || this.isRandomMove(move);
|
|
180
192
|
};
|
|
181
193
|
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
|
-
}
|
|
194
|
+
return (0, moves_1.isStartPlayerTurn)(move); // TODO: add StartSimultaneousTurns when implemented
|
|
195
|
+
};
|
|
196
|
+
MaterialRules.prototype.isUnpredictableMove = function (move, _player) {
|
|
197
|
+
return this.isRandomMove(move);
|
|
198
|
+
};
|
|
199
|
+
MaterialRules.prototype.isRandomMove = function (move) {
|
|
200
|
+
return (0, moves_1.isShuffle)(move); // TODO: || isThrowDice(move)
|
|
194
201
|
};
|
|
195
202
|
MaterialRules.prototype.restoreLocalMoves = function (game) {
|
|
196
203
|
this.game.rulesDisplay = game.rulesDisplay;
|
|
197
204
|
};
|
|
205
|
+
MaterialRules.prototype.isOver = function (playerIds) {
|
|
206
|
+
return _super.prototype.isOver.call(this, playerIds !== null && playerIds !== void 0 ? playerIds : this.game.players);
|
|
207
|
+
};
|
|
198
208
|
return MaterialRules;
|
|
199
209
|
}(Rules_1.Rules));
|
|
200
210
|
exports.MaterialRules = MaterialRules;
|
|
@@ -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,iCAWgB;AAChB,2DAAoC;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,EAAE;YACb,KAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SAChB;;IACH,CAAC;IAED,6BAAK,GAAL,UAAM,IAAkB;;QACtB,OAAO,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAA;IACpC,CAAC;IAED,qCAAa,GAAb,UAAc,IAAkB;QAAhC,iBAIC;;QAHC,OAAO,IAAI,gBAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,MAAA,IAAI,CAAC,IAAI,CAAC,KAA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MAAA,OAAO,CAAC,OAAO,mCAAI,CAAC,CAAA;QAC5C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAClD,UAAC,EAAE,IAAK,OAAA,CAAC,EAAE,GAAG,CAAC,CAAW,EAAlB,CAAkB,CAC3B,CAAA;KACF;AACH,CAAC"}
|
|
@@ -8,5 +8,5 @@ export declare abstract class SecretMaterialRules<Player extends number = number
|
|
|
8
8
|
getPlayerView(player: Player): MaterialGame<Player, MaterialType, LocationType>;
|
|
9
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"}
|
|
@@ -5,8 +5,8 @@ declare type ItemEntry<P extends number = number, L extends number = number> = [
|
|
|
5
5
|
export declare class Material<P extends number = number, M extends number = number, L extends number = number> {
|
|
6
6
|
private readonly type;
|
|
7
7
|
private readonly entries;
|
|
8
|
-
private readonly
|
|
9
|
-
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);
|
|
10
10
|
private new;
|
|
11
11
|
getItems(): MaterialItem<P, L>[];
|
|
12
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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Material.js","sourceRoot":"","sources":["../../../src/material/items/Material.ts"],"names":[],"mappings":";;;;;;AAEA,oEAAmC;AACnC,kCAAoH;AACpH,uDAAgC;AAChC,uDAAgC;AAChC,2DAAoC;AAIpC;IAME,kBAAY,IAAO,EAAE,KAAwB,EAAE,
|
|
1
|
+
{"version":3,"file":"Material.js","sourceRoot":"","sources":["../../../src/material/items/Material.ts"],"names":[],"mappings":";;;;;;AAEA,oEAAmC;AACnC,kCAAoH;AACpH,uDAAgC;AAChC,uDAAgC;AAChC,2DAAoC;AAIpC;IAME,kBAAY,IAAO,EAAE,KAAwB,EAAE,WAAmD;QAChG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QACpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAEO,sBAAG,GAAX,UAAY,OAA0B;QACpC,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;IAC3D,CAAC;IAID,2BAAQ,GAAR,UAAY,KAAuC;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAlC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AI,OAAA,KAAK,CAAC,CAAC,CAAC,EAAR,CAAQ,CAAC;aAC7C,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACR,CAAC;IACH,eAAC;AAAD,CAAC,AAxJD,IAwJC;AAxJY,4BAAQ"}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { MaterialItem } from './index';
|
|
2
2
|
import { LocationStrategy } from '../location';
|
|
3
|
-
import { MaterialMoveRandomized, MoveItem } from '../moves';
|
|
3
|
+
import { CreateItem, MaterialMoveRandomized, MoveItem } from '../moves';
|
|
4
4
|
export declare class MaterialMutator<P extends number = number, M extends number = number, L extends number = number> {
|
|
5
5
|
readonly type: M;
|
|
6
6
|
items: MaterialItem<P, L>[];
|
|
7
7
|
locationsStrategies: Partial<Record<L, LocationStrategy<P, M, L>>>;
|
|
8
8
|
constructor(type: M, items: MaterialItem<P, L>[], locationsStrategies?: Partial<Record<L, LocationStrategy<P, M, L>>>);
|
|
9
9
|
applyMove(move: MaterialMoveRandomized<P, M, L>): void;
|
|
10
|
-
|
|
10
|
+
private findMergeIndex;
|
|
11
11
|
private addItem;
|
|
12
12
|
private applyAddItemStrategy;
|
|
13
13
|
private removeItem;
|
|
14
14
|
private applyRemoveItemStrategy;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
create(move: CreateItem<P, M, L>): number;
|
|
16
|
+
move(move: MoveItem<P, M, L>): number;
|
|
17
17
|
getItemAfterMove(move: MoveItem<P, M, L>): MaterialItem<P, L>;
|
|
18
18
|
private delete;
|
|
19
19
|
private shuffle;
|
|
20
20
|
}
|
|
21
|
+
export declare const itemsCanMerge: ({ quantity: q1, ...data1 }: MaterialItem, { quantity: quantityB, ...data2 }: MaterialItem) => boolean;
|
|
@@ -25,10 +25,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.MaterialMutator = void 0;
|
|
28
|
+
exports.itemsCanMerge = exports.MaterialMutator = void 0;
|
|
29
29
|
var index_1 = require("./index");
|
|
30
30
|
var fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
31
31
|
var moves_1 = require("../moves");
|
|
32
|
+
var merge_1 = __importDefault(require("lodash/merge"));
|
|
32
33
|
var MaterialMutator = /** @class */ (function () {
|
|
33
34
|
function MaterialMutator(type, items, locationsStrategies) {
|
|
34
35
|
if (locationsStrategies === void 0) { locationsStrategies = {}; }
|
|
@@ -52,21 +53,19 @@ var MaterialMutator = /** @class */ (function () {
|
|
|
52
53
|
break;
|
|
53
54
|
}
|
|
54
55
|
};
|
|
55
|
-
MaterialMutator.prototype.
|
|
56
|
-
return this.items.
|
|
57
|
-
var itemQuantity = item.quantity, itemWithoutQuantity = __rest(item, ["quantity"]);
|
|
58
|
-
var newItemQuantity = newItem.quantity, newItemWithoutQuantity = __rest(newItem, ["quantity"]);
|
|
59
|
-
return (0, fast_deep_equal_1.default)(itemWithoutQuantity, newItemWithoutQuantity);
|
|
60
|
-
});
|
|
56
|
+
MaterialMutator.prototype.findMergeIndex = function (newItem) {
|
|
57
|
+
return this.items.findIndex(function (item) { return (0, exports.itemsCanMerge)(item, newItem); });
|
|
61
58
|
};
|
|
62
59
|
MaterialMutator.prototype.addItem = function (item) {
|
|
63
60
|
this.applyAddItemStrategy(item);
|
|
64
61
|
var availableIndex = this.items.findIndex(function (item) { return item.quantity === 0; });
|
|
65
62
|
if (availableIndex !== -1) {
|
|
66
63
|
this.items[availableIndex] = item;
|
|
64
|
+
return availableIndex;
|
|
67
65
|
}
|
|
68
66
|
else {
|
|
69
67
|
this.items.push(item);
|
|
68
|
+
return this.items.length - 1;
|
|
70
69
|
}
|
|
71
70
|
};
|
|
72
71
|
MaterialMutator.prototype.applyAddItemStrategy = function (item) {
|
|
@@ -99,12 +98,14 @@ var MaterialMutator = /** @class */ (function () {
|
|
|
99
98
|
};
|
|
100
99
|
MaterialMutator.prototype.create = function (move) {
|
|
101
100
|
var _a, _b;
|
|
102
|
-
var
|
|
103
|
-
if (
|
|
101
|
+
var mergeIndex = this.findMergeIndex(move.item);
|
|
102
|
+
if (mergeIndex !== -1) {
|
|
103
|
+
var mergeItem = this.items[mergeIndex];
|
|
104
104
|
mergeItem.quantity = ((_a = mergeItem.quantity) !== null && _a !== void 0 ? _a : 1) + ((_b = move.item.quantity) !== null && _b !== void 0 ? _b : 1);
|
|
105
|
+
return mergeIndex;
|
|
105
106
|
}
|
|
106
107
|
else {
|
|
107
|
-
this.addItem(move.item);
|
|
108
|
+
return this.addItem(move.item);
|
|
108
109
|
}
|
|
109
110
|
};
|
|
110
111
|
MaterialMutator.prototype.move = function (move) {
|
|
@@ -112,25 +113,30 @@ var MaterialMutator = /** @class */ (function () {
|
|
|
112
113
|
var quantity = (_a = move.quantity) !== null && _a !== void 0 ? _a : 1;
|
|
113
114
|
var sourceItem = this.items[move.itemIndex];
|
|
114
115
|
var itemAfterMove = this.getItemAfterMove(move);
|
|
115
|
-
var
|
|
116
|
-
if (
|
|
116
|
+
var mergeIndex = this.findMergeIndex(itemAfterMove);
|
|
117
|
+
if (mergeIndex !== -1) {
|
|
118
|
+
var mergeItem = this.items[mergeIndex];
|
|
117
119
|
mergeItem.quantity = ((_b = mergeItem.quantity) !== null && _b !== void 0 ? _b : 1) + quantity;
|
|
118
120
|
this.removeItem(sourceItem, quantity);
|
|
121
|
+
return mergeIndex;
|
|
119
122
|
}
|
|
120
123
|
else if (sourceItem.quantity && sourceItem.quantity > quantity) {
|
|
121
124
|
sourceItem.quantity -= quantity;
|
|
122
|
-
this.addItem(itemAfterMove);
|
|
125
|
+
return this.addItem(itemAfterMove);
|
|
123
126
|
}
|
|
124
127
|
else {
|
|
125
128
|
this.applyAddItemStrategy(itemAfterMove);
|
|
126
129
|
this.items[move.itemIndex] = itemAfterMove;
|
|
127
130
|
this.applyRemoveItemStrategy(sourceItem);
|
|
131
|
+
return move.itemIndex;
|
|
128
132
|
}
|
|
129
133
|
};
|
|
130
134
|
MaterialMutator.prototype.getItemAfterMove = function (move) {
|
|
131
135
|
var _a = this.items[move.itemIndex], quantity = _a.quantity, rotation = _a.rotation, itemData = __rest(_a, ["quantity", "rotation"]);
|
|
132
|
-
var
|
|
133
|
-
|
|
136
|
+
var item = __assign(__assign({}, itemData), JSON.parse(JSON.stringify(move.position)));
|
|
137
|
+
if (typeof move.reveal === 'object') {
|
|
138
|
+
(0, merge_1.default)(item, move.reveal);
|
|
139
|
+
}
|
|
134
140
|
if (move.quantity)
|
|
135
141
|
item.quantity = move.quantity;
|
|
136
142
|
return item;
|
|
@@ -148,4 +154,10 @@ var MaterialMutator = /** @class */ (function () {
|
|
|
148
154
|
return MaterialMutator;
|
|
149
155
|
}());
|
|
150
156
|
exports.MaterialMutator = MaterialMutator;
|
|
157
|
+
var itemsCanMerge = function (_a, _b) {
|
|
158
|
+
var q1 = _a.quantity, data1 = __rest(_a, ["quantity"]);
|
|
159
|
+
var quantityB = _b.quantity, data2 = __rest(_b, ["quantity"]);
|
|
160
|
+
return (0, fast_deep_equal_1.default)(data1, data2);
|
|
161
|
+
};
|
|
162
|
+
exports.itemsCanMerge = itemsCanMerge;
|
|
151
163
|
//# sourceMappingURL=MaterialMutator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaterialMutator.js","sourceRoot":"","sources":["../../../src/material/items/MaterialMutator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAgD;AAChD,oEAAmC;AAEnC,kCAAoH;
|
|
1
|
+
{"version":3,"file":"MaterialMutator.js","sourceRoot":"","sources":["../../../src/material/items/MaterialMutator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAgD;AAChD,oEAAmC;AAEnC,kCAAoH;AACpH,uDAAgC;AAEhC;IAKE,yBAAY,IAAO,EAAE,KAA2B,EACpC,mBAAuE;QAAv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CAAF;QAA8B,SAAS,cAAA,EAAK,KAAK,cAA/B,YAAiC,CAAF;IAA8B,OAAA,IAAA,yBAAK,EAAC,KAAK,EAAE,KAAK,CAAC,CAAA;CAAA,CAAA;AAA3I,QAAA,aAAa,iBAA8H"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LocalMoveType } from './LocalMove';
|
|
2
|
+
import { MoveKind } from '../MoveKind';
|
|
3
|
+
import { MaterialItem } from '../../items';
|
|
4
|
+
import { Location } from '../../location';
|
|
5
|
+
export declare type RulesDisplay<P extends number = number, M extends number = number, L extends number = number> = MaterialRulesDisplay<P, M, L> | LocationRulesDisplay<P, L>;
|
|
6
|
+
export declare enum RulesDisplayType {
|
|
7
|
+
Material = 1,
|
|
8
|
+
Location = 2
|
|
9
|
+
}
|
|
10
|
+
export declare type MaterialRulesDisplay<P extends number = number, M extends number = number, L extends number = number> = {
|
|
11
|
+
type: typeof RulesDisplayType.Material;
|
|
12
|
+
itemType: M;
|
|
13
|
+
itemIndex: number;
|
|
14
|
+
item: Partial<MaterialItem<P, L>>;
|
|
15
|
+
};
|
|
16
|
+
export declare type LocationRulesDisplay<P extends number = number, L extends number = number> = {
|
|
17
|
+
type: typeof RulesDisplayType.Location;
|
|
18
|
+
location: Location<P, L>;
|
|
19
|
+
};
|
|
20
|
+
export declare type DisplayRules<P extends number = number, M extends number = number, L extends number = number> = {
|
|
21
|
+
kind: MoveKind.LocalMove;
|
|
22
|
+
type: typeof LocalMoveType.DisplayRules;
|
|
23
|
+
rulesDisplay: RulesDisplay<P, M, L>;
|
|
24
|
+
};
|
|
25
|
+
export declare const displayRules: <P extends number = number, M extends number = number, L extends number = number>(rulesDisplay: RulesDisplay<P, M, L>) => DisplayRules<P, M, L>;
|
|
26
|
+
export declare const displayMaterialRules: <P extends number = number, M extends number = number, L extends number = number>(itemType: M, itemIndex?: number, item?: Partial<MaterialItem<P, L, any>>) => DisplayRules<P, M, L>;
|
|
27
|
+
export declare const displayLocationRules: <P extends number = number, M extends number = number, L extends number = number>(location: Location<P, L, any, number>) => DisplayRules<P, M, L>;
|
|
28
|
+
export declare type CloseRulesDisplay = {
|
|
29
|
+
kind: MoveKind.LocalMove;
|
|
30
|
+
type: typeof LocalMoveType.CloseRulesDisplay;
|
|
31
|
+
};
|
|
32
|
+
export declare const closeRulesDisplay: CloseRulesDisplay;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.closeRulesDisplay = exports.displayLocationRules = exports.displayMaterialRules = exports.displayRules = exports.RulesDisplayType = void 0;
|
|
4
|
+
var LocalMove_1 = require("./LocalMove");
|
|
5
|
+
var MoveKind_1 = require("../MoveKind");
|
|
6
|
+
var RulesDisplayType;
|
|
7
|
+
(function (RulesDisplayType) {
|
|
8
|
+
RulesDisplayType[RulesDisplayType["Material"] = 1] = "Material";
|
|
9
|
+
RulesDisplayType[RulesDisplayType["Location"] = 2] = "Location";
|
|
10
|
+
})(RulesDisplayType = exports.RulesDisplayType || (exports.RulesDisplayType = {}));
|
|
11
|
+
var displayRules = function (rulesDisplay) {
|
|
12
|
+
return ({ kind: MoveKind_1.MoveKind.LocalMove, type: LocalMove_1.LocalMoveType.DisplayRules, rulesDisplay: rulesDisplay });
|
|
13
|
+
};
|
|
14
|
+
exports.displayRules = displayRules;
|
|
15
|
+
var displayMaterialRules = function (itemType, itemIndex, item) {
|
|
16
|
+
if (itemIndex === void 0) { itemIndex = 0; }
|
|
17
|
+
if (item === void 0) { item = {}; }
|
|
18
|
+
return (0, exports.displayRules)({ type: RulesDisplayType.Material, itemType: itemType, itemIndex: itemIndex, item: item });
|
|
19
|
+
};
|
|
20
|
+
exports.displayMaterialRules = displayMaterialRules;
|
|
21
|
+
var displayLocationRules = function (location) {
|
|
22
|
+
return (0, exports.displayRules)({ type: RulesDisplayType.Location, location: location });
|
|
23
|
+
};
|
|
24
|
+
exports.displayLocationRules = displayLocationRules;
|
|
25
|
+
exports.closeRulesDisplay = { kind: MoveKind_1.MoveKind.LocalMove, type: LocalMove_1.LocalMoveType.CloseRulesDisplay };
|
|
26
|
+
//# sourceMappingURL=DisplayRules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DisplayRules.js","sourceRoot":"","sources":["../../../../src/material/moves/local/DisplayRules.ts"],"names":[],"mappings":";;;AAAA,yCAA2C;AAC3C,wCAAsC;AAQtC,IAAY,gBAEX;AAFD,WAAY,gBAAgB;IAC1B,+DAAY,CAAA;IAAE,+DAAQ,CAAA;AACxB,CAAC,EAFW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAE3B;AAoBM,IAAM,YAAY,GAAG,UAC3B,YAAmC;IAClC,OAAA,CAAC,EAAE,IAAI,EAAE,mBAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,yBAAa,CAAC,YAAY,EAAE,YAAY,cAAA,EAAE,CAAC;AAA9E,CAA8E,CAAA;AAFnE,QAAA,YAAY,gBAEuD;AAEzE,IAAM,oBAAoB,GAAG,UACnC,QAAW,EAAE,SAAqB,EAAE,IAAsC;IAA7D,0BAAA,EAAA,aAAqB;IAAE,qBAAA,EAAA,SAAsC;IACzE,OAAA,IAAA,oBAAY,EAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,UAAA,EAAE,SAAS,WAAA,EAAE,IAAI,MAAA,EAAE,CAAC;AAA5E,CAA4E,CAAA;AAFjE,QAAA,oBAAoB,wBAE6C;AAEvE,IAAM,oBAAoB,GAAG,UACnC,QAAwB;IACvB,OAAA,IAAA,oBAAY,EAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,UAAA,EAAE,CAAC;AAA3D,CAA2D,CAAA;AAFhD,QAAA,oBAAoB,wBAE4B;AAOhD,QAAA,iBAAiB,GAAsB,EAAE,IAAI,EAAE,mBAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,yBAAa,CAAC,iBAAiB,EAAE,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MoveKind } from '../MoveKind';
|
|
2
|
+
import { LocalMoveType } from './LocalMove';
|
|
3
|
+
export declare type DropItem<M extends number = number> = {
|
|
4
|
+
kind: MoveKind.LocalMove;
|
|
5
|
+
type: typeof LocalMoveType.DropItem;
|
|
6
|
+
item: DisplayedItem<M>;
|
|
7
|
+
};
|
|
8
|
+
export declare type DisplayedItem<M extends number = number> = {
|
|
9
|
+
type: M;
|
|
10
|
+
index: number;
|
|
11
|
+
displayIndex: number;
|
|
12
|
+
};
|
|
13
|
+
export declare function dropItemMove<M extends number = number>(type: M, index: number, displayIndex: number): DropItem<M>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dropItemMove = void 0;
|
|
4
|
+
var MoveKind_1 = require("../MoveKind");
|
|
5
|
+
var LocalMove_1 = require("./LocalMove");
|
|
6
|
+
function dropItemMove(type, index, displayIndex) {
|
|
7
|
+
return { kind: MoveKind_1.MoveKind.LocalMove, type: LocalMove_1.LocalMoveType.DropItem, item: { type: type, index: index, displayIndex: displayIndex } };
|
|
8
|
+
}
|
|
9
|
+
exports.dropItemMove = dropItemMove;
|
|
10
|
+
//# sourceMappingURL=DropItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropItem.js","sourceRoot":"","sources":["../../../../src/material/moves/local/DropItem.ts"],"names":[],"mappings":";;;AAAA,wCAAsC;AACtC,yCAA2C;AAc3C,SAAgB,YAAY,CAA4B,IAAO,EAAE,KAAa,EAAE,YAAoB;IAClG,OAAO,EAAE,IAAI,EAAE,mBAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,yBAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,IAAI,MAAA,EAAE,KAAK,OAAA,EAAE,YAAY,cAAA,EAAE,EAAE,CAAA;AACxG,CAAC;AAFD,oCAEC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { CloseRulesDisplay, DisplayRules } from './
|
|
2
|
-
|
|
1
|
+
import { CloseRulesDisplay, DisplayRules } from './DisplayRules';
|
|
2
|
+
import { DropItem } from './DropItem';
|
|
3
|
+
export declare type LocalMove<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> = DisplayRules<Player, MaterialType, LocationType> | CloseRulesDisplay | DropItem<MaterialType>;
|
|
3
4
|
export declare enum LocalMoveType {
|
|
4
5
|
DisplayRules = 0,
|
|
5
|
-
CloseRulesDisplay = 1
|
|
6
|
+
CloseRulesDisplay = 1,
|
|
7
|
+
DropItem = 2
|
|
6
8
|
}
|
|
@@ -5,5 +5,6 @@ var LocalMoveType;
|
|
|
5
5
|
(function (LocalMoveType) {
|
|
6
6
|
LocalMoveType[LocalMoveType["DisplayRules"] = 0] = "DisplayRules";
|
|
7
7
|
LocalMoveType[LocalMoveType["CloseRulesDisplay"] = 1] = "CloseRulesDisplay";
|
|
8
|
+
LocalMoveType[LocalMoveType["DropItem"] = 2] = "DropItem";
|
|
8
9
|
})(LocalMoveType = exports.LocalMoveType || (exports.LocalMoveType = {}));
|
|
9
10
|
//# sourceMappingURL=LocalMove.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalMove.js","sourceRoot":"","sources":["../../../../src/material/moves/local/LocalMove.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"LocalMove.js","sourceRoot":"","sources":["../../../../src/material/moves/local/LocalMove.ts"],"names":[],"mappings":";;;AAQA,IAAY,aAEX;AAFD,WAAY,aAAa;IACvB,iEAAY,CAAA;IAAE,2EAAiB,CAAA;IAAE,yDAAQ,CAAA;AAC3C,CAAC,EAFW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAExB"}
|
|
@@ -14,6 +14,7 @@ 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
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./DisplayRules"), exports);
|
|
18
|
+
__exportStar(require("./DropItem"), exports);
|
|
17
19
|
__exportStar(require("./LocalMove"), exports);
|
|
18
|
-
__exportStar(require("./RulesDisplay"), exports);
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/material/moves/local/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/material/moves/local/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,6CAA0B;AAC1B,8CAA2B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MaterialGame } from '../MaterialGame';
|
|
2
|
+
import { Rules } from '../../Rules';
|
|
3
|
+
import { CustomMove, ItemMove, MaterialMove, RuleMove } from '../moves';
|
|
4
|
+
import { Material } from '../items';
|
|
5
|
+
import { MaterialRulesMovesBuilder } from './MaterialRulesMovesBuilder';
|
|
6
|
+
import { RuleStep } from './RuleStep';
|
|
7
|
+
export declare abstract class MaterialRulesPart<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends Rules<MaterialGame<Player, MaterialType, LocationType>, MaterialMove<Player, MaterialType, LocationType>, Player> {
|
|
8
|
+
readonly material: (type: MaterialType) => Material<Player, MaterialType, LocationType>;
|
|
9
|
+
constructor(game: MaterialGame<Player, MaterialType, LocationType>, material: (type: MaterialType) => Material<Player, MaterialType, LocationType>);
|
|
10
|
+
beforeItemMove(_move: ItemMove<Player, MaterialType, LocationType>): MaterialMove<Player, MaterialType, LocationType>[];
|
|
11
|
+
afterItemMove(_move: ItemMove<Player, MaterialType, LocationType>): MaterialMove<Player, MaterialType, LocationType>[];
|
|
12
|
+
onRuleStart<RuleId extends number>(_move: RuleMove<Player, RuleId>, _previousRule?: RuleStep): MaterialMove<Player, MaterialType, LocationType>[];
|
|
13
|
+
onRuleEnd<RuleId extends number>(_move: RuleMove<Player, RuleId>): MaterialMove<Player, MaterialType, LocationType>[];
|
|
14
|
+
onCustomMove(_move: CustomMove): MaterialMove<Player, MaterialType, LocationType>[];
|
|
15
|
+
rules(): MaterialRulesMovesBuilder<Player, MaterialType, LocationType>;
|
|
16
|
+
getMemory<T>(player?: Player): T;
|
|
17
|
+
memorize<T extends Record<string, any>>(memory?: T, player?: Player): void;
|
|
18
|
+
getGameMemory<T>(player?: Player): T;
|
|
19
|
+
memorizeOnGame(memory?: Record<string, any>, player?: Player): void;
|
|
20
|
+
}
|
|
21
|
+
export interface MaterialRulesPartCreator<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> {
|
|
22
|
+
new (game: MaterialGame<Player, MaterialType, LocationType>, material: (type: MaterialType) => Material<Player, MaterialType, LocationType>): MaterialRulesPart<Player, MaterialType, LocationType>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
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.MaterialRulesPart = void 0;
|
|
30
|
+
var Rules_1 = require("../../Rules");
|
|
31
|
+
var MaterialRulesMovesBuilder_1 = require("./MaterialRulesMovesBuilder");
|
|
32
|
+
var MaterialRulesPart = /** @class */ (function (_super) {
|
|
33
|
+
__extends(MaterialRulesPart, _super);
|
|
34
|
+
function MaterialRulesPart(game, material) {
|
|
35
|
+
var _this = _super.call(this, game) || this;
|
|
36
|
+
_this.material = material;
|
|
37
|
+
return _this;
|
|
38
|
+
}
|
|
39
|
+
MaterialRulesPart.prototype.beforeItemMove = function (_move) {
|
|
40
|
+
return [];
|
|
41
|
+
};
|
|
42
|
+
MaterialRulesPart.prototype.afterItemMove = function (_move) {
|
|
43
|
+
return [];
|
|
44
|
+
};
|
|
45
|
+
MaterialRulesPart.prototype.onRuleStart = function (_move, _previousRule) {
|
|
46
|
+
return [];
|
|
47
|
+
};
|
|
48
|
+
MaterialRulesPart.prototype.onRuleEnd = function (_move) {
|
|
49
|
+
return [];
|
|
50
|
+
};
|
|
51
|
+
MaterialRulesPart.prototype.onCustomMove = function (_move) {
|
|
52
|
+
return [];
|
|
53
|
+
};
|
|
54
|
+
MaterialRulesPart.prototype.rules = function () {
|
|
55
|
+
return new MaterialRulesMovesBuilder_1.MaterialRulesMovesBuilder(this.game);
|
|
56
|
+
};
|
|
57
|
+
MaterialRulesPart.prototype.getMemory = function (player) {
|
|
58
|
+
var _a, _b, _c;
|
|
59
|
+
if (player !== undefined) {
|
|
60
|
+
return ((_b = (_a = this.game.rule.playersMemory) === null || _a === void 0 ? void 0 : _a[player]) !== null && _b !== void 0 ? _b : {});
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return ((_c = this.game.rule.memory) !== null && _c !== void 0 ? _c : {});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
MaterialRulesPart.prototype.memorize = function (memory, player) {
|
|
67
|
+
if (player !== undefined) {
|
|
68
|
+
if (!this.game.rule.playersMemory)
|
|
69
|
+
this.game.rule.playersMemory = {};
|
|
70
|
+
this.game.rule.playersMemory[player] = __assign(__assign({}, this.game.rule.playersMemory[player]), memory);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
this.game.rule.memory = __assign(__assign({}, this.game.rule.memory), memory);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
MaterialRulesPart.prototype.getGameMemory = function (player) {
|
|
77
|
+
var _a, _b, _c;
|
|
78
|
+
if (player !== undefined) {
|
|
79
|
+
return ((_b = (_a = this.game.playersMemory) === null || _a === void 0 ? void 0 : _a[player]) !== null && _b !== void 0 ? _b : {});
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return ((_c = this.game.memory) !== null && _c !== void 0 ? _c : {});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
MaterialRulesPart.prototype.memorizeOnGame = function (memory, player) {
|
|
86
|
+
if (player !== undefined) {
|
|
87
|
+
if (!this.game.playersMemory)
|
|
88
|
+
this.game.playersMemory = {};
|
|
89
|
+
this.game.playersMemory[player] = __assign(__assign({}, this.game.playersMemory[player]), memory);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
this.game.memory = __assign(__assign({}, this.game.memory), memory);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return MaterialRulesPart;
|
|
96
|
+
}(Rules_1.Rules));
|
|
97
|
+
exports.MaterialRulesPart = MaterialRulesPart;
|
|
98
|
+
//# sourceMappingURL=MaterialRulesPart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaterialRulesPart.js","sourceRoot":"","sources":["../../../src/material/rules/MaterialRulesPart.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAAmC;AAGnC,yEAAuE;AAGvE;IACU,qCAAiH;IAIzH,2BAAY,IAAsD,EAAE,QAA8E;QAAlJ,YACE,kBAAM,IAAI,CAAC,SAEZ;QADC,KAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;;IAC1B,CAAC;IAED,0CAAc,GAAd,UAAe,KAAmD;QAChE,OAAO,EAAE,CAAA;IACX,CAAC;IAED,yCAAa,GAAb,UAAc,KAAmD;QAC/D,OAAO,EAAE,CAAA;IACX,CAAC;IAED,uCAAW,GAAX,UAAmC,KAA+B,EAAE,aAAwB;QAC1F,OAAO,EAAE,CAAA;IACX,CAAC;IAED,qCAAS,GAAT,UAAiC,KAA+B;QAC9D,OAAO,EAAE,CAAA;IACX,CAAC;IAED,wCAAY,GAAZ,UAAa,KAAiB;QAC5B,OAAO,EAAE,CAAA;IACX,CAAC;IAED,iCAAK,GAAL;QACE,OAAO,IAAI,qDAAyB,CAAqC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrF,CAAC;IAED,qCAAS,GAAT,UAAa,MAAe;;QAC1B,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,OAAO,CAAC,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,IAAK,CAAC,aAAa,0CAAG,MAAM,CAAC,mCAAI,EAAE,CAAM,CAAA;SAC5D;aAAM;YACL,OAAO,CAAC,MAAA,IAAI,CAAC,IAAI,CAAC,IAAK,CAAC,MAAM,mCAAI,EAAE,CAAM,CAAA;SAC3C;IACH,CAAC;IAED,oCAAQ,GAAR,UAAwC,MAAU,EAAE,MAAe;QACjE,IAAI,MAAM,KAAK,SAAS,EAA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
|
|
@@ -5,7 +5,8 @@ import { Material } from '../items';
|
|
|
5
5
|
import { MaterialRulesMovesBuilder } from './MaterialRulesMovesBuilder';
|
|
6
6
|
import { RuleStep } from './RuleStep';
|
|
7
7
|
export declare abstract class MaterialStepRules<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends Rules<MaterialGame<Player, MaterialType, LocationType>, MaterialMove<Player, MaterialType, LocationType>, Player> {
|
|
8
|
-
material(type: MaterialType)
|
|
8
|
+
readonly material: (type: MaterialType) => Material<Player, MaterialType, LocationType>;
|
|
9
|
+
constructor(game: MaterialGame<Player, MaterialType, LocationType>, material: (type: MaterialType) => Material<Player, MaterialType, LocationType>);
|
|
9
10
|
beforeItemMove(_move: ItemMove<Player, MaterialType, LocationType>): MaterialMove<Player, MaterialType, LocationType>[];
|
|
10
11
|
afterItemMove(_move: ItemMove<Player, MaterialType, LocationType>): MaterialMove<Player, MaterialType, LocationType>[];
|
|
11
12
|
onRuleStart<RuleId extends number>(_move: RuleMove<Player, RuleId>, _previousRule?: RuleStep): MaterialMove<Player, MaterialType, LocationType>[];
|
|
@@ -18,5 +19,5 @@ export declare abstract class MaterialStepRules<Player extends number = number,
|
|
|
18
19
|
memorizeOnGame(memory?: Record<string, any>, player?: Player): void;
|
|
19
20
|
}
|
|
20
21
|
export interface MaterialRulesStepCreator<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> {
|
|
21
|
-
new (
|
|
22
|
+
new (game: MaterialGame<Player, MaterialType, LocationType>, material: (type: MaterialType) => Material<Player, MaterialType, LocationType>): MaterialStepRules<Player, MaterialType, LocationType>;
|
|
22
23
|
}
|
|
@@ -28,17 +28,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.MaterialStepRules = void 0;
|
|
30
30
|
var Rules_1 = require("../../Rules");
|
|
31
|
-
var items_1 = require("../items");
|
|
32
31
|
var MaterialRulesMovesBuilder_1 = require("./MaterialRulesMovesBuilder");
|
|
33
32
|
var MaterialStepRules = /** @class */ (function (_super) {
|
|
34
33
|
__extends(MaterialStepRules, _super);
|
|
35
|
-
function MaterialStepRules() {
|
|
36
|
-
|
|
34
|
+
function MaterialStepRules(game, material) {
|
|
35
|
+
var _this = _super.call(this, game) || this;
|
|
36
|
+
_this.material = material;
|
|
37
|
+
return _this;
|
|
37
38
|
}
|
|
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
39
|
MaterialStepRules.prototype.beforeItemMove = function (_move) {
|
|
43
40
|
return [];
|
|
44
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaterialStepRules.js","sourceRoot":"","sources":["../../../src/material/rules/MaterialStepRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAAmC;
|
|
1
|
+
{"version":3,"file":"MaterialStepRules.js","sourceRoot":"","sources":["../../../src/material/rules/MaterialStepRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAAmC;AAGnC,yEAAuE;AAGvE;IACU,qCAAiH;IAIzH,2BAAY,IAAsD,EAAE,QAA8E;QAAlJ,YACE,kBAAM,IAAI,CAAC,SAEZ;QADC,KAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;;IAC1B,CAAC;IAED,0CAAc,GAAd,UAAe,KAAmD;QAChE,OAAO,EAAE,CAAA;IACX,CAAC;IAED,yCAAa,GAAb,UAAc,KAAmD;QAC/D,OAAO,EAAE,CAAA;IACX,CAAC;IAED,uCAAW,GAAX,UAAmC,KAA+B,EAAE,aAAwB;QAC1F,OAAO,EAAE,CAAA;IACX,CAAC;IAED,qCAAS,GAAT,UAAiC,KAA+B;QAC9D,OAAO,EAAE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AAC,MAAM,mCAAI,EAAE,CAAM,CAAA;SACrC;IACH,CAAC;IAED,0CAAc,GAAd,UAAe,MAA4B,EAAE,MAAe;QAC1D,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa;gBAAE,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,EAAE,CAAA;YAC1D,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,yBAAQ,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAK,MAAM,CAAE,CAAA;SACpF;aAAM;YACL,IAAI,CAAC,IAAI,CAAC,MAAM,yBAAQ,IAAI,CAAC,IAAI,CAAC,MAAM,GAAK,MAAM,CAAE,CAAA;SACtD;IACH,CAAC;IAEH,wBAAC;AAAD,CAAC,AApED,CACU,aAAK,GAmEd;AApEqB,8CAAiB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaterialRulesPart } from './MaterialRulesPart';
|
|
2
2
|
import { MaterialMove } from '../moves';
|
|
3
|
-
export declare abstract class PlayerTurnRule<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends
|
|
3
|
+
export declare abstract class PlayerTurnRule<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends MaterialRulesPart<Player, MaterialType, LocationType> {
|
|
4
4
|
get player(): Player;
|
|
5
5
|
get nextPlayer(): Player;
|
|
6
6
|
getActivePlayer(): Player;
|
|
@@ -16,7 +16,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.PlayerTurnRule = void 0;
|
|
19
|
-
var
|
|
19
|
+
var MaterialRulesPart_1 = require("./MaterialRulesPart");
|
|
20
20
|
var PlayerTurnRule = /** @class */ (function (_super) {
|
|
21
21
|
__extends(PlayerTurnRule, _super);
|
|
22
22
|
function PlayerTurnRule() {
|
|
@@ -48,6 +48,6 @@ var PlayerTurnRule = /** @class */ (function (_super) {
|
|
|
48
48
|
return this.getPlayerMoves();
|
|
49
49
|
};
|
|
50
50
|
return PlayerTurnRule;
|
|
51
|
-
}(
|
|
51
|
+
}(MaterialRulesPart_1.MaterialRulesPart));
|
|
52
52
|
exports.PlayerTurnRule = PlayerTurnRule;
|
|
53
53
|
//# sourceMappingURL=PlayerTurnRule.js.map
|
|
@@ -15,6 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./RuleStep"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./MaterialRulesPart"), exports);
|
|
19
19
|
__exportStar(require("./PlayerTurnRule"), exports);
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gamepark/rules-api",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.5-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",
|
|
@@ -20,18 +20,14 @@
|
|
|
20
20
|
"license": "ISC",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"fast-deep-equal": "^3.1.3",
|
|
23
|
-
"lodash
|
|
24
|
-
"lodash.maxby": "^4.6.0",
|
|
25
|
-
"lodash.minby": "^4.6.0"
|
|
23
|
+
"lodash": "^4.17.21"
|
|
26
24
|
},
|
|
27
25
|
"publishConfig": {
|
|
28
26
|
"access": "public"
|
|
29
27
|
},
|
|
30
28
|
"devDependencies": {
|
|
31
|
-
"@types/lodash
|
|
32
|
-
"@types/lodash.maxby": "^4.6.7",
|
|
33
|
-
"@types/lodash.minby": "^4.6.7",
|
|
29
|
+
"@types/lodash": "^4.14.195",
|
|
34
30
|
"i18next": ">=21.3.0"
|
|
35
31
|
},
|
|
36
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "89ecbf9433f9832b1ade8404140bea3440364b84"
|
|
37
33
|
}
|