@gamepark/rules-api 6.24.2 → 6.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +20 -2
- 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 +56 -13
- 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 +68 -5
- package/dist/material/MaterialGameSetup.js.map +1 -1
- package/dist/material/MaterialRules.d.ts +133 -1
- package/dist/material/MaterialRules.js +131 -5
- 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 +265 -5
- package/dist/material/items/Material.js +266 -7
- package/dist/material/items/Material.js.map +1 -1
- package/dist/material/items/MaterialDeck.d.ts +34 -1
- package/dist/material/items/MaterialDeck.js +36 -3
- package/dist/material/items/MaterialDeck.js.map +1 -1
- package/dist/material/items/MaterialItem.d.ts +12 -0
- package/dist/material/items/MaterialMoney.d.ts +81 -0
- package/dist/material/items/MaterialMoney.js +288 -0
- package/dist/material/items/MaterialMoney.js.map +1 -0
- package/dist/material/items/MaterialMutator.d.ts +39 -0
- package/dist/material/items/MaterialMutator.js +44 -5
- package/dist/material/items/MaterialMutator.js.map +1 -1
- package/dist/material/items/index.d.ts +2 -1
- package/dist/material/items/index.js +3 -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 +75 -3
- 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 +3 -1
- package/dist/utils/action-view.util.js.map +1 -1
- package/dist/utils/action.util.js +1 -1
- package/dist/utils/action.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/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 +42 -4
- package/dist/utils/money.util.js +39 -1
- package/dist/utils/money.util.js.map +1 -1
- package/dist/utils/random.util.d.ts +6 -2
- package/dist/utils/random.util.js +6 -10
- package/dist/utils/random.util.js.map +1 -1
- package/package.json +1 -1
|
@@ -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","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;AAGhB;;;;;GAKG;AACH;IACU,uCAAsB;IAG9B,6BAAY,IAA2B,EAAmB,MAAuB;QAC/E,YAAA,MAAK,YAAC,IAAI,CAAC,SAAA;QAD6C,YAAM,GAAN,MAAM,CAAiB;;IAEjF,CAAC;IAUD,uCAAS,GAAT,UAAU,IAA2B,EA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
|
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
|
}
|
|
@@ -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
|
-
|
|
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,26 +71,56 @@ 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
|
-
|
|
44
|
-
this.game.items[type] = [];
|
|
45
|
-
var items = this.game.items[type];
|
|
46
|
-
return new items_1.Material(type, Array.from(items.entries()).filter(function (entry) { return entry[1].quantity !== 0; }), function (move) { return _this.playMove(move); });
|
|
81
|
+
return new items_1.Material(type, this.game.items[type], function (move) { return _this.playMove(move); });
|
|
47
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* Utility function to access the memory tool for the game or on player.
|
|
85
|
+
* this.game.memory can be used to store any data that is not available through the state of the material, or current rule.
|
|
86
|
+
*
|
|
87
|
+
* @param player Optional, identifier of the player if we want to manipulate a specific player's memory
|
|
88
|
+
* @returns {@link GameMemory} or {@link PlayerMemory} utility
|
|
89
|
+
* @protected
|
|
90
|
+
*/
|
|
48
91
|
MaterialGameSetup.prototype.getMemory = function (player) {
|
|
49
92
|
return player === undefined ? new memory_1.GameMemory(this.game) : new memory_1.PlayerMemory(this.game, player);
|
|
50
93
|
};
|
|
94
|
+
/**
|
|
95
|
+
* Helper function to memorize some information that does not fit in an item or the rules state, in the game state
|
|
96
|
+
* @param key Key under which the memory is store. Usually a value of a numeric enum named "Memory".
|
|
97
|
+
* @param value Value to memorize
|
|
98
|
+
* @param player optional, if we need to memorize a different value for each player.
|
|
99
|
+
*/
|
|
51
100
|
MaterialGameSetup.prototype.memorize = function (key, value, player) {
|
|
52
101
|
this.getMemory(player).memorize(key, value);
|
|
53
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* Helper function to play a {@link StartPlayerTurn} move on the game setup state.
|
|
105
|
+
* @param id Rule id to start
|
|
106
|
+
* @param player Player that starts the game (default value: this.game.players[0])
|
|
107
|
+
*/
|
|
54
108
|
MaterialGameSetup.prototype.startPlayerTurn = function (id, player) {
|
|
55
109
|
if (player === void 0) { player = this.game.players[0]; }
|
|
56
110
|
this.playMove(moves_1.MaterialMoveBuilder.startPlayerTurn(id, player));
|
|
57
111
|
};
|
|
112
|
+
/**
|
|
113
|
+
* Helper function to play a {@link StartSimultaneousRule} move on the game setup state.
|
|
114
|
+
* @param id Rule id to start
|
|
115
|
+
* @param players Players that are active (all the players by default)
|
|
116
|
+
*/
|
|
58
117
|
MaterialGameSetup.prototype.startSimultaneousRule = function (id, players) {
|
|
59
118
|
this.playMove(moves_1.MaterialMoveBuilder.startSimultaneousRule(id, players));
|
|
60
119
|
};
|
|
120
|
+
/**
|
|
121
|
+
* Helper function to play a {@link StartRule} move on the game setup state.
|
|
122
|
+
* @param id Rule id to start
|
|
123
|
+
*/
|
|
61
124
|
MaterialGameSetup.prototype.startRule = function (id) {
|
|
62
125
|
this.playMove(moves_1.MaterialMoveBuilder.startRule(id));
|
|
63
126
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaterialGameSetup.js","sourceRoot":"","sources":["../../src/material/MaterialGameSetup.ts"],"names":[],"mappings":";;;AACA,kCAA6D;AAC7D,iCAAkC;AAGlC,mCAAmD;AACnD,iCAA2D;
|
|
1
|
+
{"version":3,"file":"MaterialGameSetup.js","sourceRoot":"","sources":["../../src/material/MaterialGameSetup.ts"],"names":[],"mappings":";;;AACA,kCAA6D;AAC7D,iCAAkC;AAGlC,mCAAmD;AACnD,iCAA2D;AAG3D;;GAEG;AACH;IAAA;QAQE;;;WAGG;QACO,SAAI,GAA0B,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;IAqHhF,CAAC;IAhHC,sBAAI,oCAAK;QAHT;;WAEG;aACH;YACE,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;;;OAAA;IAED;;;;;OAKG;IACH,iCAAK,GAAL,UAAM,OAAgB,EAAE,QAAwB;QAC9C,IAAI,CAAC,IAAI,GAAG,EAAE,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,UAAA,EAAE,CAAA;QAC/E,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;QAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACnB,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAKD,sBAAI,sCAAO;QAHX;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAA;QAC1B,CAAC;;;OAAA;IAED;;;OAGG;IACH,yCAAa,GAAb,UAAc,QAAiB;IAC/B,C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,CAAC;QAC1F,IAAI,CAAC,QAAQ,CAAC,2BAAmB,CAAC,eAAe,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAA;IAChE,CAAC;IAED;;;;OAIG;IACH,iDAAqB,GAArB,UAAsD,EAAU,EAAE,OAAa;QAC7E,IAAI,CAAC,QAAQ,CAAC,2BAAmB,CAAC,qBAAqB,CAAC,EAAE,EAAE,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,AAjID,IAiIC;AAjIqB,8CAAiB;AAmIvC,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"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Action } from '../Action';
|
|
2
2
|
import { RandomMove } from '../RandomMove';
|
|
3
3
|
import { PlayMoveContext, Rules } from '../Rules';
|
|
4
|
+
import { TimeLimit } from '../TimeLimit';
|
|
4
5
|
import { Undo } from '../Undo';
|
|
5
6
|
import { UnpredictableMoves } from '../UnpredictableMove';
|
|
6
7
|
import { Material, MaterialMutator } from './items';
|
|
@@ -9,30 +10,161 @@ import { MaterialGame } from './MaterialGame';
|
|
|
9
10
|
import { GameMemory, PlayerMemory } from './memory';
|
|
10
11
|
import { MaterialMove, MaterialMoveRandomized, MaterialMoveView, RollItem } from './moves';
|
|
11
12
|
import { MaterialRulesPart, MaterialRulesPartCreator } from './rules';
|
|
12
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The MaterialRules class is the main class to implement the rules of a board game with the "Material oriented" approach.
|
|
15
|
+
* With this approach, the game state and the game moves is structured around the game material items and their movements.
|
|
16
|
+
* The rules are also automatically split into small parts.
|
|
17
|
+
* Finally, a "memory" util is available to store temporary information which is not part of the material or the rules state.
|
|
18
|
+
* If you need to implement game with hidden information, see {@link HiddenMaterialRules} or {@link SecretMaterialRules}.
|
|
19
|
+
*
|
|
20
|
+
* @typeparam Player - identifier of a player. Either a number or a numeric enum (eg: PlayerColor)
|
|
21
|
+
* @typeparam MaterialType - Numeric enum of the types of material manipulated in the game
|
|
22
|
+
* @typeparam LocationType - Numeric enum of the types of location in the game where the material can be located
|
|
23
|
+
*/
|
|
24
|
+
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>, Player>, Undo<MaterialMove<Player, MaterialType, LocationType>, Player>, UnpredictableMoves<MaterialMove<Player, MaterialType, LocationType>>, TimeLimit<MaterialGame<Player, MaterialType, LocationType>, MaterialMove<Player, MaterialType, LocationType>, Player> {
|
|
25
|
+
/**
|
|
26
|
+
* 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.
|
|
27
|
+
* You should usually create a numeric enum class "RuleId" that will list all those small parts.
|
|
28
|
+
* This "rules" property must be implemented to map each "rule id" with the corresponding MaterialRulesPart class.
|
|
29
|
+
* This way, the behavior of the rules can be delegated to the corresponding rule part at each step of the game.
|
|
30
|
+
*/
|
|
13
31
|
abstract readonly rules: Record<number, MaterialRulesPartCreator<Player, MaterialType, LocationType>>;
|
|
32
|
+
/**
|
|
33
|
+
* 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.
|
|
34
|
+
* 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
|
|
35
|
+
* the rule once and for all. If we want to create a "river" of card we can use a {@link FillGapStrategy}.
|
|
36
|
+
* Games with more complex use cases can implement their own {@link LocationStrategy}.
|
|
37
|
+
*/
|
|
14
38
|
readonly locationsStrategies: Partial<Record<MaterialType, Partial<Record<LocationType, LocationStrategy<Player, MaterialType, LocationType>>>>>;
|
|
39
|
+
/**
|
|
40
|
+
* Helper function to manipulate the material items of the game. See {@link Material}.
|
|
41
|
+
*
|
|
42
|
+
* @param type The type of Material we want to work on
|
|
43
|
+
* @returns a Material instance to manipulate all the material of that type in current game state.
|
|
44
|
+
*/
|
|
15
45
|
material(type: MaterialType): Material<Player, MaterialType, LocationType>;
|
|
46
|
+
/**
|
|
47
|
+
* Shortcut for this.game.players
|
|
48
|
+
* @returns array of the players identifiers
|
|
49
|
+
*/
|
|
16
50
|
get players(): Player[];
|
|
51
|
+
/**
|
|
52
|
+
* Utility function to access the memory tool for the game or on player.
|
|
53
|
+
* this.game.memory can be used to store any data that is not available through the state of the material, or current rule.
|
|
54
|
+
*
|
|
55
|
+
* @param player Optional, identifier of the player if we want to manipulate a specific player's memory
|
|
56
|
+
* @returns {@link GameMemory} or {@link PlayerMemory} utility
|
|
57
|
+
* @protected
|
|
58
|
+
*/
|
|
17
59
|
protected getMemory(player?: Player): GameMemory<Player> | PlayerMemory<Player>;
|
|
60
|
+
/**
|
|
61
|
+
* Retrieve the value memorized under a given key.
|
|
62
|
+
* Shortcut for this.game.memory[key] or this.game.memory[key][player]
|
|
63
|
+
*
|
|
64
|
+
* @param key Key under which the memory is store. Usually a value of a numeric enum named "Memory".
|
|
65
|
+
* @param player optional, if we need to memorize a different value for each player.
|
|
66
|
+
*/
|
|
18
67
|
remind<T = any>(key: keyof any, player?: Player): T;
|
|
68
|
+
/**
|
|
69
|
+
* Instantiates the class that handled the rules of the game corresponding to the current rule id.
|
|
70
|
+
* This function reads the current value in this.game.rule.id and instantiate the corresponding class in the {@link rules} property.
|
|
71
|
+
*
|
|
72
|
+
* @returns the class that handled the rules of the game, at current specific game state.
|
|
73
|
+
*/
|
|
19
74
|
get rulesStep(): MaterialRulesPart<Player, MaterialType, LocationType> | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Returns a utility class to change the state of the items.
|
|
77
|
+
* Used by the framework to apply the Material moves on the items (should not be manipulated directly in the games).
|
|
78
|
+
*
|
|
79
|
+
* @param type MaterialType of the item we want to modify
|
|
80
|
+
* @returns a MaterialMutator to change the state of the items
|
|
81
|
+
*/
|
|
20
82
|
mutator(type: MaterialType): MaterialMutator<Player, MaterialType, LocationType>;
|
|
83
|
+
/**
|
|
84
|
+
* Items can sometime be stored with a quantity (for example, coins).
|
|
85
|
+
* By default, if you create or move similar items to the exact same location, they will merge into one item with a quantity.
|
|
86
|
+
* 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
|
|
87
|
+
*
|
|
88
|
+
* @param _type type of items
|
|
89
|
+
* @returns true if items can merge into one item with a quantity (default behavior)
|
|
90
|
+
*/
|
|
21
91
|
itemsCanMerge(_type: MaterialType): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* In the material approach, the rules behavior is delegated to the current {@link rulesStep}. See {@link Rules.delegate}
|
|
94
|
+
*/
|
|
22
95
|
delegate(): Rules<MaterialGame<Player, MaterialType, LocationType>, MaterialMove<Player, MaterialType, LocationType>, Player> | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Randomize Shuffle of Roll moves (see {@link RandomMove.randomize})
|
|
98
|
+
* @param move The Material Move to randomize
|
|
99
|
+
* @returns the randomized move
|
|
100
|
+
*/
|
|
23
101
|
randomize(move: MaterialMove<Player, MaterialType, LocationType>): MaterialMove<Player, MaterialType, LocationType> & MaterialMoveRandomized<Player, MaterialType, LocationType>;
|
|
102
|
+
/**
|
|
103
|
+
* When a RollItem move is create, it has to be randomized on the server side before it is saved and shared.
|
|
104
|
+
* This function provides the random value. By default, it returns a value between 0 and 5 assuming a 6 sided dice is rolled.
|
|
105
|
+
* If you need to flip a coin or roll non-cubic dice, you need to override this function.
|
|
106
|
+
*
|
|
107
|
+
* @param _move The RollItem move to randomize
|
|
108
|
+
* @returns a random rolled value, by default a value between 0 and 5 (cubic dice result)
|
|
109
|
+
*/
|
|
24
110
|
roll(_move: RollItem<Player, MaterialType, LocationType>): number;
|
|
111
|
+
/**
|
|
112
|
+
* Execution of the Material Moves. See {@link Rules.play}.
|
|
113
|
+
*
|
|
114
|
+
* @param move Material move to play on the game state
|
|
115
|
+
* @param context Context in which the move was played
|
|
116
|
+
* @returns Consequences of the move
|
|
117
|
+
*/
|
|
25
118
|
play(move: MaterialMoveRandomized<Player, MaterialType, LocationType> | MaterialMoveView<Player, MaterialType, LocationType>, context?: PlayMoveContext): MaterialMove<Player, MaterialType, LocationType>[];
|
|
26
119
|
private changeRule;
|
|
120
|
+
/**
|
|
121
|
+
* By default, a Material Move can be undone if no player became active and no dice was rolled.
|
|
122
|
+
* See {@link Undo.canUndo} and {@link HiddenMaterialRules.canUndo}
|
|
123
|
+
*
|
|
124
|
+
* @param action Action to consider
|
|
125
|
+
* @param consecutiveActions Action played in between
|
|
126
|
+
* @returns true if the action can be undone by the player that played it
|
|
127
|
+
*/
|
|
27
128
|
canUndo(action: Action<MaterialMove<Player, MaterialType, LocationType>, Player>, consecutiveActions: Action<MaterialMove<Player, MaterialType, LocationType>, Player>[]): boolean;
|
|
28
129
|
private consecutiveActionBlocksUndo;
|
|
29
130
|
private actionBlocksUndo;
|
|
30
131
|
private actionActivatesPlayer;
|
|
132
|
+
/**
|
|
133
|
+
* @protected
|
|
134
|
+
* If a moves blocks the undo, any action with this move cannot be undone.
|
|
135
|
+
* By default, a move block the undo if it activates a player or exposes new information (roll result, hidden information revealed...)
|
|
136
|
+
*
|
|
137
|
+
* @param move The move to consider
|
|
138
|
+
* @returns true if the move blocks the undo
|
|
139
|
+
*/
|
|
31
140
|
protected moveBlocksUndo(move: MaterialMove<Player, MaterialType, LocationType>): boolean;
|
|
32
141
|
private moveActivatesPlayer;
|
|
142
|
+
/**
|
|
143
|
+
* Random moves, or moves that reveals something to me, are unpredictable.
|
|
144
|
+
* Unpredictable moves cannot be precomputed on client side, the server side's response is necessary.
|
|
145
|
+
* See {@link Rules.isUnpredictableMove}
|
|
146
|
+
*
|
|
147
|
+
* @param move Material move to consider
|
|
148
|
+
* @param _player The player playing the move
|
|
149
|
+
* @returns true if the move outcome cannot be predicted on client side
|
|
150
|
+
*/
|
|
33
151
|
isUnpredictableMove(move: MaterialMove<Player, MaterialType, LocationType>, _player: Player): boolean;
|
|
152
|
+
/**
|
|
153
|
+
* A Material Game is over when there is no rule left to execute. This state results of a {@link EndGame} move.
|
|
154
|
+
*
|
|
155
|
+
* @returns true if game is over
|
|
156
|
+
*/
|
|
34
157
|
isOver(): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Amount of time given to a player everytime it is their turn to play.
|
|
160
|
+
* @param playerId Id of the player, if you want to give different time depending on the id for asymmetric games.
|
|
161
|
+
* @return number of seconds to add to the player's clock
|
|
162
|
+
*/
|
|
163
|
+
giveTime(playerId: Player): number;
|
|
35
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Signature interface of the constructor of a class that implements MaterialRules
|
|
167
|
+
*/
|
|
36
168
|
export interface MaterialRulesCreator<P extends number = number, M extends number = number, L extends number = number> {
|
|
37
169
|
new (state: MaterialGame<P, M, L>, client?: {
|
|
38
170
|
player?: P;
|