@gamepark/rules-api 6.24.1 → 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.
- package/dist/Action.d.ts +7 -0
- package/dist/Bot.d.ts +21 -0
- package/dist/Bot.js +18 -2
- package/dist/Bot.js.map +1 -1
- package/dist/Competitive.d.ts +45 -0
- package/dist/Competitive.js +15 -0
- package/dist/Competitive.js.map +1 -1
- package/dist/Eliminations.d.ts +17 -0
- package/dist/Eliminations.js +5 -0
- package/dist/Eliminations.js.map +1 -1
- package/dist/GameSetup.d.ts +14 -0
- package/dist/HiddenInformation.d.ts +22 -0
- package/dist/HiddenInformation.js +5 -0
- package/dist/HiddenInformation.js.map +1 -1
- package/dist/LocalMovePreview.d.ts +14 -0
- package/dist/LocalMovePreview.js +5 -0
- package/dist/LocalMovePreview.js.map +1 -1
- package/dist/RandomMove.d.ts +17 -0
- package/dist/Rules.d.ts +119 -0
- package/dist/Rules.js +102 -1
- package/dist/Rules.js.map +1 -1
- package/dist/SecretInformation.d.ts +39 -0
- package/dist/SecretInformation.js +5 -0
- package/dist/SecretInformation.js.map +1 -1
- package/dist/TimeLimit.d.ts +22 -0
- package/dist/TimeLimit.js +5 -0
- package/dist/TimeLimit.js.map +1 -1
- package/dist/Undo.d.ts +18 -0
- package/dist/Undo.js +6 -0
- package/dist/Undo.js.map +1 -1
- package/dist/UnpredictableMove.d.ts +19 -0
- package/dist/UnpredictableMove.js +5 -0
- package/dist/UnpredictableMove.js.map +1 -1
- package/dist/material/HiddenMaterialRules.d.ts +49 -1
- package/dist/material/HiddenMaterialRules.js +49 -3
- package/dist/material/HiddenMaterialRules.js.map +1 -1
- package/dist/material/MaterialGame.d.ts +12 -0
- package/dist/material/MaterialGameSetup.d.ts +74 -0
- package/dist/material/MaterialGameSetup.js +67 -1
- package/dist/material/MaterialGameSetup.js.map +1 -1
- package/dist/material/MaterialRules.d.ts +125 -0
- package/dist/material/MaterialRules.js +122 -3
- package/dist/material/MaterialRules.js.map +1 -1
- package/dist/material/SecretMaterialRules.d.ts +31 -0
- package/dist/material/SecretMaterialRules.js +23 -1
- package/dist/material/SecretMaterialRules.js.map +1 -1
- package/dist/material/items/Material.d.ts +253 -0
- package/dist/material/items/Material.js +248 -1
- package/dist/material/items/Material.js.map +1 -1
- package/dist/material/items/MaterialDeck.d.ts +33 -0
- package/dist/material/items/MaterialDeck.js +34 -1
- package/dist/material/items/MaterialDeck.js.map +1 -1
- package/dist/material/items/MaterialItem.d.ts +12 -0
- package/dist/material/items/MaterialMutator.d.ts +39 -0
- package/dist/material/items/MaterialMutator.js +41 -2
- package/dist/material/items/MaterialMutator.js.map +1 -1
- package/dist/material/items/index.js +1 -1
- package/dist/material/items/index.js.map +1 -1
- package/dist/material/location/Location.d.ts +28 -0
- package/dist/material/location/Location.js +5 -0
- package/dist/material/location/Location.js.map +1 -1
- package/dist/material/location/LocationBuilder.js +1 -1
- package/dist/material/location/strategy/FillGapStrategy.d.ts +4 -0
- package/dist/material/location/strategy/FillGapStrategy.js +5 -1
- package/dist/material/location/strategy/FillGapStrategy.js.map +1 -1
- package/dist/material/location/strategy/LocationStrategy.d.ts +20 -0
- package/dist/material/location/strategy/PositiveSequenceStrategy.d.ts +4 -0
- package/dist/material/location/strategy/PositiveSequenceStrategy.js +5 -1
- package/dist/material/location/strategy/PositiveSequenceStrategy.js.map +1 -1
- package/dist/material/memory/GameMemory.d.ts +21 -0
- package/dist/material/memory/GameMemory.js +22 -1
- package/dist/material/memory/GameMemory.js.map +1 -1
- package/dist/material/memory/PlayerMemory.d.ts +22 -0
- package/dist/material/memory/PlayerMemory.js +23 -1
- package/dist/material/memory/PlayerMemory.js.map +1 -1
- package/dist/material/moves/CustomMove.d.ts +18 -0
- package/dist/material/moves/CustomMove.js +13 -0
- package/dist/material/moves/CustomMove.js.map +1 -1
- package/dist/material/moves/MaterialMove.d.ts +9 -0
- package/dist/material/moves/MaterialMoveBuilder.d.ts +36 -0
- package/dist/material/moves/MaterialMoveBuilder.js +36 -0
- package/dist/material/moves/MaterialMoveBuilder.js.map +1 -1
- package/dist/material/moves/MoveKind.d.ts +3 -0
- package/dist/material/moves/MoveKind.js +3 -0
- package/dist/material/moves/MoveKind.js.map +1 -1
- package/dist/material/moves/items/CreateItem.d.ts +13 -0
- package/dist/material/moves/items/CreateItem.js +10 -0
- package/dist/material/moves/items/CreateItem.js.map +1 -1
- package/dist/material/moves/items/CreateItemsAtOnce.d.ts +14 -0
- package/dist/material/moves/items/CreateItemsAtOnce.js +10 -0
- package/dist/material/moves/items/CreateItemsAtOnce.js.map +1 -1
- package/dist/material/moves/items/DeleteItem.d.ts +18 -0
- package/dist/material/moves/items/DeleteItem.js +11 -0
- package/dist/material/moves/items/DeleteItem.js.map +1 -1
- package/dist/material/moves/items/DeleteItemsAtOnce.d.ts +17 -0
- package/dist/material/moves/items/DeleteItemsAtOnce.js +10 -0
- package/dist/material/moves/items/DeleteItemsAtOnce.js.map +1 -1
- package/dist/material/moves/items/ItemMove.d.ts +12 -0
- package/dist/material/moves/items/ItemMoveType.d.ts +3 -0
- package/dist/material/moves/items/ItemMoveType.js +3 -0
- package/dist/material/moves/items/ItemMoveType.js.map +1 -1
- package/dist/material/moves/items/MoveItem.d.ts +20 -0
- package/dist/material/moves/items/MoveItem.js +11 -0
- package/dist/material/moves/items/MoveItem.js.map +1 -1
- package/dist/material/moves/items/MoveItemsAtOnce.d.ts +20 -0
- package/dist/material/moves/items/MoveItemsAtOnce.js +10 -0
- package/dist/material/moves/items/MoveItemsAtOnce.js.map +1 -1
- package/dist/material/moves/items/RollItem.d.ts +19 -0
- package/dist/material/moves/items/RollItem.js +10 -0
- package/dist/material/moves/items/RollItem.js.map +1 -1
- package/dist/material/moves/items/SelectItem.d.ts +20 -0
- package/dist/material/moves/items/SelectItem.js +11 -0
- package/dist/material/moves/items/SelectItem.js.map +1 -1
- package/dist/material/moves/items/Shuffle.d.ts +26 -0
- package/dist/material/moves/items/Shuffle.js +15 -0
- package/dist/material/moves/items/Shuffle.js.map +1 -1
- package/dist/material/moves/local/CloseTutorialPopup.d.ts +8 -0
- package/dist/material/moves/local/CloseTutorialPopup.js +5 -0
- package/dist/material/moves/local/CloseTutorialPopup.js.map +1 -1
- package/dist/material/moves/local/DisplayHelp.d.ts +18 -0
- package/dist/material/moves/local/DisplayHelp.js +3 -0
- package/dist/material/moves/local/DisplayHelp.js.map +1 -1
- package/dist/material/moves/local/DropItem.d.ts +9 -0
- package/dist/material/moves/local/LocalMove.d.ts +6 -0
- package/dist/material/moves/local/LocalMove.js +3 -0
- package/dist/material/moves/local/LocalMove.js.map +1 -1
- package/dist/material/moves/local/SetTutorialStep.d.ts +8 -0
- package/dist/material/moves/local/SetTutorialStep.js +5 -0
- package/dist/material/moves/local/SetTutorialStep.js.map +1 -1
- package/dist/material/rules/MaterialRulesPart.d.ts +76 -0
- package/dist/material/rules/MaterialRulesPart.js +74 -1
- package/dist/material/rules/MaterialRulesPart.js.map +1 -1
- package/dist/material/rules/PlayerTurnRule.d.ts +19 -0
- package/dist/material/rules/PlayerTurnRule.js +20 -1
- package/dist/material/rules/PlayerTurnRule.js.map +1 -1
- package/dist/material/rules/RuleStep.d.ts +3 -0
- package/dist/material/rules/SimultaneousRule.d.ts +25 -0
- package/dist/material/rules/SimultaneousRule.js +21 -1
- package/dist/material/rules/SimultaneousRule.js.map +1 -1
- package/dist/material/tutorial/TutorialState.d.ts +7 -0
- package/dist/options/OptionsValidationError.js +1 -1
- package/dist/options/PlayerEnumOption.js +3 -0
- package/dist/options/PlayerEnumOption.js.map +1 -1
- package/dist/utils/action-view.util.js +2 -0
- package/dist/utils/action-view.util.js.map +1 -1
- package/dist/utils/enum.util.d.ts +27 -0
- package/dist/utils/enum.util.js +24 -0
- package/dist/utils/enum.util.js.map +1 -1
- package/dist/utils/grid.squares.util.d.ts +26 -0
- package/dist/utils/grid.squares.util.js +26 -0
- package/dist/utils/grid.squares.util.js.map +1 -1
- package/dist/utils/grid.util.d.ts +8 -0
- package/dist/utils/grid.util.js +5 -0
- package/dist/utils/grid.util.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/listing.util.d.ts +12 -0
- package/dist/utils/listing.util.js +12 -0
- package/dist/utils/listing.util.js.map +1 -1
- package/dist/utils/money.util.d.ts +48 -0
- package/dist/utils/money.util.js +174 -0
- package/dist/utils/money.util.js.map +1 -0
- package/dist/utils/random.util.d.ts +11 -0
- package/dist/utils/random.util.js +11 -0
- package/dist/utils/random.util.js.map +1 -1
- package/package.json +1 -1
package/dist/Rules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rules.js","sourceRoot":"","sources":["../src/Rules.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAoC;AACpC,+CAAgD;
|
|
1
|
+
{"version":3,"file":"Rules.js","sourceRoot":"","sources":["../src/Rules.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAoC;AACpC,+CAAgD;AAEhD;;;;;;;GAOG;AACH;IAME;;;OAGG;IACH,eAAY,IAAU;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAKD,sBAAI,wBAAK;QAHT;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,IAAI,CAAA;QAClB,CAAC;;;OAAA;IAED;;;;;OAKG;IACH,wBAAQ,GAAR;QACE,OAAM;IACR,CAAC;IAED;;;;;;OAMG;IACH,yBAAS,GAAT;QACE,IAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;QAChC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACnC,CAAC;IAED;;;;;;;;OAQG;IACH,4BAAY,GAAZ,UAAa,QAAkB;QAC7B,IAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAC9B,IAAI,KAAK,CAAC,IAAI,CA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|
@@ -1,9 +1,48 @@
|
|
|
1
1
|
import { HiddenInformation } from './HiddenInformation';
|
|
2
|
+
/**
|
|
3
|
+
* Some game hide information to the player, and the information is not equally accessible by each player.
|
|
4
|
+
* For example, when a player knows the cards in their hand, but this information is not available to other players.
|
|
5
|
+
* The rules of the game need to implement this interface in that case to secure the information.
|
|
6
|
+
*
|
|
7
|
+
* It is important not to implement SecretInformation if {@link HiddenInformation} is sufficient, because implementing SecretInformation will create a
|
|
8
|
+
* distinct notification channel for each player, thus more notifications that necessary if all players have access to the same information.
|
|
9
|
+
*/
|
|
2
10
|
export interface SecretInformation<GameView = any, Move = any, MoveView = any, PlayerId = any> extends HiddenInformation<GameView, Move, MoveView> {
|
|
11
|
+
/**
|
|
12
|
+
* In a game with Secret Information, getView is called for spectators only. See {@link HiddenInformation.getView}.
|
|
13
|
+
*/
|
|
3
14
|
getView(): GameView;
|
|
15
|
+
/**
|
|
16
|
+
* In a game with Secret Information, getMoveView is called for spectators only. See {@link HiddenInformation.getMoveView}.
|
|
17
|
+
*/
|
|
4
18
|
getMoveView(move: Move): MoveView;
|
|
19
|
+
/**
|
|
20
|
+
* Same as {@link HiddenInformation.getView}, but for one player.
|
|
21
|
+
* @param playerId The player this view will be sent to
|
|
22
|
+
* @returns the state of the game this player can see
|
|
23
|
+
*/
|
|
5
24
|
getPlayerView(playerId: PlayerId): GameView;
|
|
25
|
+
/**
|
|
26
|
+
* Same as {@link HiddenInformation.getMoveView}, but for one player.
|
|
27
|
+
* @param move A move that happened in the game
|
|
28
|
+
* @param playerId The player this move view will be sent to
|
|
29
|
+
* @returns the move with less or more data depending on what to hide or reveal
|
|
30
|
+
*/
|
|
6
31
|
getPlayerMoveView?(move: Move, playerId: PlayerId): MoveView;
|
|
32
|
+
/**
|
|
33
|
+
* If some moves played must be entirely keep secret to other players, you can implement this function to prevent the move from being transmitted to
|
|
34
|
+
* another player as long as necessary.
|
|
35
|
+
* Useful for game with secret planning for instance.
|
|
36
|
+
*
|
|
37
|
+
* @param move A move played by a player
|
|
38
|
+
* @param playerId Identifier of another player
|
|
39
|
+
* @return true as long as the move must be kept secret from that player
|
|
40
|
+
*/
|
|
7
41
|
keepMoveSecret?(move: Move, playerId: PlayerId): boolean;
|
|
8
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Type guard for games with secret information
|
|
45
|
+
* @param rules Rules of the game
|
|
46
|
+
* @returns true if the game implements {@link SecretInformation}
|
|
47
|
+
*/
|
|
9
48
|
export declare function hasSecretInformation<GameView = any, Move = any, MoveView = any, PlayerId = any>(rules: Object): rules is SecretInformation<GameView, Move, MoveView, PlayerId>;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasSecretInformation = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Type guard for games with secret information
|
|
6
|
+
* @param rules Rules of the game
|
|
7
|
+
* @returns true if the game implements {@link SecretInformation}
|
|
8
|
+
*/
|
|
4
9
|
function hasSecretInformation(rules) {
|
|
5
10
|
var test = rules;
|
|
6
11
|
return typeof test.getPlayerView === 'function';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecretInformation.js","sourceRoot":"","sources":["../src/SecretInformation.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"SecretInformation.js","sourceRoot":"","sources":["../src/SecretInformation.ts"],"names":[],"mappings":";;;AAgDA;;;;GAIG;AACH,SAAgB,oBAAoB,CAA6D,KAAa;IAC5G,IAAM,IAAI,GAAG,KAA8D,CAAA;IAC3E,OAAO,OAAO,IAAI,CAAC,aAAa,KAAK,UAAU,CAAA;AACjD,CAAC;AAHD,oDAGC"}
|
package/dist/TimeLimit.d.ts
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import { Rules } from './Rules';
|
|
2
|
+
/**
|
|
3
|
+
* In games played in real time with a time limit, players start with an amount of time, and more time is added every time it is their turn to play.
|
|
4
|
+
* Players can be expelled after some time (-1 minute).
|
|
5
|
+
* This interface allows to control how much extra time is given to players every time it is their turn to play.
|
|
6
|
+
*
|
|
7
|
+
* Beginner have up to x1.5 more thinking time, so the time given here must be for "experienced" players.
|
|
8
|
+
*/
|
|
2
9
|
export interface TimeLimit<Game, Move = string, PlayerId = number> extends Rules<Game, Move, PlayerId> {
|
|
10
|
+
/**
|
|
11
|
+
* Amount of time given to a player everytime it is their turn to play.
|
|
12
|
+
* @param playerId Id of the player, if you want to give different time depending on the id for asymmetric games.
|
|
13
|
+
* @return number of seconds to add to the player's clock
|
|
14
|
+
*/
|
|
3
15
|
giveTime(playerId: PlayerId): number;
|
|
16
|
+
/**
|
|
17
|
+
* Amount of time given to a player before the game begins. Default value is 2 minutes.
|
|
18
|
+
* @param playerId Id of the player, if you want to give different time depending on the id for asymmetric games.
|
|
19
|
+
* @return starting amount of seconds for each player when the game starts
|
|
20
|
+
*/
|
|
4
21
|
startingTime?(playerId: PlayerId): number;
|
|
5
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Type guard for {@link TimeLimit} interface
|
|
25
|
+
* @param rules Rules of the game
|
|
26
|
+
* @returns true if rules implements {@link TimeLimit}
|
|
27
|
+
*/
|
|
6
28
|
export declare function hasTimeLimit<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>): rules is TimeLimit<Game, Move, PlayerId>;
|
package/dist/TimeLimit.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasTimeLimit = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Type guard for {@link TimeLimit} interface
|
|
6
|
+
* @param rules Rules of the game
|
|
7
|
+
* @returns true if rules implements {@link TimeLimit}
|
|
8
|
+
*/
|
|
4
9
|
function hasTimeLimit(rules) {
|
|
5
10
|
return typeof rules.giveTime === 'function';
|
|
6
11
|
}
|
package/dist/TimeLimit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeLimit.js","sourceRoot":"","sources":["../src/TimeLimit.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"TimeLimit.js","sourceRoot":"","sources":["../src/TimeLimit.ts"],"names":[],"mappings":";;;AAyBA;;;;GAIG;AACH,SAAgB,YAAY,CAAuB,KAAkC;IACnF,OAAO,OAAQ,KAAyC,CAAC,QAAQ,KAAK,UAAU,CAAA;AAClF,CAAC;AAFD,oCAEC"}
|
package/dist/Undo.d.ts
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { Action } from './Action';
|
|
2
|
+
/**
|
|
3
|
+
* The undo feature allow a player to undo some move played during the game.
|
|
4
|
+
* The move undone is removed from the game history: the new game state results from applying all the remaining moves from the game setup.
|
|
5
|
+
* Any direct consequences of the move (see {@link Action.consequences}) are also removed.
|
|
6
|
+
*/
|
|
2
7
|
export interface Undo<Move = string, PlayerId = number> {
|
|
8
|
+
/**
|
|
9
|
+
* This function allow an action to be undone, by the player that did it.
|
|
10
|
+
*
|
|
11
|
+
* @param action The {@link Action} to allow or not to undo.
|
|
12
|
+
* @param consecutiveActions All the actions that has been played meanwhile by the players
|
|
13
|
+
* @returns true if the action can be undone
|
|
14
|
+
*/
|
|
3
15
|
canUndo(action: Action<Move, PlayerId>, consecutiveActions: Action<Move, PlayerId>[]): boolean;
|
|
4
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to know if a game implements the Undo feature.
|
|
19
|
+
*
|
|
20
|
+
* @param rules Rules of the game
|
|
21
|
+
* @returns true if rules implements {@link Undo}
|
|
22
|
+
*/
|
|
5
23
|
export declare function hasUndo<Move, PlayerId>(rules: Object): rules is Undo<Move, PlayerId>;
|
package/dist/Undo.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasUndo = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Type guard to know if a game implements the Undo feature.
|
|
6
|
+
*
|
|
7
|
+
* @param rules Rules of the game
|
|
8
|
+
* @returns true if rules implements {@link Undo}
|
|
9
|
+
*/
|
|
4
10
|
function hasUndo(rules) {
|
|
5
11
|
var test = rules;
|
|
6
12
|
return typeof test.canUndo === 'function';
|
package/dist/Undo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Undo.js","sourceRoot":"","sources":["../src/Undo.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Undo.js","sourceRoot":"","sources":["../src/Undo.ts"],"names":[],"mappings":";;;AAkBA;;;;;GAKG;AACH,SAAgB,OAAO,CAAiB,KAAa;IACnD,IAAM,IAAI,GAAG,KAA6B,CAAA;IAC1C,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,CAAA;AAC3C,CAAC;AAHD,0BAGC"}
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { Rules } from './Rules';
|
|
2
|
+
/**
|
|
3
|
+
* A move is unpredictable for the player when the outcome is not known, ie when the state of the game after applying the move cannot be processed without
|
|
4
|
+
* the server response.
|
|
5
|
+
* It is the case for moves with random output (like rolling a die), or revealing hidden information (like drawing a card).
|
|
6
|
+
*
|
|
7
|
+
* Game Park offers a smooth experience by executing any move played immediately, without waiting for the server's response, as well as the consequences.
|
|
8
|
+
* However, it cannot be done for unpredictable moves, so this interface allows to identify which move can be played immediately, or not.
|
|
9
|
+
*/
|
|
2
10
|
export interface UnpredictableMoves<M = any, P = any> {
|
|
11
|
+
/**
|
|
12
|
+
* Tell if a move is unpredictable
|
|
13
|
+
* @param move A move
|
|
14
|
+
* @param player The player that should predict the move
|
|
15
|
+
* @returns true if the move outcome is predictable
|
|
16
|
+
*/
|
|
3
17
|
isUnpredictableMove(move: M, player: P): boolean;
|
|
4
18
|
canIgnoreServerDifference?(clientMove: M, serverMove: M): boolean;
|
|
5
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Type guard for {@link UnpredictableMoves} interface
|
|
22
|
+
* @param rules Rules of the game
|
|
23
|
+
* @returns true is rules implements {@link UnpredictableMoves}
|
|
24
|
+
*/
|
|
6
25
|
export declare const hasUnpredictableMoves: <G = any, M = any, P = any>(rules: Rules<G, M, P>) => rules is Rules<G, M, P> & UnpredictableMoves<M, P>;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasUnpredictableMoves = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Type guard for {@link UnpredictableMoves} interface
|
|
6
|
+
* @param rules Rules of the game
|
|
7
|
+
* @returns true is rules implements {@link UnpredictableMoves}
|
|
8
|
+
*/
|
|
4
9
|
var hasUnpredictableMoves = function (rules) { return typeof rules.isUnpredictableMove === 'function'; };
|
|
5
10
|
exports.hasUnpredictableMoves = hasUnpredictableMoves;
|
|
6
11
|
//# sourceMappingURL=UnpredictableMove.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnpredictableMove.js","sourceRoot":"","sources":["../src/UnpredictableMove.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"UnpredictableMove.js","sourceRoot":"","sources":["../src/UnpredictableMove.ts"],"names":[],"mappings":";;;AAsBA;;;;GAIG;AACI,IAAM,qBAAqB,GAAG,UACnC,KAAqB,IACkC,OAAA,OAAO,KAAK,CAAC,mBAAmB,KAAK,UAAU,EAA/C,CAA+C,CAAA;AAF3F,QAAA,qBAAqB,yBAEsE"}
|
|
@@ -4,23 +4,58 @@ import { MaterialItem } from './items';
|
|
|
4
4
|
import { MaterialGame } from './MaterialGame';
|
|
5
5
|
import { MaterialRules } from './MaterialRules';
|
|
6
6
|
import { MaterialMove, MaterialMoveRandomized, MaterialMoveView } from './moves';
|
|
7
|
+
/**
|
|
8
|
+
* Implement HiddenMaterialRules when you want to use the {@link MaterialRules} approach with {@link HiddenInformation}.
|
|
9
|
+
* Using some {@link HidingStrategy} allows to enforce the security of a game with hidden information easily.
|
|
10
|
+
* If the game has secret information (some players have information not available to others, link cards in their hand), then you
|
|
11
|
+
* must implement {@link SecretMaterialRules} instead.
|
|
12
|
+
*/
|
|
7
13
|
export declare abstract class HiddenMaterialRules<P extends number = number, M extends number = number, L extends number = number> extends MaterialRules<P, M, L> implements HiddenInformation<MaterialGame<P, M, L>, MaterialMove<P, M, L>, MaterialMove<P, M, L>> {
|
|
8
14
|
private readonly client?;
|
|
9
15
|
constructor(game: MaterialGame<P, M, L>, client?: {
|
|
10
16
|
player?: P | undefined;
|
|
11
17
|
} | undefined);
|
|
18
|
+
/**
|
|
19
|
+
* A hiding strategy allows to hide automatically some information about an item when it is at a specific location type.
|
|
20
|
+
* Usually, we hide the item id (or a part of it).
|
|
21
|
+
* Example: {[MaterialType.Card]: {[LocationType.Deck]: hideItemId}} will hide the id of the cards in the deck to everybody.
|
|
22
|
+
* See {@link HidingStrategy}
|
|
23
|
+
*/
|
|
12
24
|
abstract readonly hidingStrategies: Partial<Record<M, Partial<Record<L, HidingStrategy<P, L>>>>>;
|
|
13
25
|
randomize(move: MaterialMove<P, M, L>): MaterialMove<P, M, L> & MaterialMoveRandomized<P, M, L>;
|
|
14
26
|
private isRevealingItemMove;
|
|
27
|
+
/**
|
|
28
|
+
* Items that can be hidden cannot merge by default, to prevent hidden items to merge only because they have no id.
|
|
29
|
+
*/
|
|
15
30
|
itemsCanMerge(type: M): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Moves that reveal some information (like drawing a card) cannot be predicted by the player.
|
|
33
|
+
*/
|
|
16
34
|
isUnpredictableMove(move: MaterialMove<P, M, L>, player: P): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Moves than reveals an information to someone cannot be undone by default
|
|
37
|
+
*/
|
|
17
38
|
protected moveBlocksUndo(move: MaterialMove<P, M, L>): boolean;
|
|
18
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @param move A move to test
|
|
41
|
+
* @returns true if the move revealed something to some player
|
|
42
|
+
*/
|
|
43
|
+
protected moveRevealedSomething(move: MaterialMove<P, M, L>): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* With the material approach, we can offer a default working implementation for {@link HiddenInformation.getView}
|
|
46
|
+
*/
|
|
19
47
|
getView(player?: P): MaterialGame<P, M, L>;
|
|
20
48
|
private hideItem;
|
|
21
49
|
private getItemHiddenPaths;
|
|
22
50
|
private itemHasHiddenInformation;
|
|
51
|
+
/**
|
|
52
|
+
* To be able to know if a MoveItem cannot be undone, the server flags the moves with a "reveal" property.
|
|
53
|
+
* This difference must be integrated without error during the callback.
|
|
54
|
+
*/
|
|
23
55
|
canIgnoreServerDifference(clientMove: MaterialMove<P, M, L>, serverMove: MaterialMove<P, M, L>): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* With the material approach, we can offer a default working implementation for {@link HiddenInformation.getMoveView}
|
|
58
|
+
*/
|
|
24
59
|
getMoveView(move: MaterialMoveRandomized<P, M, L>, player?: P): MaterialMove<P, M, L>;
|
|
25
60
|
private getMoveItemView;
|
|
26
61
|
private getMoveAtOnceView;
|
|
@@ -30,8 +65,21 @@ export declare abstract class HiddenMaterialRules<P extends number = number, M e
|
|
|
30
65
|
private moveAtOnceWillRevealSomething;
|
|
31
66
|
private getShuffleItemsView;
|
|
32
67
|
private canSeeShuffleResult;
|
|
68
|
+
/**
|
|
69
|
+
* Override of {@link MaterialRules.play} that also removes the hidden information from items, for example when a card is flipped face down
|
|
70
|
+
*/
|
|
33
71
|
play(move: MaterialMoveRandomized<P, M, L> | MaterialMoveView<P, M, L>, context?: PlayMoveContext): MaterialMove<P, M, L>[];
|
|
34
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* A Hiding Strategy is a function that takes an item and returns a list of path to hide in the item object.
|
|
75
|
+
* See {@link hideItemId} and {@link hideFront} for 2 hiding strategy frequently used.
|
|
76
|
+
*/
|
|
35
77
|
export type HidingStrategy<P extends number = number, L extends number = number> = (item: MaterialItem<P, L>) => string[];
|
|
78
|
+
/**
|
|
79
|
+
* Hiding strategy that removes the item id
|
|
80
|
+
*/
|
|
36
81
|
export declare const hideItemId: HidingStrategy;
|
|
82
|
+
/**
|
|
83
|
+
* Hiding strategy that removes "id.front" from the item (when we have cards with composite ids, back & front)
|
|
84
|
+
*/
|
|
37
85
|
export declare const hideFront: HidingStrategy;
|
|
@@ -49,7 +49,13 @@ var set_1 = __importDefault(require("lodash/set"));
|
|
|
49
49
|
var unset_1 = __importDefault(require("lodash/unset"));
|
|
50
50
|
var MaterialRules_1 = require("./MaterialRules");
|
|
51
51
|
var moves_1 = require("./moves");
|
|
52
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Implement HiddenMaterialRules when you want to use the {@link MaterialRules} approach with {@link HiddenInformation}.
|
|
54
|
+
* Using some {@link HidingStrategy} allows to enforce the security of a game with hidden information easily.
|
|
55
|
+
* If the game has secret information (some players have information not available to others, link cards in their hand), then you
|
|
56
|
+
* must implement {@link SecretMaterialRules} instead.
|
|
57
|
+
*/
|
|
58
|
+
var HiddenMaterialRules = /** @class */ (function (_super) {
|
|
53
59
|
__extends(HiddenMaterialRules, _super);
|
|
54
60
|
function HiddenMaterialRules(game, client) {
|
|
55
61
|
var _this = _super.call(this, game) || this;
|
|
@@ -58,6 +64,11 @@ var HiddenMaterialRules = (function (_super) {
|
|
|
58
64
|
}
|
|
59
65
|
HiddenMaterialRules.prototype.randomize = function (move) {
|
|
60
66
|
if (this.isRevealingItemMove(move)) {
|
|
67
|
+
// We need to know if a MoveItem has revealed something to prevent the undo in that case.
|
|
68
|
+
// To know that, we need the position of the item before the move.
|
|
69
|
+
// To prevent having to recalculate the game state before the move, we flag the move in the database with "reveal: {}".
|
|
70
|
+
// This flag indicate that something was revealed to someone.
|
|
71
|
+
// We use the "randomize" function because is the where we can "preprocess" the move and transform it after checking it is legal and before it is saved.
|
|
61
72
|
return __assign(__assign({}, move), { reveal: {} });
|
|
62
73
|
}
|
|
63
74
|
return _super.prototype.randomize.call(this, move);
|
|
@@ -67,9 +78,15 @@ var HiddenMaterialRules = (function (_super) {
|
|
|
67
78
|
return ((0, moves_1.isMoveItem)(move) && this.game.players.some(function (player) { return _this.moveItemWillRevealSomething(move, player); })) ||
|
|
68
79
|
((0, moves_1.isMoveItemsAtOnce)(move) && this.game.players.some(function (player) { return _this.moveAtOnceWillRevealSomething(move, player); }));
|
|
69
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* Items that can be hidden cannot merge by default, to prevent hidden items to merge only because they have no id.
|
|
83
|
+
*/
|
|
70
84
|
HiddenMaterialRules.prototype.itemsCanMerge = function (type) {
|
|
71
85
|
return !this.hidingStrategies[type];
|
|
72
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* Moves that reveal some information (like drawing a card) cannot be predicted by the player.
|
|
89
|
+
*/
|
|
73
90
|
HiddenMaterialRules.prototype.isUnpredictableMove = function (move, player) {
|
|
74
91
|
var _this = this;
|
|
75
92
|
if ((0, moves_1.isMoveItem)(move)) {
|
|
@@ -91,12 +108,22 @@ var HiddenMaterialRules = (function (_super) {
|
|
|
91
108
|
return _super.prototype.isUnpredictableMove.call(this, move, player);
|
|
92
109
|
}
|
|
93
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Moves than reveals an information to someone cannot be undone by default
|
|
113
|
+
*/
|
|
94
114
|
HiddenMaterialRules.prototype.moveBlocksUndo = function (move) {
|
|
95
|
-
return _super.prototype.moveBlocksUndo.call(this, move) || this.
|
|
115
|
+
return _super.prototype.moveBlocksUndo.call(this, move) || this.moveRevealedSomething(move);
|
|
96
116
|
};
|
|
97
|
-
|
|
117
|
+
/**
|
|
118
|
+
* @param move A move to test
|
|
119
|
+
* @returns true if the move revealed something to some player
|
|
120
|
+
*/
|
|
121
|
+
HiddenMaterialRules.prototype.moveRevealedSomething = function (move) {
|
|
98
122
|
return ((0, moves_1.isMoveItem)(move) || (0, moves_1.isMoveItemsAtOnce)(move)) && !!move.reveal;
|
|
99
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* With the material approach, we can offer a default working implementation for {@link HiddenInformation.getView}
|
|
126
|
+
*/
|
|
100
127
|
HiddenMaterialRules.prototype.getView = function (player) {
|
|
101
128
|
var _this = this;
|
|
102
129
|
return __assign(__assign({}, this.game), { items: (0, mapValues_1.default)(this.game.items, function (items, stringType) {
|
|
@@ -126,6 +153,10 @@ var HiddenMaterialRules = (function (_super) {
|
|
|
126
153
|
HiddenMaterialRules.prototype.itemHasHiddenInformation = function (type, item, player) {
|
|
127
154
|
return this.getItemHiddenPaths(type, item, player).length > 0;
|
|
128
155
|
};
|
|
156
|
+
/**
|
|
157
|
+
* To be able to know if a MoveItem cannot be undone, the server flags the moves with a "reveal" property.
|
|
158
|
+
* This difference must be integrated without error during the callback.
|
|
159
|
+
*/
|
|
129
160
|
HiddenMaterialRules.prototype.canIgnoreServerDifference = function (clientMove, serverMove) {
|
|
130
161
|
if ((0, moves_1.isMoveItem)(clientMove) && (0, moves_1.isMoveItem)(serverMove)) {
|
|
131
162
|
var reveal = serverMove.reveal, serverMoveWithoutReveal = __rest(serverMove, ["reveal"]);
|
|
@@ -133,6 +164,9 @@ var HiddenMaterialRules = (function (_super) {
|
|
|
133
164
|
}
|
|
134
165
|
return false;
|
|
135
166
|
};
|
|
167
|
+
/**
|
|
168
|
+
* With the material approach, we can offer a default working implementation for {@link HiddenInformation.getMoveView}
|
|
169
|
+
*/
|
|
136
170
|
HiddenMaterialRules.prototype.getMoveView = function (move, player) {
|
|
137
171
|
var _this = this;
|
|
138
172
|
if (move.kind === moves_1.MoveKind.ItemMove && move.itemType in this.hidingStrategies) {
|
|
@@ -219,8 +253,14 @@ var HiddenMaterialRules = (function (_super) {
|
|
|
219
253
|
})) {
|
|
220
254
|
throw new RangeError("You cannot shuffle items with different hiding strategies: ".concat(JSON.stringify(move.indexes.map(function (index) { return _this.getItemHiddenPaths(move.itemType, material.getItem(index), player); }))));
|
|
221
255
|
}
|
|
256
|
+
// TODO: if we shuffle a hand of items partially hidden, we should send the partially visible information to the client.
|
|
257
|
+
// Example: It's a Wonderful World with the Extension: the back face of the player's hand are different
|
|
258
|
+
// => when the hand is shuffled we should see where the expansion cards land.
|
|
222
259
|
return !hiddenPaths.length;
|
|
223
260
|
};
|
|
261
|
+
/**
|
|
262
|
+
* Override of {@link MaterialRules.play} that also removes the hidden information from items, for example when a card is flipped face down
|
|
263
|
+
*/
|
|
224
264
|
HiddenMaterialRules.prototype.play = function (move, context) {
|
|
225
265
|
var result = _super.prototype.play.call(this, move, context);
|
|
226
266
|
if (this.client && (0, moves_1.isMoveItem)(move) && this.hidingStrategies[move.itemType]) {
|
|
@@ -243,8 +283,14 @@ var HiddenMaterialRules = (function (_super) {
|
|
|
243
283
|
return HiddenMaterialRules;
|
|
244
284
|
}(MaterialRules_1.MaterialRules));
|
|
245
285
|
exports.HiddenMaterialRules = HiddenMaterialRules;
|
|
286
|
+
/**
|
|
287
|
+
* Hiding strategy that removes the item id
|
|
288
|
+
*/
|
|
246
289
|
var hideItemId = function () { return ['id']; };
|
|
247
290
|
exports.hideItemId = hideItemId;
|
|
291
|
+
/**
|
|
292
|
+
* Hiding strategy that removes "id.front" from the item (when we have cards with composite ids, back & front)
|
|
293
|
+
*/
|
|
248
294
|
var hideFront = function () { return ['id.front']; };
|
|
249
295
|
exports.hideFront = hideFront;
|
|
250
296
|
//# sourceMappingURL=HiddenMaterialRules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HiddenMaterialRules.js","sourceRoot":"","sources":["../../src/material/HiddenMaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAA0C;AAC1C,mDAA4B;AAC5B,2DAAoC;AACpC,+DAAwC;AACxC,mDAA4B;AAC5B,uDAAgC;AAKhC,iDAA+C;AAC/C,iCAegB;
|
|
1
|
+
{"version":3,"file":"HiddenMaterialRules.js","sourceR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,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;gBACjG,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IACH,0BAAC;AAAD,CAAC,AA/OD,CACU,6BAAa,GA8OtB;AA/OqB,kDAAmB;AAuPzC;;GAEG;AACI,IAAM,UAAU,GAAmB,cAAM,OAAA,CAAC,IAAI,CAAC,EAAN,CAAM,CAAA;AAAzC,QAAA,UAAU,cAA+B;AAEtD;;GAEG;AACI,IAAM,SAAS,GAAmB,cAAM,OAAA,CAAC,UAAU,CAAC,EAAZ,CAAY,CAAA;AAA9C,QAAA,SAAS,aAAqC"}
|
|
@@ -2,6 +2,18 @@ import { MaterialItem } from './items';
|
|
|
2
2
|
import { DisplayedItem, HelpDisplay } from './moves';
|
|
3
3
|
import { RuleStep } from './rules';
|
|
4
4
|
import { TutorialState } from './tutorial';
|
|
5
|
+
/**
|
|
6
|
+
* The data structure of a game implemented with the {@link MaterialRules} approach.
|
|
7
|
+
* The game state should not be manipulated directly, but using the {@link MaterialMove} and {@link MaterialRulesPart} utilities.
|
|
8
|
+
*
|
|
9
|
+
* @property players Array of the identifiers of the players, ordered by their position around the table
|
|
10
|
+
* @property items All the {@link MaterialItem}s in the game. An item is identified by its type and its index in the array: items[type][index]
|
|
11
|
+
* @property rule The current step in the rules. See {@link MaterialRules.rules} and {@link RuleStep}
|
|
12
|
+
* @property memory A key-value record of free values when some state do not fit in items or rule properties. See {@link GameMemory} and {@link PlayerMemory}.
|
|
13
|
+
* @property helpDisplay Current help dialog opened on the client side
|
|
14
|
+
* @property droppedItem Item that was just dropped on the client side
|
|
15
|
+
* @property tutorial The {@link TutorialState}, only set for tutorial games
|
|
16
|
+
*/
|
|
5
17
|
export type MaterialGame<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> = {
|
|
6
18
|
players: Player[];
|
|
7
19
|
items: Partial<Record<MaterialType, MaterialItem<Player, LocationType>[]>>;
|
|
@@ -5,19 +5,93 @@ import { MaterialRules, MaterialRulesCreator } from './MaterialRules';
|
|
|
5
5
|
import { GameMemory, PlayerMemory } from './memory';
|
|
6
6
|
import { MaterialMove } from './moves';
|
|
7
7
|
import { TutorialState } from './tutorial';
|
|
8
|
+
/**
|
|
9
|
+
* Helper class to implement {@link GameSetup} when using the {@link MaterialRules} approach.
|
|
10
|
+
*/
|
|
8
11
|
export declare abstract class MaterialGameSetup<P extends number = number, M extends number = number, L extends number = number, Options = any> implements GameSetup<MaterialGame<P, M, L>, Options> {
|
|
12
|
+
/**
|
|
13
|
+
* The rules of the game
|
|
14
|
+
*/
|
|
9
15
|
abstract Rules: MaterialRulesCreator<P, M, L>;
|
|
16
|
+
/**
|
|
17
|
+
* The game setup state we are working on
|
|
18
|
+
* @protected
|
|
19
|
+
*/
|
|
10
20
|
protected game: MaterialGame<P, M, L>;
|
|
21
|
+
/**
|
|
22
|
+
* Get an instance of the rules of the game
|
|
23
|
+
*/
|
|
11
24
|
get rules(): MaterialRules<P, M, L>;
|
|
25
|
+
/**
|
|
26
|
+
* Entry point for {@link GameSetup}
|
|
27
|
+
* @param options Options of the game
|
|
28
|
+
* @param tutorial Initial tutorial state if any
|
|
29
|
+
* @returns the initial state of the game
|
|
30
|
+
*/
|
|
12
31
|
setup(options: Options, tutorial?: TutorialState): MaterialGame<P, M, L>;
|
|
32
|
+
/**
|
|
33
|
+
* @returns array of the player ids (shortcut for this.game.players)
|
|
34
|
+
*/
|
|
13
35
|
get players(): P[];
|
|
36
|
+
/**
|
|
37
|
+
* Override this function if you need to set up some material before the game starts. Called by {@link setup}.
|
|
38
|
+
* @param _options Options of the game
|
|
39
|
+
*/
|
|
14
40
|
setupMaterial(_options: Options): void;
|
|
41
|
+
/**
|
|
42
|
+
* Help function to execute a move immediately on the game state.
|
|
43
|
+
* When the game is on, the moves should never be played directly: the framework takes care of playing the moves when necessary
|
|
44
|
+
* (on te server, on the clients, during replays...).
|
|
45
|
+
* However, during the setup, the moves must be played immediately in the game state to provide the initial game state to the framework.
|
|
46
|
+
* This help function allows to easily play a {@link MaterialMove}, using the rules provided in {@link Rules}, including the consequences.
|
|
47
|
+
*
|
|
48
|
+
* @param move The MaterialMove to play
|
|
49
|
+
* @protected
|
|
50
|
+
*/
|
|
15
51
|
protected playMove(move: MaterialMove<P, M, L>): void;
|
|
52
|
+
/**
|
|
53
|
+
* Helper function to manipulate the items of the game. See {@link Material}.
|
|
54
|
+
* @param type The type of Material we want to work on
|
|
55
|
+
* @returns a Material instance to manipulate all the material of that type in current game state.
|
|
56
|
+
*/
|
|
16
57
|
material(type: M): Material<P, M, L>;
|
|
58
|
+
/**
|
|
59
|
+
* Utility function to access the memory tool for the game or on player.
|
|
60
|
+
* this.game.memory can be used to store any data that is not available through the state of the material, or current rule.
|
|
61
|
+
*
|
|
62
|
+
* @param player Optional, identifier of the player if we want to manipulate a specific player's memory
|
|
63
|
+
* @returns {@link GameMemory} or {@link PlayerMemory} utility
|
|
64
|
+
* @protected
|
|
65
|
+
*/
|
|
17
66
|
protected getMemory(player?: P): GameMemory<P> | PlayerMemory<P>;
|
|
67
|
+
/**
|
|
68
|
+
* Helper function to memorize some information that does not fit in an item or the rules state, in the game state
|
|
69
|
+
* @param key Key under which the memory is store. Usually a value of a numeric enum named "Memory".
|
|
70
|
+
* @param value Value to memorize
|
|
71
|
+
* @param player optional, if we need to memorize a different value for each player.
|
|
72
|
+
*/
|
|
18
73
|
memorize<T = any>(key: keyof any, value: T | ((lastValue: T) => T), player?: P): void;
|
|
74
|
+
/**
|
|
75
|
+
* Implement this function to provide the first rules step of the game (see {@link MaterialRules.rules}). Called by {@link setup}.
|
|
76
|
+
* You can use {@link startPlayerTurn} or {@link startSimultaneousRule} for instance.
|
|
77
|
+
* @param options Options of the game
|
|
78
|
+
*/
|
|
19
79
|
abstract start(options: Options): void;
|
|
80
|
+
/**
|
|
81
|
+
* Helper function to play a {@link StartPlayerTurn} move on the game setup state.
|
|
82
|
+
* @param id Rule id to start
|
|
83
|
+
* @param player Player that starts the game (default value: this.game.players[0])
|
|
84
|
+
*/
|
|
20
85
|
startPlayerTurn<RuleId extends number = number>(id: RuleId, player?: P): void;
|
|
86
|
+
/**
|
|
87
|
+
* Helper function to play a {@link StartSimultaneousRule} move on the game setup state.
|
|
88
|
+
* @param id Rule id to start
|
|
89
|
+
* @param players Players that are active (all the players by default)
|
|
90
|
+
*/
|
|
21
91
|
startSimultaneousRule<RuleId extends number = number>(id: RuleId, players?: P[]): void;
|
|
92
|
+
/**
|
|
93
|
+
* Helper function to play a {@link StartRule} move on the game setup state.
|
|
94
|
+
* @param id Rule id to start
|
|
95
|
+
*/
|
|
22
96
|
startRule<RuleId extends number = number>(id: RuleId): void;
|
|
23
97
|
}
|