@gamepark/rules-api 6.23.0 → 6.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Action.d.ts +0 -19
- package/dist/Action.js +0 -59
- package/dist/Action.js.map +1 -1
- package/dist/Bot.d.ts +12 -0
- package/dist/Bot.js +51 -0
- package/dist/Bot.js.map +1 -0
- package/dist/Competitive.d.ts +0 -1
- package/dist/Competitive.js +1 -31
- package/dist/Competitive.js.map +1 -1
- package/dist/Eliminations.js.map +1 -1
- package/dist/GameSetup.d.ts +3 -0
- package/dist/HiddenInformation.d.ts +5 -0
- package/dist/HiddenInformation.js +9 -0
- package/dist/HiddenInformation.js.map +1 -0
- package/dist/LocalMovePreview.js.map +1 -1
- package/dist/RandomMove.d.ts +0 -3
- package/dist/RandomMove.js +0 -12
- package/dist/RandomMove.js.map +1 -1
- package/dist/Rules.d.ts +5 -0
- package/dist/SecretInformation.d.ts +9 -0
- package/dist/SecretInformation.js +9 -0
- package/dist/SecretInformation.js.map +1 -0
- package/dist/TimeLimit.d.ts +0 -4
- package/dist/TimeLimit.js +1 -6
- package/dist/TimeLimit.js.map +1 -1
- package/dist/Undo.js.map +1 -1
- package/dist/UnpredictableMove.d.ts +5 -4
- package/dist/UnpredictableMove.js.map +1 -1
- package/dist/index.d.ts +3 -8
- package/dist/index.js +3 -8
- package/dist/index.js.map +1 -1
- package/dist/material/HiddenMaterialRules.d.ts +3 -3
- package/dist/material/HiddenMaterialRules.js +7 -7
- package/dist/material/HiddenMaterialRules.js.map +1 -1
- package/dist/material/MaterialGame.d.ts +3 -5
- package/dist/material/MaterialGameSetup.d.ts +3 -1
- package/dist/material/MaterialGameSetup.js +14 -6
- package/dist/material/MaterialGameSetup.js.map +1 -1
- package/dist/material/MaterialRules.d.ts +7 -7
- package/dist/material/MaterialRules.js +13 -10
- package/dist/material/MaterialRules.js.map +1 -1
- package/dist/material/SecretMaterialRules.d.ts +1 -1
- package/dist/material/SecretMaterialRules.js.map +1 -1
- package/dist/material/index.d.ts +1 -0
- package/dist/material/index.js +1 -0
- package/dist/material/index.js.map +1 -1
- package/dist/material/items/Material.d.ts +9 -14
- package/dist/material/items/Material.js +66 -93
- package/dist/material/items/Material.js.map +1 -1
- package/dist/material/items/MaterialDeck.d.ts +9 -0
- package/dist/material/items/MaterialDeck.js +43 -0
- package/dist/material/items/MaterialDeck.js.map +1 -0
- package/dist/material/items/MaterialMutator.d.ts +3 -5
- package/dist/material/items/MaterialMutator.js +11 -23
- package/dist/material/items/MaterialMutator.js.map +1 -1
- package/dist/material/items/index.d.ts +1 -0
- package/dist/material/items/index.js +1 -0
- package/dist/material/items/index.js.map +1 -1
- package/dist/material/location/Location.d.ts +1 -0
- package/dist/material/location/Location.js +12 -0
- package/dist/material/location/Location.js.map +1 -1
- package/dist/material/location/strategy/FillGapStrategy.js.map +1 -1
- package/dist/material/location/strategy/PositiveSequenceStrategy.js.map +1 -1
- package/dist/material/memory/GameMemory.js.map +1 -1
- package/dist/material/memory/PlayerMemory.js.map +1 -1
- package/dist/material/moves/CustomMove.js.map +1 -1
- package/dist/material/moves/MaterialMoveBuilder.d.ts +16 -0
- package/dist/material/moves/MaterialMoveBuilder.js +45 -0
- package/dist/material/moves/MaterialMoveBuilder.js.map +1 -0
- package/dist/material/moves/MoveKind.js.map +1 -1
- package/dist/material/moves/index.d.ts +1 -0
- package/dist/material/moves/index.js +1 -0
- package/dist/material/moves/index.js.map +1 -1
- package/dist/material/moves/items/CreateItem.js.map +1 -1
- package/dist/material/moves/items/CreateItemsAtOnce.js.map +1 -1
- package/dist/material/moves/items/DeleteItem.js.map +1 -1
- package/dist/material/moves/items/DeleteItemsAtOnce.js.map +1 -1
- package/dist/material/moves/items/ItemMoveType.js.map +1 -1
- package/dist/material/moves/items/MoveItem.js.map +1 -1
- package/dist/material/moves/items/MoveItemsAtOnce.d.ts +1 -1
- package/dist/material/moves/items/MoveItemsAtOnce.js +2 -2
- package/dist/material/moves/items/MoveItemsAtOnce.js.map +1 -1
- package/dist/material/moves/items/RollItem.js.map +1 -1
- package/dist/material/moves/items/SelectItem.js.map +1 -1
- package/dist/material/moves/items/Shuffle.js.map +1 -1
- package/dist/material/moves/items/index.d.ts +0 -1
- package/dist/material/moves/items/index.js +0 -1
- package/dist/material/moves/items/index.js.map +1 -1
- package/dist/material/moves/local/CloseTutorialPopup.js.map +1 -1
- package/dist/material/moves/local/DisplayHelp.d.ts +0 -4
- package/dist/material/moves/local/DisplayHelp.js +1 -20
- package/dist/material/moves/local/DisplayHelp.js.map +1 -1
- package/dist/material/moves/local/DropItem.d.ts +0 -1
- package/dist/material/moves/local/DropItem.js +0 -7
- package/dist/material/moves/local/DropItem.js.map +1 -1
- package/dist/material/moves/local/LocalMove.js.map +1 -1
- package/dist/material/moves/local/SetTutorialStep.js.map +1 -1
- package/dist/material/rules/MaterialRulesPart.d.ts +2 -3
- package/dist/material/rules/MaterialRulesPart.js +7 -7
- package/dist/material/rules/MaterialRulesPart.js.map +1 -1
- package/dist/material/rules/PlayerTurnRule.js.map +1 -1
- package/dist/material/rules/SimultaneousRule.d.ts +5 -3
- package/dist/material/rules/SimultaneousRule.js +8 -8
- package/dist/material/rules/SimultaneousRule.js.map +1 -1
- package/dist/material/rules/index.d.ts +0 -1
- package/dist/material/rules/index.js +0 -1
- package/dist/material/rules/index.js.map +1 -1
- package/dist/material/tutorial/TutorialState.d.ts +7 -0
- package/dist/material/tutorial/TutorialState.js +3 -0
- package/dist/material/tutorial/TutorialState.js.map +1 -0
- package/dist/material/tutorial/index.d.ts +1 -0
- package/dist/material/tutorial/index.js +18 -0
- package/dist/material/tutorial/index.js.map +1 -0
- package/dist/setup/DefaultGameSetup.d.ts +7 -0
- package/dist/setup/DefaultGameSetup.js +15 -0
- package/dist/setup/DefaultGameSetup.js.map +1 -0
- package/dist/setup/GameSetup.d.ts +3 -0
- package/dist/setup/GameSetup.js +3 -0
- package/dist/setup/GameSetup.js.map +1 -0
- package/dist/setup/GameSetupCreator.d.ts +4 -0
- package/dist/setup/GameSetupCreator.js +3 -0
- package/dist/setup/GameSetupCreator.js.map +1 -0
- package/dist/setup/index.d.ts +2 -0
- package/dist/setup/index.js +19 -0
- package/dist/setup/index.js.map +1 -0
- package/dist/utils/action-view.util.d.ts +17 -0
- package/dist/utils/action-view.util.js +48 -0
- package/dist/utils/action-view.util.js.map +1 -0
- package/dist/utils/action.util.d.ts +5 -0
- package/dist/utils/action.util.js +25 -0
- package/dist/utils/action.util.js.map +1 -0
- package/dist/utils/automatic-moves.util.d.ts +2 -0
- package/dist/utils/automatic-moves.util.js +25 -0
- package/dist/utils/automatic-moves.util.js.map +1 -0
- package/dist/utils/coordinates.util.d.ts +5 -0
- package/dist/utils/coordinates.util.js +16 -0
- package/dist/utils/coordinates.util.js.map +1 -0
- package/dist/utils/enum.util.d.ts +7 -0
- package/dist/utils/enum.util.js +20 -0
- package/dist/utils/enum.util.js.map +1 -0
- package/dist/utils/game-view.util.d.ts +2 -0
- package/dist/utils/game-view.util.js +18 -0
- package/dist/utils/game-view.util.js.map +1 -0
- package/dist/utils/grid.squares.util.d.ts +1 -1
- package/dist/utils/grid.squares.util.js +6 -5
- package/dist/utils/grid.squares.util.js.map +1 -1
- package/dist/utils/grid.util.js.map +1 -1
- package/dist/utils/index.d.ts +8 -2
- package/dist/utils/index.js +8 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/listing.util.js.map +1 -1
- package/dist/utils/loops.util.d.ts +4 -0
- package/dist/utils/loops.util.js +15 -0
- package/dist/utils/loops.util.js.map +1 -0
- package/dist/utils/random.util.d.ts +4 -0
- package/dist/utils/random.util.js +18 -0
- package/dist/utils/random.util.js.map +1 -0
- package/dist/utils/rank.util.d.ts +2 -0
- package/dist/utils/rank.util.js +35 -0
- package/dist/utils/rank.util.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MaterialGameSetup = void 0;
|
|
4
|
-
var
|
|
4
|
+
var utils_1 = require("../utils");
|
|
5
5
|
var items_1 = require("./items");
|
|
6
6
|
var memory_1 = require("./memory");
|
|
7
|
-
var
|
|
7
|
+
var moves_1 = require("./moves");
|
|
8
8
|
var MaterialGameSetup = (function () {
|
|
9
9
|
function MaterialGameSetup() {
|
|
10
10
|
this.game = { players: [], items: {}, memory: {} };
|
|
@@ -31,12 +31,19 @@ var MaterialGameSetup = (function () {
|
|
|
31
31
|
});
|
|
32
32
|
MaterialGameSetup.prototype.setupMaterial = function (_options) {
|
|
33
33
|
};
|
|
34
|
+
MaterialGameSetup.prototype.playMove = function (move) {
|
|
35
|
+
if ((0, utils_1.hasRandomMove)(this.rules)) {
|
|
36
|
+
move = this.rules.randomize(move);
|
|
37
|
+
}
|
|
38
|
+
var consequences = this.rules.play(JSON.parse(JSON.stringify(move)));
|
|
39
|
+
(0, utils_1.applyAutomaticMoves)(this.rules, consequences);
|
|
40
|
+
};
|
|
34
41
|
MaterialGameSetup.prototype.material = function (type) {
|
|
35
42
|
var _this = this;
|
|
36
43
|
if (!this.game.items[type])
|
|
37
44
|
this.game.items[type] = [];
|
|
38
45
|
var items = this.game.items[type];
|
|
39
|
-
return new items_1.Material(type, Array.from(items.entries()).filter(function (entry) { return entry[1].quantity !== 0; }), function (move) { return
|
|
46
|
+
return new items_1.Material(type, Array.from(items.entries()).filter(function (entry) { return entry[1].quantity !== 0; }), function (move) { return _this.playMove(move); });
|
|
40
47
|
};
|
|
41
48
|
MaterialGameSetup.prototype.getMemory = function (player) {
|
|
42
49
|
return player === undefined ? new memory_1.GameMemory(this.game) : new memory_1.PlayerMemory(this.game, player);
|
|
@@ -45,13 +52,14 @@ var MaterialGameSetup = (function () {
|
|
|
45
52
|
this.getMemory(player).memorize(key, value);
|
|
46
53
|
};
|
|
47
54
|
MaterialGameSetup.prototype.startPlayerTurn = function (id, player) {
|
|
48
|
-
(0
|
|
55
|
+
if (player === void 0) { player = this.game.players[0]; }
|
|
56
|
+
this.playMove(moves_1.MaterialMoveBuilder.startPlayerTurn(id, player));
|
|
49
57
|
};
|
|
50
58
|
MaterialGameSetup.prototype.startSimultaneousRule = function (id, players) {
|
|
51
|
-
|
|
59
|
+
this.playMove(moves_1.MaterialMoveBuilder.startSimultaneousRule(id, players));
|
|
52
60
|
};
|
|
53
61
|
MaterialGameSetup.prototype.startRule = function (id) {
|
|
54
|
-
|
|
62
|
+
this.playMove(moves_1.MaterialMoveBuilder.startRule(id));
|
|
55
63
|
};
|
|
56
64
|
return MaterialGameSetup;
|
|
57
65
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaterialGameSetup.js","sourceRoot":"","sources":["../../src/material/MaterialGameSetup.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"MaterialGameSetup.js","sourceRoot":"","sources":["../../src/material/MaterialGameSetup.ts"],"names":[],"mappings":";;;AACA,kCAA6D;AAC7D,iCAAkC;AAGlC,mCAAmD;AACnD,iCAA2D;AAK3D;IAAA;QAYY,SAAI,GAA0B,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;IAqHhF,CAAC;IAhHC,sBAAI,oCAAK;aAAT;YACE,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;;;OAAA;IAMD,iCAAK,GAAL,UAAM,OAAgB;QACpB,IAAI,CAAC,IAAI,GAAG,EAAE,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;QACrE,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;QAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACnB,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAKD,sBAAI,s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AC,eAAe,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,CAAC,KAAK,GAAG,CAAC,CAAW,EAArB,CAAqB,CAAC,CAAA;IACtF,CAAC;AACH,CAAC"}
|
|
@@ -2,16 +2,17 @@ import { Action } from '../Action';
|
|
|
2
2
|
import { RandomMove } from '../RandomMove';
|
|
3
3
|
import { PlayMoveContext, Rules } from '../Rules';
|
|
4
4
|
import { Undo } from '../Undo';
|
|
5
|
+
import { UnpredictableMoves } from '../UnpredictableMove';
|
|
5
6
|
import { Material, MaterialMutator } from './items';
|
|
6
7
|
import { LocationStrategy } from './location';
|
|
7
8
|
import { MaterialGame } from './MaterialGame';
|
|
8
9
|
import { GameMemory, PlayerMemory } from './memory';
|
|
9
10
|
import { MaterialMove, MaterialMoveRandomized, MaterialMoveView, RollItem } from './moves';
|
|
10
11
|
import { MaterialRulesPart, MaterialRulesPartCreator } from './rules';
|
|
11
|
-
export declare abstract class MaterialRules<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends Rules<MaterialGame<Player, MaterialType, LocationType>, MaterialMove<Player, MaterialType, LocationType>, Player> implements RandomMove<MaterialMove<Player, MaterialType, LocationType>, MaterialMoveRandomized<Player, MaterialType, LocationType>>, Undo<MaterialMove<Player, MaterialType, LocationType>, Player
|
|
12
|
-
material(type: MaterialType): Material<Player, MaterialType, LocationType>;
|
|
12
|
+
export declare abstract class MaterialRules<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends Rules<MaterialGame<Player, MaterialType, LocationType>, MaterialMove<Player, MaterialType, LocationType>, Player> implements RandomMove<MaterialMove<Player, MaterialType, LocationType>, MaterialMoveRandomized<Player, MaterialType, LocationType>>, Undo<MaterialMove<Player, MaterialType, LocationType>, Player>, UnpredictableMoves<MaterialMove<Player, MaterialType, LocationType>> {
|
|
13
13
|
abstract readonly rules: Record<number, MaterialRulesPartCreator<Player, MaterialType, LocationType>>;
|
|
14
14
|
readonly locationsStrategies: Partial<Record<MaterialType, Partial<Record<LocationType, LocationStrategy<Player, MaterialType, LocationType>>>>>;
|
|
15
|
+
material(type: MaterialType): Material<Player, MaterialType, LocationType>;
|
|
15
16
|
get players(): Player[];
|
|
16
17
|
protected getMemory(player?: Player): GameMemory<Player> | PlayerMemory<Player>;
|
|
17
18
|
remind<T = any>(key: keyof any, player?: Player): T;
|
|
@@ -24,13 +25,12 @@ export declare abstract class MaterialRules<Player extends number = number, Mate
|
|
|
24
25
|
play(move: MaterialMoveRandomized<Player, MaterialType, LocationType> | MaterialMoveView<Player, MaterialType, LocationType>, context?: PlayMoveContext): MaterialMove<Player, MaterialType, LocationType>[];
|
|
25
26
|
private changeRule;
|
|
26
27
|
canUndo(action: Action<MaterialMove<Player, MaterialType, LocationType>, Player>, consecutiveActions: Action<MaterialMove<Player, MaterialType, LocationType>, Player>[]): boolean;
|
|
27
|
-
consecutiveActionBlocksUndo
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
private consecutiveActionBlocksUndo;
|
|
29
|
+
private actionBlocksUndo;
|
|
30
|
+
private actionActivatesPlayer;
|
|
30
31
|
protected moveBlocksUndo(move: MaterialMove<Player, MaterialType, LocationType>): boolean;
|
|
31
|
-
|
|
32
|
+
private moveActivatesPlayer;
|
|
32
33
|
isUnpredictableMove(move: MaterialMove<Player, MaterialType, LocationType>, _player: Player): boolean;
|
|
33
|
-
protected isRandomMove(move: MaterialMove<Player, MaterialType, LocationType>): boolean;
|
|
34
34
|
isOver(): boolean;
|
|
35
35
|
}
|
|
36
36
|
export interface MaterialRulesCreator<P extends number = number, M extends number = number, L extends number = number> {
|
|
@@ -36,6 +36,7 @@ var Rules_1 = require("../Rules");
|
|
|
36
36
|
var items_1 = require("./items");
|
|
37
37
|
var memory_1 = require("./memory");
|
|
38
38
|
var moves_1 = require("./moves");
|
|
39
|
+
var rules_1 = require("./rules");
|
|
39
40
|
var MaterialRules = (function (_super) {
|
|
40
41
|
__extends(MaterialRules, _super);
|
|
41
42
|
function MaterialRules() {
|
|
@@ -62,7 +63,6 @@ var MaterialRules = (function (_super) {
|
|
|
62
63
|
};
|
|
63
64
|
Object.defineProperty(MaterialRules.prototype, "rulesStep", {
|
|
64
65
|
get: function () {
|
|
65
|
-
var _this = this;
|
|
66
66
|
if (!this.game.rule)
|
|
67
67
|
return;
|
|
68
68
|
var RulesStep = this.rules[this.game.rule.id];
|
|
@@ -70,7 +70,7 @@ var MaterialRules = (function (_super) {
|
|
|
70
70
|
console.error("The rules class for rules id ".concat(this.game.rule.id, " is missing"));
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
return new RulesStep(this.game
|
|
73
|
+
return new RulesStep(this.game);
|
|
74
74
|
},
|
|
75
75
|
enumerable: false,
|
|
76
76
|
configurable: true
|
|
@@ -122,6 +122,12 @@ var MaterialRules = (function (_super) {
|
|
|
122
122
|
if (move.type === moves_1.RuleMoveType.EndPlayerTurn) {
|
|
123
123
|
if ((_a = this.game.rule) === null || _a === void 0 ? void 0 : _a.players) {
|
|
124
124
|
this.game.rule.players = this.game.rule.players.filter(function (player) { return player !== move.player; });
|
|
125
|
+
if ((0, rules_1.isSimultaneousRule)(rulesStep)) {
|
|
126
|
+
consequences.push.apply(consequences, rulesStep.onPlayerTurnEnd(move, context));
|
|
127
|
+
if (this.game.rule.players.length === 0) {
|
|
128
|
+
consequences.push.apply(consequences, rulesStep.getMovesAfterPlayersDone());
|
|
129
|
+
}
|
|
130
|
+
}
|
|
125
131
|
}
|
|
126
132
|
}
|
|
127
133
|
else {
|
|
@@ -142,12 +148,12 @@ var MaterialRules = (function (_super) {
|
|
|
142
148
|
this.game.droppedItem = move.item;
|
|
143
149
|
break;
|
|
144
150
|
case moves_1.LocalMoveType.SetTutorialStep:
|
|
145
|
-
this.game.
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
this.game.tutorial.step = move.step;
|
|
152
|
+
this.game.tutorial.stepComplete = false;
|
|
153
|
+
this.game.tutorial.popupClosed = false;
|
|
148
154
|
break;
|
|
149
155
|
case moves_1.LocalMoveType.CloseTutorialPopup:
|
|
150
|
-
this.game.
|
|
156
|
+
this.game.tutorial.popupClosed = true;
|
|
151
157
|
}
|
|
152
158
|
}
|
|
153
159
|
return consequences;
|
|
@@ -214,10 +220,7 @@ var MaterialRules = (function (_super) {
|
|
|
214
220
|
return (0, moves_1.isStartPlayerTurn)(move) || (0, moves_1.isStartSimultaneousRule)(move);
|
|
215
221
|
};
|
|
216
222
|
MaterialRules.prototype.isUnpredictableMove = function (move, _player) {
|
|
217
|
-
return
|
|
218
|
-
};
|
|
219
|
-
MaterialRules.prototype.isRandomMove = function (move) {
|
|
220
|
-
return (0, moves_1.isShuffle)(move) || (0, moves_1.isRoll)(move);
|
|
223
|
+
return (0, moves_1.isRoll)(move);
|
|
221
224
|
};
|
|
222
225
|
MaterialRules.prototype.isOver = function () {
|
|
223
226
|
return !this.game.rule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaterialRules.js","sourceRoot":"","sources":["../../src/material/MaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAkC;AAClC,2DAAoC;AAGpC,kCAAiD;
|
|
1
|
+
{"version":3,"file":"MaterialRules.js","sourceRoot":"","sources":["../../src/material/MaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAkC;AAClC,2DAAoC;AAGpC,kCAAiD;AAGjD,iCAAmD;AAGnD,mCAAmD;AACnD,iCAgBgB;AAChB,iCAAyF;AAazF;IACU,iCAAiH;IAD3H;;QAqBW,yBAAmB,GAAuH,EAAE,CAAA;;IAqSvJ,CAAC;IA7RC,gCAAQ,GAAR,UAAS,IAAkB;;QACzB,OAAO,IAAI,gBAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,mCAAI,EA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IAAI,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACrD,OAAO,IAAI,CAAA;YACb,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC9C,CAAC;IAUS,sCAAc,GAAxB,UAAyB,IAAsD;QAC7E,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,IAAA,cAAM,EAAC,IAAI,CAAC,CAAA;IACvD,CAAC;IAEO,2CAAmB,GAA3B,UAA4B,IAAsD;QAChF,OAAO,IAAA,yBAAiB,EAAC,IAAI,CAAC,IAAI,IAAA,+BAAuB,EAAC,IAAI,CAAC,CAAA;IACjE,CAAC;IAWD,2CAAmB,GAAnB,UAAoB,IAAsD,EAAE,OAAe;QACzF,OAAO,IAAA,cAAM,EAAC,IAAI,CAAC,CAAA;IACrB,CAAC;IAOD,8BAAM,GAAN;QACE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;IACxB,CAAC;IACH,oBAAC;AAAD,CAAC,AA1TD,CACU,aAAK,GAyTd;AA1TqB,sCAAa"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SecretInformation } from '../
|
|
1
|
+
import { SecretInformation } from '../SecretInformation';
|
|
2
2
|
import { HiddenMaterialRules, HidingStrategy } from './HiddenMaterialRules';
|
|
3
3
|
import { MaterialItem } from './items';
|
|
4
4
|
import { MaterialGame } from './MaterialGame';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecretMaterialRules.js","sourceRoot":"","sources":["../../src/material/SecretMaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,6DAA2E;
|
|
1
|
+
{"version":3,"file":"SecretMaterialRules.js","sourceRoot":"","sources":["../../src/material/SecretMaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,6DAA2E;AAU3E;IACU,uCAAuD;IADjE;;IAuBA,CAAC;IAVC,2CAAa,GAAb,UAAc,MAAc;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC;IAKD,+CAAiB,GAAjB,UAAkB,IAAgE,EAAE,MAAc;QAChG,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACvC,CAAC;IACH,0BAAC;AAAD,CAAC,AAvBD,CACU,yCAAmB,GAsB5B;AAvBqB,kDAAmB;AAsClC,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;AAOrD,IAAM,iBAAiB,GAAmB,UAC/C,IAAwB,EAAE,MAAU,IACvB,OAAA,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,EAAnD,CAAmD,CAAA;AAFrD,QAAA,iBAAiB,qBAEoC"}
|
package/dist/material/index.d.ts
CHANGED
package/dist/material/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./location"), exports);
|
|
|
19
19
|
__exportStar(require("./memory"), exports);
|
|
20
20
|
__exportStar(require("./moves"), exports);
|
|
21
21
|
__exportStar(require("./rules"), exports);
|
|
22
|
+
__exportStar(require("./tutorial"), exports);
|
|
22
23
|
__exportStar(require("./HiddenMaterialRules"), exports);
|
|
23
24
|
__exportStar(require("./MaterialGame"), exports);
|
|
24
25
|
__exportStar(require("./MaterialRules"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/material/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,6CAA0B;AAC1B,2CAAwB;AACxB,0CAAuB;AACvB,0CAAuB;AACvB,wDAAqC;AACrC,iDAA8B;AAC9B,kDAA+B;AAC/B,sDAAmC;AACnC,wDAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/material/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,6CAA0B;AAC1B,2CAAwB;AACxB,0CAAuB;AACvB,0CAAuB;AACvB,6CAA0B;AAC1B,wDAAqC;AACrC,iDAA8B;AAC9B,kDAA+B;AAC/B,sDAAmC;AACnC,wDAAqC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Location } from '../location';
|
|
2
2
|
import { CreateItem, CreateItemsAtOnce, DeleteItem, DeleteItemsAtOnce, ItemMove, MoveItem, MoveItemsAtOnce, RollItem, SelectItem, Shuffle } from '../moves';
|
|
3
|
+
import { MaterialDeck } from './MaterialDeck';
|
|
3
4
|
import { MaterialItem } from './MaterialItem';
|
|
4
5
|
type ItemEntry<P extends number = number, L extends number = number> = [number, MaterialItem<P, L>];
|
|
5
6
|
export declare class Material<P extends number = number, M extends number = number, L extends number = number> {
|
|
@@ -8,14 +9,13 @@ export declare class Material<P extends number = number, M extends number = numb
|
|
|
8
9
|
protected readonly processMove?: ((move: ItemMove<P, M, L>) => void) | undefined;
|
|
9
10
|
constructor(type: M, entries: ItemEntry<P, L>[], processMove?: ((move: ItemMove<P, M, L>) => void) | undefined);
|
|
10
11
|
protected new(entries: ItemEntry<P, L>[]): this;
|
|
11
|
-
getItems(): MaterialItem<P, L>[];
|
|
12
12
|
getItems<Id = any>(predicate?: (item: MaterialItem<P, L, Id>) => boolean): MaterialItem<P, L, Id>[];
|
|
13
|
-
getItem<Id = any>(index: number): MaterialItem<P, L, Id
|
|
13
|
+
getItem<Id = any>(index: number): MaterialItem<P, L, Id>;
|
|
14
14
|
getItem<Id = any>(predicate?: (item: MaterialItem<P, L, Id>) => boolean): MaterialItem<P, L, Id> | undefined;
|
|
15
15
|
getIndex(): number;
|
|
16
16
|
getIndexes(): number[];
|
|
17
|
-
index(arg
|
|
18
|
-
indexes(indexes: number[]):
|
|
17
|
+
index(arg?: number | number[] | ((index: number) => boolean)): this;
|
|
18
|
+
indexes(indexes: number[]): this;
|
|
19
19
|
get length(): number;
|
|
20
20
|
getQuantity(): number;
|
|
21
21
|
filter(predicate: (item: MaterialItem<P, L>, index: number) => boolean): this;
|
|
@@ -25,11 +25,11 @@ export declare class Material<P extends number = number, M extends number = numb
|
|
|
25
25
|
player(arg?: P | ((player?: P) => boolean)): this;
|
|
26
26
|
locationId<Id extends string | number | boolean | Record<string, any> | undefined>(arg: Id | ((id: Id) => boolean)): this;
|
|
27
27
|
parent(arg?: number | ((parent?: number) => boolean)): this;
|
|
28
|
+
selected(selected?: number | boolean): this;
|
|
28
29
|
minBy(selector: (item: MaterialItem<P, L>) => number): this;
|
|
30
|
+
maxBy(selector: (item: MaterialItem<P, L>) => number): this;
|
|
29
31
|
sort(...selectors: ((item: MaterialItem<P, L>) => number)[]): this;
|
|
30
32
|
limit(count: number): this;
|
|
31
|
-
maxBy(selector: (item: MaterialItem<P, L>) => number): this;
|
|
32
|
-
selected(selected?: number | boolean): this;
|
|
33
33
|
private process;
|
|
34
34
|
createItem(item: MaterialItem<P, L>): CreateItem<P, M, L>;
|
|
35
35
|
createItems(items: MaterialItem<P, L>[]): CreateItem<P, M, L>[];
|
|
@@ -37,13 +37,13 @@ export declare class Material<P extends number = number, M extends number = numb
|
|
|
37
37
|
deleteItem(quantity?: number): DeleteItem<M>;
|
|
38
38
|
deleteItems(quantity?: number): DeleteItem<M>[];
|
|
39
39
|
deleteItemsAtOnce(): DeleteItemsAtOnce<M>;
|
|
40
|
+
moveItem(location: ((item: MaterialItem<P, L>) => Location<P, L>) | Location<P, L>, quantity?: number): MoveItem<P, M, L>;
|
|
41
|
+
moveItems(location: ((item: MaterialItem<P, L>, index: number) => Partial<Location<P, L>>) | Partial<Location<P, L>>, quantity?: number): MoveItem<P, M, L>[];
|
|
42
|
+
moveItemsAtOnce(location: Partial<Location<P, L>>): MoveItemsAtOnce<P, M, L>;
|
|
40
43
|
selectItem(quantity?: number): SelectItem<M>;
|
|
41
44
|
selectItems(quantity?: number): SelectItem<M>[];
|
|
42
45
|
unselectItem(quantity?: number): SelectItem<M>;
|
|
43
46
|
unselectItems(quantity?: number): SelectItem<M>[];
|
|
44
|
-
moveItem(location: ((item: MaterialItem<P, L>) => Location<P, L>) | Location<P, L>, quantity?: number): MoveItem<P, M, L>;
|
|
45
|
-
moveItems(location: ((item: MaterialItem<P, L>, index: number) => Partial<Location<P, L>>) | Partial<Location<P, L>>, quantity?: number): MoveItem<P, M, L>[];
|
|
46
|
-
moveItemsAtOnce(location: Partial<Location<P, L>>): MoveItemsAtOnce<P, M, L>;
|
|
47
47
|
rotateItem<R extends string | number | boolean | Record<string, any> | undefined>(arg?: R | ((item: MaterialItem<P, L>) => R)): MoveItem<P, M, L>;
|
|
48
48
|
rotateItems<R extends string | number | boolean | Record<string, any> | undefined>(arg?: R | ((item: MaterialItem<P, L>) => R | undefined)): MoveItem<P, M, L>[];
|
|
49
49
|
shuffle(): Shuffle<M>;
|
|
@@ -51,9 +51,4 @@ export declare class Material<P extends number = number, M extends number = numb
|
|
|
51
51
|
rollItems(location?: ((item: MaterialItem<P, L>) => Location<P, L>) | Location<P, L>): RollItem<P, M, L>[];
|
|
52
52
|
deck(selector?: (item: MaterialItem<P, L>) => number): MaterialDeck<P, M, L>;
|
|
53
53
|
}
|
|
54
|
-
export declare class MaterialDeck<P extends number = number, M extends number = number, L extends number = number> extends Material<P, M, L> {
|
|
55
|
-
deal(arg: ((item: MaterialItem<P, L>) => Location<P, L>) | Location<P, L>, quantity?: number): MoveItem<P, M, L>[];
|
|
56
|
-
dealOne(arg: ((item: MaterialItem<P, L>) => Location<P, L>) | Location<P, L>): MoveItem<P, M, L>;
|
|
57
|
-
dealAtOnce(arg: Location<P, L>, quantity?: number): MoveItemsAtOnce<P, M, L>;
|
|
58
|
-
}
|
|
59
54
|
export {};
|
|
@@ -1,19 +1,4 @@
|
|
|
1
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
2
|
var __assign = (this && this.__assign) || function () {
|
|
18
3
|
__assign = Object.assign || function(t) {
|
|
19
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -40,13 +25,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
26
|
};
|
|
42
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.
|
|
28
|
+
exports.Material = void 0;
|
|
44
29
|
var isEqual_1 = __importDefault(require("lodash/isEqual"));
|
|
45
30
|
var maxBy_1 = __importDefault(require("lodash/maxBy"));
|
|
46
31
|
var minBy_1 = __importDefault(require("lodash/minBy"));
|
|
47
32
|
var orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
48
33
|
var sumBy_1 = __importDefault(require("lodash/sumBy"));
|
|
49
34
|
var moves_1 = require("../moves");
|
|
35
|
+
var MaterialDeck_1 = require("./MaterialDeck");
|
|
50
36
|
var Material = (function () {
|
|
51
37
|
function Material(type, entries, processMove) {
|
|
52
38
|
this.type = type;
|
|
@@ -64,7 +50,9 @@ var Material = (function () {
|
|
|
64
50
|
Material.prototype.getItem = function (arg) {
|
|
65
51
|
if (typeof arg === 'number') {
|
|
66
52
|
var entry = this.entries.find(function (entry) { return entry[0] === arg; });
|
|
67
|
-
|
|
53
|
+
if (!entry)
|
|
54
|
+
throw new Error("Could not find any item with index ".concat(arg));
|
|
55
|
+
return entry[1];
|
|
68
56
|
}
|
|
69
57
|
else if (typeof arg === 'function') {
|
|
70
58
|
var entries = this.entries.filter(function (_a) {
|
|
@@ -85,15 +73,23 @@ var Material = (function () {
|
|
|
85
73
|
return this.entries.map(function (entry) { return entry[0]; });
|
|
86
74
|
};
|
|
87
75
|
Material.prototype.index = function (arg) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
76
|
+
switch (typeof arg) {
|
|
77
|
+
case 'function':
|
|
78
|
+
return this.filter(function (_, index) { return arg(index); });
|
|
79
|
+
case 'number':
|
|
80
|
+
var item = this.entries.find(function (_a) {
|
|
81
|
+
var index = _a[0];
|
|
82
|
+
return index === arg;
|
|
83
|
+
});
|
|
84
|
+
return this.new(item ? [item] : []);
|
|
85
|
+
case 'undefined':
|
|
86
|
+
return this.new([]);
|
|
87
|
+
default:
|
|
88
|
+
var items = this.entries.filter(function (_a) {
|
|
89
|
+
var i = _a[0];
|
|
90
|
+
return arg.includes(i);
|
|
91
|
+
});
|
|
92
|
+
return this.new(items);
|
|
97
93
|
}
|
|
98
94
|
};
|
|
99
95
|
Material.prototype.indexes = function (indexes) {
|
|
@@ -159,10 +155,18 @@ var Material = (function () {
|
|
|
159
155
|
return typeof arg === 'function' ? arg(parent) : (0, isEqual_1.default)(parent, arg);
|
|
160
156
|
});
|
|
161
157
|
};
|
|
158
|
+
Material.prototype.selected = function (selected) {
|
|
159
|
+
if (selected === void 0) { selected = true; }
|
|
160
|
+
return this.filter(function (item) { var _a; return ((_a = item.selected) !== null && _a !== void 0 ? _a : false) === selected; });
|
|
161
|
+
};
|
|
162
162
|
Material.prototype.minBy = function (selector) {
|
|
163
163
|
var min = (0, minBy_1.default)(this.entries, function (entry) { return selector(entry[1]); });
|
|
164
164
|
return this.new(min ? [min] : []);
|
|
165
165
|
};
|
|
166
|
+
Material.prototype.maxBy = function (selector) {
|
|
167
|
+
var max = (0, maxBy_1.default)(this.entries, function (entry) { return selector(entry[1]); });
|
|
168
|
+
return this.new(max ? [max] : []);
|
|
169
|
+
};
|
|
166
170
|
Material.prototype.sort = function () {
|
|
167
171
|
var selectors = [];
|
|
168
172
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -174,14 +178,6 @@ var Material = (function () {
|
|
|
174
178
|
Material.prototype.limit = function (count) {
|
|
175
179
|
return this.new(this.entries.slice(0, count));
|
|
176
180
|
};
|
|
177
|
-
Material.prototype.maxBy = function (selector) {
|
|
178
|
-
var max = (0, maxBy_1.default)(this.entries, function (entry) { return selector(entry[1]); });
|
|
179
|
-
return this.new(max ? [max] : []);
|
|
180
|
-
};
|
|
181
|
-
Material.prototype.selected = function (selected) {
|
|
182
|
-
if (selected === void 0) { selected = true; }
|
|
183
|
-
return this.filter(function (item) { var _a; return ((_a = item.selected) !== null && _a !== void 0 ? _a : false) === selected; });
|
|
184
|
-
};
|
|
185
181
|
Material.prototype.process = function (moves) {
|
|
186
182
|
if (this.processMove) {
|
|
187
183
|
for (var _i = 0, moves_2 = moves; _i < moves_2.length; _i++) {
|
|
@@ -235,95 +231,95 @@ var Material = (function () {
|
|
|
235
231
|
var moves = { kind: moves_1.MoveKind.ItemMove, type: moves_1.ItemMoveType.DeleteAtOnce, itemType: this.type, indexes: this.getIndexes() };
|
|
236
232
|
return this.process([moves])[0];
|
|
237
233
|
};
|
|
238
|
-
Material.prototype.
|
|
234
|
+
Material.prototype.moveItem = function (location, quantity) {
|
|
239
235
|
switch (this.length) {
|
|
240
236
|
case 0:
|
|
241
|
-
throw new Error('You are trying to
|
|
237
|
+
throw new Error('You are trying to move an item that does not exists');
|
|
242
238
|
case 1:
|
|
243
|
-
return this.
|
|
239
|
+
return this.moveItems(location, quantity)[0];
|
|
244
240
|
default:
|
|
245
|
-
return this.limit(1).
|
|
241
|
+
return this.limit(1).moveItems(location, quantity)[0];
|
|
246
242
|
}
|
|
247
243
|
};
|
|
248
|
-
Material.prototype.
|
|
244
|
+
Material.prototype.moveItems = function (location, quantity) {
|
|
249
245
|
var _this = this;
|
|
246
|
+
var getLocation = typeof location === 'function' ? location : function () { return location; };
|
|
250
247
|
return this.process(this.entries.map(function (entry) {
|
|
248
|
+
var location = getLocation(entry[1], entry[0]);
|
|
251
249
|
var move = {
|
|
252
250
|
kind: moves_1.MoveKind.ItemMove,
|
|
253
|
-
type: moves_1.ItemMoveType.
|
|
251
|
+
type: moves_1.ItemMoveType.Move,
|
|
254
252
|
itemType: _this.type,
|
|
255
|
-
itemIndex: entry[0]
|
|
253
|
+
itemIndex: entry[0],
|
|
254
|
+
location: location
|
|
256
255
|
};
|
|
257
256
|
if (quantity)
|
|
258
257
|
move.quantity = quantity;
|
|
259
258
|
return move;
|
|
260
259
|
}));
|
|
261
260
|
};
|
|
262
|
-
Material.prototype.
|
|
261
|
+
Material.prototype.moveItemsAtOnce = function (location) {
|
|
262
|
+
var move = {
|
|
263
|
+
kind: moves_1.MoveKind.ItemMove,
|
|
264
|
+
type: moves_1.ItemMoveType.MoveAtOnce,
|
|
265
|
+
itemType: this.type,
|
|
266
|
+
indexes: this.entries.map(function (_a) {
|
|
267
|
+
var index = _a[0];
|
|
268
|
+
return index;
|
|
269
|
+
}),
|
|
270
|
+
location: location
|
|
271
|
+
};
|
|
272
|
+
return this.process([move])[0];
|
|
273
|
+
};
|
|
274
|
+
Material.prototype.selectItem = function (quantity) {
|
|
263
275
|
switch (this.length) {
|
|
264
276
|
case 0:
|
|
265
277
|
throw new Error('You are trying to select an item that does not exists');
|
|
266
278
|
case 1:
|
|
267
|
-
return this.
|
|
279
|
+
return this.selectItems(quantity)[0];
|
|
268
280
|
default:
|
|
269
|
-
return this.limit(1).
|
|
281
|
+
return this.limit(1).selectItems(quantity)[0];
|
|
270
282
|
}
|
|
271
283
|
};
|
|
272
|
-
Material.prototype.
|
|
284
|
+
Material.prototype.selectItems = function (quantity) {
|
|
273
285
|
var _this = this;
|
|
274
286
|
return this.process(this.entries.map(function (entry) {
|
|
275
287
|
var move = {
|
|
276
288
|
kind: moves_1.MoveKind.ItemMove,
|
|
277
289
|
type: moves_1.ItemMoveType.Select,
|
|
278
290
|
itemType: _this.type,
|
|
279
|
-
itemIndex: entry[0]
|
|
280
|
-
selected: false
|
|
291
|
+
itemIndex: entry[0]
|
|
281
292
|
};
|
|
282
293
|
if (quantity)
|
|
283
294
|
move.quantity = quantity;
|
|
284
295
|
return move;
|
|
285
296
|
}));
|
|
286
297
|
};
|
|
287
|
-
Material.prototype.
|
|
298
|
+
Material.prototype.unselectItem = function (quantity) {
|
|
288
299
|
switch (this.length) {
|
|
289
300
|
case 0:
|
|
290
|
-
throw new Error('You are trying to
|
|
301
|
+
throw new Error('You are trying to select an item that does not exists');
|
|
291
302
|
case 1:
|
|
292
|
-
return this.
|
|
303
|
+
return this.unselectItems(quantity)[0];
|
|
293
304
|
default:
|
|
294
|
-
return this.limit(1).
|
|
305
|
+
return this.limit(1).unselectItems(quantity)[0];
|
|
295
306
|
}
|
|
296
307
|
};
|
|
297
|
-
Material.prototype.
|
|
308
|
+
Material.prototype.unselectItems = function (quantity) {
|
|
298
309
|
var _this = this;
|
|
299
|
-
var getLocation = typeof location === 'function' ? location : function () { return location; };
|
|
300
310
|
return this.process(this.entries.map(function (entry) {
|
|
301
|
-
var location = getLocation(entry[1], entry[0]);
|
|
302
311
|
var move = {
|
|
303
312
|
kind: moves_1.MoveKind.ItemMove,
|
|
304
|
-
type: moves_1.ItemMoveType.
|
|
313
|
+
type: moves_1.ItemMoveType.Select,
|
|
305
314
|
itemType: _this.type,
|
|
306
315
|
itemIndex: entry[0],
|
|
307
|
-
|
|
316
|
+
selected: false
|
|
308
317
|
};
|
|
309
318
|
if (quantity)
|
|
310
319
|
move.quantity = quantity;
|
|
311
320
|
return move;
|
|
312
321
|
}));
|
|
313
322
|
};
|
|
314
|
-
Material.prototype.moveItemsAtOnce = function (location) {
|
|
315
|
-
var move = {
|
|
316
|
-
kind: moves_1.MoveKind.ItemMove,
|
|
317
|
-
type: moves_1.ItemMoveType.MoveAtOnce,
|
|
318
|
-
itemType: this.type,
|
|
319
|
-
indexes: this.entries.map(function (_a) {
|
|
320
|
-
var index = _a[0];
|
|
321
|
-
return index;
|
|
322
|
-
}),
|
|
323
|
-
location: location
|
|
324
|
-
};
|
|
325
|
-
return this.process([move])[0];
|
|
326
|
-
};
|
|
327
323
|
Material.prototype.rotateItem = function (arg) {
|
|
328
324
|
switch (this.length) {
|
|
329
325
|
case 0:
|
|
@@ -376,32 +372,9 @@ var Material = (function () {
|
|
|
376
372
|
};
|
|
377
373
|
Material.prototype.deck = function (selector) {
|
|
378
374
|
if (selector === void 0) { selector = function (item) { return -item.location.x; }; }
|
|
379
|
-
return new MaterialDeck(this.type, this.entries, this.processMove).sort(selector);
|
|
375
|
+
return new MaterialDeck_1.MaterialDeck(this.type, this.entries, this.processMove).sort(selector);
|
|
380
376
|
};
|
|
381
377
|
return Material;
|
|
382
378
|
}());
|
|
383
379
|
exports.Material = Material;
|
|
384
|
-
var MaterialDeck = (function (_super) {
|
|
385
|
-
__extends(MaterialDeck, _super);
|
|
386
|
-
function MaterialDeck() {
|
|
387
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
388
|
-
}
|
|
389
|
-
MaterialDeck.prototype.deal = function (arg, quantity) {
|
|
390
|
-
if (quantity === void 0) { quantity = 1; }
|
|
391
|
-
return this.new(this.entries.splice(0, quantity)).moveItems(arg);
|
|
392
|
-
};
|
|
393
|
-
MaterialDeck.prototype.dealOne = function (arg) {
|
|
394
|
-
var deal = this.deal(arg);
|
|
395
|
-
if (deal.length === 0) {
|
|
396
|
-
throw new Error('You are trying to deal one card from an empty deck');
|
|
397
|
-
}
|
|
398
|
-
return deal[0];
|
|
399
|
-
};
|
|
400
|
-
MaterialDeck.prototype.dealAtOnce = function (arg, quantity) {
|
|
401
|
-
if (quantity === void 0) { quantity = 1; }
|
|
402
|
-
return this.new(this.entries.splice(0, quantity)).moveItemsAtOnce(arg);
|
|
403
|
-
};
|
|
404
|
-
return MaterialDeck;
|
|
405
|
-
}(Material));
|
|
406
|
-
exports.MaterialDeck = MaterialDeck;
|
|
407
380
|
//# sourceMappingURL=Material.js.map
|