@gamepark/rules-api 5.23.2 → 6.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/dist/Action.d.ts +4 -5
  2. package/dist/Action.js +6 -6
  3. package/dist/Action.js.map +1 -1
  4. package/dist/ApplyAutomaticMoves.d.ts +1 -1
  5. package/dist/ApplyAutomaticMoves.js +1 -1
  6. package/dist/ApplyAutomaticMoves.js.map +1 -1
  7. package/dist/Competitive.d.ts +2 -2
  8. package/dist/Dummy.d.ts +2 -2
  9. package/dist/Dummy.js +2 -1
  10. package/dist/Dummy.js.map +1 -1
  11. package/dist/Eliminations.d.ts +1 -1
  12. package/dist/IncompleteInformation.d.ts +2 -2
  13. package/dist/RandomMove.d.ts +2 -2
  14. package/dist/RandomMove.js +4 -2
  15. package/dist/RandomMove.js.map +1 -1
  16. package/dist/Robot.d.ts +1 -2
  17. package/dist/Rules.d.ts +2 -1
  18. package/dist/Rules.js +2 -1
  19. package/dist/Rules.js.map +1 -1
  20. package/dist/RulesCreator.d.ts +2 -2
  21. package/dist/TimeLimit.d.ts +2 -2
  22. package/dist/Undo.d.ts +2 -2
  23. package/dist/UnpredictableMove.d.ts +12 -0
  24. package/dist/UnpredictableMove.js +43 -0
  25. package/dist/UnpredictableMove.js.map +1 -0
  26. package/dist/index.d.ts +13 -18
  27. package/dist/index.js +13 -17
  28. package/dist/index.js.map +1 -1
  29. package/dist/material/HiddenMaterialRules.d.ts +19 -0
  30. package/dist/material/HiddenMaterialRules.js +138 -0
  31. package/dist/material/HiddenMaterialRules.js.map +1 -0
  32. package/dist/material/MaterialGame.d.ts +11 -0
  33. package/dist/material/MaterialGame.js +3 -0
  34. package/dist/material/MaterialGame.js.map +1 -0
  35. package/dist/material/MaterialRules.d.ts +32 -0
  36. package/dist/material/MaterialRules.js +216 -0
  37. package/dist/material/MaterialRules.js.map +1 -0
  38. package/dist/material/MaterialRulesStep.d.ts +16 -0
  39. package/dist/material/MaterialRulesStep.js +47 -0
  40. package/dist/material/MaterialRulesStep.js.map +1 -0
  41. package/dist/material/MaterialStepRules.d.ts +16 -0
  42. package/dist/material/MaterialStepRules.js +47 -0
  43. package/dist/material/MaterialStepRules.js.map +1 -0
  44. package/dist/material/PlayerRulesStep.d.ts +10 -0
  45. package/dist/material/PlayerRulesStep.js +54 -0
  46. package/dist/material/PlayerRulesStep.js.map +1 -0
  47. package/dist/material/PlayerTurnRule.d.ts +10 -0
  48. package/dist/material/PlayerTurnRule.js +54 -0
  49. package/dist/material/PlayerTurnRule.js.map +1 -0
  50. package/dist/material/SecretMaterialRules.d.ts +12 -0
  51. package/dist/material/SecretMaterialRules.js +52 -0
  52. package/dist/material/SecretMaterialRules.js.map +1 -0
  53. package/dist/material/helper/MaterialMoveBuilder.d.ts +9 -0
  54. package/dist/material/helper/MaterialMoveBuilder.js +28 -0
  55. package/dist/material/helper/MaterialMoveBuilder.js.map +1 -0
  56. package/dist/material/helper/MaterialRulesMovesBuilder.d.ts +8 -0
  57. package/dist/material/helper/MaterialRulesMovesBuilder.js +26 -0
  58. package/dist/material/helper/MaterialRulesMovesBuilder.js.map +1 -0
  59. package/dist/material/helper/MaterialSearchHelper.d.ts +18 -0
  60. package/dist/material/helper/MaterialSearchHelper.js +62 -0
  61. package/dist/material/helper/MaterialSearchHelper.js.map +1 -0
  62. package/dist/material/helper/index.d.ts +2 -0
  63. package/dist/material/helper/index.js +19 -0
  64. package/dist/material/helper/index.js.map +1 -0
  65. package/dist/material/index.d.ts +9 -0
  66. package/dist/material/index.js +26 -0
  67. package/dist/material/index.js.map +1 -0
  68. package/dist/material/items/Material.d.ts +30 -0
  69. package/dist/material/items/Material.js +149 -0
  70. package/dist/material/items/Material.js.map +1 -0
  71. package/dist/material/items/MaterialItem.d.ts +10 -0
  72. package/dist/material/items/MaterialItem.js +3 -0
  73. package/dist/material/items/MaterialItem.js.map +1 -0
  74. package/dist/material/items/MaterialOperation.d.ts +20 -0
  75. package/dist/material/items/MaterialOperation.js +147 -0
  76. package/dist/material/items/MaterialOperation.js.map +1 -0
  77. package/dist/material/items/index.d.ts +3 -0
  78. package/dist/material/items/index.js +20 -0
  79. package/dist/material/items/index.js.map +1 -0
  80. package/dist/material/location/Location.d.ts +14 -0
  81. package/dist/material/location/Location.js +12 -0
  82. package/dist/material/location/Location.js.map +1 -0
  83. package/dist/material/location/index.d.ts +2 -0
  84. package/dist/material/location/index.js +19 -0
  85. package/dist/material/location/index.js.map +1 -0
  86. package/dist/material/location/strategy/LocationStrategy.d.ts +5 -0
  87. package/dist/material/location/strategy/LocationStrategy.js +3 -0
  88. package/dist/material/location/strategy/LocationStrategy.js.map +1 -0
  89. package/dist/material/location/strategy/PositiveSequenceStrategy.d.ts +11 -0
  90. package/dist/material/location/strategy/PositiveSequenceStrategy.js +42 -0
  91. package/dist/material/location/strategy/PositiveSequenceStrategy.js.map +1 -0
  92. package/dist/material/location/strategy/index.d.ts +2 -0
  93. package/dist/material/location/strategy/index.js +19 -0
  94. package/dist/material/location/strategy/index.js.map +1 -0
  95. package/dist/material/moves/CreateItem.d.ts +7 -0
  96. package/dist/material/moves/CreateItem.js +3 -0
  97. package/dist/material/moves/CreateItem.js.map +1 -0
  98. package/dist/material/moves/CustomMove.d.ts +6 -0
  99. package/dist/material/moves/CustomMove.js +3 -0
  100. package/dist/material/moves/CustomMove.js.map +1 -0
  101. package/dist/material/moves/CustomMoves.d.ts +7 -0
  102. package/dist/material/moves/CustomMoves.js +3 -0
  103. package/dist/material/moves/CustomMoves.js.map +1 -0
  104. package/dist/material/moves/DeleteItem.d.ts +7 -0
  105. package/dist/material/moves/DeleteItem.js +3 -0
  106. package/dist/material/moves/DeleteItem.js.map +1 -0
  107. package/dist/material/moves/MaterialMove.d.ts +11 -0
  108. package/dist/material/moves/MaterialMove.js +3 -0
  109. package/dist/material/moves/MaterialMove.js.map +1 -0
  110. package/dist/material/moves/MaterialMoveType.d.ts +6 -0
  111. package/dist/material/moves/MaterialMoveType.js +11 -0
  112. package/dist/material/moves/MaterialMoveType.js.map +1 -0
  113. package/dist/material/moves/MaterialMovesBuilder.d.ts +8 -0
  114. package/dist/material/moves/MaterialMovesBuilder.js +34 -0
  115. package/dist/material/moves/MaterialMovesBuilder.js.map +1 -0
  116. package/dist/material/moves/MaterialRulesMove.d.ts +6 -0
  117. package/dist/material/moves/MaterialRulesMove.js +3 -0
  118. package/dist/material/moves/MaterialRulesMove.js.map +1 -0
  119. package/dist/material/moves/MoveItem.d.ts +17 -0
  120. package/dist/material/moves/MoveItem.js +54 -0
  121. package/dist/material/moves/MoveItem.js.map +1 -0
  122. package/dist/material/moves/MoveKind.d.ts +6 -0
  123. package/dist/material/moves/MoveKind.js +11 -0
  124. package/dist/material/moves/MoveKind.js.map +1 -0
  125. package/dist/material/moves/RulesMoves.d.ts +10 -0
  126. package/dist/material/moves/RulesMoves.js +3 -0
  127. package/dist/material/moves/RulesMoves.js.map +1 -0
  128. package/dist/material/moves/Shuffle.d.ts +9 -0
  129. package/dist/material/moves/Shuffle.js +3 -0
  130. package/dist/material/moves/Shuffle.js.map +1 -0
  131. package/dist/material/moves/index.d.ts +11 -0
  132. package/dist/material/moves/index.js +28 -0
  133. package/dist/material/moves/index.js.map +1 -0
  134. package/dist/material/moves/local/LocalMove.d.ts +6 -0
  135. package/dist/material/moves/local/LocalMove.js +9 -0
  136. package/dist/material/moves/local/LocalMove.js.map +1 -0
  137. package/dist/material/moves/local/RulesDisplay.d.ts +32 -0
  138. package/dist/material/moves/local/RulesDisplay.js +26 -0
  139. package/dist/material/moves/local/RulesDisplay.js.map +1 -0
  140. package/dist/material/moves/local/index.d.ts +2 -0
  141. package/dist/material/moves/local/index.js +19 -0
  142. package/dist/material/moves/local/index.js.map +1 -0
  143. package/dist/material/moves/rules/EndGame.d.ts +4 -0
  144. package/dist/material/moves/rules/EndGame.js +3 -0
  145. package/dist/material/moves/rules/EndGame.js.map +1 -0
  146. package/dist/material/moves/rules/MaterialRulesMovesBuilder.d.ts +8 -0
  147. package/dist/material/moves/rules/MaterialRulesMovesBuilder.js +26 -0
  148. package/dist/material/moves/rules/MaterialRulesMovesBuilder.js.map +1 -0
  149. package/dist/material/moves/rules/Memorize.d.ts +6 -0
  150. package/dist/material/moves/rules/Memorize.js +3 -0
  151. package/dist/material/moves/rules/Memorize.js.map +1 -0
  152. package/dist/material/moves/rules/MemorizeOnGame.d.ts +6 -0
  153. package/dist/material/moves/rules/MemorizeOnGame.js +3 -0
  154. package/dist/material/moves/rules/MemorizeOnGame.js.map +1 -0
  155. package/dist/material/moves/rules/RuleMove.d.ts +16 -0
  156. package/dist/material/moves/rules/RuleMove.js +19 -0
  157. package/dist/material/moves/rules/RuleMove.js.map +1 -0
  158. package/dist/material/moves/rules/StartPlayerTurn.d.ts +7 -0
  159. package/dist/material/moves/rules/StartPlayerTurn.js +3 -0
  160. package/dist/material/moves/rules/StartPlayerTurn.js.map +1 -0
  161. package/dist/material/moves/rules/StartRule.d.ts +7 -0
  162. package/dist/material/moves/rules/StartRule.js +3 -0
  163. package/dist/material/moves/rules/StartRule.js.map +1 -0
  164. package/dist/material/moves/rules/index.d.ts +4 -0
  165. package/dist/material/moves/rules/index.js +21 -0
  166. package/dist/material/moves/rules/index.js.map +1 -0
  167. package/dist/material/rules/MaterialRulesMovesBuilder.d.ts +10 -0
  168. package/dist/material/rules/MaterialRulesMovesBuilder.js +35 -0
  169. package/dist/material/rules/MaterialRulesMovesBuilder.js.map +1 -0
  170. package/dist/material/rules/MaterialStepRules.d.ts +22 -0
  171. package/dist/material/rules/MaterialStepRules.js +101 -0
  172. package/dist/material/rules/MaterialStepRules.js.map +1 -0
  173. package/dist/material/rules/PlayerTurnRule.d.ts +10 -0
  174. package/dist/material/rules/PlayerTurnRule.js +53 -0
  175. package/dist/material/rules/PlayerTurnRule.js.map +1 -0
  176. package/dist/material/rules/Rule.d.ts +5 -0
  177. package/dist/material/rules/Rule.js +3 -0
  178. package/dist/material/rules/Rule.js.map +1 -0
  179. package/dist/material/rules/RuleStep.d.ts +6 -0
  180. package/dist/material/rules/RuleStep.js +3 -0
  181. package/dist/material/rules/RuleStep.js.map +1 -0
  182. package/dist/material/rules/RulesStep.d.ts +5 -0
  183. package/dist/material/rules/RulesStep.js +3 -0
  184. package/dist/material/rules/RulesStep.js.map +1 -0
  185. package/dist/material/rules/index.d.ts +3 -0
  186. package/dist/material/rules/index.js +20 -0
  187. package/dist/material/rules/index.js.map +1 -0
  188. package/dist/options/EnumOption.d.ts +2 -3
  189. package/dist/options/EnumOption.js.map +1 -1
  190. package/dist/options/Option.d.ts +1 -2
  191. package/dist/options/OptionSpecOf.d.ts +3 -4
  192. package/dist/options/OptionsSpec.d.ts +4 -5
  193. package/dist/options/OptionsValidationError.d.ts +1 -1
  194. package/dist/options/OptionsValidationError.js +2 -1
  195. package/dist/options/OptionsValidationError.js.map +1 -1
  196. package/dist/options/PlayerIdSpec.d.ts +2 -3
  197. package/dist/options/PlayerIdSpec.js.map +1 -1
  198. package/dist/options/PlayersOptionsSpec.d.ts +3 -4
  199. package/dist/options/WithIdOption.d.ts +1 -2
  200. package/dist/options/WithPlayerOptionsSpec.d.ts +2 -3
  201. package/dist/options/WithPlayersOptions.d.ts +1 -2
  202. package/dist/options/getFallbackPlayerName.d.ts +3 -3
  203. package/dist/options/getFallbackPlayerName.js +4 -6
  204. package/dist/options/getFallbackPlayerName.js.map +1 -1
  205. package/dist/options/index.d.ts +12 -12
  206. package/dist/options/index.js +12 -12
  207. package/dist/options/index.js.map +1 -1
  208. package/dist/options/isWithPlayerIdOptions.d.ts +4 -4
  209. package/dist/options/isWithPlayerIdOptions.js +2 -1
  210. package/dist/options/isWithPlayerIdOptions.js.map +1 -1
  211. package/dist/options/providePlayerIds.d.ts +6 -6
  212. package/dist/options/providePlayerIds.js +5 -7
  213. package/dist/options/providePlayerIds.js.map +1 -1
  214. package/package.json +9 -3
