@gamepark/rules-api 7.0.0-beta.0 → 7.0.0-beta.2
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.js +1 -2
- package/dist/Bot.js +15 -37
- package/dist/Bot.js.map +1 -1
- package/dist/Competitive.js +3 -8
- package/dist/Competitive.js.map +1 -1
- package/dist/Eliminations.js +2 -5
- package/dist/Eliminations.js.map +1 -1
- package/dist/GameSetup.js +1 -2
- package/dist/HiddenInformation.js +2 -5
- package/dist/HiddenInformation.js.map +1 -1
- package/dist/LocalMovePreview.js +1 -4
- package/dist/LocalMovePreview.js.map +1 -1
- package/dist/RandomMove.js +1 -2
- package/dist/Rules.js +49 -56
- package/dist/Rules.js.map +1 -1
- package/dist/SecretInformation.js +2 -5
- package/dist/SecretInformation.js.map +1 -1
- package/dist/TimeLimit.js +1 -4
- package/dist/TimeLimit.js.map +1 -1
- package/dist/Undo.js +2 -5
- package/dist/Undo.js.map +1 -1
- package/dist/UnpredictableMove.js +1 -5
- package/dist/UnpredictableMove.js.map +1 -1
- package/dist/index.js +16 -32
- package/dist/index.js.map +1 -1
- package/dist/material/HiddenMaterialRules.js +125 -180
- package/dist/material/HiddenMaterialRules.js.map +1 -1
- package/dist/material/MaterialGame.js +1 -2
- package/dist/material/MaterialGameSetup.js +52 -70
- package/dist/material/MaterialGameSetup.js.map +1 -1
- package/dist/material/MaterialRules.js +186 -250
- package/dist/material/MaterialRules.js.map +1 -1
- package/dist/material/SecretMaterialRules.js +9 -35
- package/dist/material/SecretMaterialRules.js.map +1 -1
- package/dist/material/index.js +11 -27
- package/dist/material/index.js.map +1 -1
- package/dist/material/items/Material.js +177 -262
- package/dist/material/items/Material.js.map +1 -1
- package/dist/material/items/MaterialDeck.js +10 -36
- package/dist/material/items/MaterialDeck.js.map +1 -1
- package/dist/material/items/MaterialItem.js +1 -2
- package/dist/material/items/MaterialMoney.js +89 -141
- package/dist/material/items/MaterialMoney.js.map +1 -1
- package/dist/material/items/MaterialMutator.js +108 -145
- package/dist/material/items/MaterialMutator.js.map +1 -1
- package/dist/material/items/index.js +5 -21
- package/dist/material/items/index.js.map +1 -1
- package/dist/material/location/Location.js +1 -14
- package/dist/material/location/Location.js.map +1 -1
- package/dist/material/location/LocationBuilder.js +26 -41
- package/dist/material/location/LocationBuilder.js.map +1 -1
- package/dist/material/location/index.js +3 -19
- package/dist/material/location/index.js.map +1 -1
- package/dist/material/location/strategy/FillGapStrategy.js +9 -16
- package/dist/material/location/strategy/FillGapStrategy.js.map +1 -1
- package/dist/material/location/strategy/LocationStrategy.js +1 -2
- package/dist/material/location/strategy/PositiveSequenceStrategy.js +26 -35
- package/dist/material/location/strategy/PositiveSequenceStrategy.js.map +1 -1
- package/dist/material/location/strategy/StackingStrategy.js +15 -22
- package/dist/material/location/strategy/StackingStrategy.js.map +1 -1
- package/dist/material/location/strategy/index.js +5 -23
- package/dist/material/location/strategy/index.js.map +1 -1
- package/dist/material/memory/GameMemory.js +10 -14
- package/dist/material/memory/GameMemory.js.map +1 -1
- package/dist/material/memory/PlayerMemory.js +13 -18
- package/dist/material/memory/PlayerMemory.js.map +1 -1
- package/dist/material/memory/index.js +2 -18
- package/dist/material/memory/index.js.map +1 -1
- package/dist/material/moves/CustomMove.js +4 -9
- package/dist/material/moves/CustomMove.js.map +1 -1
- package/dist/material/moves/MaterialMove.js +1 -2
- package/dist/material/moves/MaterialMoveBuilder.js +16 -32
- package/dist/material/moves/MaterialMoveBuilder.js.map +1 -1
- package/dist/material/moves/MoveKind.js +2 -5
- package/dist/material/moves/MoveKind.js.map +1 -1
- package/dist/material/moves/index.js +7 -23
- package/dist/material/moves/index.js.map +1 -1
- package/dist/material/moves/items/CreateItem.js +6 -12
- package/dist/material/moves/items/CreateItem.js.map +1 -1
- package/dist/material/moves/items/CreateItemsAtOnce.js +6 -12
- package/dist/material/moves/items/CreateItemsAtOnce.js.map +1 -1
- package/dist/material/moves/items/DeleteItem.js +6 -12
- package/dist/material/moves/items/DeleteItem.js.map +1 -1
- package/dist/material/moves/items/DeleteItemsAtOnce.js +6 -12
- package/dist/material/moves/items/DeleteItemsAtOnce.js.map +1 -1
- package/dist/material/moves/items/ItemMove.js +1 -2
- package/dist/material/moves/items/ItemMoveType.js +2 -5
- package/dist/material/moves/items/ItemMoveType.js.map +1 -1
- package/dist/material/moves/items/MoveItem.js +6 -12
- package/dist/material/moves/items/MoveItem.js.map +1 -1
- package/dist/material/moves/items/MoveItemsAtOnce.js +6 -12
- package/dist/material/moves/items/MoveItemsAtOnce.js.map +1 -1
- package/dist/material/moves/items/RollItem.js +6 -12
- package/dist/material/moves/items/RollItem.js.map +1 -1
- package/dist/material/moves/items/SelectItem.js +6 -12
- package/dist/material/moves/items/SelectItem.js.map +1 -1
- package/dist/material/moves/items/Shuffle.js +7 -14
- package/dist/material/moves/items/Shuffle.js.map +1 -1
- package/dist/material/moves/items/index.js +11 -27
- package/dist/material/moves/items/index.js.map +1 -1
- package/dist/material/moves/local/CloseTutorialPopup.js +4 -7
- package/dist/material/moves/local/CloseTutorialPopup.js.map +1 -1
- package/dist/material/moves/local/DisplayHelp.js +2 -5
- package/dist/material/moves/local/DisplayHelp.js.map +1 -1
- package/dist/material/moves/local/DropItem.js +1 -2
- package/dist/material/moves/local/LocalMove.js +2 -5
- package/dist/material/moves/local/LocalMove.js.map +1 -1
- package/dist/material/moves/local/SetTutorialStep.js +4 -7
- package/dist/material/moves/local/SetTutorialStep.js.map +1 -1
- package/dist/material/moves/local/index.js +5 -21
- package/dist/material/moves/local/index.js.map +1 -1
- package/dist/material/moves/rules/EndGame.js +4 -7
- package/dist/material/moves/rules/EndGame.js.map +1 -1
- package/dist/material/moves/rules/EndPlayerTurn.js +4 -7
- package/dist/material/moves/rules/EndPlayerTurn.js.map +1 -1
- package/dist/material/moves/rules/RuleMove.js +3 -7
- package/dist/material/moves/rules/RuleMove.js.map +1 -1
- package/dist/material/moves/rules/StartPlayerTurn.js +4 -7
- package/dist/material/moves/rules/StartPlayerTurn.js.map +1 -1
- package/dist/material/moves/rules/StartRule.js +4 -7
- package/dist/material/moves/rules/StartRule.js.map +1 -1
- package/dist/material/moves/rules/StartSimultaneousRule.js +4 -7
- package/dist/material/moves/rules/StartSimultaneousRule.js.map +1 -1
- package/dist/material/moves/rules/index.js +6 -22
- package/dist/material/moves/rules/index.js.map +1 -1
- package/dist/material/rules/MaterialRulesPart.js +38 -63
- package/dist/material/rules/MaterialRulesPart.js.map +1 -1
- package/dist/material/rules/PlayerTurnRule.js +20 -52
- package/dist/material/rules/PlayerTurnRule.js.map +1 -1
- package/dist/material/rules/RuleStep.js +1 -2
- package/dist/material/rules/SimultaneousRule.js +19 -51
- package/dist/material/rules/SimultaneousRule.js.map +1 -1
- package/dist/material/rules/index.js +4 -20
- package/dist/material/rules/index.js.map +1 -1
- package/dist/material/tutorial/TutorialState.js +1 -2
- package/dist/material/tutorial/index.js +1 -17
- package/dist/material/tutorial/index.js.map +1 -1
- package/dist/options/EnumArrayOption.js +3 -6
- package/dist/options/EnumArrayOption.js.map +1 -1
- package/dist/options/EnumOption.js +1 -4
- package/dist/options/EnumOption.js.map +1 -1
- package/dist/options/Option.js +1 -2
- package/dist/options/OptionSpecOf.js +1 -2
- package/dist/options/OptionsSpec.js +1 -2
- package/dist/options/OptionsValidationError.js +6 -28
- package/dist/options/OptionsValidationError.js.map +1 -1
- package/dist/options/PlayerEnumOption.js +19 -29
- package/dist/options/PlayerEnumOption.js.map +1 -1
- package/dist/options/PlayersOptionsSpec.js +1 -2
- package/dist/options/WithIdOption.js +1 -2
- package/dist/options/WithPlayerOptionsSpec.js +1 -4
- package/dist/options/WithPlayerOptionsSpec.js.map +1 -1
- package/dist/options/WithPlayersOptions.js +1 -2
- package/dist/options/index.js +12 -28
- package/dist/options/index.js.map +1 -1
- package/dist/options/isWithPlayerIdOptions.js +3 -6
- package/dist/options/isWithPlayerIdOptions.js.map +1 -1
- package/dist/utils/action-view.util.js +18 -25
- package/dist/utils/action-view.util.js.map +1 -1
- package/dist/utils/action.util.js +11 -16
- package/dist/utils/action.util.js.map +1 -1
- package/dist/utils/adjacent-groups.util.js +33 -41
- package/dist/utils/adjacent-groups.util.js.map +1 -1
- package/dist/utils/automatic-moves.util.js +10 -15
- package/dist/utils/automatic-moves.util.js.map +1 -1
- package/dist/utils/enum.util.js +7 -13
- package/dist/utils/enum.util.js.map +1 -1
- package/dist/utils/game-view.util.js +5 -8
- package/dist/utils/game-view.util.js.map +1 -1
- package/dist/utils/grid.hex.util.js +36 -88
- package/dist/utils/grid.hex.util.js.map +1 -1
- package/dist/utils/grid.squares.util.js +8 -19
- package/dist/utils/grid.squares.util.js.map +1 -1
- package/dist/utils/grid.util.js +1 -5
- package/dist/utils/grid.util.js.map +1 -1
- package/dist/utils/index.js +16 -32
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/listing.util.js +8 -13
- package/dist/utils/listing.util.js.map +1 -1
- package/dist/utils/loops.util.js +3 -6
- package/dist/utils/loops.util.js.map +1 -1
- package/dist/utils/money.util.js +54 -73
- package/dist/utils/money.util.js.map +1 -1
- package/dist/utils/neighbors.util.js +6 -10
- package/dist/utils/neighbors.util.js.map +1 -1
- package/dist/utils/polyhex.util.js +36 -56
- package/dist/utils/polyhex.util.js.map +1 -1
- package/dist/utils/random.util.js +2 -5
- package/dist/utils/random.util.js.map +1 -1
- package/dist/utils/rank.util.js +9 -13
- package/dist/utils/rank.util.js.map +1 -1
- package/package.json +43 -37
- package/dist/ApplyAutomaticMoves.d.ts +0 -2
- package/dist/ApplyAutomaticMoves.js +0 -25
- package/dist/ApplyAutomaticMoves.js.map +0 -1
- package/dist/DefaultGameSetup.d.ts +0 -7
- package/dist/DefaultGameSetup.js +0 -15
- package/dist/DefaultGameSetup.js.map +0 -1
- package/dist/Dummy.d.ts +0 -7
- package/dist/Dummy.js +0 -27
- package/dist/Dummy.js.map +0 -1
- package/dist/GameSetupCreator.d.ts +0 -4
- package/dist/GameSetupCreator.js +0 -3
- package/dist/GameSetupCreator.js.map +0 -1
- package/dist/IncompleteInformation.d.ts +0 -14
- package/dist/IncompleteInformation.js +0 -38
- package/dist/IncompleteInformation.js.map +0 -1
- package/dist/LoopWithFuse.d.ts +0 -4
- package/dist/LoopWithFuse.js +0 -15
- package/dist/LoopWithFuse.js.map +0 -1
- package/dist/Robot.d.ts +0 -1
- package/dist/Robot.js +0 -3
- package/dist/Robot.js.map +0 -1
- package/dist/RulesCreator.d.ts +0 -7
- package/dist/RulesCreator.js +0 -3
- package/dist/RulesCreator.js.map +0 -1
- package/dist/material/location/strategy/StakingStrategy.d.ts +0 -12
- package/dist/material/location/strategy/StakingStrategy.js +0 -32
- package/dist/material/location/strategy/StakingStrategy.js.map +0 -1
- package/dist/material/moves/items/ItemMovesBuilder.d.ts +0 -8
- package/dist/material/moves/items/ItemMovesBuilder.js +0 -34
- package/dist/material/moves/items/ItemMovesBuilder.js.map +0 -1
- package/dist/material/rules/MaterialMoveBuilder.d.ts +0 -9
- package/dist/material/rules/MaterialMoveBuilder.js +0 -28
- package/dist/material/rules/MaterialMoveBuilder.js.map +0 -1
- package/dist/material/rules/MaterialRulesMovesBuilder.d.ts +0 -12
- package/dist/material/rules/MaterialRulesMovesBuilder.js +0 -36
- package/dist/material/rules/MaterialRulesMovesBuilder.js.map +0 -1
- package/dist/setup/DefaultGameSetup.d.ts +0 -7
- package/dist/setup/DefaultGameSetup.js +0 -15
- package/dist/setup/DefaultGameSetup.js.map +0 -1
- package/dist/setup/GameSetup.d.ts +0 -3
- package/dist/setup/GameSetup.js +0 -3
- package/dist/setup/GameSetup.js.map +0 -1
- package/dist/setup/GameSetupCreator.d.ts +0 -4
- package/dist/setup/GameSetupCreator.js +0 -3
- package/dist/setup/GameSetupCreator.js.map +0 -1
- package/dist/setup/index.d.ts +0 -2
- package/dist/setup/index.js +0 -19
- package/dist/setup/index.js.map +0 -1
- package/dist/utils/EnumUtils.d.ts +0 -1
- package/dist/utils/EnumUtils.js +0 -8
- package/dist/utils/EnumUtils.js.map +0 -1
- package/dist/utils/coordinates.util.d.ts +0 -5
- package/dist/utils/coordinates.util.js +0 -16
- package/dist/utils/coordinates.util.js.map +0 -1
- package/dist/utils/isDeadEndMove.util.d.ts +0 -2
- package/dist/utils/isDeadEndMove.util.js +0 -19
- package/dist/utils/isDeadEndMove.util.js.map +0 -1
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.MaterialMutator = void 0;
|
|
26
|
-
var es_toolkit_1 = require("es-toolkit");
|
|
27
|
-
var location_1 = require("../location");
|
|
28
|
-
var moves_1 = require("../moves");
|
|
29
|
-
var index_1 = require("./index");
|
|
1
|
+
import { isEqual, merge } from 'es-toolkit';
|
|
2
|
+
import { isSameLocationArea } from '../location';
|
|
3
|
+
import { isShuffleRandomized, ItemMoveType } from '../moves';
|
|
4
|
+
import { Material } from './index';
|
|
30
5
|
/**
|
|
31
6
|
* Helper class to change the state of any {@link MaterialItem} in a game implemented with {@link MaterialRules}.
|
|
32
7
|
*
|
|
@@ -34,7 +9,12 @@ var index_1 = require("./index");
|
|
|
34
9
|
* @typeparam M - Numeric enum of the types of material manipulated in the game
|
|
35
10
|
* @typeparam L - Numeric enum of the types of location in the game where the material can be located
|
|
36
11
|
*/
|
|
37
|
-
|
|
12
|
+
export class MaterialMutator {
|
|
13
|
+
type;
|
|
14
|
+
items;
|
|
15
|
+
locationsStrategies;
|
|
16
|
+
canMerge;
|
|
17
|
+
rulesClassName;
|
|
38
18
|
/**
|
|
39
19
|
* @param type Type of items this mutator will work on
|
|
40
20
|
* @param items Items to work with
|
|
@@ -42,10 +22,7 @@ var MaterialMutator = /** @class */ (function () {
|
|
|
42
22
|
* @param canMerge Whether to items at the exact same location can merge into one item with a quantity
|
|
43
23
|
* @param rulesClassName Constructor name of the main rules class for logging
|
|
44
24
|
*/
|
|
45
|
-
|
|
46
|
-
if (locationsStrategies === void 0) { locationsStrategies = {}; }
|
|
47
|
-
if (canMerge === void 0) { canMerge = true; }
|
|
48
|
-
if (rulesClassName === void 0) { rulesClassName = ''; }
|
|
25
|
+
constructor(type, items, locationsStrategies = {}, canMerge = true, rulesClassName = '') {
|
|
49
26
|
this.type = type;
|
|
50
27
|
this.items = items;
|
|
51
28
|
this.locationsStrategies = locationsStrategies;
|
|
@@ -56,147 +33,138 @@ var MaterialMutator = /** @class */ (function () {
|
|
|
56
33
|
* Executes a move on the game items
|
|
57
34
|
* @param move
|
|
58
35
|
*/
|
|
59
|
-
|
|
36
|
+
applyMove(move) {
|
|
60
37
|
switch (move.type) {
|
|
61
|
-
case
|
|
38
|
+
case ItemMoveType.Create:
|
|
62
39
|
this.create(move);
|
|
63
40
|
break;
|
|
64
|
-
case
|
|
65
|
-
for (
|
|
66
|
-
|
|
67
|
-
this.create(__assign(__assign({}, move), { type: moves_1.ItemMoveType.Create, item: item }));
|
|
41
|
+
case ItemMoveType.CreateAtOnce:
|
|
42
|
+
for (const item of move.items) {
|
|
43
|
+
this.create({ ...move, type: ItemMoveType.Create, item });
|
|
68
44
|
}
|
|
69
45
|
break;
|
|
70
|
-
case
|
|
46
|
+
case ItemMoveType.Move:
|
|
71
47
|
this.move(move);
|
|
72
48
|
break;
|
|
73
|
-
case
|
|
49
|
+
case ItemMoveType.MoveAtOnce:
|
|
74
50
|
this.moveItemsAtOnce(move);
|
|
75
51
|
break;
|
|
76
|
-
case
|
|
52
|
+
case ItemMoveType.Roll:
|
|
77
53
|
this.roll(move);
|
|
78
54
|
break;
|
|
79
|
-
case
|
|
55
|
+
case ItemMoveType.Delete:
|
|
80
56
|
this.delete(move);
|
|
81
57
|
break;
|
|
82
|
-
case
|
|
83
|
-
for (
|
|
84
|
-
var index = _c[_b];
|
|
58
|
+
case ItemMoveType.DeleteAtOnce:
|
|
59
|
+
for (const index of move.indexes) {
|
|
85
60
|
this.removeItem(this.items[index], Infinity);
|
|
86
61
|
}
|
|
87
62
|
break;
|
|
88
|
-
case
|
|
63
|
+
case ItemMoveType.Shuffle:
|
|
89
64
|
this.shuffle(move);
|
|
90
65
|
break;
|
|
91
|
-
case
|
|
66
|
+
case ItemMoveType.Select:
|
|
92
67
|
this.select(move);
|
|
93
68
|
break;
|
|
94
69
|
}
|
|
95
|
-
}
|
|
70
|
+
}
|
|
96
71
|
/**
|
|
97
72
|
* Find the index of an existing item we could merge a new item with (create a single item with a quantity)
|
|
98
73
|
*
|
|
99
74
|
* @param newItem An item to compare with existing items
|
|
100
75
|
* @returns {number} Index of the existing item we can merge with, or -1 if there is no possible merge
|
|
101
76
|
*/
|
|
102
|
-
|
|
77
|
+
findMergeIndex(newItem) {
|
|
103
78
|
if (!this.canMerge)
|
|
104
79
|
return -1;
|
|
105
|
-
|
|
106
|
-
return this.items.findIndex(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
MaterialMutator.prototype.addItem = function (item) {
|
|
80
|
+
const { quantity: q1, ...data1 } = newItem;
|
|
81
|
+
return this.items.findIndex(({ quantity: q2, ...data2 }) => q1 !== 0 && q2 !== 0 && isEqual(data1, data2));
|
|
82
|
+
}
|
|
83
|
+
addItem(item) {
|
|
112
84
|
this.applyAddItemStrategy(item);
|
|
113
|
-
|
|
85
|
+
const availableIndex = this.items.findIndex(item => item.quantity === 0);
|
|
114
86
|
if (availableIndex !== -1) {
|
|
115
87
|
this.items[availableIndex] = item;
|
|
116
88
|
}
|
|
117
89
|
else {
|
|
118
90
|
this.items.push(item);
|
|
119
91
|
}
|
|
120
|
-
}
|
|
92
|
+
}
|
|
121
93
|
/**
|
|
122
94
|
* Provides the index that the new item will have
|
|
123
95
|
* @param newItem An item that is going to be created
|
|
124
96
|
* @returns {number} the future index of that item
|
|
125
97
|
*/
|
|
126
|
-
|
|
127
|
-
|
|
98
|
+
getItemCreationIndex(newItem) {
|
|
99
|
+
const mergeIndex = this.findMergeIndex(newItem);
|
|
128
100
|
if (mergeIndex !== -1)
|
|
129
101
|
return mergeIndex;
|
|
130
|
-
|
|
102
|
+
const availableIndex = this.items.findIndex(item => item.quantity === 0);
|
|
131
103
|
if (availableIndex !== -1)
|
|
132
104
|
return availableIndex;
|
|
133
105
|
return this.items.length;
|
|
134
|
-
}
|
|
135
|
-
|
|
106
|
+
}
|
|
107
|
+
applyAddItemStrategy(item) {
|
|
136
108
|
if (item.location.type in this.locationsStrategies) {
|
|
137
|
-
|
|
109
|
+
const strategy = this.locationsStrategies[item.location.type];
|
|
138
110
|
if (strategy.addItem) {
|
|
139
|
-
|
|
111
|
+
const material = new Material(this.type, this.items)
|
|
140
112
|
.location(item.location.type).player(item.location.player).locationId(item.location.id).parent(item.location.parent);
|
|
141
113
|
strategy.addItem(material, item);
|
|
142
114
|
}
|
|
143
115
|
}
|
|
144
|
-
}
|
|
145
|
-
|
|
116
|
+
}
|
|
117
|
+
applyMoveItemStrategy(item, index) {
|
|
146
118
|
if (item.location.type in this.locationsStrategies) {
|
|
147
|
-
|
|
119
|
+
const strategy = this.locationsStrategies[item.location.type];
|
|
148
120
|
if (strategy.moveItem) {
|
|
149
|
-
|
|
121
|
+
const material = new Material(this.type, this.items)
|
|
150
122
|
.location(item.location.type).player(item.location.player).locationId(item.location.id).parent(item.location.parent);
|
|
151
123
|
strategy.moveItem(material, item, index);
|
|
152
124
|
}
|
|
153
125
|
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (quantity === void 0) { quantity = 1; }
|
|
158
|
-
item.quantity = Math.max(0, ((_a = item.quantity) !== null && _a !== void 0 ? _a : 1) - quantity);
|
|
126
|
+
}
|
|
127
|
+
removeItem(item, quantity = 1) {
|
|
128
|
+
item.quantity = Math.max(0, (item.quantity ?? 1) - quantity);
|
|
159
129
|
if (item.quantity === 0) {
|
|
160
130
|
this.applyRemoveItemStrategy(item);
|
|
161
131
|
}
|
|
162
|
-
}
|
|
163
|
-
|
|
132
|
+
}
|
|
133
|
+
applyRemoveItemStrategy(item) {
|
|
164
134
|
if (item.location.type in this.locationsStrategies) {
|
|
165
|
-
|
|
135
|
+
const strategy = this.locationsStrategies[item.location.type];
|
|
166
136
|
if (strategy.removeItem) {
|
|
167
|
-
|
|
137
|
+
const material = new Material(this.type, this.items)
|
|
168
138
|
.location(item.location.type).player(item.location.player).locationId(item.location.id).parent(item.location.parent);
|
|
169
139
|
strategy.removeItem(material, item);
|
|
170
140
|
}
|
|
171
141
|
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
var mergeIndex = this.findMergeIndex(move.item);
|
|
142
|
+
}
|
|
143
|
+
create(move) {
|
|
144
|
+
const mergeIndex = this.findMergeIndex(move.item);
|
|
176
145
|
if (mergeIndex !== -1) {
|
|
177
|
-
|
|
178
|
-
mergeItem.quantity = (
|
|
146
|
+
const mergeItem = this.items[mergeIndex];
|
|
147
|
+
mergeItem.quantity = (mergeItem.quantity ?? 1) + (move.item.quantity ?? 1);
|
|
179
148
|
}
|
|
180
149
|
else {
|
|
181
150
|
if (move.item.quantity && !this.canMerge) {
|
|
182
|
-
console.error(
|
|
151
|
+
console.error(`${this.rulesClassName}: do not use quantity on items that cannot merge. Items that can be hidden cannot merge.`);
|
|
183
152
|
}
|
|
184
153
|
this.addItem(JSON.parse(JSON.stringify(move.item)));
|
|
185
154
|
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
var mergeIndex = this.findMergeIndex(itemAfterMove);
|
|
155
|
+
}
|
|
156
|
+
move(move) {
|
|
157
|
+
const quantity = move.quantity ?? 1;
|
|
158
|
+
const sourceItem = this.items[move.itemIndex];
|
|
159
|
+
const itemAfterMove = this.getItemAfterMove(move);
|
|
160
|
+
const mergeIndex = this.findMergeIndex(itemAfterMove);
|
|
193
161
|
if (mergeIndex !== -1) {
|
|
194
162
|
if (mergeIndex === move.itemIndex) {
|
|
195
|
-
console.warn(
|
|
163
|
+
console.warn(`${this.rulesClassName}: item is moved to the location he already has - ${JSON.stringify(move)}`);
|
|
196
164
|
}
|
|
197
165
|
else {
|
|
198
|
-
|
|
199
|
-
mergeItem.quantity = (
|
|
166
|
+
const mergeItem = this.items[mergeIndex];
|
|
167
|
+
mergeItem.quantity = (mergeItem.quantity ?? 1) + quantity;
|
|
200
168
|
this.removeItem(sourceItem, quantity);
|
|
201
169
|
}
|
|
202
170
|
}
|
|
@@ -207,50 +175,49 @@ var MaterialMutator = /** @class */ (function () {
|
|
|
207
175
|
else {
|
|
208
176
|
this.moveItem(sourceItem, itemAfterMove, move.itemIndex);
|
|
209
177
|
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
178
|
+
}
|
|
179
|
+
roll(move) {
|
|
180
|
+
const sourceItem = this.items[move.itemIndex];
|
|
181
|
+
const itemAfterMove = { ...sourceItem, location: JSON.parse(JSON.stringify(move.location)) };
|
|
214
182
|
this.moveItem(sourceItem, itemAfterMove, move.itemIndex);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (!
|
|
183
|
+
}
|
|
184
|
+
moveItem(item, newItem, index) {
|
|
185
|
+
if (!isSameLocationArea(newItem.location, item.location)) {
|
|
218
186
|
this.applyAddItemStrategy(newItem);
|
|
219
187
|
}
|
|
220
188
|
else {
|
|
221
189
|
this.applyMoveItemStrategy(newItem, index);
|
|
222
190
|
}
|
|
223
191
|
this.items[index] = newItem;
|
|
224
|
-
if (!
|
|
192
|
+
if (!isSameLocationArea(newItem.location, item.location)) {
|
|
225
193
|
this.applyRemoveItemStrategy(item);
|
|
226
194
|
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
for (
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if (!(0, location_1.isSameLocationArea)(itemAfterMove.location, sourceItem.location)) {
|
|
195
|
+
}
|
|
196
|
+
moveItemsAtOnce(move) {
|
|
197
|
+
for (const index of move.indexes) {
|
|
198
|
+
const sourceItem = this.items[index];
|
|
199
|
+
const itemAfterMove = this.getItemAfterMoveAtOnce(move, index);
|
|
200
|
+
if (!isSameLocationArea(itemAfterMove.location, sourceItem.location)) {
|
|
234
201
|
this.applyAddItemStrategy(itemAfterMove);
|
|
235
202
|
}
|
|
236
203
|
else {
|
|
237
204
|
this.applyMoveItemStrategy(itemAfterMove, index);
|
|
238
205
|
}
|
|
239
206
|
this.items[index] = itemAfterMove;
|
|
240
|
-
if (!
|
|
207
|
+
if (!isSameLocationArea(itemAfterMove.location, sourceItem.location)) {
|
|
241
208
|
this.applyRemoveItemStrategy(sourceItem);
|
|
242
209
|
}
|
|
243
210
|
}
|
|
244
|
-
}
|
|
211
|
+
}
|
|
245
212
|
/**
|
|
246
213
|
* Provides the state of an item after it is moved
|
|
247
214
|
* @param move The move that is going to happen
|
|
248
215
|
* @return {MaterialItem} state of the item after the move is executed
|
|
249
216
|
*/
|
|
250
|
-
|
|
251
|
-
|
|
217
|
+
getItemAfterMove(move) {
|
|
218
|
+
const item = JSON.parse(JSON.stringify(this.getItemWithLocation(move.location, move.itemIndex)));
|
|
252
219
|
if (move.reveal) {
|
|
253
|
-
|
|
220
|
+
merge(item, move.reveal);
|
|
254
221
|
}
|
|
255
222
|
if (move.quantity) {
|
|
256
223
|
item.quantity = move.quantity;
|
|
@@ -259,49 +226,45 @@ var MaterialMutator = /** @class */ (function () {
|
|
|
259
226
|
delete item.quantity;
|
|
260
227
|
}
|
|
261
228
|
return item;
|
|
262
|
-
}
|
|
229
|
+
}
|
|
263
230
|
/**
|
|
264
231
|
* Provides the state of an item after it is moved
|
|
265
232
|
* @param move The move that is going to happen
|
|
266
233
|
* @param index Index of the item to consider
|
|
267
234
|
* @return {MaterialItem} state of the item after the move is executed
|
|
268
235
|
*/
|
|
269
|
-
|
|
270
|
-
|
|
236
|
+
getItemAfterMoveAtOnce(move, index) {
|
|
237
|
+
const item = JSON.parse(JSON.stringify(this.getItemWithLocation(move.location, index)));
|
|
271
238
|
if (move.reveal && move.reveal[index]) {
|
|
272
|
-
|
|
239
|
+
merge(item, move.reveal[index]);
|
|
273
240
|
}
|
|
274
241
|
return item;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
return
|
|
281
|
-
}
|
|
282
|
-
|
|
242
|
+
}
|
|
243
|
+
getItemWithLocation(location, index) {
|
|
244
|
+
const moveLocation = JSON.parse(JSON.stringify(location));
|
|
245
|
+
const actualItem = this.items[index];
|
|
246
|
+
const newLocation = location.type === undefined ? { ...actualItem.location, ...moveLocation } : moveLocation;
|
|
247
|
+
return { ...actualItem, location: newLocation };
|
|
248
|
+
}
|
|
249
|
+
delete(move) {
|
|
283
250
|
return this.removeItem(this.items[move.itemIndex], move.quantity);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
if (!(0, moves_1.isShuffleRandomized)(move))
|
|
251
|
+
}
|
|
252
|
+
shuffle(move) {
|
|
253
|
+
if (!isShuffleRandomized(move))
|
|
288
254
|
return; // Nothing to do on front-end side for a shuffle. The index swap is only required on the backend.
|
|
289
|
-
|
|
290
|
-
move.newIndexes.forEach(
|
|
291
|
-
|
|
255
|
+
const shuffledItems = move.indexes.map((index) => this.items[index]);
|
|
256
|
+
move.newIndexes.forEach((newIndex, i) => {
|
|
257
|
+
this.items[newIndex] = { ...shuffledItems[i], location: this.items[newIndex].location };
|
|
292
258
|
});
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
var item = this.items[move.itemIndex];
|
|
259
|
+
}
|
|
260
|
+
select(move) {
|
|
261
|
+
const item = this.items[move.itemIndex];
|
|
297
262
|
if (move.selected === false) {
|
|
298
263
|
delete item.selected;
|
|
299
264
|
}
|
|
300
265
|
else {
|
|
301
|
-
item.selected =
|
|
266
|
+
item.selected = move.quantity ?? true;
|
|
302
267
|
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
}());
|
|
306
|
-
exports.MaterialMutator = MaterialMutator;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
307
270
|
//# sourceMappingURL=MaterialMutator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaterialMutator.js","sourceRoot":"","sources":["../../../src/material/items/MaterialMutator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MaterialMutator.js","sourceRoot":"","sources":["../../../src/material/items/MaterialMutator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAA8B,MAAM,aAAa,CAAA;AAC5E,OAAO,EAGL,mBAAmB,EAEnB,YAAY,EAQb,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,QAAQ,EAAgB,MAAM,SAAS,CAAA;AAEhD;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;IASP;IACA;IACA;IACA;IACA;IAZnB;;;;;;OAMG;IACH,YACmB,IAAO,EACP,KAA2B,EAC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mB;QAChC,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;IACpE,CAAC;IAEO,OAAO,CAAC,IAAuC;QACrD,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAAE,OAAM,CAAC,iGAAiG;QACxI,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;QACpE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE;YACtC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAA;QACzF,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,MAAM,CAAC,IAAmB;QAChC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QACvC,IAAI,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,QAAQ,CAAA;QACtB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAA;QACvC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
1
|
// Important: Material export must come first to prevent a circular file dependency issue (see https://stackoverflow.com/a/67261675/1581466)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
export * from './Material';
|
|
3
|
+
export * from './MaterialDeck';
|
|
4
|
+
export * from './MaterialItem';
|
|
5
|
+
export * from './MaterialMoney';
|
|
6
|
+
export * from './MaterialMutator';
|
|
23
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/material/items/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/material/items/index.ts"],"names":[],"mappings":"AAAA,4IAA4I;AAC5I,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA"}
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSameLocationArea = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Utility function to know whether some locations share the same type, id, player and parent.
|
|
6
3
|
* @param locations Locations to test
|
|
7
4
|
* @returns true if all the locations belongs to the same "area" (only varies in coordinates or rotation)
|
|
8
5
|
*/
|
|
9
|
-
|
|
10
|
-
var locations = [];
|
|
11
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
12
|
-
locations[_i] = arguments[_i];
|
|
13
|
-
}
|
|
14
|
-
return locations.every(function (l, _, _a) {
|
|
15
|
-
var l0 = _a[0];
|
|
16
|
-
return l.type === l0.type && l.id === l0.id && l.player === l0.player && l.parent === l0.parent;
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
exports.isSameLocationArea = isSameLocationArea;
|
|
6
|
+
export const isSameLocationArea = (...locations) => locations.every((l, _, [l0]) => l.type === l0.type && l.id === l0.id && l.player === l0.player && l.parent === l0.parent);
|
|
20
7
|
//# sourceMappingURL=Location.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Location.js","sourceRoot":"","sources":["../../../src/material/location/Location.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Location.js","sourceRoot":"","sources":["../../../src/material/location/Location.ts"],"names":[],"mappings":"AAmCA;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAG,SAA8B,EAAW,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAC/G,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,KAAK,EAAE,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,EAAE,CAAC,MAAM,CACzF,CAAA"}
|
|
@@ -1,44 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.LocationBuilder = void 0;
|
|
15
|
-
var LocationBuilder = /** @class */ (function () {
|
|
16
|
-
function LocationBuilder(location) {
|
|
1
|
+
export class LocationBuilder {
|
|
2
|
+
location;
|
|
3
|
+
constructor(location) {
|
|
17
4
|
this.location = location;
|
|
18
5
|
}
|
|
19
|
-
|
|
20
|
-
return new LocationBuilder(
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return new LocationBuilder(
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return new LocationBuilder(
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return new LocationBuilder(
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return new LocationBuilder(
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return new LocationBuilder(
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return new LocationBuilder(
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
}());
|
|
43
|
-
exports.LocationBuilder = LocationBuilder;
|
|
6
|
+
id(id) {
|
|
7
|
+
return new LocationBuilder({ ...this.location, id });
|
|
8
|
+
}
|
|
9
|
+
player(player) {
|
|
10
|
+
return new LocationBuilder({ ...this.location, player });
|
|
11
|
+
}
|
|
12
|
+
parent(arg) {
|
|
13
|
+
const parent = typeof arg === 'number' ? arg : arg.entries[0][0];
|
|
14
|
+
return new LocationBuilder({ ...this.location, parent });
|
|
15
|
+
}
|
|
16
|
+
x(x) {
|
|
17
|
+
return new LocationBuilder({ ...this.location, x });
|
|
18
|
+
}
|
|
19
|
+
y(y) {
|
|
20
|
+
return new LocationBuilder({ ...this.location, y });
|
|
21
|
+
}
|
|
22
|
+
z(z) {
|
|
23
|
+
return new LocationBuilder({ ...this.location, z });
|
|
24
|
+
}
|
|
25
|
+
rotation(rotation) {
|
|
26
|
+
return new LocationBuilder({ ...this.location, rotation });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
44
29
|
//# sourceMappingURL=LocationBuilder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocationBuilder.js","sourceRoot":"","sources":["../../../src/material/location/LocationBuilder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LocationBuilder.js","sourceRoot":"","sources":["../../../src/material/location/LocationBuilder.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,eAAe;IACjB,QAAQ,CAA8B;IAE/C,YAAY,QAAsC;QAChD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;IAED,EAAE,CAAC,EAAM;QACP,OAAO,IAAI,eAAe,CAAqB,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAA;IAC1E,CAAC;IAED,MAAM,CAAC,MAAS;QACd,OAAO,IAAI,eAAe,CAAqB,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;IAC9E,CAAC;IAED,MAAM,CAAC,GAAoC;QACzC,MAAM,MAAM,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAChE,OAAO,IAAI,eAAe,CAAqB,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;IAC9E,CAAC;IAED,CAAC,CAAC,CAAS;QACT,OAAO,IAAI,eAAe,CAAqB,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAA;IACzE,CAAC;IAED,CAAC,CAAC,CAAS;QACT,OAAO,IAAI,eAAe,CAAqB,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAA;IACzE,CAAC;IAED,CAAC,CAAC,CAAS;QACT,OAAO,IAAI,eAAe,CAAqB,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAA;IACzE,CAAC;IAED,QAAQ,CAAC,QAAkB;QACzB,OAAO,IAAI,eAAe,CAAqB,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAA;IAChF,CAAC;CACF"}
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./strategy"), exports);
|
|
18
|
-
__exportStar(require("./Location"), exports);
|
|
19
|
-
__exportStar(require("./LocationBuilder"), exports);
|
|
1
|
+
export * from './strategy';
|
|
2
|
+
export * from './Location';
|
|
3
|
+
export * from './LocationBuilder';
|
|
20
4
|
//# sourceMappingURL=index.js.map
|