@gamepark/rules-api 6.38.5 → 7.0.0-beta.1

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 (253) 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 -9
  5. package/dist/Competitive.js.map +1 -1
  6. package/dist/Eliminations.js +2 -6
  7. package/dist/Eliminations.js.map +1 -1
  8. package/dist/GameSetup.js +1 -2
  9. package/dist/HiddenInformation.js +2 -6
  10. package/dist/HiddenInformation.js.map +1 -1
  11. package/dist/LocalMovePreview.js +1 -5
  12. package/dist/LocalMovePreview.js.map +1 -1
  13. package/dist/RandomMove.js +1 -2
  14. package/dist/Rules.js +49 -59
  15. package/dist/Rules.js.map +1 -1
  16. package/dist/SecretInformation.d.ts +11 -0
  17. package/dist/SecretInformation.js +2 -6
  18. package/dist/SecretInformation.js.map +1 -1
  19. package/dist/TimeLimit.js +1 -5
  20. package/dist/TimeLimit.js.map +1 -1
  21. package/dist/Undo.js +2 -6
  22. package/dist/Undo.js.map +1 -1
  23. package/dist/UnpredictableMove.js +1 -5
  24. package/dist/UnpredictableMove.js.map +1 -1
  25. package/dist/index.js +16 -32
  26. package/dist/index.js.map +1 -1
  27. package/dist/material/HiddenMaterialRules.d.ts +1 -1
  28. package/dist/material/HiddenMaterialRules.js +125 -189
  29. package/dist/material/HiddenMaterialRules.js.map +1 -1
  30. package/dist/material/MaterialGame.js +1 -2
  31. package/dist/material/MaterialGameSetup.js +52 -70
  32. package/dist/material/MaterialGameSetup.js.map +1 -1
  33. package/dist/material/MaterialRules.d.ts +1 -1
  34. package/dist/material/MaterialRules.js +186 -255
  35. package/dist/material/MaterialRules.js.map +1 -1
  36. package/dist/material/SecretMaterialRules.js +9 -35
  37. package/dist/material/SecretMaterialRules.js.map +1 -1
  38. package/dist/material/index.js +11 -27
  39. package/dist/material/index.js.map +1 -1
  40. package/dist/material/items/Material.js +177 -268
  41. package/dist/material/items/Material.js.map +1 -1
  42. package/dist/material/items/MaterialDeck.js +10 -36
  43. package/dist/material/items/MaterialDeck.js.map +1 -1
  44. package/dist/material/items/MaterialItem.js +1 -2
  45. package/dist/material/items/MaterialMoney.js +89 -147
  46. package/dist/material/items/MaterialMoney.js.map +1 -1
  47. package/dist/material/items/MaterialMutator.js +108 -149
  48. package/dist/material/items/MaterialMutator.js.map +1 -1
  49. package/dist/material/items/index.js +5 -21
  50. package/dist/material/items/index.js.map +1 -1
  51. package/dist/material/location/Location.js +1 -14
  52. package/dist/material/location/Location.js.map +1 -1
  53. package/dist/material/location/LocationBuilder.js +26 -41
  54. package/dist/material/location/LocationBuilder.js.map +1 -1
  55. package/dist/material/location/index.js +3 -19
  56. package/dist/material/location/index.js.map +1 -1
  57. package/dist/material/location/strategy/FillGapStrategy.js +9 -16
  58. package/dist/material/location/strategy/FillGapStrategy.js.map +1 -1
  59. package/dist/material/location/strategy/LocationStrategy.js +1 -2
  60. package/dist/material/location/strategy/PositiveSequenceStrategy.js +26 -35
  61. package/dist/material/location/strategy/PositiveSequenceStrategy.js.map +1 -1
  62. package/dist/material/location/strategy/StackingStrategy.js +15 -22
  63. package/dist/material/location/strategy/StackingStrategy.js.map +1 -1
  64. package/dist/material/location/strategy/index.js +5 -23
  65. package/dist/material/location/strategy/index.js.map +1 -1
  66. package/dist/material/memory/GameMemory.js +10 -14
  67. package/dist/material/memory/GameMemory.js.map +1 -1
  68. package/dist/material/memory/PlayerMemory.js +13 -18
  69. package/dist/material/memory/PlayerMemory.js.map +1 -1
  70. package/dist/material/memory/index.js +2 -18
  71. package/dist/material/memory/index.js.map +1 -1
  72. package/dist/material/moves/CustomMove.js +4 -9
  73. package/dist/material/moves/CustomMove.js.map +1 -1
  74. package/dist/material/moves/MaterialMove.js +1 -2
  75. package/dist/material/moves/MaterialMoveBuilder.js +16 -32
  76. package/dist/material/moves/MaterialMoveBuilder.js.map +1 -1
  77. package/dist/material/moves/MoveKind.js +2 -5
  78. package/dist/material/moves/MoveKind.js.map +1 -1
  79. package/dist/material/moves/index.js +7 -23
  80. package/dist/material/moves/index.js.map +1 -1
  81. package/dist/material/moves/items/CreateItem.js +6 -13
  82. package/dist/material/moves/items/CreateItem.js.map +1 -1
  83. package/dist/material/moves/items/CreateItemsAtOnce.js +6 -13
  84. package/dist/material/moves/items/CreateItemsAtOnce.js.map +1 -1
  85. package/dist/material/moves/items/DeleteItem.js +6 -13
  86. package/dist/material/moves/items/DeleteItem.js.map +1 -1
  87. package/dist/material/moves/items/DeleteItemsAtOnce.js +6 -13
  88. package/dist/material/moves/items/DeleteItemsAtOnce.js.map +1 -1
  89. package/dist/material/moves/items/ItemMove.js +1 -2
  90. package/dist/material/moves/items/ItemMoveType.js +2 -5
  91. package/dist/material/moves/items/ItemMoveType.js.map +1 -1
  92. package/dist/material/moves/items/MoveItem.js +6 -13
  93. package/dist/material/moves/items/MoveItem.js.map +1 -1
  94. package/dist/material/moves/items/MoveItemsAtOnce.js +6 -13
  95. package/dist/material/moves/items/MoveItemsAtOnce.js.map +1 -1
  96. package/dist/material/moves/items/RollItem.js +6 -13
  97. package/dist/material/moves/items/RollItem.js.map +1 -1
  98. package/dist/material/moves/items/SelectItem.js +6 -13
  99. package/dist/material/moves/items/SelectItem.js.map +1 -1
  100. package/dist/material/moves/items/Shuffle.js +7 -15
  101. package/dist/material/moves/items/Shuffle.js.map +1 -1
  102. package/dist/material/moves/items/index.js +11 -27
  103. package/dist/material/moves/items/index.js.map +1 -1
  104. package/dist/material/moves/local/CloseTutorialPopup.js +4 -8
  105. package/dist/material/moves/local/CloseTutorialPopup.js.map +1 -1
  106. package/dist/material/moves/local/DisplayHelp.js +2 -5
  107. package/dist/material/moves/local/DisplayHelp.js.map +1 -1
  108. package/dist/material/moves/local/DropItem.js +1 -2
  109. package/dist/material/moves/local/LocalMove.js +2 -5
  110. package/dist/material/moves/local/LocalMove.js.map +1 -1
  111. package/dist/material/moves/local/SetTutorialStep.js +4 -8
  112. package/dist/material/moves/local/SetTutorialStep.js.map +1 -1
  113. package/dist/material/moves/local/index.js +5 -21
  114. package/dist/material/moves/local/index.js.map +1 -1
  115. package/dist/material/moves/rules/EndGame.js +4 -8
  116. package/dist/material/moves/rules/EndGame.js.map +1 -1
  117. package/dist/material/moves/rules/EndPlayerTurn.js +4 -8
  118. package/dist/material/moves/rules/EndPlayerTurn.js.map +1 -1
  119. package/dist/material/moves/rules/RuleMove.js +3 -7
  120. package/dist/material/moves/rules/RuleMove.js.map +1 -1
  121. package/dist/material/moves/rules/StartPlayerTurn.js +4 -8
  122. package/dist/material/moves/rules/StartPlayerTurn.js.map +1 -1
  123. package/dist/material/moves/rules/StartRule.js +4 -8
  124. package/dist/material/moves/rules/StartRule.js.map +1 -1
  125. package/dist/material/moves/rules/StartSimultaneousRule.js +4 -8
  126. package/dist/material/moves/rules/StartSimultaneousRule.js.map +1 -1
  127. package/dist/material/moves/rules/index.js +6 -22
  128. package/dist/material/moves/rules/index.js.map +1 -1
  129. package/dist/material/rules/MaterialRulesPart.d.ts +1 -1
  130. package/dist/material/rules/MaterialRulesPart.js +38 -63
  131. package/dist/material/rules/MaterialRulesPart.js.map +1 -1
  132. package/dist/material/rules/PlayerTurnRule.js +20 -52
  133. package/dist/material/rules/PlayerTurnRule.js.map +1 -1
  134. package/dist/material/rules/RuleStep.js +1 -2
  135. package/dist/material/rules/SimultaneousRule.js +19 -51
  136. package/dist/material/rules/SimultaneousRule.js.map +1 -1
  137. package/dist/material/rules/index.js +4 -20
  138. package/dist/material/rules/index.js.map +1 -1
  139. package/dist/material/tutorial/TutorialState.js +1 -2
  140. package/dist/material/tutorial/index.js +1 -17
  141. package/dist/material/tutorial/index.js.map +1 -1
  142. package/dist/options/EnumArrayOption.js +3 -7
  143. package/dist/options/EnumArrayOption.js.map +1 -1
  144. package/dist/options/EnumOption.js +1 -5
  145. package/dist/options/EnumOption.js.map +1 -1
  146. package/dist/options/Option.js +1 -2
  147. package/dist/options/OptionSpecOf.js +1 -2
  148. package/dist/options/OptionsSpec.js +1 -2
  149. package/dist/options/OptionsValidationError.js +6 -28
  150. package/dist/options/OptionsValidationError.js.map +1 -1
  151. package/dist/options/PlayerEnumOption.js +19 -33
  152. package/dist/options/PlayerEnumOption.js.map +1 -1
  153. package/dist/options/PlayersOptionsSpec.js +1 -2
  154. package/dist/options/WithIdOption.js +1 -2
  155. package/dist/options/WithPlayerOptionsSpec.js +1 -5
  156. package/dist/options/WithPlayerOptionsSpec.js.map +1 -1
  157. package/dist/options/WithPlayersOptions.js +1 -2
  158. package/dist/options/index.js +12 -28
  159. package/dist/options/index.js.map +1 -1
  160. package/dist/options/isWithPlayerIdOptions.js +3 -7
  161. package/dist/options/isWithPlayerIdOptions.js.map +1 -1
  162. package/dist/utils/action-view.util.js +18 -26
  163. package/dist/utils/action-view.util.js.map +1 -1
  164. package/dist/utils/action.util.js +11 -17
  165. package/dist/utils/action.util.js.map +1 -1
  166. package/dist/utils/adjacent-groups.util.js +33 -42
  167. package/dist/utils/adjacent-groups.util.js.map +1 -1
  168. package/dist/utils/automatic-moves.util.js +10 -16
  169. package/dist/utils/automatic-moves.util.js.map +1 -1
  170. package/dist/utils/enum.util.js +7 -14
  171. package/dist/utils/enum.util.js.map +1 -1
  172. package/dist/utils/game-view.util.js +5 -9
  173. package/dist/utils/game-view.util.js.map +1 -1
  174. package/dist/utils/grid.hex.util.js +36 -88
  175. package/dist/utils/grid.hex.util.js.map +1 -1
  176. package/dist/utils/grid.squares.util.js +8 -19
  177. package/dist/utils/grid.squares.util.js.map +1 -1
  178. package/dist/utils/grid.util.js +1 -5
  179. package/dist/utils/grid.util.js.map +1 -1
  180. package/dist/utils/index.js +16 -32
  181. package/dist/utils/index.js.map +1 -1
  182. package/dist/utils/listing.util.js +8 -14
  183. package/dist/utils/listing.util.js.map +1 -1
  184. package/dist/utils/loops.util.js +3 -7
  185. package/dist/utils/loops.util.js.map +1 -1
  186. package/dist/utils/money.util.js +54 -79
  187. package/dist/utils/money.util.js.map +1 -1
  188. package/dist/utils/neighbors.util.js +6 -11
  189. package/dist/utils/neighbors.util.js.map +1 -1
  190. package/dist/utils/polyhex.util.js +36 -56
  191. package/dist/utils/polyhex.util.js.map +1 -1
  192. package/dist/utils/random.util.js +2 -6
  193. package/dist/utils/random.util.js.map +1 -1
  194. package/dist/utils/rank.util.js +9 -13
  195. package/dist/utils/rank.util.js.map +1 -1
  196. package/package.json +38 -38
  197. package/dist/ApplyAutomaticMoves.d.ts +0 -2
  198. package/dist/ApplyAutomaticMoves.js +0 -25
  199. package/dist/ApplyAutomaticMoves.js.map +0 -1
  200. package/dist/DefaultGameSetup.d.ts +0 -7
  201. package/dist/DefaultGameSetup.js +0 -15
  202. package/dist/DefaultGameSetup.js.map +0 -1
  203. package/dist/Dummy.d.ts +0 -7
  204. package/dist/Dummy.js +0 -27
  205. package/dist/Dummy.js.map +0 -1
  206. package/dist/GameSetupCreator.d.ts +0 -4
  207. package/dist/GameSetupCreator.js +0 -3
  208. package/dist/GameSetupCreator.js.map +0 -1
  209. package/dist/IncompleteInformation.d.ts +0 -14
  210. package/dist/IncompleteInformation.js +0 -38
  211. package/dist/IncompleteInformation.js.map +0 -1
  212. package/dist/LoopWithFuse.d.ts +0 -4
  213. package/dist/LoopWithFuse.js +0 -15
  214. package/dist/LoopWithFuse.js.map +0 -1
  215. package/dist/Robot.d.ts +0 -1
  216. package/dist/Robot.js +0 -3
  217. package/dist/Robot.js.map +0 -1
  218. package/dist/RulesCreator.d.ts +0 -7
  219. package/dist/RulesCreator.js +0 -3
  220. package/dist/RulesCreator.js.map +0 -1
  221. package/dist/material/location/strategy/StakingStrategy.d.ts +0 -12
  222. package/dist/material/location/strategy/StakingStrategy.js +0 -32
  223. package/dist/material/location/strategy/StakingStrategy.js.map +0 -1
  224. package/dist/material/moves/items/ItemMovesBuilder.d.ts +0 -8
  225. package/dist/material/moves/items/ItemMovesBuilder.js +0 -34
  226. package/dist/material/moves/items/ItemMovesBuilder.js.map +0 -1
  227. package/dist/material/rules/MaterialMoveBuilder.d.ts +0 -9
  228. package/dist/material/rules/MaterialMoveBuilder.js +0 -28
  229. package/dist/material/rules/MaterialMoveBuilder.js.map +0 -1
  230. package/dist/material/rules/MaterialRulesMovesBuilder.d.ts +0 -12
  231. package/dist/material/rules/MaterialRulesMovesBuilder.js +0 -36
  232. package/dist/material/rules/MaterialRulesMovesBuilder.js.map +0 -1
  233. package/dist/setup/DefaultGameSetup.d.ts +0 -7
  234. package/dist/setup/DefaultGameSetup.js +0 -15
  235. package/dist/setup/DefaultGameSetup.js.map +0 -1
  236. package/dist/setup/GameSetup.d.ts +0 -3
  237. package/dist/setup/GameSetup.js +0 -3
  238. package/dist/setup/GameSetup.js.map +0 -1
  239. package/dist/setup/GameSetupCreator.d.ts +0 -4
  240. package/dist/setup/GameSetupCreator.js +0 -3
  241. package/dist/setup/GameSetupCreator.js.map +0 -1
  242. package/dist/setup/index.d.ts +0 -2
  243. package/dist/setup/index.js +0 -19
  244. package/dist/setup/index.js.map +0 -1
  245. package/dist/utils/EnumUtils.d.ts +0 -1
  246. package/dist/utils/EnumUtils.js +0 -8
  247. package/dist/utils/EnumUtils.js.map +0 -1
  248. package/dist/utils/coordinates.util.d.ts +0 -5
  249. package/dist/utils/coordinates.util.js +0 -16
  250. package/dist/utils/coordinates.util.js.map +0 -1
  251. package/dist/utils/isDeadEndMove.util.d.ts +0 -2
  252. package/dist/utils/isDeadEndMove.util.js +0 -19
  253. package/dist/utils/isDeadEndMove.util.js.map +0 -1