package/dist/Action.d.ts CHANGED
@@ -1,13 +1,12 @@
1
- import { IncompleteInformation } from './index';
2
- import Rules from './Rules';
3
- declare type Action<Move = any, PlayerId = any> = {
1
+ import { Rules } from './Rules';
2
+ import { IncompleteInformation } from './IncompleteInformation';
3
+ export declare type Action<Move = any, PlayerId = any> = {
4
4
  id?: string;
5
5
  playerId: PlayerId;
6
6
  move: Move;
7
7
  consequences: Move[];
8
8
  };
9
- export default Action;
10
- export declare function playAction<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>, move: Move, playerId: PlayerId, id?: string): Action<Move, PlayerId>;
9
+ export declare function playAction<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>, move: Move, playerId: PlayerId): Action<Move, PlayerId>;
11
10
  export declare type ActionWithViews<Move = any, MoveView = Move, PlayerId = any> = {
12
11
  action: Action<Move, PlayerId>;
13
12
  views: ActionView<MoveView, PlayerId>[];
package/dist/Action.js CHANGED
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isSecretAction = exports.replayActions = exports.replayAction = exports.playActionWithViews = exports.playAction = void 0;
4
- var index_1 = require("./index");
5
4
  var RandomMove_1 = require("./RandomMove");
6
5
  var ApplyAutomaticMoves_1 = require("./ApplyAutomaticMoves");
7
- function playAction(rules, move, playerId, id) {
6
+ var IncompleteInformation_1 = require("./IncompleteInformation");
7
+ function playAction(rules, move, playerId) {
8
8
  if ((0, RandomMove_1.hasRandomMove)(rules)) {
9
9
  move = rules.randomize(move);
10
10
  }
11
- var action = { id: id, playerId: playerId, move: move, consequences: [] };
11
+ var action = { playerId: playerId, move: move, consequences: [] };
12
12
  var consequences = rules.play(JSON.parse(JSON.stringify(move)));
13
13
  (0, ApplyAutomaticMoves_1.applyAutomaticMoves)(rules, consequences, function (move) { return action.consequences.push(move); });
14
14
  return action;
@@ -25,16 +25,16 @@ function playActionWithViews(rules, move, playerId, recipients, id) {
25
25
  // Prepare action view for each player
26
26
  for (var _i = 0, recipients_1 = recipients; _i < recipients_1.length; _i++) {
27
27
  var recipient = recipients_1[_i];
28
- actionWithView.views.push({ recipient: recipient, action: { id: id, playerId: playerId, move: (0, index_1.getMoveView)(rules, move, recipient), consequences: [] } });
28
+ actionWithView.views.push({ recipient: recipient, action: { id: id, playerId: playerId, move: (0, IncompleteInformation_1.getMoveView)(rules, move, recipient), consequences: [] } });
29
29
  }
30
30
  // Prepare action view for spectators
31
- actionWithView.views.push({ action: { id: id, playerId: playerId, move: (0, index_1.getMoveView)(rules, move), consequences: [] } });
31
+ actionWithView.views.push({ action: { id: id, playerId: playerId, move: (0, IncompleteInformation_1.getMoveView)(rules, move), consequences: [] } });
32
32
  var consequences = rules.play(JSON.parse(JSON.stringify(move)));
33
33
  (0, ApplyAutomaticMoves_1.applyAutomaticMoves)(rules, consequences, function (move) {
34
34
  actionWithView.action.consequences.push(move);
35
35
  for (var _i = 0, _a = actionWithView.views; _i < _a.length; _i++) {
36
36
  var view = _a[_i];
37
- view.action.consequences.push((0, index_1.getMoveView)(rules, move, view.recipient));
37
+ view.action.consequences.push((0, IncompleteInformation_1.getMoveView)(rules, move, view.recipient));
38
38
  }
39
39
  });
40
40
  return actionWithView;
@@ -1 +1 @@
1
- {"version":3,"file":"Action.js","sourceRoot":"","sources":["../src/Action.ts"],"names":[],"mappings":";;;AAAA,iCAA0D;AAC1D,2CAA0C;AAE1C,6DAAyD;AAWzD,SAAgB,UAAU,CAAuB,KAAkC,EAAE,IAAU,EAAE,QAAkB,EAAE,EAAW;IAC9H,IAAI,IAAA,0BAAa,EAAC,KAAK,CAAC,EAAE;QACxB,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;KAC7B;IAED,IAAM,MAAM,GAA2B,EAAC,EAAE,IAAA,EAAE,QAAQ,UAAA,EAAE,IAAI,MAAA,EAAE,YAAY,EAAE,EAAE,EAAC,CAAA;IAE7E,IAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IA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AAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAA5C,CAA4C,CAAC,CAAA;AACnF,CAAC;AAHD,oCAGC;AAED,SAAgB,aAAa,CAAuB,KAAkC,EAAE,OAAiC;IACvH,OAAO,CAAC,OAAO,CAAC,UAAA,MAAM,IAAI,OAAA,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,EAA3B,CAA2B,CAAC,CAAA;AACxD,CAAC;AAFD,sCAEC;AAMD,SAAgB,cAAc,CAAC,MAAc;IAC3C,OAAO,KAAK,CAAC,OAAO,CAAE,MAAuB,CAAC,OAAO,CAAC,CAAA;AACxD,CAAC;AAFD,wCAEC"}
@@ -1,2 +1,2 @@
1
- import Rules from './Rules';
1
+ import { Rules } from './Rules';
2
2
  export declare function applyAutomaticMoves<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>, moves?: Move[], preprocessMove?: (move: Move) => void): void;
@@ -19,7 +19,7 @@ function applyAutomaticMoves(rules, moves, preprocessMove) {
19
19
  var consequences = (_a = rules.play(JSON.parse(JSON.stringify(randomizedMove)))) !== null && _a !== void 0 ? _a : [];
20
20
  moves.unshift.apply(moves, consequences);
21
21
  return true;
22
- }, { errorFn: function () { return new Error("Infinite loop detected while applying move consequences: ".concat(JSON.stringify(rules.getAutomaticMoves()), ")")); } });
22
+ }, { errorFn: function () { return new Error("Infinite loop detected while applying move consequences: ".concat(JSON.stringify(moves), ")")); } });
23
23
  }
