@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
package/dist/Action.d.ts CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * An action is a move played by a player, with the consequences that resulted from it.
3
+ * @property id Unique identifier for the action (see {@link Undo})
4
+ * @property playerId Identifier of the player which played the move at the origin of the action
5
+ * @property move Move at the origin of the action
6
+ * @property consequences All the move that automatically happened after the move was played
7
+ */
1
8
  export type Action<Move = any, PlayerId = any> = {
2
9
  id?: string;
3
10
  playerId: PlayerId;
package/dist/Bot.d.ts CHANGED
@@ -1,12 +1,33 @@
1
1
  import { RulesCreator } from './Rules';
2
+ /**
3
+ * A Bot is a player controlled by a machine for a game.
4
+ * Used to replace players that quit a game, or for opponents in tutorials.
5
+ * Could be used to create AI players.
6
+ */
2
7
  export declare abstract class Bot<Game = any, Move = any, Player = any> {
3
8
  protected player: Player;
4
9
  protected constructor(player: Player);
10
+ /**
11
+ * When to bot run, it must return a list of moves to execute given the current game state.
12
+ * @param game Current game state
13
+ * @returns The moves that the bot plays
14
+ */
5
15
  abstract run(game: Game): Move[];
6
16
  }
17
+ /**
18
+ * A random bot picks a random move to play amongst all the legal moves.
19
+ * Most board games can list efficiently all the legal moves all the time, which allows to have random bot to replace any missing opponent.
20
+ */
7
21
  export declare class RandomBot<Game = any, Move = any, Player = any> extends Bot {
8
22
  private Rules;
9
23
  constructor(Rules: RulesCreator<Game, Move, Player>, player: Player);
10
24
  run(game: Game): Move[];
25
+ /**
26
+ * The legal moves for this player at this game state.
27
+ * Can be overridden if you need to further restrict the moves you want the bot to play.
28
+ *
29
+ * @param game The game state
30
+ * @protected
31
+ */
11
32
  protected getLegalMoves(game: Game): Move[];
12
33
  }
package/dist/Bot.js CHANGED
@@ -16,14 +16,23 @@ var __extends = (this && this.__extends) || (function () {
16
16
  })();
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.RandomBot = exports.Bot = void 0;
19
- var Bot = (function () {
19
+ /**
20
+ * A Bot is a player controlled by a machine for a game.
21
+ * Used to replace players that quit a game, or for opponents in tutorials.
22
+ * Could be used to create AI players.
23
+ */
24
+ var Bot = /** @class */ (function () {
20
25
  function Bot(player) {
21
26
  this.player = player;
22
27
  }
23
28
  return Bot;
24
29
  }());
25
30
  exports.Bot = Bot;
26
- var RandomBot = (function (_super) {
31
+ /**
32
+ * A random bot picks a random move to play amongst all the legal moves.
33
+ * Most board games can list efficiently all the legal moves all the time, which allows to have random bot to replace any missing opponent.
34
+ */
35
+ var RandomBot = /** @class */ (function (_super) {
27
36
  __extends(RandomBot, _super);
28
37
  function RandomBot(Rules, player) {
29
38
  var _this = _super.call(this, player) || this;
@@ -42,6 +51,13 @@ var RandomBot = (function (_super) {
42
51
  return [moves[Math.floor(Math.random() * moves.length)]];
43
52
  }
44
53
  };
54
+ /**
55
+ * The legal moves for this player at this game state.
56
+ * Can be overridden if you need to further restrict the moves you want the bot to play.
57
+ *
58
+ * @param game The game state
59
+ * @protected
60
+ */
45
61
  RandomBot.prototype.getLegalMoves = function (game) {
46
62
  return new this.Rules(game).getLegalMoves(this.player);
47
63
  };
package/dist/Bot.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Bot.js","sourceRoot":"","sources":["../src/Bot.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAOA;IACE,aAAgC,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAC9C,CAAC;IAQH,UAAC;AAAD,CAAC,AAVD,IAUC;AAVqB,kBAAG;AAgBzB;IAAqE,6BAAG;IACtE,mBAAoB,KAAuC,EAAE,MAAc;QACzE,YAAA,MAAK,YAAC,MAAM,CAAC,SAAA;QADK,WAAK,GAAL,KAAK,CAAkC;;IAE3D,CAAC;IAED,uBAAG,GAAH,UAAI,IAAU;QACZ,IAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;QACtC,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;YACrB,KAAK,CAAC;gBACJ,OAAO,CAAC,IAAI,CAAC,uEAAuE,CAAC,CAAA;gBACrF,OAAO,EAAE,CAAA;YACX,KAAK,CAAC;gBACJ,OAAO,KAAK,CAAA;YACd;gBACE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAC5D,CAAC;IACH,CAAC;IASS,iCAAa,GAAvB,UAAwB,IAAU;QAChC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACxD,CAAC;IACH,gBAAC;AAAD,CAAC,AA5BD,CAAqE,GAAG,GA4BvE;AA5BY,8BAAS"}
1
+ {"version":3,"file":"Bot.js","sourceRoot":"","sources":["../src/Bot.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA;;;;GAIG;AACH;IACE,aAAgC,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAC9C,CAAC;IAQH,UAAC;AAAD,CAAC,AAVD,IAUC;AAVqB,kBAAG;AAYzB;;;GAGG;AACH;IAAqE,6BAAG;IACtE,mBAAoB,KAAuC,EAAE,MAAc;QACzE,YAAA,MAAK,YAAC,MAAM,CAAC,SAAA;QADK,WAAK,GAAL,KAAK,CAAkC;;IAE3D,CAAC;IAED,uBAAG,GAAH,UAAI,IAAU;QACZ,IAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;QACtC,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;YACrB,KAAK,CAAC;gBACJ,OAAO,CAAC,IAAI,CAAC,uEAAuE,CAAC,CAAA;gBACrF,OAAO,EAAE,CAAA;YACX,KAAK,CAAC;gBACJ,OAAO,KAAK,CAAA;YACd;gBACE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAC5D,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACO,iCAAa,GAAvB,UAAwB,IAAU;QAChC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACxD,CAAC;IACH,gBAAC;AAAD,CAAC,AA5BD,CAAqE,GAAG,GA4BvE;AA5BY,8BAAS"}
@@ -1,12 +1,57 @@
1
1
  import { Rules } from './Rules';
2
+ /**
3
+ * In a competitive board game, players can be ranked at the end of the game.
4
+ * If the game relies on scores and tie-breakers, implement {@link CompetitiveScore}. Otherwise, implement {@link CompetitiveRank}
5
+ */
2
6
  export type Competitive<Game = any, Move = any, PlayerId = any> = CompetitiveScore<Game, Move, PlayerId> | CompetitiveRank<Game, Move, PlayerId>;
7
+ /**
8
+ * Interface for any Competitive game that rank players based on their scores (and potential tie-breakers).
9
+ */
3
10
  export interface CompetitiveScore<Game = any, Move = any, PlayerId = any> extends Rules<Game, Move, PlayerId> {
11
+ /**
12
+ * Compute the score of a player at the end of the game
13
+ * @param playerId Identifier of a player
14
+ * @returns The score of the player
15
+ */
4
16
  getScore(playerId: PlayerId): number;
17
+ /**
18
+ * The tie-breaker function if the rules of the game includes it.
19
+ * If players have the same score (see {@link getScore}), this function will be called for both players, with tieBreaker param equals to 1.
20
+ * If successive tie-breakers exists, it will be called as long as necessary with incremental values for tieBreaker, until the function returns undefined
21
+ * @param tieBreaker depth of the tie-breaker
22
+ * @param playerId Identifier of the player
23
+ * @returns the tie-breaker value for this player, or undefined if no tie-breaker exists at this point
24
+ */
5
25
  getTieBreaker?(tieBreaker: number, playerId: PlayerId): number | undefined;
6
26
  }
27
+ /**
28
+ * Interface to rank players in Competitive games that do not rely exclusively on scores to rank the players when game is over
29
+ */
7
30
  export interface CompetitiveRank<Game = any, Move = any, PlayerId = any> extends Rules<Game, Move, PlayerId> {
31
+ /**
32
+ * Rank two players when game is over (see {@link Array.sort})
33
+ *
34
+ * @param playerA Player A to compare
35
+ * @param playerB player B to compare
36
+ * @returns A positive number if B beats A, a negative number if A beats B, 0 in case of an equality
37
+ */
8
38
  rankPlayers(playerA: PlayerId, playerB: PlayerId): number;
9
39
  }
40
+ /**
41
+ * Type guard to identify if a game's Rule is Competitive or not.
42
+ * @param rules game's Rule
43
+ * @returns true if the game is competitive
44
+ */
10
45
  export declare function isCompetitive<Game, Move, PlayerId>(rules: Rules<any, any, PlayerId>): rules is Competitive<Game, Move, PlayerId>;
46
+ /**
47
+ * Type guard to identify if a game's Rule provide scores for players.
48
+ * @param rules game's Rule
49
+ * @returns true if the game is competitive with scores
50
+ */
11
51
  export declare function isCompetitiveScore<Game, Move, PlayerId>(rules: Rules<any, any, PlayerId>): rules is CompetitiveScore<Game, Move, PlayerId>;
52
+ /**
53
+ * Type guard to identify if a game's Rule can rank the players.
54
+ * @param rules game's Rule
55
+ * @returns true if the game is competitive with ranking (used when scores are not available)
56
+ */
12
57
  export declare function isCompetitiveRank<Game, Move, PlayerId>(rules: Rules<any, any, PlayerId>): rules is CompetitiveRank<Game, Move, PlayerId>;
@@ -1,14 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isCompetitiveRank = exports.isCompetitiveScore = exports.isCompetitive = void 0;
4
+ /**
5
+ * Type guard to identify if a game's Rule is Competitive or not.
6
+ * @param rules game's Rule
7
+ * @returns true if the game is competitive
8
+ */
4
9
  function isCompetitive(rules) {
5
10
  return isCompetitiveScore(rules) || isCompetitiveRank(rules);
6
11
  }
7
12
  exports.isCompetitive = isCompetitive;
13
+ /**
14
+ * Type guard to identify if a game's Rule provide scores for players.
15
+ * @param rules game's Rule
16
+ * @returns true if the game is competitive with scores
17
+ */
8
18
  function isCompetitiveScore(rules) {
9
19
  return typeof rules.getScore === 'function';
10
20
  }
11
21
  exports.isCompetitiveScore = isCompetitiveScore;
22
+ /**
23
+ * Type guard to identify if a game's Rule can rank the players.
24
+ * @param rules game's Rule
25
+ * @returns true if the game is competitive with ranking (used when scores are not available)
26
+ */
12
27
  function isCompetitiveRank(rules) {
13
28
  return typeof rules.rankPlayers === 'function';
14
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Competitive.js","sourceRoot":"","sources":["../src/Competitive.ts"],"names":[],"mappings":";;;AAiDA,SAAgB,aAAa,CAAuB,KAAgC;IAClF,OAAO,kBAAkB,CAAC,KAAK,CAAC,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAA;AAC9D,CAAC;AAFD,sCAEC;AAOD,SAAgB,kBAAkB,CAAuB,KAAgC;IACvF,OAAO,OAAQ,KAAgD,CAAC,QAAQ,KAAK,UAAU,CAAA;AACzF,CAAC;AAFD,gDAEC;AAOD,SAAgB,iBAAiB,CAAuB,KAAgC;IACtF,OAAO,OAAQ,KAA+C,CAAC,WAAW,KAAK,UAAU,CAAA;AAC3F,CAAC;AAFD,8CAEC"}
1
+ {"version":3,"file":"Competitive.js","sourceRoot":"","sources":["../src/Competitive.ts"],"names":[],"mappings":";;;AA4CA;;;;GAIG;AACH,SAAgB,aAAa,CAAuB,KAAgC;IAClF,OAAO,kBAAkB,CAAC,KAAK,CAAC,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAA;AAC9D,CAAC;AAFD,sCAEC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAuB,KAAgC;IACvF,OAAO,OAAQ,KAAgD,CAAC,QAAQ,KAAK,UAAU,CAAA;AACzF,CAAC;AAFD,gDAEC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAuB,KAAgC;IACtF,OAAO,OAAQ,KAA+C,CAAC,WAAW,KAAK,UAAU,CAAA;AAC3F,CAAC;AAFD,8CAEC"}
@@ -1,5 +1,22 @@
1
+ /**
2
+ * @deprecated
3
+ * When It's a Wonderful World was implemented, we wanted to be able to remove completely a player from the game:
4
+ * if a players quit or is ejected, instead of being replaced by a random bot, he no longer plays, and we do not deal cards to him.
5
+ * We had to know when a player was ejected, so this interface was created to provide a custom move automatically played when the player leaves.
6
+ *
7
+ * However, we could work out this feature without this extra interface, by doing this:
8
+ * 1. allow a custom "Quit" move everytime necessary in the legal moves
9
+ * 2. implement a custom {@link Bot} for the game that plays the "Quit" move by default if available
10
+ *
11
+ * Choose this solution instead of implementing the deprecated Eliminations interface if necessary.
12
+ */
1
13
  export interface Eliminations<Move = string, PlayerId = number> {
2
14
  isEliminated(playerId: PlayerId): boolean;
3
15
  giveUpMove?(playerId: PlayerId): Move | undefined;
4
16
  }
17
+ /**
18
+ * Type guard for {@link Eliminations} interface
19
+ * @param rules Rules of a game
20
+ * @returns true if the Rules implements {@link Eliminations}
21
+ */
5
22
  export declare function hasEliminations<Move, PlayerId>(rules: Object): rules is Eliminations<Move, PlayerId>;
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hasEliminations = void 0;
4
+ /**
5
+ * Type guard for {@link Eliminations} interface
6
+ * @param rules Rules of a game
7
+ * @returns true if the Rules implements {@link Eliminations}
8
+ */
4
9
  function hasEliminations(rules) {
5
10
  var test = rules;
6
11
  return typeof test.isEliminated === 'function';
@@ -1 +1 @@
1
- {"version":3,"file":"Eliminations.js","sourceRoot":"","sources":["../src/Eliminations.ts"],"names":[],"mappings":";;;AAuBA,SAAgB,eAAe,CAAiB,KAAa;IAC3D,IAAM,IAAI,GAAG,KAAqC,CAAA;IAClD,OAAO,OAAO,IAAI,CAAC,YAAY,KAAK,UAAU,CAAA;AAChD,CAAC;AAHD,0CAGC"}
1
+ {"version":3,"file":"Eliminations.js","sourceRoot":"","sources":["../src/Eliminations.ts"],"names":[],"mappings":";;;AAkBA;;;;GAIG;AACH,SAAgB,eAAe,CAAiB,KAAa;IAC3D,IAAM,IAAI,GAAG,KAAqC,CAAA;IAClD,OAAO,OAAO,IAAI,CAAC,YAAY,KAAK,UAAU,CAAA;AAChD,CAAC;AAHD,0CAGC"}
@@ -1,6 +1,20 @@
1
+ /**
2
+ * Each game must provide the initial game state when a new game is created.
3
+ * Create a class that implements this interface to provide it.
4
+ * The constructor must not have any arguments (see {@link GameSetupCreator}).
5
+ */
1
6
  export interface GameSetup<Game = any, Options = any> {
7
+ /**
8
+ * Create a new game base on the options chosen by the players
9
+ *
10
+ * @param options Options of the game (see {@link OptionsSpec})
11
+ * @returns the initial game state
12
+ */
2
13
  setup(options: Options): Game;
3
14
  }
15
+ /**
16
+ * Creator interface for {@link GameSetup}.
17
+ */
4
18
  export interface GameSetupCreator<Game = any, Options = any> {
5
19
  new (): GameSetup<Game, Options>;
6
20
  }
@@ -1,5 +1,27 @@
1
+ /**
2
+ * Some game hide information from the players, for example when a deck is shuffled and face-down on the table.
3
+ * In that case, to prevent any cheating, it is mandatory that Game Park server does not expose this information to the players or spectators.
4
+ * Implement this interface with you Rules class to enforce this security.
5
+ * If the game does not hide the same information to every player, you need to implement {@link SecretInformation} instead
6
+ */
1
7
  export interface HiddenInformation<GameView = any, Move = any, MoveView = any> {
8
+ /**
9
+ * @returns the state of the game without the information that is hidden to the players
10
+ */
2
11
  getView(): GameView;
12
+ /**
13
+ * When a move is played, sometime some information inside it must be hidden to the players,
14
+ * and sometimes the move will reveal information to the player that was previously unavailable
15
+ * Implement this function to remove or add any such information from the given move
16
+ *
17
+ * @param move the Move to transform before sending it to the players
18
+ * @returns the state of the game without the information that is hidden to the players
19
+ */
3
20
  getMoveView(move: Move): MoveView;
4
21
  }
22
+ /**
23
+ * Type guard for games with hidden information
24
+ * @param rules Rules of the game
25
+ * @returns true if the game implements {@link HiddenInformation}
26
+ */
5
27
  export declare function hasHiddenInformation<GameView = any, Move = any, MoveView = any>(rules: Object): rules is HiddenInformation<GameView, Move, MoveView>;
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hasHiddenInformation = void 0;
4
+ /**
5
+ * Type guard for games with hidden information
6
+ * @param rules Rules of the game
7
+ * @returns true if the game implements {@link HiddenInformation}
8
+ */
4
9
  function hasHiddenInformation(rules) {
5
10
  var test = rules;
6
11
  return typeof test.getView === 'function' && typeof test.getMoveView === 'function';
@@ -1 +1 @@
1
- {"version":3,"file":"HiddenInformation.js","sourceRoot":"","sources":["../src/HiddenInformation.ts"],"names":[],"mappings":";;;AA4BA,SAAgB,oBAAoB,CAA6C,KAAa;IAC5F,IAAM,IAAI,GAAG,KAAoD,CAAA;IACjE,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,UAAU,CAAA;AACrF,CAAC;AAHD,oDAGC"}
1
+ {"version":3,"file":"HiddenInformation.js","sourceRoot":"","sources":["../src/HiddenInformation.ts"],"names":[],"mappings":";;;AAuBA;;;;GAIG;AACH,SAAgB,oBAAoB,CAA6C,KAAa;IAC5F,IAAM,IAAI,GAAG,KAAoD,CAAA;IACjE,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,UAAU,CAAA;AACrF,CAAC;AAHD,oDAGC"}
@@ -1,4 +1,18 @@
1
+ /**
2
+ * This interface allows to keep a move played only on the player's side.
3
+ * It is convenient to allow the player to "preview" the results of their action before validating it.
4
+ */
1
5
  export interface LocalMovePreview<Move = any> {
6
+ /**
7
+ * Function called on client side after a move is played, before it is sent to the server
8
+ * @param move The move that was played
9
+ * @return true if the move must not be sent to the server
10
+ */
2
11
  previewMove(move: Move): boolean;
3
12
  }
13
+ /**
14
+ * Type guard for {@link LocalMovePreview} interface
15
+ * @param rules The game's rules
16
+ * @return true if the rules implements {@link LocalMovePreview}
17
+ */
4
18
  export declare function hasLocalMovePreview<Move = any>(rules: Object): rules is LocalMovePreview<Move>;
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hasLocalMovePreview = void 0;
4
+ /**
5
+ * Type guard for {@link LocalMovePreview} interface
6
+ * @param rules The game's rules
7
+ * @return true if the rules implements {@link LocalMovePreview}
8
+ */
4
9
  function hasLocalMovePreview(rules) {
5
10
  return typeof rules.previewMove === 'function';
6
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"LocalMovePreview.js","sourceRoot":"","sources":["../src/LocalMovePreview.ts"],"names":[],"mappings":";;;AAkBA,SAAgB,mBAAmB,CAAa,KAAa;IAC3D,OAAO,OAAQ,KAAgC,CAAC,WAAW,KAAK,UAAU,CAAA;AAC5E,CAAC;AAFD,kDAEC"}
1
+ {"version":3,"file":"LocalMovePreview.js","sourceRoot":"","sources":["../src/LocalMovePreview.ts"],"names":[],"mappings":";;;AAaA;;;;GAIG;AACH,SAAgB,mBAAmB,CAAa,KAAa;IAC3D,OAAO,OAAQ,KAAgC,CAAC,WAAW,KAAK,UAAU,CAAA;AAC5E,CAAC;AAFD,kDAEC"}
@@ -1,4 +1,21 @@
1
+ /**
2
+ * Some moves have a random output. This random output must be processed by the server, otherwise players could cheat.
3
+ * Also, the random output must be saved alongside the move in order to be able to replay the game consistently.
4
+ * (Another solution would have been to use a seed for the random number generator, but this feature was not available with Javascript Math.random).
5
+ * Therefore, the move must be played and validated without the random output, then the random output must be processed and added to the move.
6
+ * This interface must be implemented in order to add the random output to the moves that requires it.
7
+ */
1
8
  export interface RandomMove<Move = any, RandomizedMove = any> {
9
+ /**
10
+ * Add the random output to a move when necessary
11
+ * @param move A move just played that might need to be randomized
12
+ * @returns the move with the random output (or unchanged move if it is not a random move)
13
+ */
2
14
  randomize(move: Move): Move & RandomizedMove;
15
+ /**
16
+ * The signature of {@link Rules.play} changes a little bit: the moves are always randomized before they are played
17
+ * @param move The move to execute, always randomized first
18
+ * @returns the consequences of the move (not randomized yet)
19
+ */
3
20
  play(move: Move & RandomizedMove): Move[];
4
21
  }
package/dist/Rules.d.ts CHANGED
@@ -1,16 +1,129 @@
1
+ /**
2
+ * The Rules class is the basic minimal API to implement when adapting a board game on Game Park.
3
+ * It has the ability to tell whether it is a player's turn to play, what moves are legal, what happens when a move is played, and when the game is over.
4
+ *
5
+ * @typeparam Game - Data structure of the game state
6
+ * @typeparam Move - Data structure of a game move
7
+ * @typeparam PlayerId - type of the player's identifiers. Usually a number or a numeric enum.
8
+ */
1
9
  export declare abstract class Rules<Game = any, Move = any, PlayerId = any> {
10
+ /**
11
+ * The state of the game
12
+ */
2
13
  game: Game;
14
+ /**
15
+ * Construct a new instance of the Rules to work on a game state
16
+ * @param game the state of the game to work on
17
+ */
3
18
  constructor(game: Game);
19
+ /**
20
+ * A shortcut for this.game for backward compatibility
21
+ */
4
22
  get state(): Game;
23
+ /**
24
+ * The delegation allows to split the rules in smaller and simpler parts.
25
+ * Override this method to delegate the behavior of the other method to another Rules class.
26
+ *
27
+ * @return the Rule you want to delegate the current game behavior to
28
+ */
5
29
  delegate(): Rules<Game, Move, PlayerId> | undefined;
30
+ /**
31
+ * The delegation allows to split the rules in smaller and simpler parts.
32
+ * Default behavior call {@link delegate} and returns either an empty array, or an array with the delegate if any.
33
+ * Override this method to delegate the behavior of the other method to multiple Rules class.
34
+ *
35
+ * @return an array of Rules to delegate the current game behavior to
36
+ */
6
37
  delegates(): Rules<Game, Move, PlayerId>[];
38
+ /**
39
+ * Implement this to tell at any point in the game which player is active or not.
40
+ * When it's a player's turn, his thinking time decreases.
41
+ * A player whose turn it's not can have authorised moves, so this method is not sufficient to prevent a player from playing.
42
+ * Supports delegation: it returns true if any {@link delegates} return true.
43
+ *
44
+ * @param playerId - Identifier of a player
45
+ * @returns true if it is this player's turn to play
46
+ */
7
47
  isTurnToPlay(playerId: PlayerId): boolean;
48
+ /**
49
+ * When only one player is active at a time, you can implement this method instead of "isTurnToPlay" to tell which player is active.
50
+ * Supports delegation: if any {@link delegates} returns an active player, it will return it.
51
+ *
52
+ * @return @typeParam PlayerId - The identifier of the active player
53
+ */
8
54
  getActivePlayer(): PlayerId | undefined;
55
+ /**
56
+ * This method allows the Game Park server to authorise only valid moves in accordance with the game rules.
57
+ * The default behavior calls {@link getLegalMoves}, and returns true when at least one move is equal.
58
+ * Supports delegation with {@link delegates}. A move is legal if it is legal for at least one delegate.
59
+ *
60
+ * @param playerId - Identifier of a player
61
+ * @param move - a Move to control
62
+ * @returns true if the move can be played by this player
63
+ */
9
64
  isLegalMove(playerId: PlayerId, move: Move): boolean;
65
+ /**
66
+ * This method lists all the moves that are legal for a given player.
67
+ * This is optional but convenient: it is used by {@link isLegalMove}, {@link Bot} and many UI features from @gamepark/react-game to automatically
68
+ * highlight what can be done on the screen.
69
+ * Beware of the size of the list however: if the game offers to many legal moves, you might have to fall back to implementing {@link isLegalMove} and a
70
+ * custom {@link Bot}.
71
+ *
72
+ * Supports delegation with {@link delegates}: by default it will return all the legal moves of each delegate.
73
+ *
74
+ * @param playerId - Identifier of a player
75
+ * @returns the list of the moves
76
+ */
10
77
  getLegalMoves(playerId: PlayerId): Move[];
78
+ /**
79
+ * When some game state require automatic actions to be taken by the players, you can return a list of moves to play played automatically.
80
+ * It can be a sequences in the rules where everything is scripted for instance (no choices left for players).
81
+ *
82
+ * @deprecated because of the lifecycle of this method, the game state must never be modified inside it. However, it is a very common mistake, so
83
+ * this method should not be used at all: use {@link play} method to return the automatic moves.
84
+ *
85
+ * Supports delegation with {@link delegates}: by default it will return all the automatic moves of each delegate.
86
+ *
87
+ * @returns the list of the moves that must be played automatically
88
+ */
11
89
  getAutomaticMoves(): Move[];
90
+ /**
91
+ * Executes a move on current game state.
92
+ * This method is the only one that should mutate the state of the game.
93
+ * When a move is played by a player, or automatically played as a consequence of another move, it will be played by this method, independently on Game Park
94
+ * server and on every player or spectator clients. It can also be replayed in replay or undo features.
95
+ *
96
+ * A move should not change a lot the game state: instead, this method should return new moves to play as consequences.
97
+ * Dividing moves into small parts with consequences is key to producing step-by-step animations in the UI.
98
+ *
99
+ * see {@link https://en.wikipedia.org/wiki/Command_pattern}
100
+ *
101
+ * Supports delegation with {@link delegates}: by default it will play the move on each delegate, and return all the consequences.
102
+ *
103
+ * @param move - the Move to execute on the game state
104
+ * @param context - context of execution: see {@link PlayMoveContext}
105
+ * @returns A list of moves that should be immediately played as consequences of this move
106
+ */
12
107
  play(move: Move, context?: PlayMoveContext): Move[];
108
+ /**
109
+ * This method must return true when the game is over.
110
+ *
111
+ * Supports delegation with {@link delegates}: by default it will return true if there is at least one delegate, and every delegate returns true.
112
+ * Default behavior returns true if playersIds is provided, and it is not {@link isTurnToPlay} for any player - however this behavior is deprecated.
113
+ *
114
+ * @param playerIds - All the player ids in the game. Do not use (deprecated).
115
+ * @returns true if game is over
116
+ */
13
117
  isOver(playerIds?: PlayerId[]): boolean;
118
+ /**
119
+ * Implement this method when some moves output cannot be predicted on the client side.
120
+ * Unpredictable moves will not be proceeded by the client, which will wait for the server's response.
121
+ * Examples: rolling dices, drawing a card
122
+ *
123
+ * @param move a move that is going to be played
124
+ * @param player the player that played this move, or the move that triggered it as a consequence
125
+ * @returns true if the move cannot be predicted from the player point of view
126
+ */
14
127
  isUnpredictableMove?(move: Move, player: PlayerId): boolean;
15
128
  }
16
129
  export interface RulesCreator<Game = any, Move = any, Player = number> {
@@ -18,6 +131,12 @@ export interface RulesCreator<Game = any, Move = any, Player = number> {
18
131
  player?: Player;
19
132
  }): Rules<Game, Move, Player>;
20
133
  }
134
+ /**
135
+ * The context when a move is played.
136
+ */
21
137
  export type PlayMoveContext = {
138
+ /**
139
+ * true if move is only played locally on a player's client
140
+ */
22
141
  local?: boolean;
23
142
  };
package/dist/Rules.js CHANGED
@@ -6,24 +6,61 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Rules = void 0;
7
7
  var isEqual_1 = __importDefault(require("lodash/isEqual"));
8
8
  var Eliminations_1 = require("./Eliminations");
9
- var Rules = (function () {
9
+ /**
10
+ * The Rules class is the basic minimal API to implement when adapting a board game on Game Park.
11
+ * It has the ability to tell whether it is a player's turn to play, what moves are legal, what happens when a move is played, and when the game is over.
12
+ *
13
+ * @typeparam Game - Data structure of the game state
14
+ * @typeparam Move - Data structure of a game move
15
+ * @typeparam PlayerId - type of the player's identifiers. Usually a number or a numeric enum.
16
+ */
17
+ var Rules = /** @class */ (function () {
18
+ /**
19
+ * Construct a new instance of the Rules to work on a game state
20
+ * @param game the state of the game to work on
21
+ */
10
22
  function Rules(game) {
11
23
  this.game = game;
12
24
  }
13
25
  Object.defineProperty(Rules.prototype, "state", {
26
+ /**
27
+ * A shortcut for this.game for backward compatibility
28
+ */
14
29
  get: function () {
15
30
  return this.game;
16
31
  },
17
32
  enumerable: false,
18
33
  configurable: true
19
34
  });
35
+ /**
36
+ * The delegation allows to split the rules in smaller and simpler parts.
37
+ * Override this method to delegate the behavior of the other method to another Rules class.
38
+ *
39
+ * @return the Rule you want to delegate the current game behavior to
40
+ */
20
41
  Rules.prototype.delegate = function () {
21
42
  return;
22
43
  };
44
+ /**
45
+ * The delegation allows to split the rules in smaller and simpler parts.
46
+ * Default behavior call {@link delegate} and returns either an empty array, or an array with the delegate if any.
47
+ * Override this method to delegate the behavior of the other method to multiple Rules class.
48
+ *
49
+ * @return an array of Rules to delegate the current game behavior to
50
+ */
23
51
  Rules.prototype.delegates = function () {
24
52
  var delegate = this.delegate();
25
53
  return delegate ? [delegate] : [];
26
54
  };
55
+ /**
56
+ * Implement this to tell at any point in the game which player is active or not.
57
+ * When it's a player's turn, his thinking time decreases.
58
+ * A player whose turn it's not can have authorised moves, so this method is not sufficient to prevent a player from playing.
59
+ * Supports delegation: it returns true if any {@link delegates} return true.
60
+ *
61
+ * @param playerId - Identifier of a player
62
+ * @returns true if it is this player's turn to play
63
+ */
27
64
  Rules.prototype.isTurnToPlay = function (playerId) {
28
65
  var rules = this.delegates();
29
66
  if (rules.some(function (rules) { return rules.isTurnToPlay(playerId); })) {
@@ -31,6 +68,12 @@ var Rules = (function () {
31
68
  }
32
69
  return playerId === this.getActivePlayer();
33
70
  };
71
+ /**
72
+ * When only one player is active at a time, you can implement this method instead of "isTurnToPlay" to tell which player is active.
73
+ * Supports delegation: if any {@link delegates} returns an active player, it will return it.
74
+ *
75
+ * @return @typeParam PlayerId - The identifier of the active player
76
+ */
34
77
  Rules.prototype.getActivePlayer = function () {
35
78
  for (var _i = 0, _a = this.delegates(); _i < _a.length; _i++) {
36
79
  var delegate = _a[_i];
@@ -40,6 +83,15 @@ var Rules = (function () {
40
83
  }
41
84
  return;
42
85
  };
86
+ /**
87
+ * This method allows the Game Park server to authorise only valid moves in accordance with the game rules.
88
+ * The default behavior calls {@link getLegalMoves}, and returns true when at least one move is equal.
89
+ * Supports delegation with {@link delegates}. A move is legal if it is legal for at least one delegate.
90
+ *
91
+ * @param playerId - Identifier of a player
92
+ * @param move - a Move to control
93
+ * @returns true if the move can be played by this player
94
+ */
43
95
  Rules.prototype.isLegalMove = function (playerId, move) {
44
96
  var rules = this.delegates();
45
97
  if (rules.some(function (rules) { return rules.isLegalMove(playerId, move); })) {
@@ -53,15 +105,64 @@ var Rules = (function () {
53
105
  }
54
106
  return false;
55
107
  };
108
+ /**
109
+ * This method lists all the moves that are legal for a given player.
110
+ * This is optional but convenient: it is used by {@link isLegalMove}, {@link Bot} and many UI features from @gamepark/react-game to automatically
111
+ * highlight what can be done on the screen.
112
+ * Beware of the size of the list however: if the game offers to many legal moves, you might have to fall back to implementing {@link isLegalMove} and a
113
+ * custom {@link Bot}.
114
+ *
115
+ * Supports delegation with {@link delegates}: by default it will return all the legal moves of each delegate.
116
+ *
117
+ * @param playerId - Identifier of a player
118
+ * @returns the list of the moves
119
+ */
56
120
  Rules.prototype.getLegalMoves = function (playerId) {
57
121
  return this.delegates().flatMap(function (rules) { return rules.getLegalMoves(playerId); });
58
122
  };
123
+ /**
124
+ * When some game state require automatic actions to be taken by the players, you can return a list of moves to play played automatically.
125
+ * It can be a sequences in the rules where everything is scripted for instance (no choices left for players).
126
+ *
127
+ * @deprecated because of the lifecycle of this method, the game state must never be modified inside it. However, it is a very common mistake, so
128
+ * this method should not be used at all: use {@link play} method to return the automatic moves.
129
+ *
130
+ * Supports delegation with {@link delegates}: by default it will return all the automatic moves of each delegate.
131
+ *
132
+ * @returns the list of the moves that must be played automatically
133
+ */
59
134
  Rules.prototype.getAutomaticMoves = function () {
60
135
  return this.delegates().flatMap(function (rules) { return rules.getAutomaticMoves(); });
61
136
  };
137
+ /**
138
+ * Executes a move on current game state.
139
+ * This method is the only one that should mutate the state of the game.
140
+ * When a move is played by a player, or automatically played as a consequence of another move, it will be played by this method, independently on Game Park
141
+ * server and on every player or spectator clients. It can also be replayed in replay or undo features.
142
+ *
143
+ * A move should not change a lot the game state: instead, this method should return new moves to play as consequences.
144
+ * Dividing moves into small parts with consequences is key to producing step-by-step animations in the UI.
145
+ *
146
+ * see {@link https://en.wikipedia.org/wiki/Command_pattern}
147
+ *
148
+ * Supports delegation with {@link delegates}: by default it will play the move on each delegate, and return all the consequences.
149
+ *
150
+ * @param move - the Move to execute on the game state
151
+ * @param context - context of execution: see {@link PlayMoveContext}
152
+ * @returns A list of moves that should be immediately played as consequences of this move
153
+ */
62
154
  Rules.prototype.play = function (move, context) {
63
155
  return this.delegates().flatMap(function (rules) { return rules.play(move, context); });
64
156
  };
157
+ /**
158
+ * This method must return true when the game is over.
159
+ *
160
+ * Supports delegation with {@link delegates}: by default it will return true if there is at least one delegate, and every delegate returns true.
161
+ * Default behavior returns true if playersIds is provided, and it is not {@link isTurnToPlay} for any player - however this behavior is deprecated.
162
+ *
163
+ * @param playerIds - All the player ids in the game. Do not use (deprecated).
164
+ * @returns true if game is over
165
+ */
65
166
  Rules.prototype.isOver = function (playerIds) {
66
167
  var _this = this;
67
168
  var delegates = this.delegates();