@gamepark/rules-api 6.24.2 → 6.24.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/dist/Action.d.ts +7 -0
  2. package/dist/Bot.d.ts +21 -0
  3. package/dist/Bot.js +18 -2
  4. package/dist/Bot.js.map +1 -1
  5. package/dist/Competitive.d.ts +45 -0
  6. package/dist/Competitive.js +15 -0
  7. package/dist/Competitive.js.map +1 -1
  8. package/dist/Eliminations.d.ts +17 -0
  9. package/dist/Eliminations.js +5 -0
  10. package/dist/Eliminations.js.map +1 -1
  11. package/dist/GameSetup.d.ts +14 -0
  12. package/dist/HiddenInformation.d.ts +22 -0
  13. package/dist/HiddenInformation.js +5 -0
  14. package/dist/HiddenInformation.js.map +1 -1
  15. package/dist/LocalMovePreview.d.ts +14 -0
  16. package/dist/LocalMovePreview.js +5 -0
  17. package/dist/LocalMovePreview.js.map +1 -1
  18. package/dist/RandomMove.d.ts +17 -0
  19. package/dist/Rules.d.ts +119 -0
  20. package/dist/Rules.js +102 -1
  21. package/dist/Rules.js.map +1 -1
  22. package/dist/SecretInformation.d.ts +39 -0
  23. package/dist/SecretInformation.js +5 -0
  24. package/dist/SecretInformation.js.map +1 -1
  25. package/dist/TimeLimit.d.ts +22 -0
  26. package/dist/TimeLimit.js +5 -0
  27. package/dist/TimeLimit.js.map +1 -1
  28. package/dist/Undo.d.ts +18 -0
  29. package/dist/Undo.js +6 -0
  30. package/dist/Undo.js.map +1 -1
  31. package/dist/UnpredictableMove.d.ts +19 -0
  32. package/dist/UnpredictableMove.js +5 -0
  33. package/dist/UnpredictableMove.js.map +1 -1
  34. package/dist/material/HiddenMaterialRules.d.ts +48 -0
  35. package/dist/material/HiddenMaterialRules.js +47 -1
  36. package/dist/material/HiddenMaterialRules.js.map +1 -1
  37. package/dist/material/MaterialGame.d.ts +12 -0
  38. package/dist/material/MaterialGameSetup.d.ts +74 -0
  39. package/dist/material/MaterialGameSetup.js +67 -1
  40. package/dist/material/MaterialGameSetup.js.map +1 -1
  41. package/dist/material/MaterialRules.d.ts +125 -0
  42. package/dist/material/MaterialRules.js +117 -1
  43. package/dist/material/MaterialRules.js.map +1 -1
  44. package/dist/material/SecretMaterialRules.d.ts +31 -0
  45. package/dist/material/SecretMaterialRules.js +23 -1
  46. package/dist/material/SecretMaterialRules.js.map +1 -1
  47. package/dist/material/items/Material.d.ts +253 -0
  48. package/dist/material/items/Material.js +248 -1
  49. package/dist/material/items/Material.js.map +1 -1
  50. package/dist/material/items/MaterialDeck.d.ts +33 -0
  51. package/dist/material/items/MaterialDeck.js +34 -1
  52. package/dist/material/items/MaterialDeck.js.map +1 -1
  53. package/dist/material/items/MaterialItem.d.ts +12 -0
  54. package/dist/material/items/MaterialMutator.d.ts +39 -0
  55. package/dist/material/items/MaterialMutator.js +41 -2
  56. package/dist/material/items/MaterialMutator.js.map +1 -1
  57. package/dist/material/items/index.js +1 -1
  58. package/dist/material/items/index.js.map +1 -1
  59. package/dist/material/location/Location.d.ts +28 -0
  60. package/dist/material/location/Location.js +5 -0
  61. package/dist/material/location/Location.js.map +1 -1
  62. package/dist/material/location/LocationBuilder.js +1 -1
  63. package/dist/material/location/strategy/FillGapStrategy.d.ts +4 -0
  64. package/dist/material/location/strategy/FillGapStrategy.js +5 -1
  65. package/dist/material/location/strategy/FillGapStrategy.js.map +1 -1
  66. package/dist/material/location/strategy/LocationStrategy.d.ts +20 -0
  67. package/dist/material/location/strategy/PositiveSequenceStrategy.d.ts +4 -0
  68. package/dist/material/location/strategy/PositiveSequenceStrategy.js +5 -1
  69. package/dist/material/location/strategy/PositiveSequenceStrategy.js.map +1 -1
  70. package/dist/material/memory/GameMemory.d.ts +21 -0
  71. package/dist/material/memory/GameMemory.js +22 -1
  72. package/dist/material/memory/GameMemory.js.map +1 -1
  73. package/dist/material/memory/PlayerMemory.d.ts +22 -0
  74. package/dist/material/memory/PlayerMemory.js +23 -1
  75. package/dist/material/memory/PlayerMemory.js.map +1 -1
  76. package/dist/material/moves/CustomMove.d.ts +18 -0
  77. package/dist/material/moves/CustomMove.js +13 -0
  78. package/dist/material/moves/CustomMove.js.map +1 -1
  79. package/dist/material/moves/MaterialMove.d.ts +9 -0
  80. package/dist/material/moves/MaterialMoveBuilder.d.ts +36 -0
  81. package/dist/material/moves/MaterialMoveBuilder.js +36 -0
  82. package/dist/material/moves/MaterialMoveBuilder.js.map +1 -1
  83. package/dist/material/moves/MoveKind.d.ts +3 -0
  84. package/dist/material/moves/MoveKind.js +3 -0
  85. package/dist/material/moves/MoveKind.js.map +1 -1
  86. package/dist/material/moves/items/CreateItem.d.ts +13 -0
  87. package/dist/material/moves/items/CreateItem.js +10 -0
  88. package/dist/material/moves/items/CreateItem.js.map +1 -1
  89. package/dist/material/moves/items/CreateItemsAtOnce.d.ts +14 -0
  90. package/dist/material/moves/items/CreateItemsAtOnce.js +10 -0
  91. package/dist/material/moves/items/CreateItemsAtOnce.js.map +1 -1
  92. package/dist/material/moves/items/DeleteItem.d.ts +18 -0
  93. package/dist/material/moves/items/DeleteItem.js +11 -0
  94. package/dist/material/moves/items/DeleteItem.js.map +1 -1
  95. package/dist/material/moves/items/DeleteItemsAtOnce.d.ts +17 -0
  96. package/dist/material/moves/items/DeleteItemsAtOnce.js +10 -0
  97. package/dist/material/moves/items/DeleteItemsAtOnce.js.map +1 -1
  98. package/dist/material/moves/items/ItemMove.d.ts +12 -0
  99. package/dist/material/moves/items/ItemMoveType.d.ts +3 -0
  100. package/dist/material/moves/items/ItemMoveType.js +3 -0
  101. package/dist/material/moves/items/ItemMoveType.js.map +1 -1
  102. package/dist/material/moves/items/MoveItem.d.ts +20 -0
  103. package/dist/material/moves/items/MoveItem.js +11 -0
  104. package/dist/material/moves/items/MoveItem.js.map +1 -1
  105. package/dist/material/moves/items/MoveItemsAtOnce.d.ts +20 -0
  106. package/dist/material/moves/items/MoveItemsAtOnce.js +10 -0
  107. package/dist/material/moves/items/MoveItemsAtOnce.js.map +1 -1
  108. package/dist/material/moves/items/RollItem.d.ts +19 -0
  109. package/dist/material/moves/items/RollItem.js +10 -0
  110. package/dist/material/moves/items/RollItem.js.map +1 -1
  111. package/dist/material/moves/items/SelectItem.d.ts +20 -0
  112. package/dist/material/moves/items/SelectItem.js +11 -0
  113. package/dist/material/moves/items/SelectItem.js.map +1 -1
  114. package/dist/material/moves/items/Shuffle.d.ts +26 -0
  115. package/dist/material/moves/items/Shuffle.js +15 -0
  116. package/dist/material/moves/items/Shuffle.js.map +1 -1
  117. package/dist/material/moves/local/CloseTutorialPopup.d.ts +8 -0
  118. package/dist/material/moves/local/CloseTutorialPopup.js +5 -0
  119. package/dist/material/moves/local/CloseTutorialPopup.js.map +1 -1
  120. package/dist/material/moves/local/DisplayHelp.d.ts +18 -0
  121. package/dist/material/moves/local/DisplayHelp.js +3 -0
  122. package/dist/material/moves/local/DisplayHelp.js.map +1 -1
  123. package/dist/material/moves/local/DropItem.d.ts +9 -0
  124. package/dist/material/moves/local/LocalMove.d.ts +6 -0
  125. package/dist/material/moves/local/LocalMove.js +3 -0
  126. package/dist/material/moves/local/LocalMove.js.map +1 -1
  127. package/dist/material/moves/local/SetTutorialStep.d.ts +8 -0
  128. package/dist/material/moves/local/SetTutorialStep.js +5 -0
  129. package/dist/material/moves/local/SetTutorialStep.js.map +1 -1
  130. package/dist/material/rules/MaterialRulesPart.d.ts +76 -0
  131. package/dist/material/rules/MaterialRulesPart.js +74 -1
  132. package/dist/material/rules/MaterialRulesPart.js.map +1 -1
  133. package/dist/material/rules/PlayerTurnRule.d.ts +19 -0
  134. package/dist/material/rules/PlayerTurnRule.js +20 -1
  135. package/dist/material/rules/PlayerTurnRule.js.map +1 -1
  136. package/dist/material/rules/RuleStep.d.ts +3 -0
  137. package/dist/material/rules/SimultaneousRule.d.ts +25 -0
  138. package/dist/material/rules/SimultaneousRule.js +21 -1
  139. package/dist/material/rules/SimultaneousRule.js.map +1 -1
  140. package/dist/material/tutorial/TutorialState.d.ts +7 -0
  141. package/dist/options/OptionsValidationError.js +1 -1
  142. package/dist/options/PlayerEnumOption.js +3 -0
  143. package/dist/options/PlayerEnumOption.js.map +1 -1
  144. package/dist/utils/action-view.util.js +2 -0
  145. package/dist/utils/action-view.util.js.map +1 -1
  146. package/dist/utils/enum.util.d.ts +27 -0
  147. package/dist/utils/enum.util.js +24 -0
  148. package/dist/utils/enum.util.js.map +1 -1
  149. package/dist/utils/grid.squares.util.d.ts +26 -0
  150. package/dist/utils/grid.squares.util.js +26 -0
  151. package/dist/utils/grid.squares.util.js.map +1 -1
  152. package/dist/utils/grid.util.d.ts +8 -0
  153. package/dist/utils/grid.util.js +5 -0
  154. package/dist/utils/grid.util.js.map +1 -1
  155. package/dist/utils/listing.util.d.ts +12 -0
  156. package/dist/utils/listing.util.js +12 -0
  157. package/dist/utils/listing.util.js.map +1 -1
  158. package/dist/utils/money.util.d.ts +41 -4
  159. package/dist/utils/money.util.js +38 -1
  160. package/dist/utils/money.util.js.map +1 -1
  161. package/dist/utils/random.util.d.ts +11 -0
  162. package/dist/utils/random.util.js +11 -0
  163. package/dist/utils/random.util.js.map +1 -1
  164. package/package.json +1 -1