24
24
  exports.applyAutomaticMoves = applyAutomaticMoves;
25
25
  //# sourceMappingURL=ApplyAutomaticMoves.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ApplyAutomaticMoves.js","sourceRoot":"","sources":["../src/ApplyAutomaticMoves.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAC1C,+CAA2C;AAG3C,SAAgB,mBAAmB,CAAuB,KAAkC,EAAE,KAAkB,EAAE,cAAqC;IAAzD,sBAAA,EAAA,UAAkB;IAC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,IAAI,OAAV,KAAK,EAAS,KAAK,CAAC,iBAAiB,EAAE,EAAC;SACzC;QACD,IAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAA;QAC1B,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAA;QACvB,IAAM,cAAc,GAAG,IAAA,0BAAa,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAC1E,IAAI,cAAc;YAAE,cAAc,CAAC,cAAc,CAAC,CAAA;QAClD,IAAM,YAAY,GAAG,MAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,mCAAI,EAAE,CAAA;QACjF,KAAK,CAAC,OAAO,OAAb,KAAK,EAAY,YAAY,EAAC;QAC9B,OAAO,IAAI,CAAA;IACb,CAAC,EAAE,EAAC,OAAO,EAAE,cAAM,OAAA,IAAI,KAAK,CAAC,mEAA4D,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAG,CAAC,EAA/F,CAA+F,EAAC,CAAC,CAAA;AACtH,CAAC;AAbD,kDAaC"}
