@gamepark/rules-api 6.0.4-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/material/HiddenMaterialRules.d.ts +3 -4
- package/dist/material/HiddenMaterialRules.js +3 -6
- package/dist/material/HiddenMaterialRules.js.map +1 -1
- package/dist/material/MaterialGame.d.ts +2 -1
- package/dist/material/MaterialRules.d.ts +10 -9
- package/dist/material/MaterialRules.js +21 -7
- package/dist/material/MaterialRules.js.map +1 -1
- package/dist/material/items/MaterialMutator.d.ts +5 -4
- package/dist/material/items/MaterialMutator.js +23 -14
- 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/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
|
@@ -4,12 +4,11 @@ import { MaterialGame } from './MaterialGame';
|
|
|
4
4
|
import { MaterialMove, MaterialRulesMoveRandomized } from './moves';
|
|
5
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>>>>>;
|
|
7
|
+
abstract get hidingStrategies(): Partial<Record<M, Partial<Record<L, HidingStrategy<P, L>>>>>;
|
|
8
8
|
material(type: M): Material<P, M, L>;
|
|
9
|
-
getItemTypeHidingStrategies(type: M): Partial<Record<L, HidingStrategy<P, L>>> | undefined;
|
|
10
9
|
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;
|
|
10
|
+
protected moveBlocksUndo(move: MaterialMove<P, M, L>): boolean;
|
|
11
|
+
protected moveRevealsSomething(move: MaterialMove<P, M, L>): boolean;
|
|
13
12
|
getView(player?: P): any;
|
|
14
13
|
private hideItem;
|
|
15
14
|
private getItemHiddenPaths;
|
|
@@ -41,7 +41,7 @@ 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");
|
|
@@ -63,9 +63,6 @@ var HiddenMaterialRules = /** @class */ (function (_super) {
|
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
|
-
HiddenMaterialRules.prototype.getItemTypeHidingStrategies = function (type) {
|
|
67
|
-
return this.hidingStrategies[type];
|
|
68
|
-
};
|
|
69
66
|
HiddenMaterialRules.prototype.isUnpredictableMove = function (move, player) {
|
|
70
67
|
if ((0, moves_1.isMoveItem)(move)) {
|
|
71
68
|
return this.moveItemWillRevealSomething(move, player);
|
|
@@ -82,9 +79,9 @@ var HiddenMaterialRules = /** @class */ (function (_super) {
|
|
|
82
79
|
};
|
|
83
80
|
HiddenMaterialRules.prototype.getView = function (player) {
|
|
84
81
|
var _this = this;
|
|
85
|
-
return __assign(__assign({}, this.game), { items: (0,
|
|
82
|
+
return __assign(__assign({}, this.game), { items: (0, mapvalues_1.default)(this.game.items, function (items, stringType) {
|
|
86
83
|
var itemsType = parseInt(stringType);
|
|
87
|
-
var hidingStrategies = _this.
|
|
84
|
+
var hidingStrategies = _this.hidingStrategies[itemsType];
|
|
88
85
|
if (!hidingStrategies || !items)
|
|
89
86
|
return items;
|
|
90
87
|
return items.map(function (item) { return _this.hideItem(itemsType, item, player); });
|
|
@@ -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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IAAM,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;QAC9E,IAAM,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,wBAAO,IAAI,GAAK,IAAI,CAAC,QAAQ,GAAI,MAAM,CAAC,CAAA;QACtG,OAAO,IAAA,oBAAU,EAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAA;IACxD,CAAC;IAEO,yDAA2B,GAAnC,UAAoC,IAAuB,EAAE,MAAU;QACrE,OAAO,IAAI,CAAC,uBAAuB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;IAC9D,CAAC;IAEO,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,21 +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;
|
|
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
31
|
isUnpredictableMove(move: MaterialMove<Player, MaterialType, LocationType>, _player: Player): boolean;
|
|
32
|
-
isRandomMove(move: MaterialMove<Player, MaterialType, LocationType>): boolean;
|
|
32
|
+
protected isRandomMove(move: MaterialMove<Player, MaterialType, LocationType>): boolean;
|
|
33
33
|
restoreLocalMoves(game: MaterialGame<Player, MaterialType, LocationType>): void;
|
|
34
|
+
isOver(playerIds?: Player[]): boolean;
|
|
34
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;
|
|
@@ -79,7 +83,7 @@ var MaterialRules = /** @class */ (function (_super) {
|
|
|
79
83
|
var _this = this;
|
|
80
84
|
if (!this.game.rule)
|
|
81
85
|
return;
|
|
82
|
-
var RulesStep = this.
|
|
86
|
+
var RulesStep = this.rules[this.game.rule.id];
|
|
83
87
|
return new RulesStep(this.game, function (type) { return _this.material(type); });
|
|
84
88
|
};
|
|
85
89
|
MaterialRules.prototype.start = function (id, player, memory) {
|
|
@@ -89,7 +93,7 @@ var MaterialRules = /** @class */ (function (_super) {
|
|
|
89
93
|
if (move.kind === moves_1.MoveKind.ItemMove) {
|
|
90
94
|
switch (move.type) {
|
|
91
95
|
case moves_1.ItemMoveType.Shuffle:
|
|
92
|
-
return __assign(__assign({}, move), { newIndexes: (0,
|
|
96
|
+
return __assign(__assign({}, move), { newIndexes: (0, shuffle_1.default)(move.indexes) });
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
99
|
return move;
|
|
@@ -105,8 +109,12 @@ var MaterialRules = /** @class */ (function (_super) {
|
|
|
105
109
|
}
|
|
106
110
|
if (!this.game.items[move.itemType])
|
|
107
111
|
this.game.items[move.itemType] = [];
|
|
108
|
-
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]);
|
|
109
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
|
+
}
|
|
110
118
|
if (delegate) {
|
|
111
119
|
consequences.push.apply(consequences, delegate.afterItemMove(move));
|
|
112
120
|
}
|
|
@@ -143,6 +151,9 @@ var MaterialRules = /** @class */ (function (_super) {
|
|
|
143
151
|
case moves_1.LocalMoveType.CloseRulesDisplay:
|
|
144
152
|
delete this.game.rulesDisplay;
|
|
145
153
|
break;
|
|
154
|
+
case moves_1.LocalMoveType.DropItem:
|
|
155
|
+
this.game.droppedItem = move.item;
|
|
156
|
+
break;
|
|
146
157
|
}
|
|
147
158
|
}
|
|
148
159
|
return consequences;
|
|
@@ -191,6 +202,9 @@ var MaterialRules = /** @class */ (function (_super) {
|
|
|
191
202
|
MaterialRules.prototype.restoreLocalMoves = function (game) {
|
|
192
203
|
this.game.rulesDisplay = game.rulesDisplay;
|
|
193
204
|
};
|
|
205
|
+
MaterialRules.prototype.isOver = function (playerIds) {
|
|
206
|
+
return _super.prototype.isOver.call(this, playerIds !== null && playerIds !== void 0 ? playerIds : this.game.players);
|
|
207
|
+
};
|
|
194
208
|
return MaterialRules;
|
|
195
209
|
}(Rules_1.Rules));
|
|
196
210
|
exports.MaterialRules = MaterialRules;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaterialRules.js","sourceRoot":"","sources":["../../src/material/MaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kCAAg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CAAC;IAED,2CAAmB,GAAnB,UAAoB,IAAsD,EAAE,OAAe;QACzF,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAES,oCAAY,GAAtB,UAAuB,IAAsD;QAC3E,OAAO,IAAA,iBAAS,EAAC,IAAI,CAAC,CAAA,CAAC,6BAA6B;IACtD,CAAC;IAED,yCAAiB,GAAjB,UAAkB,IAAsD;QACtE,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAA;IAC5C,CAAC;IAED,8BAAM,GAAN,UAAO,SAAoB;QACzB,OAAO,iBAAM,MAAM,YAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACrD,CAAC;IACH,oBAAC;AAAD,CAAC,AA5LD,CACU,aAAK,GA2Ld;AA5LqB,sCAAa;AA8LnC,SAAS,YAAY,CAAiC,OAAY;;IAChE,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAClC,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAC,MAAW,IAAK,OAAA,MAAM,CAAC,EAAE,EAAT,CAAS,CAAC,CAAA;KACvD;SAAM;QACL,IAAM,eAAe,GAAG,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"}
|
|
@@ -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,7 +25,7 @@ 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");
|
|
@@ -53,21 +53,19 @@ var MaterialMutator = /** @class */ (function () {
|
|
|
53
53
|
break;
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
MaterialMutator.prototype.
|
|
57
|
-
return this.items.
|
|
58
|
-
var itemQuantity = item.quantity, itemWithoutQuantity = __rest(item, ["quantity"]);
|
|
59
|
-
var newItemQuantity = newItem.quantity, newItemWithoutQuantity = __rest(newItem, ["quantity"]);
|
|
60
|
-
return (0, fast_deep_equal_1.default)(itemWithoutQuantity, newItemWithoutQuantity);
|
|
61
|
-
});
|
|
56
|
+
MaterialMutator.prototype.findMergeIndex = function (newItem) {
|
|
57
|
+
return this.items.findIndex(function (item) { return (0, exports.itemsCanMerge)(item, newItem); });
|
|
62
58
|
};
|
|
63
59
|
MaterialMutator.prototype.addItem = function (item) {
|
|
64
60
|
this.applyAddItemStrategy(item);
|
|
65
61
|
var availableIndex = this.items.findIndex(function (item) { return item.quantity === 0; });
|
|
66
62
|
if (availableIndex !== -1) {
|
|
67
63
|
this.items[availableIndex] = item;
|
|
64
|
+
return availableIndex;
|
|
68
65
|
}
|
|
69
66
|
else {
|
|
70
67
|
this.items.push(item);
|
|
68
|
+
return this.items.length - 1;
|
|
71
69
|
}
|
|
72
70
|
};
|
|
73
71
|
MaterialMutator.prototype.applyAddItemStrategy = function (item) {
|
|
@@ -100,12 +98,14 @@ var MaterialMutator = /** @class */ (function () {
|
|
|
100
98
|
};
|
|
101
99
|
MaterialMutator.prototype.create = function (move) {
|
|
102
100
|
var _a, _b;
|
|
103
|
-
var
|
|
104
|
-
if (
|
|
101
|
+
var mergeIndex = this.findMergeIndex(move.item);
|
|
102
|
+
if (mergeIndex !== -1) {
|
|
103
|
+
var mergeItem = this.items[mergeIndex];
|
|
105
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;
|
|
106
106
|
}
|
|
107
107
|
else {
|
|
108
|
-
this.addItem(move.item);
|
|
108
|
+
return this.addItem(move.item);
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
111
|
MaterialMutator.prototype.move = function (move) {
|
|
@@ -113,24 +113,27 @@ var MaterialMutator = /** @class */ (function () {
|
|
|
113
113
|
var quantity = (_a = move.quantity) !== null && _a !== void 0 ? _a : 1;
|
|
114
114
|
var sourceItem = this.items[move.itemIndex];
|
|
115
115
|
var itemAfterMove = this.getItemAfterMove(move);
|
|
116
|
-
var
|
|
117
|
-
if (
|
|
116
|
+
var mergeIndex = this.findMergeIndex(itemAfterMove);
|
|
117
|
+
if (mergeIndex !== -1) {
|
|
118
|
+
var mergeItem = this.items[mergeIndex];
|
|
118
119
|
mergeItem.quantity = ((_b = mergeItem.quantity) !== null && _b !== void 0 ? _b : 1) + quantity;
|
|
119
120
|
this.removeItem(sourceItem, quantity);
|
|
121
|
+
return mergeIndex;
|
|
120
122
|
}
|
|
121
123
|
else if (sourceItem.quantity && sourceItem.quantity > quantity) {
|
|
122
124
|
sourceItem.quantity -= quantity;
|
|
123
|
-
this.addItem(itemAfterMove);
|
|
125
|
+
return this.addItem(itemAfterMove);
|
|
124
126
|
}
|
|
125
127
|
else {
|
|
126
128
|
this.applyAddItemStrategy(itemAfterMove);
|
|
127
129
|
this.items[move.itemIndex] = itemAfterMove;
|
|
128
130
|
this.applyRemoveItemStrategy(sourceItem);
|
|
131
|
+
return move.itemIndex;
|
|
129
132
|
}
|
|
130
133
|
};
|
|
131
134
|
MaterialMutator.prototype.getItemAfterMove = function (move) {
|
|
132
135
|
var _a = this.items[move.itemIndex], quantity = _a.quantity, rotation = _a.rotation, itemData = __rest(_a, ["quantity", "rotation"]);
|
|
133
|
-
var item = __assign(__assign({}, itemData), move.position);
|
|
136
|
+
var item = __assign(__assign({}, itemData), JSON.parse(JSON.stringify(move.position)));
|
|
134
137
|
if (typeof move.reveal === 'object') {
|
|
135
138
|
(0, merge_1.default)(item, move.reveal);
|
|
136
139
|
}
|
|
@@ -151,4 +154,10 @@ var MaterialMutator = /** @class */ (function () {
|
|
|
151
154
|
return MaterialMutator;
|
|
152
155
|
}());
|
|
153
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;
|
|
154
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;AACpH,uDAAgC;AAEhC;IAKE,yBAAY,IAAO,EAAE,KAA2B,EACpC,mBAAuE;QAAvE,oCAAA,EAAA,wBAAuE;QACjF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAA;IAChD,CAAC;IAED,mCAAS,GAAT,UAAU,IAAqC;QAC7C,QAAQ,IAAI,CAAC,IAAI,EAAE;YACjB,KAAK,oBAAY,CAAC,MAAM;gBACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;gBACjB,MAAK;YACP,KAAK,oBAAY,CAAC,IAAI;gBACpB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACf,MAAK;YACP,KAAK,oBAAY,CAAC,MAAM;gBACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;gBACjB,MAAK;YACP,KAAK,oBAAY,CAAC,OAAO;gBACvB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;gBAClB,MAAK;SACR;IACH,CAAC;
|
|
1
|
+
{"version":3,"file":"MaterialMutator.js","sourceRoot":"","sources":["../../../src/material/items/MaterialMutator.ts"],"names":[],"mappings":";;;;;;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AAD,CAAC,AA9HD,IA8HC;AA9HY,0CAAe;AAgIrB,IAAM,aAAa,GAAG,UAAC,EAAwC,EAAE,EAA+C;IAAvF,IAAU,EAAE,cAAA,EAAK,KAAK,cAAxB,YAA0B,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,C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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
|
}
|