@gamepark/rules-api 6.24.2 → 6.24.3

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 (164) hide show
  1. package/dist/Action.d.ts +7 -0
  2. package/dist/Bot.d.ts +21 -0
  3. package/dist/Bot.js +18 -2
  4. package/dist/Bot.js.map +1 -1
  5. package/dist/Competitive.d.ts +45 -0
  6. package/dist/Competitive.js +15 -0
  7. package/dist/Competitive.js.map +1 -1
  8. package/dist/Eliminations.d.ts +17 -0
  9. package/dist/Eliminations.js +5 -0
  10. package/dist/Eliminations.js.map +1 -1
  11. package/dist/GameSetup.d.ts +14 -0
  12. package/dist/HiddenInformation.d.ts +22 -0
  13. package/dist/HiddenInformation.js +5 -0
  14. package/dist/HiddenInformation.js.map +1 -1
  15. package/dist/LocalMovePreview.d.ts +14 -0
  16. package/dist/LocalMovePreview.js +5 -0
  17. package/dist/LocalMovePreview.js.map +1 -1
  18. package/dist/RandomMove.d.ts +17 -0
  19. package/dist/Rules.d.ts +119 -0
  20. package/dist/Rules.js +102 -1
  21. package/dist/Rules.js.map +1 -1
  22. package/dist/SecretInformation.d.ts +39 -0
  23. package/dist/SecretInformation.js +5 -0
  24. package/dist/SecretInformation.js.map +1 -1
  25. package/dist/TimeLimit.d.ts +22 -0
  26. package/dist/TimeLimit.js +5 -0
  27. package/dist/TimeLimit.js.map +1 -1
  28. package/dist/Undo.d.ts +18 -0
  29. package/dist/Undo.js +6 -0
  30. package/dist/Undo.js.map +1 -1
  31. package/dist/UnpredictableMove.d.ts +19 -0
  32. package/dist/UnpredictableMove.js +5 -0
  33. package/dist/UnpredictableMove.js.map +1 -1
  34. package/dist/material/HiddenMaterialRules.d.ts +48 -0
  35. package/dist/material/HiddenMaterialRules.js +47 -1
  36. package/dist/material/HiddenMaterialRules.js.map +1 -1
  37. package/dist/material/MaterialGame.d.ts +12 -0
  38. package/dist/material/MaterialGameSetup.d.ts +74 -0
  39. package/dist/material/MaterialGameSetup.js +67 -1
  40. package/dist/material/MaterialGameSetup.js.map +1 -1
  41. package/dist/material/MaterialRules.d.ts +125 -0
  42. package/dist/material/MaterialRules.js +117 -1
  43. package/dist/material/MaterialRules.js.map +1 -1
  44. package/dist/material/SecretMaterialRules.d.ts +31 -0
  45. package/dist/material/SecretMaterialRules.js +23 -1
  46. package/dist/material/SecretMaterialRules.js.map +1 -1
  47. package/dist/material/items/Material.d.ts +253 -0
  48. package/dist/material/items/Material.js +248 -1
  49. package/dist/material/items/Material.js.map +1 -1
  50. package/dist/material/items/MaterialDeck.d.ts +33 -0
  51. package/dist/material/items/MaterialDeck.js +34 -1
  52. package/dist/material/items/MaterialDeck.js.map +1 -1
  53. package/dist/material/items/MaterialItem.d.ts +12 -0
  54. package/dist/material/items/MaterialMutator.d.ts +39 -0
  55. package/dist/material/items/MaterialMutator.js +41 -2
  56. package/dist/material/items/MaterialMutator.js.map +1 -1
  57. package/dist/material/items/index.js +1 -1
  58. package/dist/material/items/index.js.map +1 -1
  59. package/dist/material/location/Location.d.ts +28 -0
  60. package/dist/material/location/Location.js +5 -0
  61. package/dist/material/location/Location.js.map +1 -1
  62. package/dist/material/location/LocationBuilder.js +1 -1
  63. package/dist/material/location/strategy/FillGapStrategy.d.ts +4 -0
  64. package/dist/material/location/strategy/FillGapStrategy.js +5 -1
  65. package/dist/material/location/strategy/FillGapStrategy.js.map +1 -1
  66. package/dist/material/location/strategy/LocationStrategy.d.ts +20 -0
  67. package/dist/material/location/strategy/PositiveSequenceStrategy.d.ts +4 -0
  68. package/dist/material/location/strategy/PositiveSequenceStrategy.js +5 -1
  69. package/dist/material/location/strategy/PositiveSequenceStrategy.js.map +1 -1
  70. package/dist/material/memory/GameMemory.d.ts +21 -0
  71. package/dist/material/memory/GameMemory.js +22 -1
  72. package/dist/material/memory/GameMemory.js.map +1 -1
  73. package/dist/material/memory/PlayerMemory.d.ts +22 -0
  74. package/dist/material/memory/PlayerMemory.js +23 -1
  75. package/dist/material/memory/PlayerMemory.js.map +1 -1
  76. package/dist/material/moves/CustomMove.d.ts +18 -0
  77. package/dist/material/moves/CustomMove.js +13 -0
  78. package/dist/material/moves/CustomMove.js.map +1 -1
  79. package/dist/material/moves/MaterialMove.d.ts +9 -0
  80. package/dist/material/moves/MaterialMoveBuilder.d.ts +36 -0
  81. package/dist/material/moves/MaterialMoveBuilder.js +36 -0
  82. package/dist/material/moves/MaterialMoveBuilder.js.map +1 -1
  83. package/dist/material/moves/MoveKind.d.ts +3 -0
  84. package/dist/material/moves/MoveKind.js +3 -0
  85. package/dist/material/moves/MoveKind.js.map +1 -1
  86. package/dist/material/moves/items/CreateItem.d.ts +13 -0
  87. package/dist/material/moves/items/CreateItem.js +10 -0
  88. package/dist/material/moves/items/CreateItem.js.map +1 -1
  89. package/dist/material/moves/items/CreateItemsAtOnce.d.ts +14 -0
  90. package/dist/material/moves/items/CreateItemsAtOnce.js +10 -0
  91. package/dist/material/moves/items/CreateItemsAtOnce.js.map +1 -1
  92. package/dist/material/moves/items/DeleteItem.d.ts +18 -0
  93. package/dist/material/moves/items/DeleteItem.js +11 -0
  94. package/dist/material/moves/items/DeleteItem.js.map +1 -1
  95. package/dist/material/moves/items/DeleteItemsAtOnce.d.ts +17 -0
  96. package/dist/material/moves/items/DeleteItemsAtOnce.js +10 -0
  97. package/dist/material/moves/items/DeleteItemsAtOnce.js.map +1 -1
  98. package/dist/material/moves/items/ItemMove.d.ts +12 -0
  99. package/dist/material/moves/items/ItemMoveType.d.ts +3 -0
  100. package/dist/material/moves/items/ItemMoveType.js +3 -0
  101. package/dist/material/moves/items/ItemMoveType.js.map +1 -1
  102. package/dist/material/moves/items/MoveItem.d.ts +20 -0
  103. package/dist/material/moves/items/MoveItem.js +11 -0
  104. package/dist/material/moves/items/MoveItem.js.map +1 -1
  105. package/dist/material/moves/items/MoveItemsAtOnce.d.ts +20 -0
  106. package/dist/material/moves/items/MoveItemsAtOnce.js +10 -0
  107. package/dist/material/moves/items/MoveItemsAtOnce.js.map +1 -1
  108. package/dist/material/moves/items/RollItem.d.ts +19 -0
  109. package/dist/material/moves/items/RollItem.js +10 -0
  110. package/dist/material/moves/items/RollItem.js.map +1 -1
  111. package/dist/material/moves/items/SelectItem.d.ts +20 -0
  112. package/dist/material/moves/items/SelectItem.js +11 -0
  113. package/dist/material/moves/items/SelectItem.js.map +1 -1
  114. package/dist/material/moves/items/Shuffle.d.ts +26 -0
  115. package/dist/material/moves/items/Shuffle.js +15 -0
  116. package/dist/material/moves/items/Shuffle.js.map +1 -1
  117. package/dist/material/moves/local/CloseTutorialPopup.d.ts +8 -0
  118. package/dist/material/moves/local/CloseTutorialPopup.js +5 -0
  119. package/dist/material/moves/local/CloseTutorialPopup.js.map +1 -1
  120. package/dist/material/moves/local/DisplayHelp.d.ts +18 -0
  121. package/dist/material/moves/local/DisplayHelp.js +3 -0
  122. package/dist/material/moves/local/DisplayHelp.js.map +1 -1
  123. package/dist/material/moves/local/DropItem.d.ts +9 -0
  124. package/dist/material/moves/local/LocalMove.d.ts +6 -0
  125. package/dist/material/moves/local/LocalMove.js +3 -0
  126. package/dist/material/moves/local/LocalMove.js.map +1 -1
  127. package/dist/material/moves/local/SetTutorialStep.d.ts +8 -0
  128. package/dist/material/moves/local/SetTutorialStep.js +5 -0
  129. package/dist/material/moves/local/SetTutorialStep.js.map +1 -1
  130. package/dist/material/rules/MaterialRulesPart.d.ts +76 -0
  131. package/dist/material/rules/MaterialRulesPart.js +74 -1
  132. package/dist/material/rules/MaterialRulesPart.js.map +1 -1
  133. package/dist/material/rules/PlayerTurnRule.d.ts +19 -0
  134. package/dist/material/rules/PlayerTurnRule.js +20 -1
  135. package/dist/material/rules/PlayerTurnRule.js.map +1 -1
  136. package/dist/material/rules/RuleStep.d.ts +3 -0
  137. package/dist/material/rules/SimultaneousRule.d.ts +25 -0
  138. package/dist/material/rules/SimultaneousRule.js +21 -1
  139. package/dist/material/rules/SimultaneousRule.js.map +1 -1
  140. package/dist/material/tutorial/TutorialState.d.ts +7 -0
  141. package/dist/options/OptionsValidationError.js +1 -1
  142. package/dist/options/PlayerEnumOption.js +3 -0
  143. package/dist/options/PlayerEnumOption.js.map +1 -1
  144. package/dist/utils/action-view.util.js +2 -0
  145. package/dist/utils/action-view.util.js.map +1 -1
  146. package/dist/utils/enum.util.d.ts +27 -0
  147. package/dist/utils/enum.util.js +24 -0
  148. package/dist/utils/enum.util.js.map +1 -1
  149. package/dist/utils/grid.squares.util.d.ts +26 -0
  150. package/dist/utils/grid.squares.util.js +26 -0
  151. package/dist/utils/grid.squares.util.js.map +1 -1
  152. package/dist/utils/grid.util.d.ts +8 -0
  153. package/dist/utils/grid.util.js +5 -0
  154. package/dist/utils/grid.util.js.map +1 -1
  155. package/dist/utils/listing.util.d.ts +12 -0
  156. package/dist/utils/listing.util.js +12 -0
  157. package/dist/utils/listing.util.js.map +1 -1
  158. package/dist/utils/money.util.d.ts +41 -4
  159. package/dist/utils/money.util.js +38 -1
  160. package/dist/utils/money.util.js.map +1 -1
  161. package/dist/utils/random.util.d.ts +11 -0
  162. package/dist/utils/random.util.js +11 -0
  163. package/dist/utils/random.util.js.map +1 -1
  164. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PlayerTurnRule.js","sourceRoot":"","sources":["../../../src/material/rules/PlayerTurnRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,yDAAuD;AAKvD;IACU,kCAAqD;IAD/D;;IAuCA,CAAC;IAjCC,sBAAI,kCAAM;aAAV;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAK,CAAC,MAAO,CAAA;QAChC,CAAC;;;OAAA;IAKD,sBAAI,sCAAU;aAAd;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAA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;IACX,CAAC;IACH,qBAAC;AAAD,CAAC,AAvCD,CACU,qCAAiB,GAsC1B;AAvCqB,wCAAc"}
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Common data structure for any step of the rules
3
+ */
1
4
  export type RuleStep<Player extends number = number, RuleId extends number = number> = {
2
5
  id: RuleId;
3
6
  player?: Player;
@@ -1,12 +1,37 @@
1
1
  import { PlayMoveContext } from '../../Rules';
2
2
  import { EndPlayerTurn, MaterialMove } from '../moves';
3
3
  import { MaterialRulesPart } from './MaterialRulesPart';
4
+ /**
5
+ * Base class for any part of the rules where multiple players have to do something at the same time.
6
+ */
4
7
  export declare abstract class SimultaneousRule<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends MaterialRulesPart<Player, MaterialType, LocationType> {
5
8
  endPlayerTurn: <P extends number = number>(player: P) => EndPlayerTurn<P>;
9
+ /**
10
+ * See {@link Rules.isTurnToPlay}
11
+ */
6
12
  isTurnToPlay(player: Player): boolean;
13
+ /**
14
+ * See {@link Rules.getLegalMoves}
15
+ */
7
16
  getLegalMoves(player: Player): MaterialMove<Player, MaterialType, LocationType>[];
8
17
  abstract getActivePlayerLegalMoves(playerId: Player): MaterialMove<Player, MaterialType, LocationType>[];
18
+ /**
19
+ * This function is called immediately after a {@link EndPlayerTurn} has been played.
20
+ * @param _move The move which has just been played
21
+ * @param _context Context of execution
22
+ * @returns {MaterialMove[]} Any consequences that should automatically be played after the move
23
+ */
9
24
  onPlayerTurnEnd(_move: EndPlayerTurn<Player>, _context?: PlayMoveContext): MaterialMove<Player, MaterialType, LocationType>[];
25
+ /**
26
+ * Implement this to return the consequences when all the players have completed their task.
27
+ * Usually, a new rule part should start.
28
+ * @returns the consequences when the last awaited player have played
29
+ */
10
30
  abstract getMovesAfterPlayersDone(): MaterialMove<Player, MaterialType, LocationType>[];
11
31
  }
32
+ /**
33
+ * Type guard to know if a {@link MaterialRulesPart} is a {@link SimultaneousRule}
34
+ * @param rule The rule
35
+ * @returns true if the rule if a {@link SimultaneousRule}
36
+ */
12
37
  export declare function isSimultaneousRule<P extends number = number, M extends number = number, L extends number = number>(rule?: MaterialRulesPart<P, M, L>): rule is SimultaneousRule<P, M, L>;
@@ -18,26 +18,46 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.isSimultaneousRule = exports.SimultaneousRule = void 0;
19
19
  var moves_1 = require("../moves");
20
20
  var MaterialRulesPart_1 = require("./MaterialRulesPart");
21
- var SimultaneousRule = (function (_super) {
21
+ /**
22
+ * Base class for any part of the rules where multiple players have to do something at the same time.
23
+ */
24
+ var SimultaneousRule = /** @class */ (function (_super) {
22
25
  __extends(SimultaneousRule, _super);
23
26
  function SimultaneousRule() {
24
27
  var _this = _super !== null && _super.apply(this, arguments) || this;
25
28
  _this.endPlayerTurn = moves_1.MaterialMoveBuilder.endPlayerTurn;
26
29
  return _this;
27
30
  }
31
+ /**
32
+ * See {@link Rules.isTurnToPlay}
33
+ */
28
34
  SimultaneousRule.prototype.isTurnToPlay = function (player) {
29
35
  var _a, _b, _c;
30
36
  return (_c = (_b = (_a = this.game.rule) === null || _a === void 0 ? void 0 : _a.players) === null || _b === void 0 ? void 0 : _b.includes(player)) !== null && _c !== void 0 ? _c : false;
31
37
  };
38
+ /**
39
+ * See {@link Rules.getLegalMoves}
40
+ */
32
41
  SimultaneousRule.prototype.getLegalMoves = function (player) {
33
42
  return this.isTurnToPlay(player) ? this.getActivePlayerLegalMoves(player) : [];
34
43
  };
44
+ /**
45
+ * This function is called immediately after a {@link EndPlayerTurn} has been played.
46
+ * @param _move The move which has just been played
47
+ * @param _context Context of execution
48
+ * @returns {MaterialMove[]} Any consequences that should automatically be played after the move
49
+ */
35
50
  SimultaneousRule.prototype.onPlayerTurnEnd = function (_move, _context) {
36
51
  return [];
37
52
  };
38
53
  return SimultaneousRule;
39
54
  }(MaterialRulesPart_1.MaterialRulesPart));
40
55
  exports.SimultaneousRule = SimultaneousRule;
56
+ /**
57
+ * Type guard to know if a {@link MaterialRulesPart} is a {@link SimultaneousRule}
58
+ * @param rule The rule
59
+ * @returns true if the rule if a {@link SimultaneousRule}
60
+ */
41
61
  function isSimultaneousRule(rule) {
42
62
  return rule !== undefined && typeof rule.getMovesAfterPlayersDone === 'function';
43
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SimultaneousRule.js","sourceRoot":"","sources":["../../../src/material/rules/SimultaneousRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,kCAA2E;AAC3E,yDAAuD;AAKvD;IACU,oCAAqD;IAD/D;;QAGE,mBAAa,GAAG,2BAAmB,CAAC,aAAa,CAAA;;IAkCnD,CAAC;IA7BC,uCAAY,GAAZ,UAAa,MAAc;;QACzB,OAAO,MAAA,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,IAAI,0CAAE,OAAO,0CAAE,QAAQ,CAAC,MAAM,CAAC,mCAAI,KAAK,CAAA;IAC3D,CAAC;IAKD,wCAAa,GAAb,UAAc,MAAc;QAC1B,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAChF,CAAC;IAUD,0CAAe,GAAf,UAAgB,KAA4B,EAAE,QAA0B;QACtE,OAAO,EAAE,CAAA;IACX,CAAC;IAQH,uBAAC;AAAD,CAAC,AArCD,CACU,qCAAiB,GAoC1B;AArCqB,4CAAgB;AA4CtC,SAAgB,kBAAkB,CAChC,IAAiC;IAEjC,OAAO,IAAI,KAAK,SAAS,IAAI,OAAQ,IAAkC,CAAC,wBAAwB,KAAK,UAAU,CAAA;AACjH,CAAC;AAJD,gDAIC"}
1
+ {"version":3,"file":"SimultaneousRule.js","sourceRoot":"","sources":["../../../src/material/rules/SimultaneousRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,kCAA2E;AAC3E,yDAAuD;AAEvD;;GAEG;AACH;IACU,oCAAqD;IAD/D;;QAGE,mBAAa,GAAG,2BAAmB,CAAC,aAAa,CAAA;;IAkCnD,CAAC;IAhCC;;OAEG;IACH,uCAAY,GAAZ,UAAa,MAAc;;QACzB,OAAO,MAAA,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,IAAI,0CAAE,OAAO,0CAAE,QAAQ,CAAC,MAAM,CAAC,mCAAI,KAAK,CAAA;IAC3D,CAAC;IAED;;OAEG;IACH,wCAAa,GAAb,UAAc,MAAc;QAC1B,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAChF,CAAC;IAID;;;;;OAKG;IACH,0CAAe,GAAf,UAAgB,KAA4B,EAAE,QAA0B;QACtE,OAAO,EAAE,CAAA;IACX,CAAC;IAQH,uBAAC;AAAD,CAAC,AArCD,CACU,qCAAiB,GAoC1B;AArCqB,4CAAgB;AAuCtC;;;;GAIG;AACH,SAAgB,kBAAkB,CAChC,IAAiC;IAEjC,OAAO,IAAI,KAAK,SAAS,IAAI,OAAQ,IAAkC,CAAC,wBAAwB,KAAK,UAAU,CAAA;AACjH,CAAC;AAJD,gDAIC"}
@@ -1,4 +1,11 @@
1
1
  import { MaterialMove } from '../moves';
2
+ /**
3
+ * Data structure for the state of the tutorial in a tutorial game implement with {@link MaterialRules}.
4
+ * @property step Current step of the tutorial.
5
+ * @property popupClosed true when the popup has been closed by the player.
6
+ * @property stepComplete if true, the tutorial engine will move on to next step automatically.
7
+ * @property interrupt The automatic consequences that have been interrupted to display some information explaining what is happening.
8
+ */
2
9
  export type TutorialState<P extends number = number, M extends number = number, L extends number = number> = {
3
10
  step: number;
4
11
  popupClosed: boolean;
@@ -16,7 +16,7 @@ var __extends = (this && this.__extends) || (function () {
16
16
  })();
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.OptionsValidationError = void 0;
19
- var OptionsValidationError = (function (_super) {
19
+ var OptionsValidationError = /** @class */ (function (_super) {
20
20
  __extends(OptionsValidationError, _super);
21
21
  function OptionsValidationError(message, fields) {
22
22
  if (fields === void 0) { fields = []; }
@@ -20,6 +20,7 @@ function getPlayersAvailableValues(spec, players) {
20
20
  }
21
21
  exports.getPlayersAvailableValues = getPlayersAvailableValues;
22
22
  function generatePlayersOption(playersChoices, option) {
23
+ // Force to pick mandatory values
23
24
  var mandatoryValues = getPlayersMandatoryValues(option, playersChoices.length);
24
25
  for (var _i = 0, mandatoryValues_1 = mandatoryValues; _i < mandatoryValues_1.length; _i++) {
25
26
  var mandatoryValue = mandatoryValues_1[_i];
@@ -29,6 +30,7 @@ function generatePlayersOption(playersChoices, option) {
29
30
  playersChoices[index] = mandatoryValue;
30
31
  }
31
32
  }
33
+ // Remove invalid choices
32
34
  var availableValues = getPlayersAvailableValues(option, playersChoices.length);
33
35
  var _loop_1 = function (i) {
34
36
  var choice = playersChoices[i];
@@ -52,6 +54,7 @@ function generatePlayersOption(playersChoices, option) {
52
54
  _loop_1(i);
53
55
  }
54
56
  if (!option.optional) {
57
+ // Provide missing choices (different values if possible)
55
58
  var remainingValues = (0, difference_1.default)(availableValues, playersChoices);
56
59
  for (var i = 0; i < playersChoices.length; i++) {
57
60
  if (playersChoices[i] === null) {
@@ -1 +1 @@
1
- {"version":3,"file":"PlayerEnumOption.js","sourceRoot":"","sources":["../../src/options/PlayerEnumOption.ts"],"names":[],"mappings":";;;;;;AACA,iEAA0C;AAc1C,SAAgB,yBAAyB,CAAU,IAAyB,EAAE,OAAe;IAC3F,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AACtD,CAAC;AAFD,8DAEC;AAED,SAAgB,yBAAyB,CAAU,IAAyB,EAAE,OAAe;IAC3F,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,IAAM,mBAAiB,GAAG,IAAI,CAAC,WAAW,CAAC,O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,CAAC,CAAC,CAAC,CAAC,CAAA;YACtG,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,cAAqB,CAAA;AAC9B,CAAC;AA3CD,sDA2CC"}
@@ -13,10 +13,12 @@ function playActionWithViews(rules, move, playerId, recipients, id) {
13
13
  action: { id: id, playerId: playerId, move: move, consequences: [] },
14
14
  views: []
15
15
  };
16
+ // Prepare action view for each player
16
17
  for (var _i = 0, recipients_1 = recipients; _i < recipients_1.length; _i++) {
17
18
  var recipient = recipients_1[_i];
18
19
  actionWithView.views.push({ recipient: recipient, action: { id: id, playerId: playerId, move: getMoveView(rules, move, recipient), consequences: [] } });
19
20
  }
21
+ // Prepare action view for spectators
20
22
  actionWithView.views.push({ action: { id: id, playerId: playerId, move: getMoveView(rules, move), consequences: [] } });
21
23
  var consequences = rules.play(JSON.parse(JSON.stringify(move)));
22
24
  (0, automatic_moves_util_1.applyAutomaticMoves)(rules, consequences, function (move) {
@@ -1 +1 @@
1
- {"version":3,"file":"action-view.util.js","sourceRoot":"","sources":["../../src/utils/action-view.util.ts"],"names":[],"mappings":";;;AACA,0DAA8E;AAE9E,0DAA2D;AAC3D,+DAA4D;AAC5D,6CAA6C;AAY7C,SAAgB,mBAAmB,CACjC,KAA4E,EAAE,IAAU,EAAE,QAAkB,EAAE,UAAsB,EAAE,EAAW;IAGjJ,IAAI,IAAA,2BAAa,EAAC,KAAK,CAAC,EAAE,CAAC;QACzB,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;IAED,IAAM,cAAc,GAA8C;QAChE,MAAM,EAAE,EAAE,EAAE,IAAA,EAAE,QAAQ,UAAA,EAAE,IAAI,MAAA,EAAE,YAAY,EAAE,EAAE,EAAE;QAChD,KAAK,EAAE,EAAE;KACV,CAAA;IAGD,KAAwB,UAAU,EAAV,yBAAU,EAAV,wBAAU,EAAV,IAAU,EAAE,CAAC;QAAhC,IAAM,SAAS,mBAAA;QAClB,cAAc,CAAC,K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IAAI,IAAA,wCAAoB,EAA2B,KAAK,CAAC,EAAE,CAAC;QACjE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC5D,CAAC;SAAM,CAAC;QACN,OAAO,IAAuB,CAAA;IAChC,CAAC;AACH,CAAC;AARD,kCAQC;AAMD,SAAgB,cAAc,CAAC,MAAc;IAC3C,OAAO,KAAK,CAAC,OAAO,CAAE,MAAuB,CAAC,OAAO,CAAC,CAAA;AACxD,CAAC;AAFD,wCAEC"}
@@ -1,7 +1,34 @@
1
+ /**
2
+ * Generic type for typescript enum objects
3
+ */
1
4
  export type Enum<E> = Record<keyof E, number | string> & {
2
5
  [k: number]: string;
3
6
  };
7
+ /**
8
+ * Get the keys of an enum at run time.
9
+ * Credits to https://github.com/tranvansang/enum-for
10
+ *
11
+ * @param enumType The enumeration
12
+ * @returns returns the list of the keys of the enum
13
+ */
4
14
  export declare function getEnumKeys<E extends Enum<E>>(enumType: E): Array<keyof E>;
15
+ /**
16
+ * Get the values of an enum at run time.
17
+ * Credits to https://github.com/tranvansang/enum-for
18
+ *
19
+ * @param enumType The enumeration
20
+ * @returns returns the list of the values of the enum
21
+ */
5
22
  export declare function getEnumValues<E extends Enum<E>>(enumType: E): Array<E[keyof E]>;
23
+ /**
24
+ * Get the entries of an enum at run time.
25
+ * Credits to https://github.com/tranvansang/enum-for
26
+ *
27
+ * @param enumType The enumeration
28
+ * @returns returns the list of the entries of the enum
29
+ */
6
30
  export declare function getEnumEntries<E extends Enum<E>>(enumType: E): Array<[keyof E, E[keyof E]]>;
31
+ /**
32
+ * @deprecated Use getEnumValues instead
33
+ */
7
34
  export declare function isEnumValue<T>(value: string | T): value is T;
@@ -1,18 +1,42 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isEnumValue = exports.getEnumEntries = exports.getEnumValues = exports.getEnumKeys = void 0;
4
+ /**
5
+ * Get the keys of an enum at run time.
6
+ * Credits to https://github.com/tranvansang/enum-for
7
+ *
8
+ * @param enumType The enumeration
9
+ * @returns returns the list of the keys of the enum
10
+ */
4
11
  function getEnumKeys(enumType) {
5
12
  return Object.keys(enumType).filter(function (key) { return isNaN(Number(key)); });
6
13
  }
7
14
  exports.getEnumKeys = getEnumKeys;
15
+ /**
16
+ * Get the values of an enum at run time.
17
+ * Credits to https://github.com/tranvansang/enum-for
18
+ *
19
+ * @param enumType The enumeration
20
+ * @returns returns the list of the values of the enum
21
+ */
8
22
  function getEnumValues(enumType) {
9
23
  return getEnumKeys(enumType).map(function (key) { return enumType[key]; });
10
24
  }
11
25
  exports.getEnumValues = getEnumValues;
26
+ /**
27
+ * Get the entries of an enum at run time.
28
+ * Credits to https://github.com/tranvansang/enum-for
29
+ *
30
+ * @param enumType The enumeration
31
+ * @returns returns the list of the entries of the enum
32
+ */
12
33
  function getEnumEntries(enumType) {
13
34
  return getEnumKeys(enumType).map(function (key) { return [key, enumType[key]]; });
14
35
  }
15
36
  exports.getEnumEntries = getEnumEntries;
37
+ /**
38
+ * @deprecated Use getEnumValues instead
39
+ */
16
40
  function isEnumValue(value) {
17
41
  return typeof value !== 'string';
18
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"enum.util.js","sourceRoot":"","sources":["../../src/utils/enum.util.ts"],"names":[],"mappings":";;;AAYA,SAAgB,WAAW,CAAoB,QAAW;IACxD,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAA,GAAG,IAAI,OAAA,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAlB,CAAkB,CAAmB,CAAA;AAClF,CAAC;AAFD,kCAEC;AASD,SAAgB,aAAa,CAAoB,QAAW;IAC1D,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,UAAA,GAAG,IAAI,OAAA,QAAQ,CAAC,GAAG,CAAC,EAAb,CAAa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@@
1
1
  import { XYCoordinates } from './grid.util';
2
+ /**
3
+ * Check if two squares in a grid are orthogonally adjacent based on their coordinates
4
+ * @param square1 Coordinates of the first square
5
+ * @param square2 Coordinates of the second square
6
+ * @returns true if the squares are orthogonally adjacent
7
+ */
2
8
  export declare const areAdjacentSquares: (square1: Partial<XYCoordinates>, square2: Partial<XYCoordinates>) => boolean;
9
+ /**
10
+ * Get the distance between 2 squares in a square-grid, ie the minimum number of steps you need to take to go from square 1 to square 2 following
11
+ * orthogonally adjacent squares
12
+ * @param square1 Coordinates of the first square
13
+ * @param square2 Coordinates of the second square
14
+ * @returns the distance between square1 and square2
15
+ */
3
16
  export declare const getDistanceBetweenSquares: (square1: XYCoordinates, square2: XYCoordinates) => number;
17
+ /**
18
+ * The direction (cardinal points) you can orient in a square grid
19
+ */
4
20
  export declare enum Direction {
5
21
  North = 1,
6
22
  South = 2,
7
23
  East = 3,
8
24
  West = 4
9
25
  }
26
+ /**
27
+ * List of the 4 {@link Direction}s
28
+ */
10
29
  export declare const directions: Direction[];
30
+ /**
31
+ * Get the coordinates of the next square if you move in a square grid following a direction
32
+ * @param origin The coordinates of the square you start from
33
+ * @param direction The direction you move to
34
+ * @param distance The number of steps you move (A by default)
35
+ * @returns the coordinates of the destination square
36
+ */
11
37
  export declare const getSquareInDirection: (origin: Partial<XYCoordinates>, direction: Direction, distance?: number) => XYCoordinates;
@@ -3,14 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSquareInDirection = exports.directions = exports.Direction = exports.getDistanceBetweenSquares = exports.areAdjacentSquares = void 0;
4
4
  var enum_util_1 = require("./enum.util");
5
5
  var grid_util_1 = require("./grid.util");
6
+ /**
7
+ * Check if two squares in a grid are orthogonally adjacent based on their coordinates
8
+ * @param square1 Coordinates of the first square
9
+ * @param square2 Coordinates of the second square
10
+ * @returns true if the squares are orthogonally adjacent
11
+ */
6
12
  var areAdjacentSquares = function (square1, square2) {
7
13
  return (0, grid_util_1.isXYCoordinates)(square1) && (0, grid_util_1.isXYCoordinates)(square2) && (0, exports.getDistanceBetweenSquares)(square1, square2) === 1;
8
14
  };
9
15
  exports.areAdjacentSquares = areAdjacentSquares;
16
+ /**
17
+ * Get the distance between 2 squares in a square-grid, ie the minimum number of steps you need to take to go from square 1 to square 2 following
18
+ * orthogonally adjacent squares
19
+ * @param square1 Coordinates of the first square
20
+ * @param square2 Coordinates of the second square
21
+ * @returns the distance between square1 and square2
22
+ */
10
23
  var getDistanceBetweenSquares = function (square1, square2) {
11
24
  return Math.abs(square1.x - square2.x) + Math.abs(square1.y - square2.y);
12
25
  };
13
26
  exports.getDistanceBetweenSquares = getDistanceBetweenSquares;
27
+ /**
28
+ * The direction (cardinal points) you can orient in a square grid
29
+ */
14
30
  var Direction;
15
31
  (function (Direction) {
16
32
  Direction[Direction["North"] = 1] = "North";
@@ -18,7 +34,17 @@ var Direction;
18
34
  Direction[Direction["East"] = 3] = "East";
19
35
  Direction[Direction["West"] = 4] = "West";
20
36
  })(Direction || (exports.Direction = Direction = {}));
37
+ /**
38
+ * List of the 4 {@link Direction}s
39
+ */
21
40
  exports.directions = (0, enum_util_1.getEnumValues)(Direction);
41
+ /**
42
+ * Get the coordinates of the next square if you move in a square grid following a direction
43
+ * @param origin The coordinates of the square you start from
44
+ * @param direction The direction you move to
45
+ * @param distance The number of steps you move (A by default)
46
+ * @returns the coordinates of the destination square
47
+ */
22
48
  var getSquareInDirection = function (origin, direction, distance) {
23
49
  if (distance === void 0) { distance = 1; }
24
50
  if (origin.x === undefined || origin.y === undefined)
@@ -1 +1 @@
1
- {"version":3,"file":"grid.squares.util.js","sourceRoot":"","sources":["../../src/utils/grid.squares.util.ts"],"names":[],"mappings":";;;AAAA,yCAA2C;AAC3C,yCAA4D;AAQrD,IAAM,kBAAkB,GAAG,UAAC,OAA+B,EAAE,OAA+B;IACjG,OAAA,IAAA,2BAAe,EAAC,OAAO,CAAC,IAAI,IAAA,2BAAe,EAAC,OAAO,CAAC,IAAI,IA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,wCAAwC,CAAC,CAAA;IAC/G,OAAO;QACL,CAAC,EAAE,SAAS,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACrH,CAAC,EAAE,SAAS,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;KACxH,CAAA;AACH,CAAC,CAAA;AANY,QAAA,oBAAoB,wBAMhC"}
@@ -1,5 +1,13 @@
1
+ /**
2
+ * Type for any object with XY number coordinates
3
+ */
1
4
  export type XYCoordinates = {
2
5
  x: number;
3
6
  y: number;
4
7
  };
8
+ /**
9
+ * Type guard to know if we have an object with XY coordinates
10
+ * @param coordinates The object
11
+ * @returns true if coordinates is a {@link XYCoordinates}
12
+ */
5
13
  export declare const isXYCoordinates: (coordinates: any) => coordinates is XYCoordinates;
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isXYCoordinates = void 0;
4
+ /**
5
+ * Type guard to know if we have an object with XY coordinates
6
+ * @param coordinates The object
7
+ * @returns true if coordinates is a {@link XYCoordinates}
8
+ */
4
9
  var isXYCoordinates = function (coordinates) {
5
10
  return typeof coordinates === 'object' && typeof coordinates.x === 'number' && typeof coordinates.y === 'number';
6
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"grid.util.js","sourceRoot":"","sources":["../../src/utils/grid.util.ts"],"names":[],"mappings":";;;AAaO,IAAM,eAAe,GAAG,UAAC,WAAgB;IAC9C,OAAO,OAAO,WAAW,KAAK,QAAQ,IAAI,OAAO,WAAW,CAAC,CAAC,KAAK,QAAQ,IAAI,OAAO,WAAW,CAAC,CAAC,KAAK,QAAQ,CAAA;AAClH,CAAC,CAAA;AAFY,QAAA,eAAe,mBAE3B"}
1
+ {"version":3,"file":"grid.util.js","sourceRoot":"","sources":["../../src/utils/grid.util.ts"],"names":[],"mappings":";;;AAQA;;;;GAIG;AACI,IAAM,eAAe,GAAG,UAAC,WAAgB;IAC9C,OAAO,OAAO,WAAW,KAAK,QAAQ,IAAI,OAAO,WAAW,CAAC,CAAC,KAAK,QAAQ,IAAI,OAAO,WAAW,CAAC,CAAC,KAAK,QAAQ,CAAA;AAClH,CAAC,CAAA;AAFY,QAAA,eAAe,mBAE3B"}
@@ -1,2 +1,14 @@
1
+ /**
2
+ * A listing is a quantity of items indexed by they identifier
3
+ * Use this function to get a list of items where each item is included as much time as their listed quantity
4
+ * @param listing The listing
5
+ * @returns the list matching the listing
6
+ */
1
7
  export declare function listingToList<T extends number>(listing: Partial<Record<T, number>>): T[];
8
+ /**
9
+ * A listing is a quantity of items indexed by they identifier
10
+ * Use this function to get a listing based on a list with potential duplicates
11
+ * @param list The list
12
+ * @returns the listing matching the list
13
+ */
2
14
  export declare function listToListing<T extends number>(list: T[]): Partial<Record<T, number>>;
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.listToListing = exports.listingToList = void 0;
4
+ /**
5
+ * A listing is a quantity of items indexed by they identifier
6
+ * Use this function to get a list of items where each item is included as much time as their listed quantity
7
+ * @param listing The listing
8
+ * @returns the list matching the listing
9
+ */
4
10
  function listingToList(listing) {
5
11
  var list = [];
6
12
  for (var key in listing) {
@@ -12,6 +18,12 @@ function listingToList(listing) {
12
18
  return list;
13
19
  }
14
20
  exports.listingToList = listingToList;
21
+ /**
22
+ * A listing is a quantity of items indexed by they identifier
23
+ * Use this function to get a listing based on a list with potential duplicates
24
+ * @param list The list
25
+ * @returns the listing matching the list
26
+ */
15
27
  function listToListing(list) {
16
28
  var listing = [];
17
29
  for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
@@ -1 +1 @@
1
- {"version":3,"file":"listing.util.js","sourceRoot":"","sources":["../../src/utils/listing.util.ts"],"names":[],"mappings":";;;AAMA,SAAgB,aAAa,CAAmB,OAAmC;IACjF,IAAM,IAAI,GAAQ,EAAE,CAAA;IACpB,KAAK,IAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,IAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAM,CAAA;QACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAE,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACnB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AATD,sCASC;AAQD,SAAgB,aAAa,CAAmB,IAAS;IACvD,IAAM,OAAO,GAA+B,EAAE,CAAA;IAC9C,KAAgB,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,EAAE,CAAC;QAAlB,IAAM,CAAC,aAAA;QACV,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IAC/C,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAND,sCAMC"}
1
+ {"version":3,"file":"listing.util.js","sourceRoot":"","sources":["../../src/utils/listing.util.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,aAAa,CAAmB,OAAmC;IACjF,IAAM,IAAI,GAAQ,EAAE,CAAA;IACpB,KAAK,IAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,IAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAM,CAAA;QACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAE,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACnB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AATD,sCASC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAAmB,IAAS;IACvD,IAAM,OAAO,GAA+B,EAAE,CAAA;IAC9C,KAAgB,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,EAAE,CAAC;QAAlB,IAAM,CAAC,aAAA;QACV,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IAC/C,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAND,sCAMC"}
@@ -1,11 +1,48 @@
1
1
  import { Location, Material, MaterialMove } from '../material';
2
- export declare class Money<Unit extends number = number> {
2
+ /**
3
+ * This class help manipulate any kind of money with arbitrary unit values, like a set of coins of values 1, 2, 5, 10 for instance.
4
+ */
5
+ export declare class Money<Unit extends number = number, P extends number = number, M extends number = number, L extends number = number> {
3
6
  private units;
4
7
  constructor(units: Unit[]);
5
- count(material: Material): number;
6
- createOrDelete(material: Material, location: Location, amount: number): MaterialMove[];
7
- moveAmount(material: Material, origin: Location, target: Location, amount: number): MaterialMove[];
8
+ /**
9
+ * Count the total value of a material instance
10
+ * @param material The material to count
11
+ * @returns the sum of each item id multiplied by its quantity
12
+ */
13
+ count(material: Material<P, M, L>): number;
14
+ /**
15
+ * Perform an operation of adding or removing an amount from a location by creating or deleting items
16
+ * @param material The material instance
17
+ * @param location The location to filter material onto, and to create new items in
18
+ * @param amount Amount to create or delete
19
+ * @returns the moves that need to be played to perform the operation
20
+ */
21
+ createOrDelete(material: Material<P, M, L>, location: Location<P, L>, amount: number): MaterialMove<P, M, L>[];
22
+ /**
23
+ * Move an amount of money from a place to another place. It searches after the easiest way to do it, making money with the bank only if necessary.
24
+ * @param material Material instance for the money (needs to be unfiltered)
25
+ * @param origin Location to remove money from
26
+ * @param target Location to move money to
27
+ * @param amount Amount of money to transfer
28
+ * @returns the moves that need to be played to perform the operation
29
+ */
30
+ moveAmount(material: Material<P, M, L>, origin: Location<P, L>, target: Location<P, L>, amount: number): MaterialMove<P, M, L>[];
31
+ /**
32
+ * Creates a new record indexes by all units, with value equal to 0 for each unit
33
+ */
8
34
  get record(): Record<Unit, number>;
35
+ /**
36
+ * Return the best way to gain an amount, prioritizing the highest unit values
37
+ * @param amount Amount to gain, default 1
38
+ * @returns the record of coins to earn (only positive values)
39
+ */
9
40
  gain(amount?: number): Record<Unit, number>;
41
+ /**
42
+ * Return the best way to spend an amount of owned units, prioritizing the smallest unit values
43
+ * @param owned Amount of units owned before spending
44
+ * @param amount Amount to gain, default 1
45
+ * @returns the record of coins to give away and eventually take (positive and negative values)
46
+ */
10
47
  spend(owned: Record<Unit, number>, amount?: number): Record<Unit, number>;
11
48
  }
@@ -9,14 +9,29 @@ var isEqual_1 = __importDefault(require("lodash/isEqual"));
9
9
  var keyBy_1 = __importDefault(require("lodash/keyBy"));
10
10
  var mapValues_1 = __importDefault(require("lodash/mapValues"));
11
11
  var sumBy_1 = __importDefault(require("lodash/sumBy"));
12
- var Money = (function () {
12
+ /**
13
+ * This class help manipulate any kind of money with arbitrary unit values, like a set of coins of values 1, 2, 5, 10 for instance.
14
+ */
15
+ var Money = /** @class */ (function () {
13
16
  function Money(units) {
14
17
  this.units = units;
15
18
  this.units.sort(function (a, b) { return a - b; });
16
19
  }
20
+ /**
21
+ * Count the total value of a material instance
22
+ * @param material The material to count
23
+ * @returns the sum of each item id multiplied by its quantity
24
+ */
17
25
  Money.prototype.count = function (material) {
18
26
  return (0, sumBy_1.default)(material.getItems(), function (item) { var _a, _b; return ((_a = item.id) !== null && _a !== void 0 ? _a : 1) * ((_b = item.quantity) !== null && _b !== void 0 ? _b : 1); });
19
27
  };
28
+ /**
29
+ * Perform an operation of adding or removing an amount from a location by creating or deleting items
30
+ * @param material The material instance
31
+ * @param location The location to filter material onto, and to create new items in
32
+ * @param amount Amount to create or delete
33
+ * @returns the moves that need to be played to perform the operation
34
+ */
20
35
  Money.prototype.createOrDelete = function (material, location, amount) {
21
36
  material = material.location(function (l) { return (0, isEqual_1.default)(l, location); });
22
37
  var moves = [];
@@ -32,6 +47,14 @@ var Money = (function () {
32
47
  }
33
48
  return moves;
34
49
  };
50
+ /**
51
+ * Move an amount of money from a place to another place. It searches after the easiest way to do it, making money with the bank only if necessary.
52
+ * @param material Material instance for the money (needs to be unfiltered)
53
+ * @param origin Location to remove money from
54
+ * @param target Location to move money to
55
+ * @param amount Amount of money to transfer
56
+ * @returns the moves that need to be played to perform the operation
57
+ */
35
58
  Money.prototype.moveAmount = function (material, origin, target, amount) {
36
59
  if (!amount)
37
60
  return [];
@@ -92,12 +115,20 @@ var Money = (function () {
92
115
  return moves;
93
116
  };
94
117
  Object.defineProperty(Money.prototype, "record", {
118
+ /**
119
+ * Creates a new record indexes by all units, with value equal to 0 for each unit
120
+ */
95
121
  get: function () {
96
122
  return (0, mapValues_1.default)((0, keyBy_1.default)(this.units), function (_) { return 0; });
97
123
  },
98
124
  enumerable: false,
99
125
  configurable: true
100
126
  });
127
+ /**
128
+ * Return the best way to gain an amount, prioritizing the highest unit values
129
+ * @param amount Amount to gain, default 1
130
+ * @returns the record of coins to earn (only positive values)
131
+ */
101
132
  Money.prototype.gain = function (amount) {
102
133
  if (amount === void 0) { amount = 1; }
103
134
  var gain = this.record;
@@ -107,6 +138,12 @@ var Money = (function () {
107
138
  });
108
139
  return gain;
109
140
  };
141
+ /**
142
+ * Return the best way to spend an amount of owned units, prioritizing the smallest unit values
143
+ * @param owned Amount of units owned before spending
144
+ * @param amount Amount to gain, default 1
145
+ * @returns the record of coins to give away and eventually take (positive and negative values)
146
+ */
110
147
  Money.prototype.spend = function (owned, amount) {
111
148
  if (amount === void 0) { amount = 1; }
112
149
  var delta = (0, mapValues_1.default)(owned, function (_) { return 0; });
@@ -1 +1 @@
1
- {"version":3,"file":"money.util.js","sourceRoot":"","sources":["../../src/utils/money.util.ts"],"names":[],"mappings":";;;;;;AAAA,qEAA8C;AAC9C,2DAAoC;AACpC,uDAAgC;AAChC,+DAAwC;AACxC,uDAAgC;AAMhC;IACE,eAAoB,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;QAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK,CAAC,CAAA;IAClC,CAAC;IAOD,qBAAK,GAAL,UAAM,QAAkB;QACtB,OAAO,IAAA,eAAK,EAAC,QAAQ,CAAC,QAAQ,EAAQ,EAAE,UAAA,IAAI,gBAAI,OAAA,CAAC,MAAA,IAAI,CAAC,EAAE,mCAAI,CAAC,CAAC,GAAG,CAAC,MAAA,IAAI,CAAC,QAAQ,mCAAI,CAAC,CAAC,CAAA,EAAA,CAAC,CAAA;IACxF,CAAC;IASD,8BAAc,GAAd,UAAe,QAAkB,EAAE,QAAkB,EAAE,MAAc;QACnE,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,UAAA,CAAC,IAAI,OAAA,IAAA,iBAAO,EAAC,CAAC,EAAE,QAAQ,CAAC,EAApB,CAAoB,CAAC,CAAA;QACvD,IAAM,KAAK,GAAmB,EAAE,CAAA;QAChC,IAAM,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAA,mBAAS,EAAC,IAAA,eAAK,EAAC,IAAI,CAAC,KAAK,CAAC,EAAE,UAAA,IAAI,IAAI,OAAA,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,E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