@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.
Files changed (249) hide show
  1. package/dist/Action.js +1 -2
  2. package/dist/Bot.js +15 -37
  3. package/dist/Bot.js.map +1 -1
  4. package/dist/Competitive.js +3 -8
  5. package/dist/Competitive.js.map +1 -1
  6. package/dist/Eliminations.js +2 -5
  7. package/dist/Eliminations.js.map +1 -1
  8. package/dist/GameSetup.js +1 -2
  9. package/dist/HiddenInformation.js +2 -5
  10. package/dist/HiddenInformation.js.map +1 -1
  11. package/dist/LocalMovePreview.js +1 -4
  12. package/dist/LocalMovePreview.js.map +1 -1
  13. package/dist/RandomMove.js +1 -2
  14. package/dist/Rules.js +49 -56
  15. package/dist/Rules.js.map +1 -1
  16. package/dist/SecretInformation.js +2 -5
  17. package/dist/SecretInformation.js.map +1 -1
  18. package/dist/TimeLimit.js +1 -4
  19. package/dist/TimeLimit.js.map +1 -1
  20. package/dist/Undo.js +2 -5
  21. package/dist/Undo.js.map +1 -1
  22. package/dist/UnpredictableMove.js +1 -5
  23. package/dist/UnpredictableMove.js.map +1 -1
  24. package/dist/index.js +16 -32
  25. package/dist/index.js.map +1 -1
  26. package/dist/material/HiddenMaterialRules.js +125 -180
  27. package/dist/material/HiddenMaterialRules.js.map +1 -1
  28. package/dist/material/MaterialGame.js +1 -2
  29. package/dist/material/MaterialGameSetup.js +52 -70
  30. package/dist/material/MaterialGameSetup.js.map +1 -1
  31. package/dist/material/MaterialRules.js +186 -250
  32. package/dist/material/MaterialRules.js.map +1 -1
  33. package/dist/material/SecretMaterialRules.js +9 -35
  34. package/dist/material/SecretMaterialRules.js.map +1 -1
  35. package/dist/material/index.js +11 -27
  36. package/dist/material/index.js.map +1 -1
  37. package/dist/material/items/Material.js +177 -262
  38. package/dist/material/items/Material.js.map +1 -1
  39. package/dist/material/items/MaterialDeck.js +10 -36
  40. package/dist/material/items/MaterialDeck.js.map +1 -1
  41. package/dist/material/items/MaterialItem.js +1 -2
  42. package/dist/material/items/MaterialMoney.js +89 -141
  43. package/dist/material/items/MaterialMoney.js.map +1 -1
  44. package/dist/material/items/MaterialMutator.js +108 -145
  45. package/dist/material/items/MaterialMutator.js.map +1 -1
  46. package/dist/material/items/index.js +5 -21
  47. package/dist/material/items/index.js.map +1 -1
  48. package/dist/material/location/Location.js +1 -14
  49. package/dist/material/location/Location.js.map +1 -1
  50. package/dist/material/location/LocationBuilder.js +26 -41
  51. package/dist/material/location/LocationBuilder.js.map +1 -1
  52. package/dist/material/location/index.js +3 -19
  53. package/dist/material/location/index.js.map +1 -1
  54. package/dist/material/location/strategy/FillGapStrategy.js +9 -16
  55. package/dist/material/location/strategy/FillGapStrategy.js.map +1 -1
  56. package/dist/material/location/strategy/LocationStrategy.js +1 -2
  57. package/dist/material/location/strategy/PositiveSequenceStrategy.js +26 -35
  58. package/dist/material/location/strategy/PositiveSequenceStrategy.js.map +1 -1
  59. package/dist/material/location/strategy/StackingStrategy.js +15 -22
  60. package/dist/material/location/strategy/StackingStrategy.js.map +1 -1
  61. package/dist/material/location/strategy/index.js +5 -23
  62. package/dist/material/location/strategy/index.js.map +1 -1
  63. package/dist/material/memory/GameMemory.js +10 -14
  64. package/dist/material/memory/GameMemory.js.map +1 -1
  65. package/dist/material/memory/PlayerMemory.js +13 -18
  66. package/dist/material/memory/PlayerMemory.js.map +1 -1
  67. package/dist/material/memory/index.js +2 -18
  68. package/dist/material/memory/index.js.map +1 -1
  69. package/dist/material/moves/CustomMove.js +4 -9
  70. package/dist/material/moves/CustomMove.js.map +1 -1
  71. package/dist/material/moves/MaterialMove.js +1 -2
  72. package/dist/material/moves/MaterialMoveBuilder.js +16 -32
  73. package/dist/material/moves/MaterialMoveBuilder.js.map +1 -1
  74. package/dist/material/moves/MoveKind.js +2 -5
  75. package/dist/material/moves/MoveKind.js.map +1 -1
  76. package/dist/material/moves/index.js +7 -23
  77. package/dist/material/moves/index.js.map +1 -1
  78. package/dist/material/moves/items/CreateItem.js +6 -12
  79. package/dist/material/moves/items/CreateItem.js.map +1 -1
  80. package/dist/material/moves/items/CreateItemsAtOnce.js +6 -12
  81. package/dist/material/moves/items/CreateItemsAtOnce.js.map +1 -1
  82. package/dist/material/moves/items/DeleteItem.js +6 -12
  83. package/dist/material/moves/items/DeleteItem.js.map +1 -1
  84. package/dist/material/moves/items/DeleteItemsAtOnce.js +6 -12
  85. package/dist/material/moves/items/DeleteItemsAtOnce.js.map +1 -1
  86. package/dist/material/moves/items/ItemMove.js +1 -2
  87. package/dist/material/moves/items/ItemMoveType.js +2 -5
  88. package/dist/material/moves/items/ItemMoveType.js.map +1 -1
  89. package/dist/material/moves/items/MoveItem.js +6 -12
  90. package/dist/material/moves/items/MoveItem.js.map +1 -1
  91. package/dist/material/moves/items/MoveItemsAtOnce.js +6 -12
  92. package/dist/material/moves/items/MoveItemsAtOnce.js.map +1 -1
  93. package/dist/material/moves/items/RollItem.js +6 -12
  94. package/dist/material/moves/items/RollItem.js.map +1 -1
  95. package/dist/material/moves/items/SelectItem.js +6 -12
  96. package/dist/material/moves/items/SelectItem.js.map +1 -1
  97. package/dist/material/moves/items/Shuffle.js +7 -14
  98. package/dist/material/moves/items/Shuffle.js.map +1 -1
  99. package/dist/material/moves/items/index.js +11 -27
  100. package/dist/material/moves/items/index.js.map +1 -1
  101. package/dist/material/moves/local/CloseTutorialPopup.js +4 -7
  102. package/dist/material/moves/local/CloseTutorialPopup.js.map +1 -1
  103. package/dist/material/moves/local/DisplayHelp.js +2 -5
  104. package/dist/material/moves/local/DisplayHelp.js.map +1 -1
  105. package/dist/material/moves/local/DropItem.js +1 -2
  106. package/dist/material/moves/local/LocalMove.js +2 -5
  107. package/dist/material/moves/local/LocalMove.js.map +1 -1
  108. package/dist/material/moves/local/SetTutorialStep.js +4 -7
  109. package/dist/material/moves/local/SetTutorialStep.js.map +1 -1
  110. package/dist/material/moves/local/index.js +5 -21
  111. package/dist/material/moves/local/index.js.map +1 -1
  112. package/dist/material/moves/rules/EndGame.js +4 -7
  113. package/dist/material/moves/rules/EndGame.js.map +1 -1
  114. package/dist/material/moves/rules/EndPlayerTurn.js +4 -7
  115. package/dist/material/moves/rules/EndPlayerTurn.js.map +1 -1
  116. package/dist/material/moves/rules/RuleMove.js +3 -7
  117. package/dist/material/moves/rules/RuleMove.js.map +1 -1
  118. package/dist/material/moves/rules/StartPlayerTurn.js +4 -7
  119. package/dist/material/moves/rules/StartPlayerTurn.js.map +1 -1
  120. package/dist/material/moves/rules/StartRule.js +4 -7
  121. package/dist/material/moves/rules/StartRule.js.map +1 -1
  122. package/dist/material/moves/rules/StartSimultaneousRule.js +4 -7
  123. package/dist/material/moves/rules/StartSimultaneousRule.js.map +1 -1
  124. package/dist/material/moves/rules/index.js +6 -22
  125. package/dist/material/moves/rules/index.js.map +1 -1
  126. package/dist/material/rules/MaterialRulesPart.js +38 -63
  127. package/dist/material/rules/MaterialRulesPart.js.map +1 -1
  128. package/dist/material/rules/PlayerTurnRule.js +20 -52
  129. package/dist/material/rules/PlayerTurnRule.js.map +1 -1
  130. package/dist/material/rules/RuleStep.js +1 -2
  131. package/dist/material/rules/SimultaneousRule.js +19 -51
  132. package/dist/material/rules/SimultaneousRule.js.map +1 -1
  133. package/dist/material/rules/index.js +4 -20
  134. package/dist/material/rules/index.js.map +1 -1
  135. package/dist/material/tutorial/TutorialState.js +1 -2
  136. package/dist/material/tutorial/index.js +1 -17
  137. package/dist/material/tutorial/index.js.map +1 -1
  138. package/dist/options/EnumArrayOption.js +3 -6
  139. package/dist/options/EnumArrayOption.js.map +1 -1
  140. package/dist/options/EnumOption.js +1 -4
  141. package/dist/options/EnumOption.js.map +1 -1
  142. package/dist/options/Option.js +1 -2
  143. package/dist/options/OptionSpecOf.js +1 -2
  144. package/dist/options/OptionsSpec.js +1 -2
  145. package/dist/options/OptionsValidationError.js +6 -28
  146. package/dist/options/OptionsValidationError.js.map +1 -1
  147. package/dist/options/PlayerEnumOption.js +19 -29
  148. package/dist/options/PlayerEnumOption.js.map +1 -1
  149. package/dist/options/PlayersOptionsSpec.js +1 -2
  150. package/dist/options/WithIdOption.js +1 -2
  151. package/dist/options/WithPlayerOptionsSpec.js +1 -4
  152. package/dist/options/WithPlayerOptionsSpec.js.map +1 -1
  153. package/dist/options/WithPlayersOptions.js +1 -2
  154. package/dist/options/index.js +12 -28
  155. package/dist/options/index.js.map +1 -1
  156. package/dist/options/isWithPlayerIdOptions.js +3 -6
  157. package/dist/options/isWithPlayerIdOptions.js.map +1 -1
  158. package/dist/utils/action-view.util.js +18 -25
  159. package/dist/utils/action-view.util.js.map +1 -1
  160. package/dist/utils/action.util.js +11 -16
  161. package/dist/utils/action.util.js.map +1 -1
  162. package/dist/utils/adjacent-groups.util.js +33 -41
  163. package/dist/utils/adjacent-groups.util.js.map +1 -1
  164. package/dist/utils/automatic-moves.util.js +10 -15
  165. package/dist/utils/automatic-moves.util.js.map +1 -1
  166. package/dist/utils/enum.util.js +7 -13
  167. package/dist/utils/enum.util.js.map +1 -1
  168. package/dist/utils/game-view.util.js +5 -8
  169. package/dist/utils/game-view.util.js.map +1 -1
  170. package/dist/utils/grid.hex.util.js +36 -88
  171. package/dist/utils/grid.hex.util.js.map +1 -1
  172. package/dist/utils/grid.squares.util.js +8 -19
  173. package/dist/utils/grid.squares.util.js.map +1 -1
  174. package/dist/utils/grid.util.js +1 -5
  175. package/dist/utils/grid.util.js.map +1 -1
  176. package/dist/utils/index.js +16 -32
  177. package/dist/utils/index.js.map +1 -1
  178. package/dist/utils/listing.util.js +8 -13
  179. package/dist/utils/listing.util.js.map +1 -1
  180. package/dist/utils/loops.util.js +3 -6
  181. package/dist/utils/loops.util.js.map +1 -1
  182. package/dist/utils/money.util.js +54 -73
  183. package/dist/utils/money.util.js.map +1 -1
  184. package/dist/utils/neighbors.util.js +6 -10
  185. package/dist/utils/neighbors.util.js.map +1 -1
  186. package/dist/utils/polyhex.util.js +36 -56
  187. package/dist/utils/polyhex.util.js.map +1 -1
  188. package/dist/utils/random.util.js +2 -5
  189. package/dist/utils/random.util.js.map +1 -1
  190. package/dist/utils/rank.util.js +9 -13
  191. package/dist/utils/rank.util.js.map +1 -1
  192. package/package.json +43 -37
  193. package/dist/ApplyAutomaticMoves.d.ts +0 -2
  194. package/dist/ApplyAutomaticMoves.js +0 -25
  195. package/dist/ApplyAutomaticMoves.js.map +0 -1
  196. package/dist/DefaultGameSetup.d.ts +0 -7
  197. package/dist/DefaultGameSetup.js +0 -15
  198. package/dist/DefaultGameSetup.js.map +0 -1
  199. package/dist/Dummy.d.ts +0 -7
  200. package/dist/Dummy.js +0 -27
  201. package/dist/Dummy.js.map +0 -1
  202. package/dist/GameSetupCreator.d.ts +0 -4
  203. package/dist/GameSetupCreator.js +0 -3
  204. package/dist/GameSetupCreator.js.map +0 -1
  205. package/dist/IncompleteInformation.d.ts +0 -14
  206. package/dist/IncompleteInformation.js +0 -38
  207. package/dist/IncompleteInformation.js.map +0 -1
  208. package/dist/LoopWithFuse.d.ts +0 -4
  209. package/dist/LoopWithFuse.js +0 -15
  210. package/dist/LoopWithFuse.js.map +0 -1
  211. package/dist/Robot.d.ts +0 -1
  212. package/dist/Robot.js +0 -3
  213. package/dist/Robot.js.map +0 -1
  214. package/dist/RulesCreator.d.ts +0 -7
  215. package/dist/RulesCreator.js +0 -3
  216. package/dist/RulesCreator.js.map +0 -1
  217. package/dist/material/location/strategy/StakingStrategy.d.ts +0 -12
  218. package/dist/material/location/strategy/StakingStrategy.js +0 -32
  219. package/dist/material/location/strategy/StakingStrategy.js.map +0 -1
  220. package/dist/material/moves/items/ItemMovesBuilder.d.ts +0 -8
  221. package/dist/material/moves/items/ItemMovesBuilder.js +0 -34
  222. package/dist/material/moves/items/ItemMovesBuilder.js.map +0 -1
  223. package/dist/material/rules/MaterialMoveBuilder.d.ts +0 -9
  224. package/dist/material/rules/MaterialMoveBuilder.js +0 -28
  225. package/dist/material/rules/MaterialMoveBuilder.js.map +0 -1
  226. package/dist/material/rules/MaterialRulesMovesBuilder.d.ts +0 -12
  227. package/dist/material/rules/MaterialRulesMovesBuilder.js +0 -36
  228. package/dist/material/rules/MaterialRulesMovesBuilder.js.map +0 -1
  229. package/dist/setup/DefaultGameSetup.d.ts +0 -7
  230. package/dist/setup/DefaultGameSetup.js +0 -15
  231. package/dist/setup/DefaultGameSetup.js.map +0 -1
  232. package/dist/setup/GameSetup.d.ts +0 -3
  233. package/dist/setup/GameSetup.js +0 -3
  234. package/dist/setup/GameSetup.js.map +0 -1
  235. package/dist/setup/GameSetupCreator.d.ts +0 -4
  236. package/dist/setup/GameSetupCreator.js +0 -3
  237. package/dist/setup/GameSetupCreator.js.map +0 -1
  238. package/dist/setup/index.d.ts +0 -2
  239. package/dist/setup/index.js +0 -19
  240. package/dist/setup/index.js.map +0 -1
  241. package/dist/utils/EnumUtils.d.ts +0 -1
  242. package/dist/utils/EnumUtils.js +0 -8
  243. package/dist/utils/EnumUtils.js.map +0 -1
  244. package/dist/utils/coordinates.util.d.ts +0 -5
  245. package/dist/utils/coordinates.util.js +0 -16
  246. package/dist/utils/coordinates.util.js.map +0 -1
  247. package/dist/utils/isDeadEndMove.util.d.ts +0 -2
  248. package/dist/utils/isDeadEndMove.util.js +0 -19
  249. package/dist/utils/isDeadEndMove.util.js.map +0 -1