@@ -1,5 +1,5 @@
1
- import Rules from './Rules';
2
- export default interface Competitive<Game, Move = string, PlayerId = number> extends Rules<Game, Move, PlayerId> {
1
+ import { Rules } from './Rules';
2
+ export interface Competitive<Game, Move = string, PlayerId = number> extends Rules<Game, Move, PlayerId> {
3
3
  rankPlayers(playerA: PlayerId, playerB: PlayerId): number;
4
4
  getScore?(playerId: PlayerId): number;
5
5
  }
package/dist/Dummy.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import RulesCreator from './RulesCreator';
2
- export default class Dummy<Game, Move = string, PlayerId = number> {
1
+ import { RulesCreator } from './RulesCreator';
2
+ export declare class Dummy<Game, Move = string, PlayerId = number> {
3
3
  Rules: RulesCreator<Game, Move, PlayerId>;
4
4
  constructor(Rules: RulesCreator<Game, Move, PlayerId>);
5
5
  getRandomMove(state: Game, playerId: PlayerId): Promise<Move[]>;
package/dist/Dummy.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Dummy = void 0;
3
4
  var Dummy = /** @class */ (function () {
4
5
  function Dummy(Rules) {
5
6
  this.Rules = Rules;
@@ -22,5 +23,5 @@ var Dummy = /** @class */ (function () {
22
23
  };
23
24
  return Dummy;
24
25
  }());
25
- exports.default = Dummy;
26
+ exports.Dummy = Dummy;
26
27
  //# sourceMappingURL=Dummy.js.map
package/dist/Dummy.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Dummy.js","sourceRoot":"","sources":["../src/Dummy.ts"],"names":[],"mappings":";;AAEA;IAIE,eAAY,KAAyC;QACnD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,6BAAa,GAAb,UAAc,KAAW,EAAE,QAAkB;QAC3C,IAAI,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QAC/C,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAC7C,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3E,CAAC;IAED,6BAAa,GAAb,UAAc,KAAW,EAAE,QAAkB;QAC3C,IAAM,KAAK,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACnC,IAAI,KAAK,CAAC,aAAa,EAAE;YACvB,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;SACrC;aAAM;YACL,OAAO,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAA;YAC9E,OAAO,EAAE,CAAA;SACV;IACH,CAAC;IACH,YAAC;AAAD,CAAC,AAvBD,IAuBC"}
1
+ {"version":3,"file":"Dummy.js","sourceRoot":"","sources":["../src/Dummy.ts"],"names":[],"mappings":";;;AAEA;IAIE,eAAY,KAAyC;QACnD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,6BAAa,GAAb,UAAc,KAAW,EAAE,QAAkB;QAC3C,IAAI,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QAC/C,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAC7C,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3E,CAAC;IAED,6BAAa,GAAb,UAAc,KAAW,EAAE,QAAkB;QAC3C,IAAM,KAAK,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACnC,IAAI,KAAK,CAAC,aAAa,EAAE;YACvB,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;SACrC;aAAM;YACL,OAAO,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAA;YAC9E,OAAO,EAAE,CAAA;SACV;IACH,CAAC;IACH,YAAC;AAAD,CAAC,AAvBD,IAuBC;AAvBY,sBAAK"}
@@ -1,4 +1,4 @@
1
- export default interface Eliminations<Move = string, PlayerId = number> {
1
+ export interface Eliminations<Move = string, PlayerId = number> {
2
2
  isEliminated(playerId: PlayerId): boolean;
3
3
  giveUpMove?(playerId: PlayerId): Move | undefined;
4
4
  }
@@ -1,5 +1,5 @@
1
- import Rules from './Rules';
2
- export default interface IncompleteInformation<GameView = any, Move = any, MoveView = any> {
1
+ import { Rules } from './Rules';
2
+ export interface IncompleteInformation<GameView = any, Move = any, MoveView = any> {
3
3
  getView(): GameView;
4
4
  getMoveView(move: Move): MoveView;
5
5
  }
@@ -1,5 +1,5 @@
1
- import Rules from './Rules';
2
- export default interface RandomMove<Move = string, RandomizedMove = string> {
1
+ import { Rules } from './Rules';
2
+ export interface RandomMove<Move = any, RandomizedMove = any> {
3
3
  randomize(move: Move): Move & RandomizedMove;
4
4
  play(move: Move & RandomizedMove): Move[];
5
5
  }
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.randomizeMoves = exports.hasRandomMove = void 0;
4
4
  function hasRandomMove(rules) {
5
5
  var test = rules;
6
- return typeof test.randomize === 'function';
6
+ return typeof test.randomize === "function";
7
7
  }
8
8
  exports.hasRandomMove = hasRandomMove;
9
9
  function randomizeMoves(rules, moves) {
10
- return hasRandomMove(rules) ? moves.map(function (move) { return rules.randomize(move); }) : moves;
10
+ return hasRandomMove(rules)
11
+ ? moves.map(function (move) { return rules.randomize(move); })
12
+ : moves;
11
13
  }
12
14
  exports.randomizeMoves = randomizeMoves;
13
15
  //# sourceMappingURL=RandomMove.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RandomMove.js","sourceRoot":"","sources":["../src/RandomMove.ts"],"names":[],"mappings":";;;AAQA,SAAgB,aAAa,CAA6B,KAAwB;IAChF,IAAM,IAAI,GAAG,KAA6D,CAAA;IAC1E,OAAO,OAAO,IAAI,CAAC,SAAS,KAAK,UAAU,CAAA;AAC7C,CAAC;AAHD,sCAGC;AAED,SAAgB,cAAc,CAAoC,KAAwB,EAAE,KAAa;IACvG,OAAO,aAAa,CAA6B,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAA,IAAI,IAAI,OAAA,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAArB,CAAqB,CAAC,CAAC,CAAC,CAAE,KAAmC,CAAA;AAC3I,CAAC;AAFD,wCAEC"}
1
+ {"version":3,"file":"RandomMove.js","sourceRoot":"","sources":["../src/RandomMove.ts"],"names":[],"mappings":";;;AAQA,SAAgB,aAAa,CAC3B,KAAwB;IAExB,IAAM,IAAI,GAAG,KAA6D,CAAA;IAC1E,OAAO,OAAO,IAAI,CAAC,SAAS,KAAK,UAAU,CAAA;AAC7C,CAAC;AALD,sCAKC;AAED,SAAgB,cAAc,CAC5B,KAAwB,EACxB,KAAa;IAEb,OAAO,aAAa,CAA6B,KAAK,CAAC;QACrD,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI,IAAK,OAAA,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAArB,CAAqB,CAAC;QAC5C,CAAC,CAAE,KAAmC,CAAA;AAC1C,CAAC;AAPD,wCAOC"}
package/dist/Robot.d.ts CHANGED
@@ -1,2 +1 @@
1
- declare type Robot<Game, Move = string, PlayerId = number> = (state: Game, playerId: PlayerId) => Promise<Move[]>;
2
- export default Robot;
1
+ export declare type Robot<Game, Move = string, PlayerId = number> = (state: Game, playerId: PlayerId) => Promise<Move[]>;
package/dist/Rules.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export default abstract class Rules<Game = any, Move = any, PlayerId = any> {
1
+ export declare abstract class Rules<Game = any, Move = any, PlayerId = any> {
2
2
  game: Game;
3
3
  constructor(game: Game);
4
4
  get state(): Game;
@@ -11,4 +11,5 @@ export default abstract class Rules<Game = any, Move = any, PlayerId = any> {
11
11
  getAutomaticMoves(): Move[];
12
12
  play(move: Move): Move[];
13
13
  isOver(playerIds?: PlayerId[]): boolean;
14
+ isUnpredictableMove?(move: Move): boolean;
14
15
  }
package/dist/Rules.js CHANGED
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Rules = void 0;
6
7
  var fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
7
8
  var Eliminations_1 = require("./Eliminations");
8
9
  var Rules = /** @class */ (function () {
@@ -71,5 +72,5 @@ var Rules = /** @class */ (function () {
71
72
  };
72
73
  return Rules;
73
74
  }());
74
- exports.default = Rules;
75
+ exports.Rules = Rules;
75
76
  //# 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,oEAAmC;AACnC,+CAA8C;AAE9C;IAGE,eAAY,IAAU;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,sBAAI,wBAAK;aAAT;YACE,OAAO,IAAI,CAAC,IAAI,CAAA;QAClB,CAAC;;;OAAA;IAED,wBAAQ,GAAR;QACE,OAAM;IACR,CAAC;IAED,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,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;YACrD,OAAO,IAAI,CAAA;SACZ;QACD,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,OAAO,QAAQ,KAAK,IAAI,CAAC,eAAe,EAAE,CAAA;SAC3C;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAID,2BAAW,GAAX,UAAY,QAAkB,EAAE,IAAU;QACxC,IAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAC9B,IAAI,KAAK,CAAC,IAAI,CAAC,UAAA,KAAK,IAAI,OAAA,KA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AC;IAED,sBAAM,GAAN,UAAO,SAAsB;QAA7B,iBAYC;QAXC,IAAM,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAClC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,UAAA,QAAQ,IAAI,OAAA,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,EAA1B,CAA0B,CAAC,EAAE;YACnF,OAAO,IAAI,CAAA;SACZ;QACD,IAAI,SAAS,EAAE;YACb,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,UAAA,QAAQ,IAAI,OAAA,KAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAA3B,CAA2B,CAAC,CAAA;SAChE;QACD,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,OAAO,IAAI,CAAC,eAAe,EAAE,KAAK,SAAS,CAAA;SAC5C;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAGH,YAAC;AAAD,CAAC,AA1ED,IA0EC;AA1EqB,sBAAK"}
@@ -1,5 +1,5 @@
1
- import Rules from './Rules';
2
- export default interface RulesCreator<Game = any, Move = any, PlayerId = number, Options = any> {
1
+ import { Rules } from './Rules';
2
+ export interface RulesCreator<Game = any, Move = any, PlayerId = number, Options = any> {
3
3
  new (state: Game): Rules<Game, Move, PlayerId>;
4
4
  new (options: Options): Rules<Game, Move, PlayerId>;
5
5
  }
@@ -1,5 +1,5 @@
1
- import Rules from './Rules';
2
- export default interface TimeLimit<Game, Move = string, PlayerId = number> extends Rules<Game, Move, PlayerId> {
1
+ import { Rules } from './Rules';
2
+ export interface TimeLimit<Game, Move = string, PlayerId = number> extends Rules<Game, Move, PlayerId> {
3
3
  /**
4
4
  * Amount of time given to a player everytime it is their turn to play.
5
5
  * @param playerId Id of the player, if you want to give different time depending of the id for asymmetric games.
package/dist/Undo.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import Action from './Action';
2
- export default interface Undo<Game, Move = string, PlayerId = number> {
1
+ import { Action } from './Action';
2
+ export interface Undo<Game, Move = string, PlayerId = number> {
3
3
  canUndo(action: Action<Move, PlayerId>, consecutiveActions: Action<Move, PlayerId>[]): boolean;
4
4
  restoreLocalMoves?(localState: Game): void;
5
5
  }
@@ -0,0 +1,12 @@
1
+ import { Rules } from './Rules';
2
+ export declare type RulesWithUnpredictableMoves<G = any, M = any, P = any> = Rules<G, M, P> & {
3
+ isUnpredictableMove(move: M): boolean;
4
+ };
5
+ export declare const hasUnpredictableMoves: <G = any, M = any, P = any>(rules: Rules<G, M, P>) => rules is RulesWithUnpredictableMoves<G, M, P>;
6
+ export declare class UnpredictableMoveFilter<G = any, M = any, P = any> extends Rules<G, M, P> {
7
+ rules: RulesWithUnpredictableMoves<G, M, P>;
8
+ constructor(rules: RulesWithUnpredictableMoves<G, M, P>);
9
+ play(move: M): M[];
10
+ getAutomaticMoves(): M[];
11
+ filterUnpredictableMoves(moves: M[]): M[];
12
+ }
@@ -0,0 +1,43 @@
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.UnpredictableMoveFilter = exports.hasUnpredictableMoves = void 0;
19
+ var Rules_1 = require("./Rules");
20
+ var hasUnpredictableMoves = function (rules) { return typeof rules.isUnpredictableMove === 'function'; };
21
+ exports.hasUnpredictableMoves = hasUnpredictableMoves;
22
+ var UnpredictableMoveFilter = /** @class */ (function (_super) {
23
+ __extends(UnpredictableMoveFilter, _super);
24
+ function UnpredictableMoveFilter(rules) {
25
+ var _this = _super.call(this, rules.game) || this;
26
+ _this.rules = rules;
27
+ return _this;
28
+ }
29
+ UnpredictableMoveFilter.prototype.play = function (move) {
30
+ return this.filterUnpredictableMoves(_super.prototype.play.call(this, move));
31
+ };
32
+ UnpredictableMoveFilter.prototype.getAutomaticMoves = function () {
33
+ return this.filterUnpredictableMoves(_super.prototype.getAutomaticMoves.call(this));
34
+ };
35
+ UnpredictableMoveFilter.prototype.filterUnpredictableMoves = function (moves) {
36
+ var _this = this;
37
+ var firstUnpredictableMoveIndex = moves.findIndex(function (move) { return !_this.rules.isUnpredictableMove(move); });
38
+ return (firstUnpredictableMoveIndex !== -1 ? moves.slice(0, firstUnpredictableMoveIndex) : moves);
39
+ };
40
+ return UnpredictableMoveFilter;
41
+ }(Rules_1.Rules));
42
+ exports.UnpredictableMoveFilter = UnpredictableMoveFilter;
43
+ //# sourceMappingURL=UnpredictableMove.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnpredictableMove.js","sourceRoot":"","sources":["../src/UnpredictableMove.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iCAA+B;AAMxB,IAAM,qBAAqB,GAAG,UACnC,KAAqB,IAC6B,OAAA,OAAO,KAAK,CAAC,mBAAmB,KAAK,UAAU,EAA/C,CAA+C,CAAA;AAFtF,QAAA,qBAAqB,yBAEiE;AAEnG;IAAwE,2CAAc;IAGpF,iCAAY,KAA2C;QAAvD,YACE,kBAAM,KAAK,CAAC,IAAI,CAAC,SAElB;QADC,KAAI,CAAC,KAAK,GAAG,KAAK,CAAA;;IACpB,CAAC;IAED,sCAAI,GAAJ,UAAK,IAAO;QACV,OAAO,IAAI,CAAC,wBAAwB,CAAC,iBAAM,IAAI,YAAC,IAAI,CAAC,CAAC,CAAA;IACxD,CAAC;IAED,mDAAiB,GAAjB;QACE,OAAO,IAAI,CAAC,wBAAwB,CAAC,iBAAM,iBAAiB,WAAE,CAAC,CAAA;IACjE,CAAC;IAED,0DAAwB,GAAxB,UAAyB,KAAU;QAAnC,iBAGC;QAFC,IAAM,2BAA2B,GAAG,KAAK,CAAC,SAAS,CAAC,UAAA,IAAI,IAAI,OAAA,CAAC,KAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAArC,CAAqC,CAAC,CAAA;QAClG,OAAO,CAAC,2BAA2B,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,2BAA2B,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IACnG,CAAC;IACH,8BAAC;AAAD,CAAC,AApBD,CAAwE,aAAK,GAoB5E;AApBY,0DAAuB"}
package/dist/index.d.ts CHANGED
@@ -1,22 +1,17 @@
1
- export { default as Rules } from './Rules';
2
- export { default as RulesCreator } from './RulesCreator';
3
- export { default as Action } from './Action';
1
+ export * from './material';
2
+ export * from './options';
3
+ export * from './utils';
4
4
  export * from './Action';
5
- export { default as IncompleteInformation } from './IncompleteInformation';
6
- export * from './IncompleteInformation';
7
- export { default as Undo } from './Undo';
8
- export * from './Undo';
9
- export { default as Competitive } from './Competitive';
5
+ export * from './ApplyAutomaticMoves';
10
6
  export * from './Competitive';
11
- export { default as Eliminations } from './Eliminations';
12
- export * from './Eliminations';
13
- export { default as RandomMove } from './RandomMove';
7
+ export * from './Dummy';
14
8
  export * from './Eliminations';
15
- export { default as TimeLimit } from './TimeLimit';
9
+ export * from './IncompleteInformation';
10
+ export * from './LoopWithFuse';
11
+ export * from './RandomMove';
12
+ export * from './Robot';
13
+ export * from './Rules';
14
+ export * from './RulesCreator';
16
15
  export * from './TimeLimit';
17
- export { default as Robot } from './Robot';
18
- export { default as Dummy } from './Dummy';
19
- export * from './options';
20
- export * from './utils';
21
- export { applyAutomaticMoves } from './ApplyAutomaticMoves';
22
- export { loopWithFuse } from './LoopWithFuse';
16
+ export * from './Undo';
17
+ export * from './UnpredictableMove';
package/dist/index.js CHANGED
@@ -13,26 +13,22 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
16
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.loopWithFuse = exports.applyAutomaticMoves = exports.Dummy = exports.Rules = void 0;
21
- var Rules_1 = require("./Rules");
22
- Object.defineProperty(exports, "Rules", { enumerable: true, get: function () { return __importDefault(Rules_1).default; } });
17
+ __exportStar(require("./material"), exports);
18
+ __exportStar(require("./options"), exports);
19
+ __exportStar(require("./utils"), exports);
23
20
  __exportStar(require("./Action"), exports);
24
- __exportStar(require("./IncompleteInformation"), exports);
25
- __exportStar(require("./Undo"), exports);
21
+ __exportStar(require("./ApplyAutomaticMoves"), exports);
26
22
  __exportStar(require("./Competitive"), exports);
23
+ __exportStar(require("./Dummy"), exports);
27
24
  __exportStar(require("./Eliminations"), exports);
28
- __exportStar(require("./Eliminations"), exports);
25
+ __exportStar(require("./IncompleteInformation"), exports);
26
+ __exportStar(require("./LoopWithFuse"), exports);
27
+ __exportStar(require("./RandomMove"), exports);
28
+ __exportStar(require("./Robot"), exports);
29
+ __exportStar(require("./Rules"), exports);
30
+ __exportStar(require("./RulesCreator"), exports);
29
31
  __exportStar(require("./TimeLimit"), exports);
30
- var Dummy_1 = require("./Dummy");
31
- Object.defineProperty(exports, "Dummy", { enumerable: true, get: function () { return __importDefault(Dummy_1).default; } });
32
- __exportStar(require("./options"), exports);
33
- __exportStar(require("./utils"), exports);
34
- var ApplyAutomaticMoves_1 = require("./ApplyAutomaticMoves");
35
- Object.defineProperty(exports, "applyAutomaticMoves", { enumerable: true, get: function () { return ApplyAutomaticMoves_1.applyAutomaticMoves; } });
36
- var LoopWithFuse_1 = require("./LoopWithFuse");
37
- Object.defineProperty(exports, "loopWithFuse", { enumerable: true, get: function () { return LoopWithFuse_1.loopWithFuse; } });
32
+ __exportStar(require("./Undo"), exports);
33
+ __exportStar(require("./UnpredictableMove"), exports);
38
34
  //# 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,iCAAwC;AAAhC,+GAAA,OAAO,OAAS;AAIxB,2CAAwB;AAGxB,0DAAuC;AAGvC,yCAAsB;AAGtB,gDAA6B;AAG7B,iDAA8B;AAG9B,iDAA8B;AAG9B,8CAA2B;AAG3B,iCAAwC;AAAhC,+GAAA,OAAO,OAAS;AAExB,4CAAyB;AACzB,0CAAuB;AACvB,6DAAyD;AAAjD,0HAAA,mBAAmB,OAAA;AAC3B,+CAA2C;AAAnC,4GAAA,YAAY,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,4CAAyB;AACzB,0CAAuB;AACvB,2CAAwB;AACxB,wDAAqC;AACrC,gDAA6B;AAC7B,0CAAuB;AACvB,iDAA8B;AAC9B,0DAAuC;AACvC,iDAA8B;AAC9B,+CAA4B;AAC5B,0CAAuB;AACvB,0CAAuB;AACvB,iDAA8B;AAC9B,8CAA2B;AAC3B,yCAAsB;AACtB,sDAAmC"}
@@ -0,0 +1,19 @@
1
+ import { IncompleteInformation } from '../IncompleteInformation';
2
+ import { MaterialRules } from './MaterialRules';
3
+ import { MaterialGame } from './MaterialGame';
4
+ import { CreateItem, MaterialRulesMove, MaterialRulesMoveRandomized, MoveItem } from './moves';
5
+ import { MaterialItem } from './items';
6
+ export declare abstract class HiddenMaterialRules<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends MaterialRules<Player, MaterialType, LocationType> implements IncompleteInformation<MaterialGame<Player, MaterialType, LocationType>, MaterialRulesMove<Player, MaterialType, LocationType>, MaterialRulesMove<Player, MaterialType, LocationType>> {
7
+ abstract hidingStrategies: Partial<Record<MaterialType, Partial<Record<LocationType, HidingStrategy<Player, LocationType>>>>>;
8
+ getItemTypeHidingStrategies(type: MaterialType): Partial<Record<LocationType, HidingStrategy<Player, LocationType>>> | undefined;
9
+ isUnpredictableMove(move: MaterialRulesMove<Player, MaterialType, LocationType>): boolean;
10
+ randomize(move: MaterialRulesMove<Player, MaterialType, LocationType>): MaterialRulesMove<Player, MaterialType, LocationType> & MaterialRulesMoveRandomized<Player, MaterialType, LocationType>;
11
+ getView(player?: Player): any;
12
+ hideItem(type: MaterialType, item: MaterialItem<Player, LocationType>, player?: Player): MaterialItem<Player, LocationType>;
13
+ getMoveView(move: MaterialRulesMoveRandomized<Player, MaterialType, LocationType>, player?: Player): MaterialRulesMove<Player, MaterialType, LocationType>;
14
+ getMoveItemView(move: MoveItem<Player, MaterialType, LocationType>, player?: Player): MoveItem<Player, MaterialType, LocationType>;
15
+ getCreateItemsView(move: CreateItem<Player, MaterialType, LocationType>, player?: Player): CreateItem<Player, MaterialType, LocationType>;
16
+ private getShuffleItemsView;
17
+ }
18
+ export declare type HidingStrategy<P extends number = number, L extends number = number> = (item: MaterialItem<P, L>) => MaterialItem<P, L>;
19
+ export declare const hideItemId: <P extends number = number, L extends number = number>(item: MaterialItem<P, L, any>) => Omit<MaterialItem<P, L, any>, "id">;
@@ -0,0 +1,138 @@
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
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __rest = (this && this.__rest) || function (s, e) {
29
+ var t = {};
30
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
31
+ t[p] = s[p];
32
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
33
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
34
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
35
+ t[p[i]] = s[p[i]];
36
+ }
37
+ return t;
38
+ };
39
+ var __importDefault = (this && this.__importDefault) || function (mod) {
40
+ return (mod && mod.__esModule) ? mod : { "default": mod };
41
+ };
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.hideItemId = exports.HiddenMaterialRules = void 0;
44
+ var lodash_mapvalues_1 = __importDefault(require("lodash.mapvalues"));
45
+ var MaterialRules_1 = require("./MaterialRules");
46
+ var moves_1 = require("./moves");
47
+ var items_1 = require("./items");
48
+ var fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
49
+ var HiddenMaterialRules = /** @class */ (function (_super) {
50
+ __extends(HiddenMaterialRules, _super);
51
+ function HiddenMaterialRules() {
52
+ return _super !== null && _super.apply(this, arguments) || this;
53
+ }
54
+ HiddenMaterialRules.prototype.getItemTypeHidingStrategies = function (type) {
55
+ return this.hidingStrategies[type];
56
+ };
57
+ HiddenMaterialRules.prototype.isUnpredictableMove = function (move) {
58
+ if (_super.prototype.isUnpredictableMove.call(this, move))
59
+ return true;
60
+ if (move.kind !== moves_1.MoveKind.MaterialMove)
61
+ return false;
62
+ if (move.type === moves_1.MaterialMoveType.Move) {
63
+ return move.reveal === true;
64
+ }
65
+ return false;
66
+ };
67
+ HiddenMaterialRules.prototype.randomize = function (move) {
68
+ if (move.kind === moves_1.MoveKind.MaterialMove && move.type === moves_1.MaterialMoveType.Move) {
69
+ // Hack the randomize function to flag any item movement that reveals something, thus making the action undoable
70
+ for (var _i = 0, _a = this.game.players; _i < _a.length; _i++) {
71
+ var player = _a[_i];
72
+ var moveView = this.getMoveItemView(move, player);
73
+ if (!(0, fast_deep_equal_1.default)(move, moveView)) {
74
+ return _super.prototype.randomize.call(this, __assign(__assign({}, move), { reveal: true }));
75
+ }
76
+ }
77
+ }
78
+ return _super.prototype.randomize.call(this, move);
79
+ };
80
+ HiddenMaterialRules.prototype.getView = function (player) {
81
+ var _this = this;
82
+ return __assign(__assign({}, this.game), { items: (0, lodash_mapvalues_1.default)(this.game.items, function (items, stringType) {
83
+ var itemsType = parseInt(stringType);
84
+ var hidingStrategies = _this.getItemTypeHidingStrategies(itemsType);
85
+ if (!hidingStrategies || !items)
86
+ return items;
87
+ return items.map(function (item) { return _this.hideItem(itemsType, item, player); });
88
+ }) });
89
+ };
90
+ HiddenMaterialRules.prototype.hideItem = function (type, item, player) {
91
+ var hidingStrategies = this.hidingStrategies[type];
92
+ if (!hidingStrategies)
93
+ return item;
94
+ var strategy = hidingStrategies[item.location.type];
95
+ if (!strategy)
96
+ return item;
97
+ return strategy(item, player);
98
+ };
99
+ HiddenMaterialRules.prototype.getMoveView = function (move, player) {
100
+ if (move.kind === moves_1.MoveKind.MaterialMove && move.itemType in this.hidingStrategies) {
101
+ switch (move.type) {
102
+ case moves_1.MaterialMoveType.Move:
103
+ return this.getMoveItemView(move, player);
104
+ case moves_1.MaterialMoveType.Create:
105
+ return this.getCreateItemsView(move, player);
106
+ case moves_1.MaterialMoveType.Shuffle:
107
+ return this.getShuffleItemsView(move, player);
108
+ }
109
+ }
110
+ return move;
111
+ };
112
+ HiddenMaterialRules.prototype.getMoveItemView = function (move, player) {
113
+ if (!(0, items_1.isItemWithLocation)(move.item))
114
+ return move;
115
+ var movedItem = this.material(move.itemType).getItem(move.itemIndex);
116
+ var movedItemView = this.hideItem(move.itemType, movedItem, player);
117
+ if ((0, fast_deep_equal_1.default)(movedItem, movedItemView))
118
+ return move;
119
+ var item = __assign(__assign({}, move.item), { id: movedItem.id });
120
+ return __assign(__assign({}, move), { item: this.hideItem(move.itemType, item, player) });
121
+ };
122
+ HiddenMaterialRules.prototype.getCreateItemsView = function (move, player) {
123
+ return __assign(__assign({}, move), { item: this.hideItem(move.itemType, move.item, player) });
124
+ };
125
+ HiddenMaterialRules.prototype.getShuffleItemsView = function (move, _player) {
126
+ // TODO: if shuffling a player's hand, the player should see the result and get the new indexes
127
+ var newIndexes = move.newIndexes, moveView = __rest(move, ["newIndexes"]);
128
+ return moveView;
129
+ };
130
+ return HiddenMaterialRules;
131
+ }(MaterialRules_1.MaterialRules));
132
+ exports.HiddenMaterialRules = HiddenMaterialRules;
133
+ var hideItemId = function (item) {
134
+ var id = item.id, hiddenItem = __rest(item, ["id"]);
135
+ return hiddenItem;
136
+ };
137
+ exports.hideItemId = hideItemId;
138
+ //# sourceMappingURL=HiddenMaterialRules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HiddenMaterialRules.js","sourceRoot":"","sources":["../../src/material/HiddenMaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sEAAwC;AACxC,iDAA+C;AAE/C,iCASgB;AAChB,iCAA0D;AAE1D,oEAAmC;AAEnC;IACU,uCAAiD;IAD3D;;IAoFA,CAAC;IA9EC,yDAA2B,GAA3B,UAA4B,IAAkB;QAC5C,OAAO,IAAI,CAA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AF,CAAS;IAClC,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAHY,QAAA,UAAU,cAGtB"}
@@ -0,0 +1,11 @@
1
+ import { MaterialItem } from './items';
2
+ import { RuleStep } from './rules';
3
+ import { RulesDisplay } from './moves';
4
+ export declare type MaterialGame<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> = {
5
+ players: Player[];
6
+ items: Partial<Record<MaterialType, MaterialItem<Player, LocationType>[]>>;
7
+ rule?: RuleStep<Player>;
8
+ memory?: Record<string, any>;
9
+ playersMemory?: Partial<Record<Player, Record<string, any>>>;
10
+ rulesDisplay?: RulesDisplay<Player, MaterialType, LocationType>;
11
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=MaterialGame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MaterialGame.js","sourceRoot":"","sources":["../../src/material/MaterialGame.ts"],"names":[],"mappings":""}