package/dist/Action.js CHANGED
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=Action.js.map
package/dist/Bot.js CHANGED
@@ -1,46 +1,26 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.RandomBot = exports.Bot = void 0;
19
1
  /**
20
2
  * A Bot is a player controlled by a machine for a game.
21
3
  * Used to replace players that quit a game, or for opponents in tutorials.
22
4
  * Could be used to create AI players.
23
5
  */
24
- var Bot = /** @class */ (function () {
25
- function Bot(player) {
6
+ export class Bot {
7
+ player;
8
+ constructor(player) {
26
9
  this.player = player;
27
10
  }
28
- return Bot;
29
- }());
30
- exports.Bot = Bot;
11
+ }
31
12
  /**
32
13
  * A random bot picks a random move to play amongst all the legal moves.
33
14
  * Most board games can list efficiently all the legal moves all the time, which allows to have random bot to replace any missing opponent.
34
15
  */
35
- var RandomBot = /** @class */ (function (_super) {
36
- __extends(RandomBot, _super);
37
- function RandomBot(Rules, player) {
38
- var _this = _super.call(this, player) || this;
39
- _this.Rules = Rules;
40
- return _this;
16
+ export class RandomBot extends Bot {
17
+ Rules;
18
+ constructor(Rules, player) {
19
+ super(player);
20
+ this.Rules = Rules;
41
21
  }
42
- RandomBot.prototype.run = function (game) {
43
- var moves = this.getLegalMoves(game);
22
+ run(game) {
23
+ const moves = this.getLegalMoves(game);
44
24
  switch (moves.length) {
45
25
  case 0:
46
26
  console.warn('Random bot requires at least one legal move from getLegalMoves to run');
@@ -50,7 +30,7 @@ var RandomBot = /** @class */ (function (_super) {
50
30
  default:
51
31
  return [moves[Math.floor(Math.random() * moves.length)]];
52
32
  }
53
- };
33
+ }
54
34
  /**
55
35
  * The legal moves for this player at this game state.
56
36
  * Can be overridden if you need to further restrict the moves you want the bot to play.
@@ -58,10 +38,8 @@ var RandomBot = /** @class */ (function (_super) {
58
38
  * @param game The game state
59
39
  * @protected
60
40
  */
61
- RandomBot.prototype.getLegalMoves = function (game) {
41
+ getLegalMoves(game) {
62
42
  return new this.Rules(game).getLegalMoves(this.player);
63
- };
64
- return RandomBot;
65
- }(Bot));
66
- exports.RandomBot = RandomBot;
43
+ }
44
+ }
67
45
  //# sourceMappingURL=Bot.js.map
package/dist/Bot.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Bot.js","sourceRoot":"","sources":["../src/Bot.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA;;;;GAIG;AACH;IACE,aAAgC,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAC9C,CAAC;IAQH,UAAC;AAAD,CAAC,AAVD,IAUC;AAVqB,kBAAG;AAYzB;;;GAGG;AACH;IAAqE,6BAAG;IACtE,mBAAoB,KAAuC,EAAE,MAAc;QACzE,YAAA,MAAK,YAAC,MAAM,CAAC,SAAA;QADK,WAAK,GAAL,KAAK,CAAkC;;IAE3D,CAAC;IAED,uBAAG,GAAH,UAAI,IAAU;QACZ,IAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;QACtC,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;YACrB,KAAK,CAAC;gBACJ,OAAO,CAAC,IAAI,CAAC,uEAAuE,CAAC,CAAA;gBACrF,OAAO,EAAE,CAAA;YACX,KAAK,CAAC;gBACJ,OAAO,KAAK,CAAA;YACd;gBACE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAC5D,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACO,iCAAa,GAAvB,UAAwB,IAAU;QAChC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACxD,CAAC;IACH,gBAAC;AAAD,CAAC,AA5BD,CAAqE,GAAG,GA4BvE;AA5BY,8BAAS"}
1
+ {"version":3,"file":"Bot.js","sourceRoot":"","sources":["../src/Bot.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAgB,GAAG;IACS;IAAhC,YAAgC,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAC9C,CAAC;CAQF;AAED;;;GAGG;AACH,MAAM,OAAO,SAAgD,SAAQ,GAAG;IAClD;IAApB,YAAoB,KAAuC,EAAE,MAAc;QACzE,KAAK,CAAC,MAAM,CAAC,CAAA;QADK,UAAK,GAAL,KAAK,CAAkC;IAE3D,CAAC;IAED,GAAG,CAAC,IAAU;QACZ,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;QACtC,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;YACrB,KAAK,CAAC;gBACJ,OAAO,CAAC,IAAI,CAAC,uEAAuE,CAAC,CAAA;gBACrF,OAAO,EAAE,CAAA;YACX,KAAK,CAAC;gBACJ,OAAO,KAAK,CAAA;YACd;gBACE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAC5D,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACO,aAAa,CAAC,IAAU;QAChC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACxD,CAAC;CACF"}
@@ -1,31 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isCompetitiveRank = exports.isCompetitiveScore = exports.isCompetitive = void 0;
4
1
  /**
5
2
  * Type guard to identify if a game's Rule is Competitive or not.
6
3
  * @param rules game's Rule
7
4
  * @returns true if the game is competitive
8
5
  */
9
- function isCompetitive(rules) {
6
+ export function isCompetitive(rules) {
10
7
  return isCompetitiveScore(rules) || isCompetitiveRank(rules);
11
8
  }
12
- exports.isCompetitive = isCompetitive;
13
9
  /**
14
10
  * Type guard to identify if a game's Rule provide scores for players.
15
11
  * @param rules game's Rule
16
12
  * @returns true if the game is competitive with scores
17
13
  */
18
- function isCompetitiveScore(rules) {
14
+ export function isCompetitiveScore(rules) {
19
15
  return typeof rules.getScore === 'function';
20
16
  }
21
- exports.isCompetitiveScore = isCompetitiveScore;
22
17
  /**
23
18
  * Type guard to identify if a game's Rule can rank the players.
24
19
  * @param rules game's Rule
25
20
  * @returns true if the game is competitive with ranking (used when scores are not available)
26
21
  */
27
- function isCompetitiveRank(rules) {
22
+ export function isCompetitiveRank(rules) {
28
23
  return typeof rules.rankPlayers === 'function';
29
24
  }
30
- exports.isCompetitiveRank = isCompetitiveRank;
31
25
  //# sourceMappingURL=Competitive.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Competitive.js","sourceRoot":"","sources":["../src/Competitive.ts"],"names":[],"mappings":";;;AA8CA;;;;GAIG;AACH,SAAgB,aAAa,CAAuB,KAAgC;IAClF,OAAO,kBAAkB,CAAC,KAAK,CAAC,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAA;AAC9D,CAAC;AAFD,sCAEC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAuB,KAAgC;IACvF,OAAO,OAAQ,KAAgD,CAAC,QAAQ,KAAK,UAAU,CAAA;AACzF,CAAC;AAFD,gDAEC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAuB,KAAgC;IACtF,OAAO,OAAQ,KAA+C,CAAC,WAAW,KAAK,UAAU,CAAA;AAC3F,CAAC;AAFD,8CAEC"}
1
+ {"version":3,"file":"Competitive.js","sourceRoot":"","sources":["../src/Competitive.ts"],"names":[],"mappings":"AA8CA;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAuB,KAAgC;IAClF,OAAO,kBAAkB,CAAC,KAAK,CAAC,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAA;AAC9D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAuB,KAAgC;IACvF,OAAO,OAAQ,KAAgD,CAAC,QAAQ,KAAK,UAAU,CAAA;AACzF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAuB,KAAgC;IACtF,OAAO,OAAQ,KAA+C,CAAC,WAAW,KAAK,UAAU,CAAA;AAC3F,CAAC"}
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasEliminations = void 0;
4
1
  /**
5
2
  * Type guard for {@link Eliminations} interface
6
3
  * @param rules Rules of a game
7
4
  * @returns true if the Rules implements {@link Eliminations}
8
5
  */
9
- function hasEliminations(rules) {
10
- var test = rules;
6
+ export function hasEliminations(rules) {
7
+ const test = rules;
11
8
  return typeof test.isEliminated === 'function';
12
9
  }
13
- exports.hasEliminations = hasEliminations;
14
10
  //# sourceMappingURL=Eliminations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Eliminations.js","sourceRoot":"","sources":["../src/Eliminations.ts"],"names":[],"mappings":";;;AAkBA;;;;GAIG;AACH,SAAgB,eAAe,CAAiB,KAAa;IAC3D,IAAM,IAAI,GAAG,KAAqC,CAAA;IAClD,OAAO,OAAO,IAAI,CAAC,YAAY,KAAK,UAAU,CAAA;AAChD,CAAC;AAHD,0CAGC"}
1
+ {"version":3,"file":"Eliminations.js","sourceRoot":"","sources":["../src/Eliminations.ts"],"names":[],"mappings":"AAkBA;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAiB,KAAa;IAC3D,MAAM,IAAI,GAAG,KAAqC,CAAA;IAClD,OAAO,OAAO,IAAI,CAAC,YAAY,KAAK,UAAU,CAAA;AAChD,CAAC"}
package/dist/GameSetup.js CHANGED
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=GameSetup.js.map
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasHiddenInformation = void 0;
4
1
  /**
5
2
  * Type guard for games with hidden information
6
3
  * @param rules Rules of the game
7
4
  * @returns true if the game implements {@link HiddenInformation}
8
5
  */
9
- function hasHiddenInformation(rules) {
10
- var test = rules;
6
+ export function hasHiddenInformation(rules) {
7
+ const test = rules;
11
8
  return typeof test.getView === 'function' && typeof test.getMoveView === 'function';
12
9
  }
13
- exports.hasHiddenInformation = hasHiddenInformation;
14
10
  //# sourceMappingURL=HiddenInformation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HiddenInformation.js","sourceRoot":"","sources":["../src/HiddenInformation.ts"],"names":[],"mappings":";;;AAuBA;;;;GAIG;AACH,SAAgB,oBAAoB,CAA6C,KAAa;IAC5F,IAAM,IAAI,GAAG,KAAoD,CAAA;IACjE,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,UAAU,CAAA;AACrF,CAAC;AAHD,oDAGC"}
1
+ {"version":3,"file":"HiddenInformation.js","sourceRoot":"","sources":["../src/HiddenInformation.ts"],"names":[],"mappings":"AAuBA;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAA6C,KAAa;IAC5F,MAAM,IAAI,GAAG,KAAoD,CAAA;IACjE,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,UAAU,CAAA;AACrF,CAAC"}
@@ -1,13 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasLocalMovePreview = void 0;
4
1
  /**
5
2
  * Type guard for {@link LocalMovePreview} interface
6
3
  * @param rules The game's rules
7
4
  * @return true if the rules implements {@link LocalMovePreview}
8
5
  */
9
- function hasLocalMovePreview(rules) {
6
+ export function hasLocalMovePreview(rules) {
10
7
  return typeof rules.previewMove === 'function';
11
8
  }
12
- exports.hasLocalMovePreview = hasLocalMovePreview;
13
9
  //# sourceMappingURL=LocalMovePreview.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LocalMovePreview.js","sourceRoot":"","sources":["../src/LocalMovePreview.ts"],"names":[],"mappings":";;;AAaA;;;;GAIG;AACH,SAAgB,mBAAmB,CAAa,KAAa;IAC3D,OAAO,OAAQ,KAAgC,CAAC,WAAW,KAAK,UAAU,CAAA;AAC5E,CAAC;AAFD,kDAEC"}
1
+ {"version":3,"file":"LocalMovePreview.js","sourceRoot":"","sources":["../src/LocalMovePreview.ts"],"names":[],"mappings":"AAaA;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAa,KAAa;IAC3D,OAAO,OAAQ,KAAgC,CAAC,WAAW,KAAK,UAAU,CAAA;AAC5E,CAAC"}
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=RandomMove.js.map
package/dist/Rules.js CHANGED
@@ -1,11 +1,5 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Rules = void 0;
7
- var isEqual_1 = __importDefault(require("lodash/isEqual"));
8
- var Eliminations_1 = require("./Eliminations");
1
+ import { isEqual } from 'es-toolkit';
2
+ import { hasEliminations } from './Eliminations';
9
3
  /**
10
4
  * The Rules class is the basic minimal API to implement when adapting a board game on Game Park.
11
5
  * It has the ability to tell whether it is a player's turn to play, what moves are legal, what happens when a move is played, and when the game is over.
@@ -14,33 +8,33 @@ var Eliminations_1 = require("./Eliminations");
14
8
  * @typeparam Move - Data structure of a game move
15
9
  * @typeparam PlayerId - type of the player's identifiers. Usually a number or a numeric enum.
16
10
  */
17
- var Rules = /** @class */ (function () {
11
+ export class Rules {
12
+ /**
13
+ * The state of the game
14
+ */
15
+ game;
18
16
  /**
19
17
  * Construct a new instance of the Rules to work on a game state
20
18
  * @param game the state of the game to work on
21
19
  */
22
- function Rules(game) {
20
+ constructor(game) {
23
21
  this.game = game;
24
22
  }
25
- Object.defineProperty(Rules.prototype, "state", {
26
- /**
27
- * A shortcut for this.game for backward compatibility
28
- */
29
- get: function () {
30
- return this.game;
31
- },
32
- enumerable: false,
33
- configurable: true
34
- });
23
+ /**
24
+ * A shortcut for this.game for backward compatibility
25
+ */
26
+ get state() {
27
+ return this.game;
28
+ }
35
29
  /**
36
30
  * The delegation allows to split the rules in smaller and simpler parts.
37
31
  * Override this method to delegate the behavior of the other method to another Rules class.
38
32
  *
39
33
  * @return the Rule you want to delegate the current game behavior to
40
34
  */
41
- Rules.prototype.delegate = function () {
35
+ delegate() {
42
36
  return;
43
- };
37
+ }
44
38
  /**
45
39
  * The delegation allows to split the rules in smaller and simpler parts.
46
40
  * Default behavior call {@link delegate} and returns either an empty array, or an array with the delegate if any.
@@ -48,10 +42,10 @@ var Rules = /** @class */ (function () {
48
42
  *
49
43
  * @return an array of Rules to delegate the current game behavior to
50
44
  */
51
- Rules.prototype.delegates = function () {
52
- var delegate = this.delegate();
45
+ delegates() {
46
+ const delegate = this.delegate();
53
47
  return delegate ? [delegate] : [];
54
- };
48
+ }
55
49
  /**
56
50
  * Implement this to tell at any point in the game which player is active or not.
57
51
  * When it's a player's turn, his thinking time decreases.
@@ -61,28 +55,27 @@ var Rules = /** @class */ (function () {
61
55
  * @param playerId - Identifier of a player
62
56
  * @returns true if it is this player's turn to play
63
57
  */
64
- Rules.prototype.isTurnToPlay = function (playerId) {
65
- var rules = this.delegates();
66
- if (rules.some(function (rules) { return rules.isTurnToPlay(playerId); })) {
58
+ isTurnToPlay(playerId) {
59
+ const rules = this.delegates();
60
+ if (rules.some(rules => rules.isTurnToPlay(playerId))) {
67
61
  return true;
68
62
  }
69
63
  return playerId === this.getActivePlayer();
70
- };
64
+ }
71
65
  /**
72
66
  * When only one player is active at a time, you can implement this method instead of "isTurnToPlay" to tell which player is active.
73
67
  * Supports delegation: if any {@link delegates} returns an active player, it will return it.
74
68
  *
75
69
  * @return @typeParam PlayerId - The identifier of the active player
76
70
  */
77
- Rules.prototype.getActivePlayer = function () {
78
- for (var _i = 0, _a = this.delegates(); _i < _a.length; _i++) {
79
- var delegate = _a[_i];
80
- var activePlayer = delegate.getActivePlayer();
71
+ getActivePlayer() {
72
+ for (const delegate of this.delegates()) {
73
+ const activePlayer = delegate.getActivePlayer();
81
74
  if (activePlayer !== undefined)
82
75
  return activePlayer;
83
76
  }
84
77
  return;
85
- };
78
+ }
86
79
  /**
87
80
  * This method allows the Game Park server to authorise only valid moves in accordance with the game rules.
88
81
  * The default behavior calls {@link getLegalMoves}, and returns true when at least one move is equal.
@@ -92,19 +85,19 @@ var Rules = /** @class */ (function () {
92
85
  * @param move - a Move to control
93
86
  * @returns true if the move can be played by this player
94
87
  */
95
- Rules.prototype.isLegalMove = function (playerId, move) {
96
- var rules = this.delegates();
97
- if (rules.some(function (rules) { return rules.isLegalMove(playerId, move); })) {
88
+ isLegalMove(playerId, move) {
89
+ const rules = this.delegates();
90
+ if (rules.some(rules => rules.isLegalMove(playerId, move))) {
98
91
  return true;
99
92
  }
100
- if (this.getLegalMoves(playerId).some(function (legalMove) { return (0, isEqual_1.default)(move, legalMove); })) {
93
+ if (this.getLegalMoves(playerId).some(legalMove => isEqual(move, legalMove))) {
101
94
  return true;
102
95
  }
103
- if ((0, Eliminations_1.hasEliminations)(this) && this.giveUpMove) {
104
- return (0, isEqual_1.default)(move, this.giveUpMove(playerId));
96
+ if (hasEliminations(this) && this.giveUpMove) {
97
+ return isEqual(move, this.giveUpMove(playerId));
105
98
  }
106
99
  return false;
107
- };
100
+ }
108
101
  /**
109
102
  * This method lists all the moves that are legal for a given player.
110
103
  * This is optional but convenient: it is used by {@link isLegalMove}, {@link Bot} and many UI features from @gamepark/react-game to automatically
@@ -117,9 +110,9 @@ var Rules = /** @class */ (function () {
117
110
  * @param playerId - Identifier of a player
118
111
  * @returns the list of the moves
119
112
  */
120
- Rules.prototype.getLegalMoves = function (playerId) {
121
- return this.delegates().flatMap(function (rules) { return rules.getLegalMoves(playerId); });
122
- };
113
+ getLegalMoves(playerId) {
114
+ return this.delegates().flatMap(rules => rules.getLegalMoves(playerId));
115
+ }
123
116
  /**
124
117
  * When some game state require automatic actions to be taken by the players, you can return a list of moves to play played automatically.
125
118
  * It can be a sequences in the rules where everything is scripted for instance (no choices left for players).
@@ -128,9 +121,9 @@ var Rules = /** @class */ (function () {
128
121
  *
129
122
  * @returns the list of the moves that must be played automatically
130
123
  */
131
- Rules.prototype.getAutomaticMoves = function () {
132
- return this.delegates().flatMap(function (rules) { return rules.getAutomaticMoves(); });
133
- };
124
+ getAutomaticMoves() {
125
+ return this.delegates().flatMap(rules => rules.getAutomaticMoves());
126
+ }
134
127
  /**
135
128
  * Executes a move on current game state.
136
129
  * This method is the only one that should mutate the state of the game.
@@ -148,9 +141,9 @@ var Rules = /** @class */ (function () {
148
141
  * @param context - context of execution: see {@link PlayMoveContext}
149
142
  * @returns A list of moves that should be immediately played as consequences of this move
150
143
  */
151
- Rules.prototype.play = function (move, context) {
152
- return this.delegates().flatMap(function (rules) { return rules.play(move, context); });
153
- };
144
+ play(move, context) {
145
+ return this.delegates().flatMap(rules => rules.play(move, context));
146
+ }
154
147
  /**
155
148
  * This method must return true when the game is over.
156
149
  *
@@ -160,18 +153,15 @@ var Rules = /** @class */ (function () {
160
153
  * @param playerIds - All the player ids in the game. Do not use (deprecated).
161
154
  * @returns true if game is over
162
155
  */
163
- Rules.prototype.isOver = function (playerIds) {
164
- var _this = this;
165
- var delegates = this.delegates();
166
- if (delegates.length > 0 && delegates.every(function (delegate) { return delegate.isOver(playerIds); })) {
156
+ isOver(playerIds) {
157
+ const delegates = this.delegates();
158
+ if (delegates.length > 0 && delegates.every(delegate => delegate.isOver(playerIds))) {
167
159
  return true;
168
160
  }
169
161
  if (playerIds) {
170
- return !playerIds.some(function (playerId) { return _this.isTurnToPlay(playerId); });
162
+ return !playerIds.some(playerId => this.isTurnToPlay(playerId));
171
163
  }
172
164
  return this.getActivePlayer() === undefined;
173
- };
174
- return Rules;
175
- }());
176
- exports.Rules = Rules;
165
+ }
166
+ }
177
167
  //# sourceMappingURL=Rules.js.map
package/dist/Rules.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Rules.js","sourceRoot":"","sources":["../src/Rules.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAoC;AACpC,+CAAgD;AAEhD;;;;;;;GAOG;AACH;IAME;;;OAGG;IACH,eAAY,IAAU;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAKD,sBAAI,wBAAK;QAHT;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,IAAI,CAAA;QAClB,CAAC;;;OAAA;IAED;;;;;OAKG;IACH,wBAAQ,GAAR;QACE,OAAM;IACR,CAAC;IAED;;;;;;OAMG;IACH,yBAAS,GAAT;QACE,IAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;QAChC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACnC,CAAC;IAED;;;;;;;;OAQG;IACH,4BAAY,GAAZ,UAAa,QAAkB;QAC7B,IAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAC9B,IAAI,KAAK,CAAC,IAAI,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,EAA5B,CAA4B,CAAC,EAAE,CAAC;YACtD,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,QAAQ,KAAK,IAAI,CAAC,eAAe,EAAE,CAAA;IAC5C,CAAC;IAED;;;;;OAKG;IACH,+BAAe,GAAf;QACE,KAAuB,UAAgB,EA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C;YACd,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAA;QACjE,CAAC;QACD,OAAO,IAAI,CAAC,eAAe,EAAE,KAAK,SAAS,CAAA;IAC7C,CAAC;CAYF"}
@@ -1,3 +1,4 @@
1
+ import { Action } from './Action';
1
2
  import { HiddenInformation } from './HiddenInformation';
2
3
  /**
3
4
  * Some game hide information to the player, and the information is not equally accessible by each player.
@@ -39,6 +40,16 @@ export interface SecretInformation<GameView = any, Move = any, MoveView = any, P
39
40
  * @return true as long as the move must be kept secret from that player
40
41
  */
41
42
  keepMoveSecret?(move: Move, playerId: PlayerId): boolean;
43
+ /**
44
+ * If some actions played must be entirely keep secret to other players, you can implement this function to prevent the action from being transmitted to
45
+ * another player as long as necessary.
46
+ * Useful for game with secret planning for instance.
47
+ *
48
+ * @param action An action played by a player
49
+ * @param playerId Identifier of another player
50
+ * @return true as long as the move must be kept secret from that player
51
+ */
52
+ keepActionSecret?(action: Action<Move, PlayerId>, playerId: PlayerId): boolean;
42
53
  }
43
54
  /**
44
55
  * Type guard for games with secret information
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasSecretInformation = void 0;
4
1
  /**
5
2
  * Type guard for games with secret information
6
3
  * @param rules Rules of the game
7
4
  * @returns true if the game implements {@link SecretInformation}
8
5
  */
9
- function hasSecretInformation(rules) {
10
- var test = rules;
6
+ export function hasSecretInformation(rules) {
7
+ const test = rules;
11
8
  return typeof test.getPlayerView === 'function';
12
9
  }
13
- exports.hasSecretInformation = hasSecretInformation;
14
10
  //# sourceMappingURL=SecretInformation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SecretInformation.js","sourceRoot":"","sources":["../src/SecretInformation.ts"],"names":[],"mappings":";;;AAgDA;;;;GAIG;AACH,SAAgB,oBAAoB,CAA6D,KAAa;IAC5G,IAAM,IAAI,GAAG,KAA8D,CAAA;IAC3E,OAAO,OAAO,IAAI,CAAC,aAAa,KAAK,UAAU,CAAA;AACjD,CAAC;AAHD,oDAGC"}
1
+ {"version":3,"file":"SecretInformation.js","sourceRoot":"","sources":["../src/SecretInformation.ts"],"names":[],"mappings":"AA4DA;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAA6D,KAAa;IAC5G,MAAM,IAAI,GAAG,KAA8D,CAAA;IAC3E,OAAO,OAAO,IAAI,CAAC,aAAa,KAAK,UAAU,CAAA;AACjD,CAAC"}
package/dist/TimeLimit.js CHANGED
@@ -1,13 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasTimeLimit = void 0;
4
1
  /**
5
2
  * Type guard for {@link TimeLimit} interface
6
3
  * @param rules Rules of the game
7
4
  * @returns true if rules implements {@link TimeLimit}
8
5
  */
9
- function hasTimeLimit(rules) {
6
+ export function hasTimeLimit(rules) {
10
7
  return typeof rules.giveTime === 'function';
11
8
  }
12
- exports.hasTimeLimit = hasTimeLimit;
13
9
  //# sourceMappingURL=TimeLimit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeLimit.js","sourceRoot":"","sources":["../src/TimeLimit.ts"],"names":[],"mappings":";;;AAyBA;;;;GAIG;AACH,SAAgB,YAAY,CAAuB,KAAkC;IACnF,OAAO,OAAQ,KAAyC,CAAC,QAAQ,KAAK,UAAU,CAAA;AAClF,CAAC;AAFD,oCAEC"}
1
+ {"version":3,"file":"TimeLimit.js","sourceRoot":"","sources":["../src/TimeLimit.ts"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAuB,KAAkC;IACnF,OAAO,OAAQ,KAAyC,CAAC,QAAQ,KAAK,UAAU,CAAA;AAClF,CAAC"}
package/dist/Undo.js CHANGED
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasUndo = void 0;
4
1
  /**
5
2
  * Type guard to know if a game implements the Undo feature.
6
3
  *
7
4
  * @param rules Rules of the game
8
5
  * @returns true if rules implements {@link Undo}
9
6
  */
10
- function hasUndo(rules) {
11
- var test = rules;
7
+ export function hasUndo(rules) {
8
+ const test = rules;
12
9
  return typeof test.canUndo === 'function';
13
10
  }
14
- exports.hasUndo = hasUndo;
15
11
  //# sourceMappingURL=Undo.js.map
package/dist/Undo.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Undo.js","sourceRoot":"","sources":["../src/Undo.ts"],"names":[],"mappings":";;;AA0BA;;;;;GAKG;AACH,SAAgB,OAAO,CAAuB,KAAa;IACzD,IAAM,IAAI,GAAG,KAAmC,CAAA;IAChD,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,CAAA;AAC3C,CAAC;AAHD,0BAGC"}
1
+ {"version":3,"file":"Undo.js","sourceRoot":"","sources":["../src/Undo.ts"],"names":[],"mappings":"AA0BA;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAuB,KAAa;IACzD,MAAM,IAAI,GAAG,KAAmC,CAAA;IAChD,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,CAAA;AAC3C,CAAC"}
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasUnpredictableMoves = void 0;
4
1
  /**
5
2
  * Type guard for {@link UnpredictableMoves} interface
6
3
  * @param rules Rules of the game
7
4
  * @returns true is rules implements {@link UnpredictableMoves}
8
5
  */
9
- var hasUnpredictableMoves = function (rules) { return typeof rules.isUnpredictableMove === 'function'; };
10
- exports.hasUnpredictableMoves = hasUnpredictableMoves;
6
+ export const hasUnpredictableMoves = (rules) => typeof rules.isUnpredictableMove === 'function';
11
7
  //# sourceMappingURL=UnpredictableMove.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnpredictableMove.js","sourceRoot":"","sources":["../src/UnpredictableMove.ts"],"names":[],"mappings":";;;AAsBA;;;;GAIG;AACI,IAAM,qBAAqB,GAAG,UACnC,KAAqB,IACkC,OAAA,OAAO,KAAK,CAAC,mBAAmB,KAAK,UAAU,EAA/C,CAA+C,CAAA;AAF3F,QAAA,qBAAqB,yBAEsE"}
1
+ {"version":3,"file":"UnpredictableMove.js","sourceRoot":"","sources":["../src/UnpredictableMove.ts"],"names":[],"mappings":"AAsBA;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,KAAqB,EAC+B,EAAE,CAAC,OAAO,KAAK,CAAC,mBAAmB,KAAK,UAAU,CAAA"}
package/dist/index.js CHANGED
@@ -1,33 +1,17 @@
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
- __exportStar(require("./material"), exports);
18
- __exportStar(require("./options"), exports);
19
- __exportStar(require("./utils"), exports);
20
- __exportStar(require("./Action"), exports);
21
- __exportStar(require("./Bot"), exports);
22
- __exportStar(require("./Competitive"), exports);
23
- __exportStar(require("./Eliminations"), exports);
24
- __exportStar(require("./GameSetup"), exports);
25
- __exportStar(require("./HiddenInformation"), exports);
26
- __exportStar(require("./LocalMovePreview"), exports);
27
- __exportStar(require("./RandomMove"), exports);
28
- __exportStar(require("./Rules"), exports);
29
- __exportStar(require("./SecretInformation"), exports);
30
- __exportStar(require("./TimeLimit"), exports);
31
- __exportStar(require("./Undo"), exports);
32
- __exportStar(require("./UnpredictableMove"), exports);
1
+ export * from './material';
2
+ export * from './options';
3
+ export * from './utils';
4
+ export * from './Action';
5
+ export * from './Bot';
6
+ export * from './Competitive';
7
+ export * from './Eliminations';
8
+ export * from './GameSetup';
9
+ export * from './HiddenInformation';
10
+ export * from './LocalMovePreview';
11
+ export * from './RandomMove';
12
+ export * from './Rules';
13
+ export * from './SecretInformation';
14
+ export * from './TimeLimit';
15
+ export * from './Undo';
16
+ export * from './UnpredictableMove';
33
17
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,4CAAyB;AACzB,0CAAuB;AACvB,2CAAwB;AACxB,wCAAqB;AACrB,gDAA6B;AAC7B,iDAA8B;AAC9B,8CAA2B;AAC3B,sDAAmC;AACnC,qDAAkC;AAClC,+CAA4B;AAC5B,0CAAuB;AACvB,sDAAmC;AACnC,8CAA2B;AAC3B,yCAAsB;AACtB,sDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AACrB,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,QAAQ,CAAA;AACtB,cAAc,qBAAqB,CAAA"}
@@ -13,7 +13,7 @@ import { MaterialMove, MaterialMoveRandomized, MaterialMoveView } from './moves'
13
13
  export declare abstract class HiddenMaterialRules<P extends number = number, M extends number = number, L extends number = number, R extends number = number> extends MaterialRules<P, M, L, R> implements HiddenInformation<MaterialGame<P, M, L, R>, MaterialMove<P, M, L, R>, MaterialMove<P, M, L, R>> {
14
14
  private readonly client?;
15
15
  constructor(game: MaterialGame<P, M, L, R>, client?: {
16
- player?: P | undefined;
16
+ player?: P;
17
17
  } | undefined);
18
18
  /**
19
19
  * A hiding strategy allows to hide automatically some information about an item when it is at a specific location type.