@@ -1,33 +1,8 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
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
- 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.Material = void 0;
26
- var es_toolkit_1 = require("es-toolkit");
27
- var compat_1 = require("es-toolkit/compat");
28
- var location_1 = require("../location");
29
- var moves_1 = require("../moves");
30
- var index_1 = require("./index");
1
+ import { isEqual, maxBy, minBy, sumBy } from 'es-toolkit';
2
+ import { orderBy } from 'es-toolkit/compat';
3
+ import { isSameLocationArea } from '../location';
4
+ import { ItemMoveType, MoveKind } from '../moves';
5
+ import { MaterialDeck, MaterialMoney } from './index';
31
6
  /**
32
7
  * The Material class is the core helper class that help manipulate the game items in a simple way.
33
8
  * It includes two kind of functions: functions to filter items, and functions to build {@link ItemMove} objects.
@@ -37,7 +12,11 @@ var index_1 = require("./index");
37
12
  * @typeparam M - Numeric enum of the types of material manipulated in the game
38
13
  * @typeparam L - Numeric enum of the types of location in the game where the material can be located
39
14
  */
40
- var Material = /** @class */ (function () {
15
+ export class Material {
16
+ type;
17
+ items;
18
+ processMove;
19
+ entries;
41
20
  /**
42
21
  * Construct a new Material helper instance
43
22
  * @param {number} type Type of items this instance will work on
@@ -45,9 +24,7 @@ var Material = /** @class */ (function () {
45
24
  * @param {function} processMove if provided, this function will be executed on every move created with this instance
46
25
  * @param {ItemEntry[]} entries The list of items to work on. Each entry consists of an array with the index of the item, and the item
47
26
  */
48
- function Material(type, items, processMove, entries) {
49
- if (items === void 0) { items = []; }
50
- if (entries === void 0) { entries = Array.from(items.entries()).filter(function (entry) { return entry[1].quantity !== 0; }); }
27
+ constructor(type, items = [], processMove, entries = Array.from(items.entries()).filter(entry => entry[1].quantity !== 0)) {
51
28
  this.type = type;
52
29
  this.items = items;
53
30
  this.processMove = processMove;
@@ -59,10 +36,10 @@ var Material = /** @class */ (function () {
59
36
  * @returns {this} the new Material instance
60
37
  * @protected
61
38
  */
62
- Material.prototype.new = function (entries) {
63
- var Class = this.constructor;
39
+ new(entries) {
40
+ const Class = this.constructor;
64
41
  return new Class(this.type, this.items, this.processMove, entries);
65
- };
42
+ }
66
43
  /**
67
44
  * Use this function to collect all the items in the current Material instance.
68
45
  * For example, you can filter then collect the matching items: this.material(type).location(locationType).getItems()
@@ -71,10 +48,10 @@ var Material = /** @class */ (function () {
71
48
  * @param {function} predicate If provided, only the items matching the predicate will be returned
72
49
  * @returns {MaterialItem[]} the items in this Material instance
73
50
  */
74
- Material.prototype.getItems = function (predicate) {
75
- var items = this.entries.map(function (entry) { return entry[1]; });
51
+ getItems(predicate) {
52
+ const items = this.entries.map(entry => entry[1]);
76
53
  return predicate ? items.filter(predicate) : items;
77
- };
54
+ }
78
55
  /**
79
56
  * Use this function to collect this first item in the current Material instance.
80
57
  * You can use {@link sort} to sort the items first.
@@ -82,91 +59,70 @@ var Material = /** @class */ (function () {
82
59
  * @param {number | function} arg Index of the item, or predicate function
83
60
  * @returns {MaterialItem | undefined} the item, or undefined if none match
84
61
  */
85
- Material.prototype.getItem = function (arg) {
62
+ getItem(arg) {
86
63
  if (typeof arg === 'number') {
87
- var entry = this.entries.find(function (entry) { return entry[0] === arg; });
64
+ const entry = this.entries.find(entry => entry[0] === arg);
88
65
  if (!entry)
89
- throw new Error("Could not find any item with index ".concat(arg, " for type ").concat(this.type));
66
+ throw new Error(`Could not find any item with index ${arg} for type ${this.type}`);
90
67
  return entry[1];
91
68
  }
92
69
  else if (typeof arg === 'function') {
93
- var entries = this.entries.filter(function (_a) {
94
- var item = _a[1];
95
- return arg(item);
96
- });
70
+ const entries = this.entries.filter(([, item]) => arg(item));
97
71
  return entries.length ? entries[0][1] : undefined;
98
72
  }
99
73
  else {
100
74
  return this.entries.length ? this.entries[0][1] : undefined;
101
75
  }
102
- };
76
+ }
103
77
  /**
104
78
  * @returns {number} index of the first item
105
79
  */
106
- Material.prototype.getIndex = function () {
107
- var _a, _b;
108
- return (_b = (_a = this.entries[0]) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : -1;
109
- };
80
+ getIndex() {
81
+ return this.entries[0]?.[0] ?? -1;
82
+ }
110
83
  /**
111
84
  * @returns {number[]} indexes of the items
112
85
  */
113
- Material.prototype.getIndexes = function () {
114
- return this.entries.map(function (entry) { return entry[0]; });
115
- };
86
+ getIndexes() {
87
+ return this.entries.map(entry => entry[0]);
88
+ }
116
89
  /**
117
90
  * Filter and return a new instance with only the items that match a specific index, or a specific index predicate
118
91
  * @param {number | function} arg The index to keep, or the predicate matching the indexes to keep
119
92
  */
120
- Material.prototype.index = function (arg) {
93
+ index(arg) {
121
94
  switch (typeof arg) {
122
95
  case 'function':
123
- return this.filter(function (_, index) { return arg(index); });
96
+ return this.filter((_, index) => arg(index));
124
97
  case 'number':
125
- var item = this.entries.find(function (_a) {
126
- var index = _a[0];
127
- return index === arg;
128
- });
98
+ const item = this.entries.find(([index]) => index === arg);
129
99
  return this.new(item ? [item] : []);
130
100
  case 'undefined':
131
101
  return this.new([]);
132
102
  default:
133
- var items = this.entries.filter(function (_a) {
134
- var i = _a[0];
135
- return arg.includes(i);
136
- });
103
+ const items = this.entries.filter(([i]) => arg.includes(i));
137
104
  return this.new(items);
138
105
  }
139
- };
106
+ }
140
107
  /**
141
108
  * @deprecated Use {@link index} instead
142
109
  */
143
- Material.prototype.indexes = function (indexes) {
144
- var items = this.entries.filter(function (_a) {
145
- var i = _a[0];
146
- return indexes.includes(i);
147
- });
110
+ indexes(indexes) {
111
+ const items = this.entries.filter(([i]) => indexes.includes(i));
148
112
  return this.new(items);
149
- };
150
- Object.defineProperty(Material.prototype, "length", {
151
- /**
152
- * @returns {number} number of items
153
- */
154
- get: function () {
155
- return this.entries.length;
156
- },
157
- enumerable: false,
158
- configurable: true
159
- });
113
+ }
114
+ /**
115
+ * @returns {number} number of items
116
+ */
117
+ get length() {
118
+ return this.entries.length;
119
+ }
160
120
  /**
161
121
  * @returns {number} Sum of the quantity of all items
162
122
  */
163
- Material.prototype.getQuantity = function () {
164
- return (0, es_toolkit_1.sumBy)(this.entries, function (_a) {
165
- var _b;
166
- var item = _a[1];
167
- return (_b = item.quantity) !== null && _b !== void 0 ? _b : 1;
168
- });
169
- };
123
+ getQuantity() {
124
+ return sumBy(this.entries, ([, item]) => item.quantity ?? 1);
125
+ }
170
126
  /**
171
127
  * This function filter the items and returns a new instance with only the filtered items.
172
128
  * This function is the top level filtering function, but other function can be used to simplify the code:
@@ -175,94 +131,72 @@ var Material = /** @class */ (function () {
175
131
  * @param {function} predicate The predicate function. Takes every item and index, and keep the item if it returns true
176
132
  * @returns {this} New instance with only the items that match the predicate
177
133
  */
178
- Material.prototype.filter = function (predicate) {
179
- return this.new(this.entries.filter(function (_a) {
180
- var index = _a[0], item = _a[1];
181
- return predicate(item, index);
182
- }));
183
- };
134
+ filter(predicate) {
135
+ return this.new(this.entries.filter(([index, item]) => predicate(item, index)));
136
+ }
184
137
  /**
185
138
  * Filters the items based on their ids.
186
139
  *
187
140
  * @param {function | string | number | Record} arg Id to keep, or predicate function to match the ids of the items to keep
188
141
  * @returns {this} New instance with only the items which ids match the argument
189
142
  */
190
- Material.prototype.id = function (arg) {
191
- return this.filter(function (_a) {
192
- var id = _a.id;
193
- return typeof arg === 'function' ? arg(id) : (0, es_toolkit_1.isEqual)(id, arg);
194
- });
195
- };
143
+ id(arg) {
144
+ return this.filter(({ id }) => typeof arg === 'function' ? arg(id) : isEqual(id, arg));
145
+ }
196
146
  /**
197
147
  * Filters the items based on their location type, or their location.
198
148
  *
199
149
  * @param {function | number} arg Location type to keep, or predicate function to match the location of the items to keep
200
150
  * @returns {this} New instance with only the items which locations match the argument
201
151
  */
202
- Material.prototype.location = function (arg) {
203
- return this.filter(function (_a) {
204
- var location = _a.location;
205
- return typeof arg === 'function' ? arg(location) : location.type === arg;
206
- });
207
- };
152
+ location(arg) {
153
+ return this.filter(({ location }) => typeof arg === 'function' ? arg(location) : location.type === arg);
154
+ }
208
155
  /**
209
156
  * Filters the items based on their rotation (item.location.rotation)
210
157
  *
211
158
  * @param {function | string | number | boolean | Record} arg rotation to keep, or predicate function to match the rotations of the items to keep
212
159
  * @returns {this} New instance with only the items which rotation match the argument
213
160
  */
214
- Material.prototype.rotation = function (arg) {
215
- return this.location(function (_a) {
216
- var rotation = _a.rotation;
217
- return typeof arg === 'function' ? arg(rotation) : (0, es_toolkit_1.isEqual)(rotation, arg);
218
- });
219
- };
161
+ rotation(arg) {
162
+ return this.location(({ rotation }) => typeof arg === 'function' ? arg(rotation) : isEqual(rotation, arg));
163
+ }
220
164
  /**
221
165
  * Filters the items based on their owner (item.location.player)
222
166
  *
223
167
  * @param {function | number} arg player id to keep, or predicate function to match the owner player of the items to keep
224
168
  * @returns {this} New instance with only the items which owner match the argument
225
169
  */
226
- Material.prototype.player = function (arg) {
227
- return this.location(function (_a) {
228
- var player = _a.player;
229
- return typeof arg === 'function' ? arg(player) : player === arg;
230
- });
231
- };
170
+ player(arg) {
171
+ return this.location(({ player }) => typeof arg === 'function' ? arg(player) : player === arg);
172
+ }
232
173
  /**
233
174
  * Filters the items based on their location's id (item.location.id)
234
175
  *
235
176
  * @param {function | number} arg location id to keep, or predicate function to match the location id of the items to keep
236
177
  * @returns {this} New instance with only the items which location id match the argument
237
178
  */
238
- Material.prototype.locationId = function (arg) {
239
- return this.location(function (_a) {
240
- var id = _a.id;
241
- return typeof arg === 'function' ? arg(id) : (0, es_toolkit_1.isEqual)(id, arg);
242
- });
243
- };
179
+ locationId(arg) {
180
+ return this.location(({ id }) => typeof arg === 'function' ? arg(id) : isEqual(id, arg));
181
+ }
244
182
  /**
245
183
  * Filters the items based on their location's parent (item.location.parent).
246
184
  *
247
185
  * @param {function | number} arg location parent to keep, or predicate function to match the location parent of the items to keep
248
186
  * @returns {this} New instance with only the items which location parent match the argument
249
187
  */
250
- Material.prototype.parent = function (arg) {
251
- return this.location(function (_a) {
252
- var parent = _a.parent;
253
- return typeof arg === 'function' ? arg(parent) : (0, es_toolkit_1.isEqual)(parent, arg);
254
- });
255
- };
188
+ parent(arg) {
189
+ return this.location(({ parent }) => typeof arg === 'function' ? arg(parent) : isEqual(parent, arg));
190
+ }
256
191
  /**
257
192
  * Filters the items that are selected (item.selected).
258
193
  *
259
194
  * @param {number | boolean} selected The selected value to compare (default is true)
260
195
  * @returns {this} New instance with only the items which are selected
261
196
  */
262
- Material.prototype.selected = function (selected) {
263
- if (selected === void 0) { selected = true; }
264
- return this.filter(function (item) { var _a; return ((_a = item.selected) !== null && _a !== void 0 ? _a : false) === selected; });
265
- };
197
+ selected(selected = true) {
198
+ return this.filter(item => (item.selected ?? false) === selected);
199
+ }
266
200
  /**
267
201
  * Keep only the item that has the minimum value returned by the selector argument.
268
202
  * See {@link minBy} from Lodash
@@ -270,10 +204,10 @@ var Material = /** @class */ (function () {
270
204
  * @param {function} selector The function that evaluate the item's value
271
205
  * @returns {this} New instance with only the item which has the minimum value
272
206
  */
273
- Material.prototype.minBy = function (selector) {
274
- var min = (0, es_toolkit_1.minBy)(this.entries, function (entry) { return selector(entry[1]); });
207
+ minBy(selector) {
208
+ const min = minBy(this.entries, entry => selector(entry[1]));
275
209
  return this.new(min ? [min] : []);
276
- };
210
+ }
277
211
  /**
278
212
  * Keep only the item that has the maximum value returned by the selector argument.
279
213
  * See {@link maxBy} from Lodash
@@ -281,10 +215,10 @@ var Material = /** @class */ (function () {
281
215
  * @param {function} selector The function that evaluate the item's value
282
216
  * @returns {this} New instance with only the item which has the maximum value
283
217
  */
284
- Material.prototype.maxBy = function (selector) {
285
- var max = (0, es_toolkit_1.maxBy)(this.entries, function (entry) { return selector(entry[1]); });
218
+ maxBy(selector) {
219
+ const max = maxBy(this.entries, entry => selector(entry[1]));
286
220
  return this.new(max ? [max] : []);
287
- };
221
+ }
288
222
  /**
289
223
  * Return a new material instance which items are ordered based on provided selector functions.
290
224
  * See {@link orderBy} from Lodash
@@ -292,14 +226,10 @@ var Material = /** @class */ (function () {
292
226
  * @param {...function} selectors The function or functions that evaluate each item's value
293
227
  * @returns {this} New instance with items ordered by the selector functions
294
228
  */
295
- Material.prototype.sort = function () {
296
- var selectors = [];
297
- for (var _i = 0; _i < arguments.length; _i++) {
298
- selectors[_i] = arguments[_i];
299
- }
300
- var orderedItems = (0, compat_1.orderBy)(this.entries, selectors.map(function (s) { return function (entry) { return s(entry[1]); }; }));
229
+ sort(...selectors) {
230
+ let orderedItems = orderBy(this.entries, selectors.map((s) => (entry) => s(entry[1])));
301
231
  return this.new(orderedItems);
302
- };
232
+ }
303
233
  /**
304
234
  * Return a new material instance with only the first N items.
305
235
  * You have to use {@link sort} first as the items are ordered initially by index, which is not relevant.
@@ -308,56 +238,54 @@ var Material = /** @class */ (function () {
308
238
  * @param count Number of items to keep
309
239
  * @returns {this} New instance with only the first "count" items
310
240
  */
311
- Material.prototype.limit = function (count) {
241
+ limit(count) {
312
242
  return this.new(this.entries.slice(0, count));
313
- };
314
- Material.prototype.process = function (moves) {
243
+ }
244
+ process(moves) {
315
245
  if (this.processMove) {
316
- for (var _i = 0, moves_2 = moves; _i < moves_2.length; _i++) {
317
- var move = moves_2[_i];
246
+ for (const move of moves) {
318
247
  this.processMove(move);
319
248
  }
320
249
  }
321
250
  return moves;
322
- };
251
+ }
323
252
  /**
324
253
  * Prepare a move that will create a new item
325
254
  * @param {MaterialItem} item The item to create
326
255
  * @returns {CreateItem} the move that creates an item when executed
327
256
  */
328
- Material.prototype.createItem = function (item) {
257
+ createItem(item) {
329
258
  return this.createItems([item])[0];
330
- };
259
+ }
331
260
  /**
332
261
  * Prepare a list of moves to create new items
333
262
  * @param {MaterialItem[]} items The items to create
334
263
  * @returns {CreateItem[]} the moves that creates the new items when executed
335
264
  */
336
- Material.prototype.createItems = function (items) {
337
- var _this = this;
338
- return this.process(items.map(function (item) { return ({
339
- kind: moves_1.MoveKind.ItemMove,
340
- type: moves_1.ItemMoveType.Create,
341
- itemType: _this.type,
342
- item: item
343
- }); }));
344
- };
265
+ createItems(items) {
266
+ return this.process(items.map(item => ({
267
+ kind: MoveKind.ItemMove,
268
+ type: ItemMoveType.Create,
269
+ itemType: this.type,
270
+ item
271
+ })));
272
+ }
345
273
  /**
346
274
  * Prepare one move to create new items
347
275
  * @param {MaterialItem[]} items The items to create
348
276
  * @returns {CreateItemsAtOnce} the move that creates the new items when executed
349
277
  */
350
- Material.prototype.createItemsAtOnce = function (items) {
351
- var move = { kind: moves_1.MoveKind.ItemMove, type: moves_1.ItemMoveType.CreateAtOnce, itemType: this.type, items: items };
278
+ createItemsAtOnce(items) {
279
+ const move = { kind: MoveKind.ItemMove, type: ItemMoveType.CreateAtOnce, itemType: this.type, items };
352
280
  return this.process([move])[0];
353
- };
281
+ }
354
282
  /**
355
283
  * Prepare a move that will delete current first item in this material instance
356
284
  *
357
285
  * @param {number | undefined} quantity Optional: for items with a quantity, the number of items to remove. If undefined, the item is completely removed
358
286
  * @returns {DeleteItem} the move that delete the item, or a part of its quantity, when executed
359
287
  */
360
- Material.prototype.deleteItem = function (quantity) {
288
+ deleteItem(quantity) {
361
289
  switch (this.length) {
362
290
  case 0:
363
291
  throw new Error('You are trying to delete an item that does not exists');
@@ -366,36 +294,35 @@ var Material = /** @class */ (function () {
366
294
  default:
367
295
  return this.limit(1).deleteItems(quantity)[0];
368
296
  }
369
- };
297
+ }
370
298
  /**
371
299
  * Prepare moves that will delete all the items in this material instance
372
300
  *
373
301
  * @param {number | undefined} quantity Optional: for items with a quantity, the number of items to remove. If undefined, the items are completely removed
374
302
  * @returns {DeleteItem[]} the moves that delete the items, or a part of their quantity, when executed
375
303
  */
376
- Material.prototype.deleteItems = function (quantity) {
377
- var _this = this;
378
- return this.process(this.entries.map(function (entry) {
379
- var move = {
380
- kind: moves_1.MoveKind.ItemMove,
381
- type: moves_1.ItemMoveType.Delete,
382
- itemType: _this.type,
304
+ deleteItems(quantity) {
305
+ return this.process(this.entries.map(entry => {
306
+ const move = {
307
+ kind: MoveKind.ItemMove,
308
+ type: ItemMoveType.Delete,
309
+ itemType: this.type,
383
310
  itemIndex: entry[0]
384
311
  };
385
312
  if (quantity)
386
313
  move.quantity = quantity;
387
314
  return move;
388
315
  }));
389
- };
316
+ }
390
317
  /**
391
318
  * Prepare one move that will delete all the items in this material instance
392
319
  *
393
320
  * @returns {DeleteItemsAtOnce} the move that delete the items when executed
394
321
  */
395
- Material.prototype.deleteItemsAtOnce = function () {
396
- var moves = { kind: moves_1.MoveKind.ItemMove, type: moves_1.ItemMoveType.DeleteAtOnce, itemType: this.type, indexes: this.getIndexes() };
322
+ deleteItemsAtOnce() {
323
+ const moves = { kind: MoveKind.ItemMove, type: ItemMoveType.DeleteAtOnce, itemType: this.type, indexes: this.getIndexes() };
397
324
  return this.process([moves])[0];
398
- };
325
+ }
399
326
  /**
400
327
  * Prepare a move that will change the location of the current first item in this material instance
401
328
  *
@@ -403,7 +330,7 @@ var Material = /** @class */ (function () {
403
330
  * @param {number | undefined} quantity Optional: for items with a quantity, the number of items to move. If undefined, the item is completely moved.
404
331
  * @returns {MoveItem} the move that will change the location of the item (or a part of its quantity) when executed
405
332
  */
406
- Material.prototype.moveItem = function (location, quantity) {
333
+ moveItem(location, quantity) {
407
334
  switch (this.length) {
408
335
  case 0:
409
336
  throw new Error('You are trying to move an item that does not exists');
@@ -412,7 +339,7 @@ var Material = /** @class */ (function () {
412
339
  default:
413
340
  return this.limit(1).moveItems(location, quantity)[0];
414
341
  }
415
- };
342
+ }
416
343
  /**
417
344
  * Prepare moves that will change the location of all the items in this material instance
418
345
  *
@@ -420,49 +347,45 @@ var Material = /** @class */ (function () {
420
347
  * @param {number | undefined} quantity Optional: for items with a quantity, the number of items to move. If undefined, the items are completely moved.
421
348
  * @returns {MoveItem[]} the moves that will change the location of the items (or a part of their quantity) when executed
422
349
  */
423
- Material.prototype.moveItems = function (location, quantity) {
424
- var _this = this;
425
- var getLocation = typeof location === 'function' ? location : function () { return location; };
426
- return this.process(this.entries.map(function (entry) {
427
- var location = getLocation(entry[1], entry[0]);
428
- var move = {
429
- kind: moves_1.MoveKind.ItemMove,
430
- type: moves_1.ItemMoveType.Move,
431
- itemType: _this.type,
350
+ moveItems(location, quantity) {
351
+ const getLocation = typeof location === 'function' ? location : () => location;
352
+ return this.process(this.entries.map(entry => {
353
+ const location = getLocation(entry[1], entry[0]);
354
+ const move = {
355
+ kind: MoveKind.ItemMove,
356
+ type: ItemMoveType.Move,
357
+ itemType: this.type,
432
358
  itemIndex: entry[0],
433
- location: location
359
+ location
434
360
  };
435
361
  if (quantity)
436
362
  move.quantity = quantity;
437
363
  return move;
438
364
  }));
439
- };
365
+ }
440
366
  /**
441
367
  * Prepare one move that will change the location of all the items in this material instance
442
368
  *
443
369
  * @param {Location} location The new location of the items. It can only be the same location for every item.
444
370
  * @returns {MoveItemsAtOnce} the move that will change the location of the items when executed
445
371
  */
446
- Material.prototype.moveItemsAtOnce = function (location) {
447
- var move = {
448
- kind: moves_1.MoveKind.ItemMove,
449
- type: moves_1.ItemMoveType.MoveAtOnce,
372
+ moveItemsAtOnce(location) {
373
+ const move = {
374
+ kind: MoveKind.ItemMove,
375
+ type: ItemMoveType.MoveAtOnce,
450
376
  itemType: this.type,
451
- indexes: this.entries.map(function (_a) {
452
- var index = _a[0];
453
- return index;
454
- }),
455
- location: location
377
+ indexes: this.entries.map(([index]) => index),
378
+ location
456
379
  };
457
380
  return this.process([move])[0];
458
- };
381
+ }
459
382
  /**
460
383
  * Prepare a move that will select current first item in this material instance
461
384
  *
462
385
  * @param {number | undefined} quantity Optional: for items with a quantity, the number of items to select. If undefined, the item is completely selected.
463
386
  * @returns {SelectItem} the move that will select the item (or a part of its quantity) when executed
464
387
  */
465
- Material.prototype.selectItem = function (quantity) {
388
+ selectItem(quantity) {
466
389
  switch (this.length) {
467
390
  case 0:
468
391
  throw new Error('You are trying to select an item that does not exists');
@@ -471,34 +394,33 @@ var Material = /** @class */ (function () {
471
394
  default:
472
395
  return this.limit(1).selectItems(quantity)[0];
473
396
  }
474
- };
397
+ }
475
398
  /**
476
399
  * Prepare a move that will select all the items in this material instance
477
400
  *
478
401
  * @param {number | undefined} quantity Optional: for items with a quantity, the number of items to select. If undefined, the items are completely selected.
479
402
  * @returns {SelectItem[]} the moves that will select the items (or a part of their quantity) when executed
480
403
  */
481
- Material.prototype.selectItems = function (quantity) {
482
- var _this = this;
483
- return this.process(this.entries.map(function (entry) {
484
- var move = {
485
- kind: moves_1.MoveKind.ItemMove,
486
- type: moves_1.ItemMoveType.Select,
487
- itemType: _this.type,
404
+ selectItems(quantity) {
405
+ return this.process(this.entries.map(entry => {
406
+ const move = {
407
+ kind: MoveKind.ItemMove,
408
+ type: ItemMoveType.Select,
409
+ itemType: this.type,
488
410
  itemIndex: entry[0]
489
411
  };
490
412
  if (quantity)
491
413
  move.quantity = quantity;
492
414
  return move;
493
415
  }));
494
- };
416
+ }
495
417
  /**
496
418
  * Prepare a move that will unselect current first item in this material instance
497
419
  *
498
420
  * @param {number | undefined} quantity Optional: for items with a quantity, the number of items to unselect. If undefined, the item is completely unselected.
499
421
  * @returns {SelectItem} the move that will unselect the item (or a part of its quantity) when executed
500
422
  */
501
- Material.prototype.unselectItem = function (quantity) {
423
+ unselectItem(quantity) {
502
424
  switch (this.length) {
503
425
  case 0:
504
426
  throw new Error('You are trying to select an item that does not exists');
@@ -507,20 +429,19 @@ var Material = /** @class */ (function () {
507
429
  default:
508
430
  return this.limit(1).unselectItems(quantity)[0];
509
431
  }
510
- };
432
+ }
511
433
  /**
512
434
  * Prepare a move that will unselect all the items in this material instance
513
435
  *
514
436
  * @param {number | undefined} quantity Optional: for items with a quantity, the number of items to unselect. If undefined, the items are completely unselected.
515
437
  * @returns {SelectItem[]} the moves that will unselect the items (or a part of their quantity) when executed
516
438
  */
517
- Material.prototype.unselectItems = function (quantity) {
518
- var _this = this;
519
- return this.process(this.entries.map(function (entry) {
520
- var move = {
521
- kind: moves_1.MoveKind.ItemMove,
522
- type: moves_1.ItemMoveType.Select,
523
- itemType: _this.type,
439
+ unselectItems(quantity) {
440
+ return this.process(this.entries.map(entry => {
441
+ const move = {
442
+ kind: MoveKind.ItemMove,
443
+ type: ItemMoveType.Select,
444
+ itemType: this.type,
524
445
  itemIndex: entry[0],
525
446
  selected: false
526
447
  };
@@ -528,7 +449,7 @@ var Material = /** @class */ (function () {
528
449
  move.quantity = quantity;
529
450
  return move;
530
451
  }));
531
- };
452
+ }
532
453
  /**
533
454
  * Prepare a move that will rotate current first item in this material instance.
534
455
  * This function creates a {@link MoveItem} but copies the existing location values, only replacing the rotation property.
@@ -537,7 +458,7 @@ var Material = /** @class */ (function () {
537
458
  * In case of a function, process the value based on the item state.
538
459
  * @returns {MoveItem} the move that will rotate the item when executed
539
460
  */
540
- Material.prototype.rotateItem = function (arg) {
461
+ rotateItem(arg) {
541
462
  switch (this.length) {
542
463
  case 0:
543
464
  throw new Error('You are trying to rotate an item that does not exists');
@@ -546,7 +467,7 @@ var Material = /** @class */ (function () {
546
467
  default:
547
468
  return this.limit(1).rotateItems(arg)[0];
548
469
  }
549
- };
470
+ }
550
471
  /**
551
472
  * Prepare a move that will rotate all the items in this material instance.
552
473
  * This function creates an array of {@link MoveItem} but copies the existing locations values, only replacing the rotation property.
@@ -555,36 +476,35 @@ var Material = /** @class */ (function () {
555
476
  * In case of a function, process the value based on the item state.
556
477
  * @returns {MoveItem[]} the moves that will rotate the item when executed
557
478
  */
558
- Material.prototype.rotateItems = function (arg) {
559
- return this.moveItems(function (item) {
560
- var rotation = typeof arg === 'function' ? arg(item) : arg;
561
- var _a = item.location, oldRotation = _a.rotation, location = __rest(_a, ["rotation"]);
562
- return rotation !== undefined ? (__assign(__assign({}, location), { rotation: rotation })) : location;
479
+ rotateItems(arg) {
480
+ return this.moveItems(item => {
481
+ const rotation = typeof arg === 'function' ? arg(item) : arg;
482
+ const { rotation: oldRotation, ...location } = item.location;
483
+ return rotation !== undefined ? ({ ...location, rotation }) : location;
563
484
  });
564
- };
485
+ }
565
486
  /**
566
487
  * Prepare a move that will shuffle all the items in the current material instance
567
488
  * @returns {Shuffle} the move that shuffle the items when executed
568
489
  */
569
- Material.prototype.shuffle = function () {
570
- var _this = this;
571
- if (process.env.NODE_ENV === 'development' && this.entries.some(function (e) { return !(0, location_1.isSameLocationArea)(e[1].location, _this.entries[0][1].location); })) {
490
+ shuffle() {
491
+ if (process.env.NODE_ENV === 'development' && this.entries.some(e => !isSameLocationArea(e[1].location, this.entries[0][1].location))) {
572
492
  console.warn('Calling shuffle on items with different location areas might be a mistake.');
573
493
  }
574
494
  return this.process([{
575
- kind: moves_1.MoveKind.ItemMove,
576
- type: moves_1.ItemMoveType.Shuffle,
495
+ kind: MoveKind.ItemMove,
496
+ type: ItemMoveType.Shuffle,
577
497
  itemType: this.type,
578
- indexes: this.entries.map(function (entry) { return entry[0]; })
498
+ indexes: this.entries.map(entry => entry[0])
579
499
  }])[0];
580
- };
500
+ }
581
501
  /**
582
502
  * Prepare a move that will roll the current first item in this material instance. See {@link RollItem}.
583
503
  *
584
504
  * @param {Location | function} location The new location of the item. It can be a function to process the location based on the item current state.
585
505
  * @returns {RollItem} the move that rolls the item when executed
586
506
  */
587
- Material.prototype.rollItem = function (location) {
507
+ rollItem(location) {
588
508
  switch (this.length) {
589
509
  case 0:
590
510
  throw new Error('You are trying to roll an item that does not exists');
@@ -593,46 +513,41 @@ var Material = /** @class */ (function () {
593
513
  default:
594
514
  return this.limit(1).rollItems(location)[0];
595
515
  }
596
- };
516
+ }
597
517
  /**
598
518
  * Prepare a move that will roll all the items in this material instance. See {@link RollItem}.
599
519
  *
600
520
  * @param {Location | function} location The new location of the items. It can be a function to process the location based on each item current state.
601
521
  * @returns {RollItem[]} the moves that rolls the items when executed
602
522
  */
603
- Material.prototype.rollItems = function (location) {
604
- var _this = this;
605
- if (location === void 0) { location = function (item) { return item.location; }; }
606
- var getLocation = typeof location === 'function' ? location : function () { return location; };
607
- return this.process(this.entries.map(function (entry) {
608
- var location = getLocation(entry[1]);
523
+ rollItems(location = (item) => item.location) {
524
+ const getLocation = typeof location === 'function' ? location : () => location;
525
+ return this.process(this.entries.map(entry => {
526
+ const location = getLocation(entry[1]);
609
527
  return ({
610
- kind: moves_1.MoveKind.ItemMove,
611
- type: moves_1.ItemMoveType.Roll,
612
- itemType: _this.type,
528
+ kind: MoveKind.ItemMove,
529
+ type: ItemMoveType.Roll,
530
+ itemType: this.type,
613
531
  itemIndex: entry[0],
614
- location: location
532
+ location
615
533
  });
616
534
  }));
617
- };
535
+ }
618
536
  /**
619
537
  * Return a new {@link MaterialDeck} helper class, to deal cards easily.
620
538
  *
621
539
  * @param selector The sort to apply on the deck. See {@link sort}. Defaults to -item.location.x
622
540
  */
623
- Material.prototype.deck = function (selector) {
624
- if (selector === void 0) { selector = function (item) { return -item.location.x; }; }
625
- return new index_1.MaterialDeck(this.type, this.items, this.processMove, this.entries).sort(selector);
626
- };
541
+ deck(selector = item => -item.location.x) {
542
+ return new MaterialDeck(this.type, this.items, this.processMove, this.entries).sort(selector);
543
+ }
627
544
  /**
628
545
  * Return a new {@link MaterialMoney} helper class, to deal with moving money units easily.
629
546
  *
630
547
  * @param units The different units that exists in stock to count this money
631
548
  */
632
- Material.prototype.money = function (units) {
633
- return new index_1.MaterialMoney(this.type, units, this.items, this.processMove, this.entries);
634
- };
635
- return Material;
636
- }());
637
- exports.Material = Material;
549
+ money(units) {
550
+ return new MaterialMoney(this.type, units, this.items, this.processMove, this.entries);
551
+ }
552
+ }
638
553
  //# sourceMappingURL=Material.js.map