@@ -5,17 +5,33 @@ var utils_1 = require("../utils");
5
5
  var items_1 = require("./items");
6
6
  var memory_1 = require("./memory");
7
7
  var moves_1 = require("./moves");
8
- var MaterialGameSetup = (function () {
8
+ /**
9
+ * Helper class to implement {@link GameSetup} when using the {@link MaterialRules} approach.
10
+ */
11
+ var MaterialGameSetup = /** @class */ (function () {
9
12
  function MaterialGameSetup() {
13
+ /**
14
+ * The game setup state we are working on
15
+ * @protected
16
+ */
10
17
  this.game = { players: [], items: {}, memory: {} };
11
18
  }
12
19
  Object.defineProperty(MaterialGameSetup.prototype, "rules", {
20
+ /**
21
+ * Get an instance of the rules of the game
22
+ */
13
23
  get: function () {
14
24
  return new this.Rules(this.game);
15
25
  },
16
26
  enumerable: false,
17
27
  configurable: true
18
28
  });
29
+ /**
30
+ * Entry point for {@link GameSetup}
31
+ * @param options Options of the game
32
+ * @param tutorial Initial tutorial state if any
33
+ * @returns the initial state of the game
34
+ */
19
35
  MaterialGameSetup.prototype.setup = function (options, tutorial) {
20
36
  this.game = { players: getPlayerIds(options), items: {}, memory: {}, tutorial: tutorial };
21
37
  this.setupMaterial(options);
@@ -23,14 +39,31 @@ var MaterialGameSetup = (function () {
23
39
  return this.game;
24
40
  };
25
41
  Object.defineProperty(MaterialGameSetup.prototype, "players", {
42
+ /**
43
+ * @returns array of the player ids (shortcut for this.game.players)
44
+ */
26
45
  get: function () {
27
46
  return this.game.players;
28
47
  },
29
48
  enumerable: false,
30
49
  configurable: true
31
50
  });
51
+ /**
52
+ * Override this function if you need to set up some material before the game starts. Called by {@link setup}.
53
+ * @param _options Options of the game
54
+ */
32
55
  MaterialGameSetup.prototype.setupMaterial = function (_options) {
33
56
  };
57
+ /**
58
+ * Help function to execute a move immediately on the game state.
59
+ * When the game is on, the moves should never be played directly: the framework takes care of playing the moves when necessary
60
+ * (on te server, on the clients, during replays...).
61
+ * However, during the setup, the moves must be played immediately in the game state to provide the initial game state to the framework.
62
+ * This help function allows to easily play a {@link MaterialMove}, using the rules provided in {@link Rules}, including the consequences.
63
+ *
64
+ * @param move The MaterialMove to play
65
+ * @protected
66
+ */
34
67
  MaterialGameSetup.prototype.playMove = function (move) {
35
68
  if ((0, utils_1.hasRandomMove)(this.rules)) {
36
69
  move = this.rules.randomize(move);
@@ -38,6 +71,11 @@ var MaterialGameSetup = (function () {
38
71
  var consequences = this.rules.play(JSON.parse(JSON.stringify(move)));
39
72
  (0, utils_1.applyAutomaticMoves)(this.rules, consequences);
40
73
  };
74
+ /**
75
+ * Helper function to manipulate the items of the game. See {@link Material}.
76
+ * @param type The type of Material we want to work on
77
+ * @returns a Material instance to manipulate all the material of that type in current game state.
78
+ */
41
79
  MaterialGameSetup.prototype.material = function (type) {
42
80
  var _this = this;
43
81
  if (!this.game.items[type])
@@ -45,19 +83,47 @@ var MaterialGameSetup = (function () {
45
83
  var items = this.game.items[type];
46
84
  return new items_1.Material(type, Array.from(items.entries()).filter(function (entry) { return entry[1].quantity !== 0; }), function (move) { return _this.playMove(move); });
47
85
  };
86
+ /**
87
+ * Utility function to access the memory tool for the game or on player.
88
+ * this.game.memory can be used to store any data that is not available through the state of the material, or current rule.
89
+ *
90
+ * @param player Optional, identifier of the player if we want to manipulate a specific player's memory
91
+ * @returns {@link GameMemory} or {@link PlayerMemory} utility
92
+ * @protected
93
+ */
48
94
  MaterialGameSetup.prototype.getMemory = function (player) {
49
95
  return player === undefined ? new memory_1.GameMemory(this.game) : new memory_1.PlayerMemory(this.game, player);
50
96
  };
97
+ /**
98
+ * Helper function to memorize some information that does not fit in an item or the rules state, in the game state
99
+ * @param key Key under which the memory is store. Usually a value of a numeric enum named "Memory".
100
+ * @param value Value to memorize
101
+ * @param player optional, if we need to memorize a different value for each player.
102
+ */
51
103
  MaterialGameSetup.prototype.memorize = function (key, value, player) {
52
104
  this.getMemory(player).memorize(key, value);
53
105
  };
106
+ /**
107
+ * Helper function to play a {@link StartPlayerTurn} move on the game setup state.
108
+ * @param id Rule id to start
109
+ * @param player Player that starts the game (default value: this.game.players[0])
110
+ */
54
111
  MaterialGameSetup.prototype.startPlayerTurn = function (id, player) {
55
112
  if (player === void 0) { player = this.game.players[0]; }
56
113
  this.playMove(moves_1.MaterialMoveBuilder.startPlayerTurn(id, player));
57
114
  };
115
+ /**
116
+ * Helper function to play a {@link StartSimultaneousRule} move on the game setup state.
117
+ * @param id Rule id to start
118
+ * @param players Players that are active (all the players by default)
119
+ */
58
120
  MaterialGameSetup.prototype.startSimultaneousRule = function (id, players) {
59
121
  this.playMove(moves_1.MaterialMoveBuilder.startSimultaneousRule(id, players));
60
122
  };
123
+ /**
124
+ * Helper function to play a {@link StartRule} move on the game setup state.
125
+ * @param id Rule id to start
126
+ */
61
127
  MaterialGameSetup.prototype.startRule = function (id) {
62
128
  this.playMove(moves_1.MaterialMoveBuilder.startRule(id));
63
129
  };
@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,OAAO,CAAC,CAAC,CAAA;IACvE,CAAC;IAED;;;OAGG;IACH,qCAAS,GAAT,UAA0C,EAAU;QAClD,IAAI,CAAC,QAAQ,CAAC,2BAAmB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;IAClD,CAAC;IACH,wBAAC;AAAD,CAAC,AAnID,IAmIC;AAnIqB,8CAAiB;AAqIvC,SAAS,YAAY,CAAiC,OAAY;;IAChE,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnC,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAC,MAAW,EAAE,KAAa,YAAK,OAAA,MAAA,MAAM,CAAC,EAAE,mCAAI,KAAK,GAAG,CAAC,CAAA,EAAA,CAAC,CAAA;IACpF,CAAC;SAAM,CAAC;QACN,IAAM,eAAe,GAAG,MAAA,OAAO,CAAC,OAAO,mCAAI,CAAC,CAAA;QAC5C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,CAAC,KAAK,GAAG,CAAC,CAAW,EAArB,CAAqB,CAAC,CAAA;IACtF,CAAC;AACH,CAAC"}
@@ -9,30 +9,155 @@ import { MaterialGame } from './MaterialGame';
9
9
  import { GameMemory, PlayerMemory } from './memory';
10
10
  import { MaterialMove, MaterialMoveRandomized, MaterialMoveView, RollItem } from './moves';
11
11
  import { MaterialRulesPart, MaterialRulesPartCreator } from './rules';
12
+ /**
13
+ * The MaterialRules class is the main class to implement the rules of a board game with the "Material oriented" approach.
14
+ * With this approach, the game state and the game moves is structured around the game material items and their movements.
15
+ * The rules are also automatically split into small parts.
16
+ * Finally, a "memory" util is available to store temporary information which is not part of the material or the rules state.
17
+ * If you need to implement game with hidden information, see {@link HiddenMaterialRules} or {@link SecretMaterialRules}.
18
+ *
19
+ * @typeparam Player - identifier of a player. Either a number or a numeric enum (eg: PlayerColor)
20
+ * @typeparam MaterialType - Numeric enum of the types of material manipulated in the game
21
+ * @typeparam LocationType - Numeric enum of the types of location in the game where the material can be located
22
+ */
12
23
  export declare abstract class MaterialRules<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends Rules<MaterialGame<Player, MaterialType, LocationType>, MaterialMove<Player, MaterialType, LocationType>, Player> implements RandomMove<MaterialMove<Player, MaterialType, LocationType>, MaterialMoveRandomized<Player, MaterialType, LocationType>>, Undo<MaterialMove<Player, MaterialType, LocationType>, Player>, UnpredictableMoves<MaterialMove<Player, MaterialType, LocationType>> {
24
+ /**
25
+ * When you implement a game using the "material" approach, you are also strongly advised to split the rules of the game into many small parts.
26
+ * You should usually create a numeric enum class "RuleId" that will list all those small parts.
27
+ * This "rules" property must be implemented to map each "rule id" with the corresponding MaterialRulesPart class.
28
+ * This way, the behavior of the rules can be delegated to the corresponding rule part at each step of the game.
29
+ */
13
30
  abstract readonly rules: Record<number, MaterialRulesPartCreator<Player, MaterialType, LocationType>>;
31
+ /**
32
+ * The "location strategies" are global rules that always apply in a game when we want to maintain a consistency in the position of the material.
33
+ * For example, we usually want the cards in a player hand to always go from x=0 to x=n without a gap, so we use a {@link PositiveSequenceStrategy} to enforce
34
+ * the rule once and for all. If we want to create a "river" of card we can use a {@link FillGapStrategy}.
35
+ * Games with more complex use cases can implement their own {@link LocationStrategy}.
36
+ */
14
37
  readonly locationsStrategies: Partial<Record<MaterialType, Partial<Record<LocationType, LocationStrategy<Player, MaterialType, LocationType>>>>>;
38
+ /**
39
+ * Helper function to manipulate the material items of the game. See {@link Material}.
40
+ *
41
+ * @param type The type of Material we want to work on
42
+ * @returns a Material instance to manipulate all the material of that type in current game state.
43
+ */
15
44
  material(type: MaterialType): Material<Player, MaterialType, LocationType>;
45
+ /**
46
+ * Shortcut for this.game.players
47
+ * @returns array of the players identifiers
48
+ */
16
49
  get players(): Player[];
50
+ /**
51
+ * Utility function to access the memory tool for the game or on player.
52
+ * this.game.memory can be used to store any data that is not available through the state of the material, or current rule.
53
+ *
54
+ * @param player Optional, identifier of the player if we want to manipulate a specific player's memory
55
+ * @returns {@link GameMemory} or {@link PlayerMemory} utility
56
+ * @protected
57
+ */
17
58
  protected getMemory(player?: Player): GameMemory<Player> | PlayerMemory<Player>;
59
+ /**
60
+ * Retrieve the value memorized under a given key.
61
+ * Shortcut for this.game.memory[key] or this.game.memory[key][player]
62
+ *
63
+ * @param key Key under which the memory is store. Usually a value of a numeric enum named "Memory".
64
+ * @param player optional, if we need to memorize a different value for each player.
65
+ */
18
66
  remind<T = any>(key: keyof any, player?: Player): T;
67
+ /**
68
+ * Instantiates the class that handled the rules of the game corresponding to the current rule id.
69
+ * This function reads the current value in this.game.rule.id and instantiate the corresponding class in the {@link rules} property.
70
+ *
71
+ * @returns the class that handled the rules of the game, at current specific game state.
72
+ */
19
73
  get rulesStep(): MaterialRulesPart<Player, MaterialType, LocationType> | undefined;
74
+ /**
75
+ * Returns a utility class to change the state of the items.
76
+ * Used by the framework to apply the Material moves on the items (should not be manipulated directly in the games).
77
+ *
78
+ * @param type MaterialType of the item we want to modify
79
+ * @returns a MaterialMutator to change the state of the items
80
+ */
20
81
  mutator(type: MaterialType): MaterialMutator<Player, MaterialType, LocationType>;
82
+ /**
83
+ * Items can sometime be stored with a quantity (for example, coins).
84
+ * By default, if you create or move similar items to the exact same location, they will merge into one item with a quantity.
85
+ * However, if you have 2 cards that can be at the same spot for a short time (swapping or replacing), you can override this function to prevent them to merge
86
+ *
87
+ * @param _type type of items
88
+ * @returns true if items can merge into one item with a quantity (default behavior)
89
+ */
21
90
  itemsCanMerge(_type: MaterialType): boolean;
91
+ /**
92
+ * In the material approach, the rules behavior is delegated to the current {@link rulesStep}. See {@link Rules.delegate}
93
+ */
22
94
  delegate(): Rules<MaterialGame<Player, MaterialType, LocationType>, MaterialMove<Player, MaterialType, LocationType>, Player> | undefined;
95
+ /**
96
+ * Randomize Shuffle of Roll moves (see {@link RandomMove.randomize})
97
+ * @param move The Material Move to randomize
98
+ * @returns the randomized move
99
+ */
23
100
  randomize(move: MaterialMove<Player, MaterialType, LocationType>): MaterialMove<Player, MaterialType, LocationType> & MaterialMoveRandomized<Player, MaterialType, LocationType>;
101
+ /**
102
+ * When a RollItem move is create, it has to be randomized on the server side before it is saved and shared.
103
+ * This function provides the random value. By default, it returns a value between 0 and 5 assuming a 6 sided dice is rolled.
104
+ * If you need to flip a coin or roll non-cubic dice, you need to override this function.
105
+ *
106
+ * @param _move The RollItem move to randomize
107
+ * @returns a random rolled value, by default a value between 0 and 5 (cubic dice result)
108
+ */
24
109
  roll(_move: RollItem<Player, MaterialType, LocationType>): number;
110
+ /**
111
+ * Execution of the Material Moves. See {@link Rules.play}.
112
+ *
113
+ * @param move Material move to play on the game state
114
+ * @param context Context in which the move was played
115
+ * @returns Consequences of the move
116
+ */
25
117
  play(move: MaterialMoveRandomized<Player, MaterialType, LocationType> | MaterialMoveView<Player, MaterialType, LocationType>, context?: PlayMoveContext): MaterialMove<Player, MaterialType, LocationType>[];
26
118
  private changeRule;
119
+ /**
120
+ * By default, a Material Move can be undone if no player became active and no dice was rolled.
121
+ * See {@link Undo.canUndo} and {@link HiddenMaterialRules.canUndo}
122
+ *
123
+ * @param action Action to consider
124
+ * @param consecutiveActions Action played in between
125
+ * @returns true if the action can be undone by the player that played it
126
+ */
27
127
  canUndo(action: Action<MaterialMove<Player, MaterialType, LocationType>, Player>, consecutiveActions: Action<MaterialMove<Player, MaterialType, LocationType>, Player>[]): boolean;
28
128
  private consecutiveActionBlocksUndo;
29
129
  private actionBlocksUndo;
30
130
  private actionActivatesPlayer;
131
+ /**
132
+ * @protected
133
+ * If a moves blocks the undo, any action with this move cannot be undone.
134
+ * By default, a move block the undo if it activates a player or exposes new information (roll result, hidden information revealed...)
135
+ *
136
+ * @param move The move to consider
137
+ * @returns true if the move blocks the undo
138
+ */
31
139
  protected moveBlocksUndo(move: MaterialMove<Player, MaterialType, LocationType>): boolean;
32
140
  private moveActivatesPlayer;
141
+ /**
142
+ * Random moves, or moves that reveals something to me, are unpredictable.
143
+ * Unpredictable moves cannot be precomputed on client side, the server side's response is necessary.
144
+ * See {@link Rules.isUnpredictableMove}
145
+ *
146
+ * @param move Material move to consider
147
+ * @param _player The player playing the move
148
+ * @returns true if the move outcome cannot be predicted on client side
149
+ */
33
150
  isUnpredictableMove(move: MaterialMove<Player, MaterialType, LocationType>, _player: Player): boolean;
151
+ /**
152
+ * A Material Game is over when there is no rule left to execute. This state results of a {@link EndGame} move.
153
+ *
154
+ * @returns true if game is over
155
+ */
34
156
  isOver(): boolean;
35
157
  }
158
+ /**
159
+ * Signature interface of the constructor of a class that implements MaterialRules
160
+ */
36
161
  export interface MaterialRulesCreator<P extends number = number, M extends number = number, L extends number = number> {
37
162
  new (state: MaterialGame<P, M, L>, client?: {
38
163
  player?: P;
@@ -37,31 +37,79 @@ var items_1 = require("./items");
37
37
  var memory_1 = require("./memory");
38
38
  var moves_1 = require("./moves");
39
39
  var rules_1 = require("./rules");
40
- var MaterialRules = (function (_super) {
40
+ /**
41
+ * The MaterialRules class is the main class to implement the rules of a board game with the "Material oriented" approach.
42
+ * With this approach, the game state and the game moves is structured around the game material items and their movements.
43
+ * The rules are also automatically split into small parts.
44
+ * Finally, a "memory" util is available to store temporary information which is not part of the material or the rules state.
45
+ * If you need to implement game with hidden information, see {@link HiddenMaterialRules} or {@link SecretMaterialRules}.
46
+ *
47
+ * @typeparam Player - identifier of a player. Either a number or a numeric enum (eg: PlayerColor)
48
+ * @typeparam MaterialType - Numeric enum of the types of material manipulated in the game
49
+ * @typeparam LocationType - Numeric enum of the types of location in the game where the material can be located
50
+ */
51
+ var MaterialRules = /** @class */ (function (_super) {
41
52
  __extends(MaterialRules, _super);
42
53
  function MaterialRules() {
43
54
  var _this = _super !== null && _super.apply(this, arguments) || this;
55
+ /**
56
+ * The "location strategies" are global rules that always apply in a game when we want to maintain a consistency in the position of the material.
57
+ * For example, we usually want the cards in a player hand to always go from x=0 to x=n without a gap, so we use a {@link PositiveSequenceStrategy} to enforce
58
+ * the rule once and for all. If we want to create a "river" of card we can use a {@link FillGapStrategy}.
59
+ * Games with more complex use cases can implement their own {@link LocationStrategy}.
60
+ */
44
61
  _this.locationsStrategies = {};
45
62
  return _this;
46
63
  }
64
+ /**
65
+ * Helper function to manipulate the material items of the game. See {@link Material}.
66
+ *
67
+ * @param type The type of Material we want to work on
68
+ * @returns a Material instance to manipulate all the material of that type in current game state.
69
+ */
47
70
  MaterialRules.prototype.material = function (type) {
48
71
  var _a;
49
72
  return new items_1.Material(type, Array.from(((_a = this.game.items[type]) !== null && _a !== void 0 ? _a : []).entries()).filter(function (entry) { return entry[1].quantity !== 0; }));
50
73
  };
51
74
  Object.defineProperty(MaterialRules.prototype, "players", {
75
+ /**
76
+ * Shortcut for this.game.players
77
+ * @returns array of the players identifiers
78
+ */
52
79
  get: function () {
53
80
  return this.game.players;
54
81
  },
55
82
  enumerable: false,
56
83
  configurable: true
57
84
  });
85
+ /**
86
+ * Utility function to access the memory tool for the game or on player.
87
+ * this.game.memory can be used to store any data that is not available through the state of the material, or current rule.
88
+ *
89
+ * @param player Optional, identifier of the player if we want to manipulate a specific player's memory
90
+ * @returns {@link GameMemory} or {@link PlayerMemory} utility
91
+ * @protected
92
+ */
58
93
  MaterialRules.prototype.getMemory = function (player) {
59
94
  return player === undefined ? new memory_1.GameMemory(this.game) : new memory_1.PlayerMemory(this.game, player);
60
95
  };
96
+ /**
97
+ * Retrieve the value memorized under a given key.
98
+ * Shortcut for this.game.memory[key] or this.game.memory[key][player]
99
+ *
100
+ * @param key Key under which the memory is store. Usually a value of a numeric enum named "Memory".
101
+ * @param player optional, if we need to memorize a different value for each player.
102
+ */
61
103
  MaterialRules.prototype.remind = function (key, player) {
62
104
  return this.getMemory(player).remind(key);
63
105
  };
64
106
  Object.defineProperty(MaterialRules.prototype, "rulesStep", {
107
+ /**
108
+ * Instantiates the class that handled the rules of the game corresponding to the current rule id.
109
+ * This function reads the current value in this.game.rule.id and instantiate the corresponding class in the {@link rules} property.
110
+ *
111
+ * @returns the class that handled the rules of the game, at current specific game state.
112
+ */
65
113
  get: function () {
66
114
  if (!this.game.rule)
67
115
  return;
@@ -75,16 +123,39 @@ var MaterialRules = (function (_super) {
75
123
  enumerable: false,
76
124
  configurable: true
77
125
  });
126
+ /**
127
+ * Returns a utility class to change the state of the items.
128
+ * Used by the framework to apply the Material moves on the items (should not be manipulated directly in the games).
129
+ *
130
+ * @param type MaterialType of the item we want to modify
131
+ * @returns a MaterialMutator to change the state of the items
132
+ */
78
133
  MaterialRules.prototype.mutator = function (type) {
79
134
  var _a;
80
135
  return new items_1.MaterialMutator(type, (_a = this.game.items[type]) !== null && _a !== void 0 ? _a : [], this.locationsStrategies[type], this.itemsCanMerge(type));
81
136
  };
137
+ /**
138
+ * Items can sometime be stored with a quantity (for example, coins).
139
+ * By default, if you create or move similar items to the exact same location, they will merge into one item with a quantity.
140
+ * However, if you have 2 cards that can be at the same spot for a short time (swapping or replacing), you can override this function to prevent them to merge
141
+ *
142
+ * @param _type type of items
143
+ * @returns true if items can merge into one item with a quantity (default behavior)
144
+ */
82
145
  MaterialRules.prototype.itemsCanMerge = function (_type) {
83
146
  return true;
84
147
  };
148
+ /**
149
+ * In the material approach, the rules behavior is delegated to the current {@link rulesStep}. See {@link Rules.delegate}
150
+ */
85
151
  MaterialRules.prototype.delegate = function () {
86
152
  return this.rulesStep;
87
153
  };
154
+ /**
155
+ * Randomize Shuffle of Roll moves (see {@link RandomMove.randomize})
156
+ * @param move The Material Move to randomize
157
+ * @returns the randomized move
158
+ */
88
159
  MaterialRules.prototype.randomize = function (move) {
89
160
  if ((0, moves_1.isShuffle)(move)) {
90
161
  return __assign(__assign({}, move), { newIndexes: (0, shuffle_1.default)(move.indexes) });
@@ -94,9 +165,24 @@ var MaterialRules = (function (_super) {
94
165
  }
95
166
  return move;
96
167
  };
168
+ /**
169
+ * When a RollItem move is create, it has to be randomized on the server side before it is saved and shared.
170
+ * This function provides the random value. By default, it returns a value between 0 and 5 assuming a 6 sided dice is rolled.
171
+ * If you need to flip a coin or roll non-cubic dice, you need to override this function.
172
+ *
173
+ * @param _move The RollItem move to randomize
174
+ * @returns a random rolled value, by default a value between 0 and 5 (cubic dice result)
175
+ */
97
176
  MaterialRules.prototype.roll = function (_move) {
98
177
  return (0, random_1.default)(5);
99
178
  };
179
+ /**
180
+ * Execution of the Material Moves. See {@link Rules.play}.
181
+ *
182
+ * @param move Material move to play on the game state
183
+ * @param context Context in which the move was played
184
+ * @returns Consequences of the move
185
+ */
100
186
  MaterialRules.prototype.play = function (move, context) {
101
187
  var _a, _b;
102
188
  var consequences = [];
@@ -181,6 +267,14 @@ var MaterialRules = (function (_super) {
181
267
  }
182
268
  return moves.concat((_f = (_e = this.rulesStep) === null || _e === void 0 ? void 0 : _e.onRuleStart(move, rule, context)) !== null && _f !== void 0 ? _f : []);
183
269
  };
270
+ /**
271
+ * By default, a Material Move can be undone if no player became active and no dice was rolled.
272
+ * See {@link Undo.canUndo} and {@link HiddenMaterialRules.canUndo}
273
+ *
274
+ * @param action Action to consider
275
+ * @param consecutiveActions Action played in between
276
+ * @returns true if the action can be undone by the player that played it
277
+ */
184
278
  MaterialRules.prototype.canUndo = function (action, consecutiveActions) {
185
279
  for (var i = consecutiveActions.length - 1; i >= 0; i--) {
186
280
  if (this.consecutiveActionBlocksUndo(action, consecutiveActions[i])) {
@@ -216,15 +310,37 @@ var MaterialRules = (function (_super) {
216
310
  }
217
311
  return this.moveActivatesPlayer(action.move);
218
312
  };
313
+ /**
314
+ * @protected
315
+ * If a moves blocks the undo, any action with this move cannot be undone.
316
+ * By default, a move block the undo if it activates a player or exposes new information (roll result, hidden information revealed...)
317
+ *
318
+ * @param move The move to consider
319
+ * @returns true if the move blocks the undo
320
+ */
219
321
  MaterialRules.prototype.moveBlocksUndo = function (move) {
220
322
  return this.moveActivatesPlayer(move) || (0, moves_1.isRoll)(move);
221
323
  };
222
324
  MaterialRules.prototype.moveActivatesPlayer = function (move) {
223
325
  return (0, moves_1.isStartPlayerTurn)(move) || (0, moves_1.isStartSimultaneousRule)(move);
224
326
  };
327
+ /**
328
+ * Random moves, or moves that reveals something to me, are unpredictable.
329
+ * Unpredictable moves cannot be precomputed on client side, the server side's response is necessary.
330
+ * See {@link Rules.isUnpredictableMove}
331
+ *
332
+ * @param move Material move to consider
333
+ * @param _player The player playing the move
334
+ * @returns true if the move outcome cannot be predicted on client side
335
+ */
225
336
  MaterialRules.prototype.isUnpredictableMove = function (move, _player) {
226
337
  return (0, moves_1.isRoll)(move);
227
338
  };
339
+ /**
340
+ * A Material Game is over when there is no rule left to execute. This state results of a {@link EndGame} move.
341
+ *
342
+ * @returns true if game is over
343
+ */
228
344
  MaterialRules.prototype.isOver = function () {
229
345
  return !this.game.rule;
230
346
  };
@@ -1 +1 @@
1
- {"version":3,"file":"MaterialRules.js","sourceRoot":"","sources":["../../src/material/MaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAkC;AAClC,2DAAoC;AAGpC,kCAAiD;AAGjD,iCAAmD;AAGnD,mCAAmD;AACnD,iCAgBgB;AAChB,iCAAyF;AAazF;IACU,iCAAiH;IAD3H;;QAqBW,yBAAmB,GAAuH,EAAE,CAAA;;IAuSvJ,CAAC;IA/RC,gCAAQ,GAAR,UAAS,IAAkB;;QACzB,OAAO,IAAI,gBAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,EAAvB,CAAuB,CAAC,CAAC,CAAA;IACzH,CAAC;IAMD,sBAAI,kCAAO;aAAX;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,O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,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACzC,CAAC;IAEO,6CAAqB,GAA7B,UAA8B,MAAwE;QACpG,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACzD,IAAI,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACrD,OAAO,IAAI,CAAA;YACb,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC9C,CAAC;IAED;;;;;;;OAOG;IACO,sCAAc,GAAxB,UAAyB,IAAsD;QAC7E,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,IAAA,cAAM,EAAC,IAAI,CAAC,CAAA;IACvD,CAAC;IAEO,2CAAmB,GAA3B,UAA4B,IAAsD;QAChF,OAAO,IAAA,yBAAiB,EAAC,IAAI,CAAC,IAAI,IAAA,+BAAuB,EAAC,IAAI,CAAC,CAAA;IACjE,CAAC;IAED;;;;;;;;OAQG;IACH,2CAAmB,GAAnB,UAAoB,IAAsD,EAAE,OAAe;QACzF,OAAO,IAAA,cAAM,EAAC,IAAI,CAAC,CAAA;IACrB,CAAC;IAED;;;;OAIG;IACH,8BAAM,GAAN;QACE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;IACxB,CAAC;IACH,oBAAC;AAAD,CAAC,AA5TD,CACU,aAAK,GA2Td;AA5TqB,sCAAa"}
@@ -3,11 +3,42 @@ import { HiddenMaterialRules, HidingStrategy } from './HiddenMaterialRules';
3
3
  import { MaterialItem } from './items';
4
4
  import { MaterialGame } from './MaterialGame';
5
5
  import { MaterialMove, MaterialMoveRandomized } from './moves';
6
+ /**
7
+ * Implement SecretMaterialRules when you want to use the {@link MaterialRules} approach with {@link SecretInformation}.
8
+ * Using some {@link HidingSecretsStrategy} allows to enforce the security of a game with secret information easily.
9
+ * If the game has only hidden information (all players have the same information), then you must implement {@link HiddenMaterialRules} instead.
10
+ */
6
11
  export declare abstract class SecretMaterialRules<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends HiddenMaterialRules<Player, MaterialType, LocationType> implements SecretInformation<MaterialGame, MaterialMove<Player, MaterialType, LocationType>, MaterialMove<Player, MaterialType, LocationType>, Player> {
12
+ /**
13
+ * Link {@link HiddenMaterialRules.hidingStrategies}, but with knowledge of whom the item should be hidden from.
14
+ * See {@link HidingSecretsStrategy}
15
+ */
7
16
  abstract hidingStrategies: Partial<Record<MaterialType, Partial<Record<LocationType, HidingSecretsStrategy<Player, LocationType>>>>>;
17
+ /**
18
+ * With the material approach, we can offer a default working implementation for {@link SecretInformation.getPlayerView}
19
+ */
8
20
  getPlayerView(player: Player): MaterialGame<Player, MaterialType, LocationType>;
21
+ /**
22
+ * With the material approach, we can offer a default working implementation for {@link SecretInformation.getPlayerMoveView}
23
+ */
9
24
  getPlayerMoveView(move: MaterialMoveRandomized<Player, MaterialType, LocationType>, player: Player): MaterialMove<Player, MaterialType, LocationType>;
10
25
  }
26
+ /**
27
+ * A Hiding Strategy is a function that takes an item and a player and returns a list of path to hide in the item object.
28
+ * If the player parameter is undefined, the function must return the information to hide from the spectators.
29
+ * See {@link hideItemIdToOthers} and {@link hideFrontToOthers} for 2 HidingSecretsStrategy frequently used.
30
+ */
11
31
  export type HidingSecretsStrategy<P extends number = number, L extends number = number> = (item: MaterialItem<P, L>, player?: P) => string[];
32
+ /**
33
+ * Hide the item id to all players except the player that is equal to item.location.player.
34
+ * Used to hide cards in a player's hand from others for instance.
35
+ * @param item The item to hide information from
36
+ * @param player The player to hide information to (or the spectator)
37
+ */
12
38
  export declare const hideItemIdToOthers: <P extends number = number, L extends number = number>(item: MaterialItem<P, L>, player?: P) => string[];
39
+ /**
40
+ * Hide the item.id.front to all players except the player that is equal to item.location.player.
41
+ * @param item The item to hide information from
42
+ * @param player The player to hide information to (or the spectator)
43
+ */
13
44
  export declare const hideFrontToOthers: HidingStrategy;
@@ -17,22 +17,44 @@ var __extends = (this && this.__extends) || (function () {
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.hideFrontToOthers = exports.hideItemIdToOthers = exports.SecretMaterialRules = void 0;
19
19
  var HiddenMaterialRules_1 = require("./HiddenMaterialRules");
20
- var SecretMaterialRules = (function (_super) {
20
+ /**
21
+ * Implement SecretMaterialRules when you want to use the {@link MaterialRules} approach with {@link SecretInformation}.
22
+ * Using some {@link HidingSecretsStrategy} allows to enforce the security of a game with secret information easily.
23
+ * If the game has only hidden information (all players have the same information), then you must implement {@link HiddenMaterialRules} instead.
24
+ */
25
+ var SecretMaterialRules = /** @class */ (function (_super) {
21
26
  __extends(SecretMaterialRules, _super);
22
27
  function SecretMaterialRules() {
23
28
  return _super !== null && _super.apply(this, arguments) || this;
24
29
  }
30
+ /**
31
+ * With the material approach, we can offer a default working implementation for {@link SecretInformation.getPlayerView}
32
+ */
25
33
  SecretMaterialRules.prototype.getPlayerView = function (player) {
26
34
  return this.getView(player);
27
35
  };
36
+ /**
37
+ * With the material approach, we can offer a default working implementation for {@link SecretInformation.getPlayerMoveView}
38
+ */
28
39
  SecretMaterialRules.prototype.getPlayerMoveView = function (move, player) {
29
40
  return this.getMoveView(move, player);
30
41
  };
31
42
  return SecretMaterialRules;
32
43
  }(HiddenMaterialRules_1.HiddenMaterialRules));
33
44
  exports.SecretMaterialRules = SecretMaterialRules;
45
+ /**
46
+ * Hide the item id to all players except the player that is equal to item.location.player.
47
+ * Used to hide cards in a player's hand from others for instance.
48
+ * @param item The item to hide information from
49
+ * @param player The player to hide information to (or the spectator)
50
+ */
34
51
  var hideItemIdToOthers = function (item, player) { return item.location.player === player ? [] : ['id']; };
35
52
  exports.hideItemIdToOthers = hideItemIdToOthers;
53
+ /**
54
+ * Hide the item.id.front to all players except the player that is equal to item.location.player.
55
+ * @param item The item to hide information from
56
+ * @param player The player to hide information to (or the spectator)
57
+ */
36
58
  var hideFrontToOthers = function (item, player) { return item.location.player === player ? [] : ['id.front']; };
37
59
  exports.hideFrontToOthers = hideFrontToOthers;
38
60
  //# sourceMappingURL=SecretMaterialRules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SecretMaterialRules.js","sourceRoot":"","sources":["../../src/material/SecretMaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,6DAA2E;AAU3E;IACU,uCAAuD;IADjE;;IAuBA,CAAC;IAVC,2CAAa,GAAb,UAAc,MAAc;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC;IAKD,+CAAiB,GAAjB,UAAkB,IAAgE,EAAE,MAAc;QAChG,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACvC,CAAC;IACH,0BAAC;AAAD,CAAC,AAvBD,CACU,yCAAmB,GAsB5B;AAvBqB,kDAAmB;AAsClC,IAAM,kBAAkB,GAAG,UAChC,IAAwB,EAAE,MAAU,IACvB,OAAA,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAA7C,CAA6C,CAAA;AAF/C,QAAA,kBAAkB,sBAE6B;AAOrD,IAAM,iBAAiB,GAAmB,UAC/C,IAAwB,EAAE,MAAU,IACvB,OAAA,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,EAAnD,CAAmD,CAAA;AAFrD,QAAA,iBAAiB,qBAEoC"}
1
+ {"version":3,"file":"SecretMaterialRules.js","sourceRoot":"","sources":["../../src/material/SecretMaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,6DAA2E;AAK3E;;;;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