@gamepark/rules-api 5.23.2 → 6.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Action.d.ts +4 -5
- package/dist/Action.js +6 -6
- package/dist/Action.js.map +1 -1
- package/dist/ApplyAutomaticMoves.d.ts +1 -1
- package/dist/ApplyAutomaticMoves.js +1 -1
- package/dist/ApplyAutomaticMoves.js.map +1 -1
- package/dist/Competitive.d.ts +2 -2
- package/dist/Dummy.d.ts +2 -2
- package/dist/Dummy.js +2 -1
- package/dist/Dummy.js.map +1 -1
- package/dist/Eliminations.d.ts +1 -1
- package/dist/IncompleteInformation.d.ts +2 -2
- package/dist/RandomMove.d.ts +2 -2
- package/dist/RandomMove.js +4 -2
- package/dist/RandomMove.js.map +1 -1
- package/dist/Robot.d.ts +1 -2
- package/dist/Rules.d.ts +2 -1
- package/dist/Rules.js +2 -1
- package/dist/Rules.js.map +1 -1
- package/dist/RulesCreator.d.ts +2 -2
- package/dist/TimeLimit.d.ts +2 -2
- package/dist/Undo.d.ts +2 -2
- package/dist/UnpredictableMove.d.ts +12 -0
- package/dist/UnpredictableMove.js +43 -0
- package/dist/UnpredictableMove.js.map +1 -0
- package/dist/index.d.ts +13 -18
- package/dist/index.js +13 -17
- package/dist/index.js.map +1 -1
- package/dist/material/HiddenMaterialRules.d.ts +19 -0
- package/dist/material/HiddenMaterialRules.js +138 -0
- package/dist/material/HiddenMaterialRules.js.map +1 -0
- package/dist/material/MaterialGame.d.ts +11 -0
- package/dist/material/MaterialGame.js +3 -0
- package/dist/material/MaterialGame.js.map +1 -0
- package/dist/material/MaterialRules.d.ts +32 -0
- package/dist/material/MaterialRules.js +216 -0
- package/dist/material/MaterialRules.js.map +1 -0
- package/dist/material/MaterialRulesStep.d.ts +16 -0
- package/dist/material/MaterialRulesStep.js +47 -0
- package/dist/material/MaterialRulesStep.js.map +1 -0
- package/dist/material/MaterialStepRules.d.ts +16 -0
- package/dist/material/MaterialStepRules.js +47 -0
- package/dist/material/MaterialStepRules.js.map +1 -0
- package/dist/material/PlayerRulesStep.d.ts +10 -0
- package/dist/material/PlayerRulesStep.js +54 -0
- package/dist/material/PlayerRulesStep.js.map +1 -0
- package/dist/material/PlayerTurnRule.d.ts +10 -0
- package/dist/material/PlayerTurnRule.js +54 -0
- package/dist/material/PlayerTurnRule.js.map +1 -0
- package/dist/material/SecretMaterialRules.d.ts +12 -0
- package/dist/material/SecretMaterialRules.js +52 -0
- package/dist/material/SecretMaterialRules.js.map +1 -0
- package/dist/material/helper/MaterialMoveBuilder.d.ts +9 -0
- package/dist/material/helper/MaterialMoveBuilder.js +28 -0
- package/dist/material/helper/MaterialMoveBuilder.js.map +1 -0
- package/dist/material/helper/MaterialRulesMovesBuilder.d.ts +8 -0
- package/dist/material/helper/MaterialRulesMovesBuilder.js +26 -0
- package/dist/material/helper/MaterialRulesMovesBuilder.js.map +1 -0
- package/dist/material/helper/MaterialSearchHelper.d.ts +18 -0
- package/dist/material/helper/MaterialSearchHelper.js +62 -0
- package/dist/material/helper/MaterialSearchHelper.js.map +1 -0
- package/dist/material/helper/index.d.ts +2 -0
- package/dist/material/helper/index.js +19 -0
- package/dist/material/helper/index.js.map +1 -0
- package/dist/material/index.d.ts +9 -0
- package/dist/material/index.js +26 -0
- package/dist/material/index.js.map +1 -0
- package/dist/material/items/Material.d.ts +30 -0
- package/dist/material/items/Material.js +149 -0
- package/dist/material/items/Material.js.map +1 -0
- package/dist/material/items/MaterialItem.d.ts +10 -0
- package/dist/material/items/MaterialItem.js +3 -0
- package/dist/material/items/MaterialItem.js.map +1 -0
- package/dist/material/items/MaterialOperation.d.ts +20 -0
- package/dist/material/items/MaterialOperation.js +147 -0
- package/dist/material/items/MaterialOperation.js.map +1 -0
- package/dist/material/items/index.d.ts +3 -0
- package/dist/material/items/index.js +20 -0
- package/dist/material/items/index.js.map +1 -0
- package/dist/material/location/Location.d.ts +14 -0
- package/dist/material/location/Location.js +12 -0
- package/dist/material/location/Location.js.map +1 -0
- package/dist/material/location/index.d.ts +2 -0
- package/dist/material/location/index.js +19 -0
- package/dist/material/location/index.js.map +1 -0
- package/dist/material/location/strategy/LocationStrategy.d.ts +5 -0
- package/dist/material/location/strategy/LocationStrategy.js +3 -0
- package/dist/material/location/strategy/LocationStrategy.js.map +1 -0
- package/dist/material/location/strategy/PositiveSequenceStrategy.d.ts +11 -0
- package/dist/material/location/strategy/PositiveSequenceStrategy.js +42 -0
- package/dist/material/location/strategy/PositiveSequenceStrategy.js.map +1 -0
- package/dist/material/location/strategy/index.d.ts +2 -0
- package/dist/material/location/strategy/index.js +19 -0
- package/dist/material/location/strategy/index.js.map +1 -0
- package/dist/material/moves/CreateItem.d.ts +7 -0
- package/dist/material/moves/CreateItem.js +3 -0
- package/dist/material/moves/CreateItem.js.map +1 -0
- package/dist/material/moves/CustomMove.d.ts +6 -0
- package/dist/material/moves/CustomMove.js +3 -0
- package/dist/material/moves/CustomMove.js.map +1 -0
- package/dist/material/moves/CustomMoves.d.ts +7 -0
- package/dist/material/moves/CustomMoves.js +3 -0
- package/dist/material/moves/CustomMoves.js.map +1 -0
- package/dist/material/moves/DeleteItem.d.ts +7 -0
- package/dist/material/moves/DeleteItem.js +3 -0
- package/dist/material/moves/DeleteItem.js.map +1 -0
- package/dist/material/moves/MaterialMove.d.ts +11 -0
- package/dist/material/moves/MaterialMove.js +3 -0
- package/dist/material/moves/MaterialMove.js.map +1 -0
- package/dist/material/moves/MaterialMoveType.d.ts +6 -0
- package/dist/material/moves/MaterialMoveType.js +11 -0
- package/dist/material/moves/MaterialMoveType.js.map +1 -0
- package/dist/material/moves/MaterialMovesBuilder.d.ts +8 -0
- package/dist/material/moves/MaterialMovesBuilder.js +34 -0
- package/dist/material/moves/MaterialMovesBuilder.js.map +1 -0
- package/dist/material/moves/MaterialRulesMove.d.ts +6 -0
- package/dist/material/moves/MaterialRulesMove.js +3 -0
- package/dist/material/moves/MaterialRulesMove.js.map +1 -0
- package/dist/material/moves/MoveItem.d.ts +17 -0
- package/dist/material/moves/MoveItem.js +54 -0
- package/dist/material/moves/MoveItem.js.map +1 -0
- package/dist/material/moves/MoveKind.d.ts +6 -0
- package/dist/material/moves/MoveKind.js +11 -0
- package/dist/material/moves/MoveKind.js.map +1 -0
- package/dist/material/moves/RulesMoves.d.ts +10 -0
- package/dist/material/moves/RulesMoves.js +3 -0
- package/dist/material/moves/RulesMoves.js.map +1 -0
- package/dist/material/moves/Shuffle.d.ts +9 -0
- package/dist/material/moves/Shuffle.js +3 -0
- package/dist/material/moves/Shuffle.js.map +1 -0
- package/dist/material/moves/index.d.ts +11 -0
- package/dist/material/moves/index.js +28 -0
- package/dist/material/moves/index.js.map +1 -0
- package/dist/material/moves/local/LocalMove.d.ts +6 -0
- package/dist/material/moves/local/LocalMove.js +9 -0
- package/dist/material/moves/local/LocalMove.js.map +1 -0
- package/dist/material/moves/local/RulesDisplay.d.ts +32 -0
- package/dist/material/moves/local/RulesDisplay.js +26 -0
- package/dist/material/moves/local/RulesDisplay.js.map +1 -0
- package/dist/material/moves/local/index.d.ts +2 -0
- package/dist/material/moves/local/index.js +19 -0
- package/dist/material/moves/local/index.js.map +1 -0
- package/dist/material/moves/rules/EndGame.d.ts +4 -0
- package/dist/material/moves/rules/EndGame.js +3 -0
- package/dist/material/moves/rules/EndGame.js.map +1 -0
- package/dist/material/moves/rules/MaterialRulesMovesBuilder.d.ts +8 -0
- package/dist/material/moves/rules/MaterialRulesMovesBuilder.js +26 -0
- package/dist/material/moves/rules/MaterialRulesMovesBuilder.js.map +1 -0
- package/dist/material/moves/rules/Memorize.d.ts +6 -0
- package/dist/material/moves/rules/Memorize.js +3 -0
- package/dist/material/moves/rules/Memorize.js.map +1 -0
- package/dist/material/moves/rules/MemorizeOnGame.d.ts +6 -0
- package/dist/material/moves/rules/MemorizeOnGame.js +3 -0
- package/dist/material/moves/rules/MemorizeOnGame.js.map +1 -0
- package/dist/material/moves/rules/RuleMove.d.ts +16 -0
- package/dist/material/moves/rules/RuleMove.js +19 -0
- package/dist/material/moves/rules/RuleMove.js.map +1 -0
- package/dist/material/moves/rules/StartPlayerTurn.d.ts +7 -0
- package/dist/material/moves/rules/StartPlayerTurn.js +3 -0
- package/dist/material/moves/rules/StartPlayerTurn.js.map +1 -0
- package/dist/material/moves/rules/StartRule.d.ts +7 -0
- package/dist/material/moves/rules/StartRule.js +3 -0
- package/dist/material/moves/rules/StartRule.js.map +1 -0
- package/dist/material/moves/rules/index.d.ts +4 -0
- package/dist/material/moves/rules/index.js +21 -0
- package/dist/material/moves/rules/index.js.map +1 -0
- package/dist/material/rules/MaterialRulesMovesBuilder.d.ts +10 -0
- package/dist/material/rules/MaterialRulesMovesBuilder.js +35 -0
- package/dist/material/rules/MaterialRulesMovesBuilder.js.map +1 -0
- package/dist/material/rules/MaterialStepRules.d.ts +22 -0
- package/dist/material/rules/MaterialStepRules.js +101 -0
- package/dist/material/rules/MaterialStepRules.js.map +1 -0
- package/dist/material/rules/PlayerTurnRule.d.ts +10 -0
- package/dist/material/rules/PlayerTurnRule.js +53 -0
- package/dist/material/rules/PlayerTurnRule.js.map +1 -0
- package/dist/material/rules/Rule.d.ts +5 -0
- package/dist/material/rules/Rule.js +3 -0
- package/dist/material/rules/Rule.js.map +1 -0
- package/dist/material/rules/RuleStep.d.ts +6 -0
- package/dist/material/rules/RuleStep.js +3 -0
- package/dist/material/rules/RuleStep.js.map +1 -0
- package/dist/material/rules/RulesStep.d.ts +5 -0
- package/dist/material/rules/RulesStep.js +3 -0
- package/dist/material/rules/RulesStep.js.map +1 -0
- package/dist/material/rules/index.d.ts +3 -0
- package/dist/material/rules/index.js +20 -0
- package/dist/material/rules/index.js.map +1 -0
- package/dist/options/EnumOption.d.ts +2 -3
- package/dist/options/EnumOption.js.map +1 -1
- package/dist/options/Option.d.ts +1 -2
- package/dist/options/OptionSpecOf.d.ts +3 -4
- package/dist/options/OptionsSpec.d.ts +4 -5
- package/dist/options/OptionsValidationError.d.ts +1 -1
- package/dist/options/OptionsValidationError.js +2 -1
- package/dist/options/OptionsValidationError.js.map +1 -1
- package/dist/options/PlayerIdSpec.d.ts +2 -3
- package/dist/options/PlayerIdSpec.js.map +1 -1
- package/dist/options/PlayersOptionsSpec.d.ts +3 -4
- package/dist/options/WithIdOption.d.ts +1 -2
- package/dist/options/WithPlayerOptionsSpec.d.ts +2 -3
- package/dist/options/WithPlayersOptions.d.ts +1 -2
- package/dist/options/getFallbackPlayerName.d.ts +3 -3
- package/dist/options/getFallbackPlayerName.js +4 -6
- package/dist/options/getFallbackPlayerName.js.map +1 -1
- package/dist/options/index.d.ts +12 -12
- package/dist/options/index.js +12 -12
- package/dist/options/index.js.map +1 -1
- package/dist/options/isWithPlayerIdOptions.d.ts +4 -4
- package/dist/options/isWithPlayerIdOptions.js +2 -1
- package/dist/options/isWithPlayerIdOptions.js.map +1 -1
- package/dist/options/providePlayerIds.d.ts +6 -6
- package/dist/options/providePlayerIds.js +5 -7
- package/dist/options/providePlayerIds.js.map +1 -1
- package/package.json +9 -3
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MaterialGame } from './MaterialGame';
|
|
2
|
+
import { Rules } from '../Rules';
|
|
3
|
+
import { MaterialRulesMove, MaterialRulesMoveRandomized } from './moves';
|
|
4
|
+
import { Material, MaterialItem, MaterialOperation } from './items';
|
|
5
|
+
import { RandomMove } from '../RandomMove';
|
|
6
|
+
import { MaterialRulesStepCreator, MaterialStepRules } from './rules';
|
|
7
|
+
import { LocationStrategy } from './location';
|
|
8
|
+
import { Undo } from '../Undo';
|
|
9
|
+
import { Action } from '../Action';
|
|
10
|
+
export declare abstract class MaterialRules<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends Rules<MaterialGame<Player, MaterialType, LocationType>, MaterialRulesMove<Player, MaterialType, LocationType>, Player> implements RandomMove<MaterialRulesMove<Player, MaterialType, LocationType>, MaterialRulesMoveRandomized<Player, MaterialType, LocationType>>, Undo<MaterialGame<Player, MaterialType, LocationType>, MaterialRulesMove<Player, MaterialType, LocationType>, Player> {
|
|
11
|
+
constructor(state: MaterialGame<Player, MaterialType, LocationType>);
|
|
12
|
+
constructor(options: any);
|
|
13
|
+
items(type: MaterialType): MaterialItem<Player, LocationType>[];
|
|
14
|
+
material(type: MaterialType): Material<Player, MaterialType, LocationType>;
|
|
15
|
+
materialOperations(type: MaterialType): MaterialOperation<Player, MaterialType, LocationType>;
|
|
16
|
+
abstract setup(options: any): void;
|
|
17
|
+
abstract get rulesSteps(): Record<number, MaterialRulesStepCreator<Player, MaterialType, LocationType>>;
|
|
18
|
+
getLocationsStrategies(): Partial<Record<MaterialType, Partial<Record<LocationType, LocationStrategy<Player, MaterialType, LocationType>>>>>;
|
|
19
|
+
get players(): Player[];
|
|
20
|
+
getMemory<T>(player?: Player): T;
|
|
21
|
+
delegate(): MaterialStepRules<Player, MaterialType, LocationType> | undefined;
|
|
22
|
+
start<RuleId extends number = number>(id: RuleId, player?: Player, memory?: Record<string, any>): void;
|
|
23
|
+
randomize(move: MaterialRulesMove<Player, MaterialType, LocationType>): MaterialRulesMove<Player, MaterialType, LocationType> & MaterialRulesMoveRandomized<Player, MaterialType, LocationType>;
|
|
24
|
+
play(move: MaterialRulesMove<Player, MaterialType, LocationType> & MaterialRulesMoveRandomized<Player, MaterialType, LocationType>): MaterialRulesMove<Player, MaterialType, LocationType>[];
|
|
25
|
+
canUndo(action: Action<MaterialRulesMove<Player, MaterialType, LocationType>, Player>, consecutiveActions: Action<MaterialRulesMove<Player, MaterialType, LocationType>, Player>[]): boolean;
|
|
26
|
+
actionBlocksUndo(action: Action<MaterialRulesMove<Player, MaterialType, LocationType>, Player>): boolean;
|
|
27
|
+
actionActivatesPlayer(action: Action<MaterialRulesMove<Player, MaterialType, LocationType>, Player>): boolean;
|
|
28
|
+
moveBlocksUndo(move: MaterialRulesMove<Player, MaterialType, LocationType>): boolean;
|
|
29
|
+
moveActivatesPlayer(move: MaterialRulesMove<Player, MaterialType, LocationType>): boolean;
|
|
30
|
+
isUnpredictableMove(move: MaterialRulesMove<Player, MaterialType, LocationType>): boolean;
|
|
31
|
+
restoreLocalMoves(game: MaterialGame<Player, MaterialType, LocationType>): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.MaterialRules = void 0;
|
|
33
|
+
var Rules_1 = require("../Rules");
|
|
34
|
+
var moves_1 = require("./moves");
|
|
35
|
+
var lodash_shuffle_1 = __importDefault(require("lodash.shuffle"));
|
|
36
|
+
var items_1 = require("./items");
|
|
37
|
+
var MaterialRules = /** @class */ (function (_super) {
|
|
38
|
+
__extends(MaterialRules, _super);
|
|
39
|
+
function MaterialRules(arg) {
|
|
40
|
+
var _this = this;
|
|
41
|
+
var isNewGame = !arg.items;
|
|
42
|
+
_this = _super.call(this, isNewGame ? { players: getPlayerIds(arg), items: {} } : arg) || this;
|
|
43
|
+
if (isNewGame) {
|
|
44
|
+
_this.setup(arg);
|
|
45
|
+
}
|
|
46
|
+
return _this;
|
|
47
|
+
}
|
|
48
|
+
MaterialRules.prototype.items = function (type) {
|
|
49
|
+
var _a;
|
|
50
|
+
return (_a = this.game.items[type]) !== null && _a !== void 0 ? _a : [];
|
|
51
|
+
};
|
|
52
|
+
MaterialRules.prototype.material = function (type) {
|
|
53
|
+
var _a;
|
|
54
|
+
return new items_1.Material(type, Array.from(((_a = this.game.items[type]) !== null && _a !== void 0 ? _a : []).entries()).filter(function (entry) { return entry[1].quantity !== 0; }));
|
|
55
|
+
};
|
|
56
|
+
MaterialRules.prototype.materialOperations = function (type) {
|
|
57
|
+
if (!this.game.items[type])
|
|
58
|
+
this.game.items[type] = [];
|
|
59
|
+
return new items_1.MaterialOperation(type, this.game.items[type], this.getLocationsStrategies()[type]);
|
|
60
|
+
};
|
|
61
|
+
MaterialRules.prototype.getLocationsStrategies = function () {
|
|
62
|
+
return {};
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(MaterialRules.prototype, "players", {
|
|
65
|
+
get: function () {
|
|
66
|
+
return this.game.players;
|
|
67
|
+
},
|
|
68
|
+
enumerable: false,
|
|
69
|
+
configurable: true
|
|
70
|
+
});
|
|
71
|
+
MaterialRules.prototype.getMemory = function (player) {
|
|
72
|
+
var _a;
|
|
73
|
+
var playerMemory = player && this.game.playersMemory ? (_a = this.game.playersMemory[player]) !== null && _a !== void 0 ? _a : {} : {};
|
|
74
|
+
return __assign(__assign({}, this.game.memory), playerMemory);
|
|
75
|
+
};
|
|
76
|
+
MaterialRules.prototype.delegate = function () {
|
|
77
|
+
if (!this.game.rule)
|
|
78
|
+
return;
|
|
79
|
+
var RulesStep = this.rulesSteps[this.game.rule.id];
|
|
80
|
+
return new RulesStep(this.game);
|
|
81
|
+
};
|
|
82
|
+
MaterialRules.prototype.start = function (id, player, memory) {
|
|
83
|
+
this.game.rule = { id: id, player: player, memory: memory };
|
|
84
|
+
};
|
|
85
|
+
MaterialRules.prototype.randomize = function (move) {
|
|
86
|
+
if (move.kind === moves_1.MoveKind.MaterialMove) {
|
|
87
|
+
switch (move.type) {
|
|
88
|
+
case moves_1.MaterialMoveType.Shuffle:
|
|
89
|
+
return __assign(__assign({}, move), { newIndexes: (0, lodash_shuffle_1.default)(move.indexes) });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return move;
|
|
93
|
+
};
|
|
94
|
+
MaterialRules.prototype.play = function (move) {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
var consequences = [];
|
|
97
|
+
var delegate = this.delegate();
|
|
98
|
+
switch (move.kind) {
|
|
99
|
+
case moves_1.MoveKind.MaterialMove:
|
|
100
|
+
if (delegate) {
|
|
101
|
+
consequences.push.apply(consequences, delegate.beforeMaterialMove(move));
|
|
102
|
+
}
|
|
103
|
+
var material = this.materialOperations(move.itemType);
|
|
104
|
+
switch (move.type) {
|
|
105
|
+
case moves_1.MaterialMoveType.Create:
|
|
106
|
+
material.create(move.item);
|
|
107
|
+
break;
|
|
108
|
+
case moves_1.MaterialMoveType.Delete:
|
|
109
|
+
material.delete(move.itemIndex, move.quantity);
|
|
110
|
+
break;
|
|
111
|
+
case moves_1.MaterialMoveType.Shuffle:
|
|
112
|
+
material.shuffle(move.indexes, move.newIndexes);
|
|
113
|
+
break;
|
|
114
|
+
case moves_1.MaterialMoveType.Move:
|
|
115
|
+
material.move(move.itemIndex, move.item);
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
if (delegate) {
|
|
119
|
+
consequences.push.apply(consequences, delegate.afterMaterialMove(move));
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
case moves_1.MoveKind.RulesMove:
|
|
123
|
+
var rule = this.game.rule;
|
|
124
|
+
if (delegate) {
|
|
125
|
+
consequences.push.apply(consequences, delegate.onRuleEnd(move));
|
|
126
|
+
}
|
|
127
|
+
switch (move.type) {
|
|
128
|
+
case moves_1.RuleMoveType.StartPlayerTurn:
|
|
129
|
+
this.game.rule = { id: move.id, player: move.player, memory: move.memory };
|
|
130
|
+
break;
|
|
131
|
+
case moves_1.RuleMoveType.StartRule:
|
|
132
|
+
this.game.rule = { id: move.id, player: (_a = move.player) !== null && _a !== void 0 ? _a : (_b = this.game.rule) === null || _b === void 0 ? void 0 : _b.player, memory: move.memory };
|
|
133
|
+
break;
|
|
134
|
+
case moves_1.RuleMoveType.EndGame:
|
|
135
|
+
delete this.game.rule;
|
|
136
|
+
}
|
|
137
|
+
if (move.type !== moves_1.RuleMoveType.EndGame) {
|
|
138
|
+
consequences.push.apply(consequences, this.delegate().onRuleStart(move, rule));
|
|
139
|
+
}
|
|
140
|
+
break;
|
|
141
|
+
case moves_1.MoveKind.CustomMove:
|
|
142
|
+
if (delegate) {
|
|
143
|
+
consequences.push.apply(consequences, delegate.onCustomMove(move));
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
case moves_1.MoveKind.LocalMove:
|
|
147
|
+
switch (move.type) {
|
|
148
|
+
case moves_1.LocalMoveType.DisplayRules:
|
|
149
|
+
this.game.rulesDisplay = move.rulesDisplay;
|
|
150
|
+
break;
|
|
151
|
+
case moves_1.LocalMoveType.CloseRulesDisplay:
|
|
152
|
+
delete this.game.rulesDisplay;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return consequences;
|
|
157
|
+
};
|
|
158
|
+
MaterialRules.prototype.canUndo = function (action, consecutiveActions) {
|
|
159
|
+
for (var i = consecutiveActions.length - 1; i >= 0; i--) {
|
|
160
|
+
var consecutiveAction = consecutiveActions[i];
|
|
161
|
+
if (consecutiveAction.playerId === action.playerId || this.actionActivatesPlayer(consecutiveAction)) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return !this.actionBlocksUndo(action);
|
|
166
|
+
};
|
|
167
|
+
MaterialRules.prototype.actionBlocksUndo = function (action) {
|
|
168
|
+
for (var i = action.consequences.length - 1; i >= 0; i--) {
|
|
169
|
+
if (this.moveBlocksUndo(action.consequences[i])) {
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return this.moveBlocksUndo(action.move);
|
|
174
|
+
};
|
|
175
|
+
MaterialRules.prototype.actionActivatesPlayer = function (action) {
|
|
176
|
+
for (var i = action.consequences.length - 1; i >= 0; i--) {
|
|
177
|
+
if (this.moveActivatesPlayer(action.consequences[i])) {
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return this.moveActivatesPlayer(action.move);
|
|
182
|
+
};
|
|
183
|
+
MaterialRules.prototype.moveBlocksUndo = function (move) {
|
|
184
|
+
return this.moveActivatesPlayer(move) || this.isUnpredictableMove(move);
|
|
185
|
+
};
|
|
186
|
+
MaterialRules.prototype.moveActivatesPlayer = function (move) {
|
|
187
|
+
return move.kind === moves_1.MoveKind.RulesMove && (move.type === moves_1.RuleMoveType.StartPlayerTurn); // TODO: add StartSimultaneousTurns when implemented
|
|
188
|
+
};
|
|
189
|
+
MaterialRules.prototype.isUnpredictableMove = function (move) {
|
|
190
|
+
if (move.kind !== moves_1.MoveKind.MaterialMove)
|
|
191
|
+
return false;
|
|
192
|
+
switch (move.type) {
|
|
193
|
+
case moves_1.MaterialMoveType.Shuffle:
|
|
194
|
+
// case MaterialMoveType.ThrowDice:
|
|
195
|
+
return true;
|
|
196
|
+
default:
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
MaterialRules.prototype.restoreLocalMoves = function (game) {
|
|
201
|
+
this.game.rulesDisplay = game.rulesDisplay;
|
|
202
|
+
};
|
|
203
|
+
return MaterialRules;
|
|
204
|
+
}(Rules_1.Rules));
|
|
205
|
+
exports.MaterialRules = MaterialRules;
|
|
206
|
+
function getPlayerIds(options) {
|
|
207
|
+
var _a;
|
|
208
|
+
if (Array.isArray(options.players)) {
|
|
209
|
+
return options.players.map(function (player) { return player.id; });
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
var numberOfPlayers = (_a = options.players) !== null && _a !== void 0 ? _a : 2;
|
|
213
|
+
return Array.from(Array(numberOfPlayers).keys()).map(function (id) { return (id + 1); });
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=MaterialRules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaterialRules.js","sourceRoot":"","sources":["../../src/material/MaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kCAAgC;AAChC,iCAAiI;AACjI,kEAAoC;AACpC,iCAAmE;AAOnE;IACU,iCAAsH;IAM9H,uBAAY,GAAQ;QAApB,iBAMC;QALC,IAAM,SAAS,GAAG,CAAE,GAAoB,CAAC,KAAK,CAAA;gBAC9C,kBAAM,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAClE,IAAI,SAAS,EAAE;YACb,KAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SAChB;;IACH,CAAC;IAED,6BAAK,GAAL,UAAM,IAAkB;;QACtB,OAAO,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAA;IACpC,CAAC;IAED,gCAAQ,GAAR,UAAS,IAAkB;;QACzB,OAAO,IAAI,gBAAQ,CAAC,IAA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CAAC;IAED,yCAAiB,GAAjB,UAAkB,IAAsD;QACtE,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAA;IAC5C,CAAC;IACH,oBAAC;AAAD,CAAC,AA1LD,CACU,aAAK,GAyLd;AA1LqB,sCAAa;AA4LnC,SAAS,YAAY,CAAiC,OAAY;;IAChE,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAClC,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAC,MAAW,IAAK,OAAA,MAAM,CAAC,EAAE,EAAT,CAAS,CAAC,CAAA;KACvD;SAAM;QACL,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,CAClD,UAAC,EAAE,IAAK,OAAA,CAAC,EAAE,GAAG,CAAC,CAAW,EAAlB,CAAkB,CAC3B,CAAA;KACF;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MaterialGame } from './MaterialGame';
|
|
2
|
+
import { Rules } from '../Rules';
|
|
3
|
+
import { MaterialRulesMove } from './moves';
|
|
4
|
+
import { Material } from './items';
|
|
5
|
+
import { MaterialRulesMovesBuilder } from './helper';
|
|
6
|
+
export declare abstract class MaterialRulesStep<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends Rules<MaterialGame<Player, MaterialType, LocationType>, MaterialRulesMove<Player, MaterialType, LocationType>, Player> {
|
|
7
|
+
getData<T>(): T;
|
|
8
|
+
constructor(game: MaterialGame<Player, MaterialType, LocationType>);
|
|
9
|
+
material(type: MaterialType): Material<Player, MaterialType, LocationType>;
|
|
10
|
+
beforePlay(_move: MaterialRulesMove<Player, MaterialType, LocationType>): MaterialRulesMove<Player, MaterialType, LocationType>[];
|
|
11
|
+
afterPlay(_move: MaterialRulesMove<Player, MaterialType, LocationType>): MaterialRulesMove<Player, MaterialType, LocationType>[];
|
|
12
|
+
rules(): MaterialRulesMovesBuilder<Player, MaterialType, LocationType>;
|
|
13
|
+
}
|
|
14
|
+
export interface MaterialRulesStepCreator<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> {
|
|
15
|
+
new (state: MaterialGame<Player, MaterialType, LocationType>): MaterialRulesStep<Player, MaterialType, LocationType>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.MaterialRulesStep = void 0;
|
|
19
|
+
var Rules_1 = require("../Rules");
|
|
20
|
+
var items_1 = require("./items");
|
|
21
|
+
var helper_1 = require("./helper");
|
|
22
|
+
var MaterialRulesStep = /** @class */ (function (_super) {
|
|
23
|
+
__extends(MaterialRulesStep, _super);
|
|
24
|
+
function MaterialRulesStep(game) {
|
|
25
|
+
return _super.call(this, game) || this;
|
|
26
|
+
}
|
|
27
|
+
MaterialRulesStep.prototype.getData = function () {
|
|
28
|
+
var _a;
|
|
29
|
+
return (_a = this.game.rule) === null || _a === void 0 ? void 0 : _a.data;
|
|
30
|
+
};
|
|
31
|
+
MaterialRulesStep.prototype.material = function (type) {
|
|
32
|
+
var _a;
|
|
33
|
+
return new items_1.Material(type, Array.from(((_a = this.game.items[type]) !== null && _a !== void 0 ? _a : []).entries()).filter(function (entry) { return entry[1].quantity !== 0; }));
|
|
34
|
+
};
|
|
35
|
+
MaterialRulesStep.prototype.beforePlay = function (_move) {
|
|
36
|
+
return [];
|
|
37
|
+
};
|
|
38
|
+
MaterialRulesStep.prototype.afterPlay = function (_move) {
|
|
39
|
+
return [];
|
|
40
|
+
};
|
|
41
|
+
MaterialRulesStep.prototype.rules = function () {
|
|
42
|
+
return new helper_1.MaterialRulesMovesBuilder(this.game);
|
|
43
|
+
};
|
|
44
|
+
return MaterialRulesStep;
|
|
45
|
+
}(Rules_1.Rules));
|
|
46
|
+
exports.MaterialRulesStep = MaterialRulesStep;
|
|
47
|
+
//# sourceMappingURL=MaterialRulesStep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaterialRulesStep.js","sourceRoot":"","sources":["../../src/material/MaterialRulesStep.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,kCAAgC;AAEhC,iCAAkC;AAClC,mCAAoD;AAEpD;IACU,qCAAsH;IAM9H,2BAAY,IAAsD;eAChE,kBAAM,IAAI,CAAC;IACb,CAAC;IAND,mCAAO,GAAP;;QACE,OAAO,MAAA,IAAI,CAAC,IAAI,CAAC,IAAI,0CAAE,IAAS,CAAA;IAClC,CAAC;IAMD,oCAAQ,GAAR,UAAS,IAAkB;;QACzB,OAAO,IAAI,gBAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,EAAvB,CAAuB,CAAC,CAAC,CAAA;IACzH,CAAC;IAED,sCAAU,GAAV,UAAW,KAA4D;QACrE,OAAO,EAAE,CAAA;IACX,CAAC;IAED,qCAAS,GAAT,UAAU,KAA4D;QACpE,OAAO,EAAE,CAAA;IACX,CAAC;IAED,iCAAK,GAAL;QACE,OAAO,IAAI,kCAAyB,CAAqC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrF,CAAC;IACH,wBAAC;AAAD,CAAC,AA1BD,CACU,aAAK,GAyBd;AA1BqB,8CAAiB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MaterialGame } from './MaterialGame';
|
|
2
|
+
import { Rules } from '../Rules';
|
|
3
|
+
import { MaterialRulesMove } from './moves';
|
|
4
|
+
import { Material } from './items';
|
|
5
|
+
import { MaterialRulesMovesBuilder } from './helper';
|
|
6
|
+
export declare abstract class MaterialStepRules<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends Rules<MaterialGame<Player, MaterialType, LocationType>, MaterialRulesMove<Player, MaterialType, LocationType>, Player> {
|
|
7
|
+
getData<T>(): T;
|
|
8
|
+
constructor(game: MaterialGame<Player, MaterialType, LocationType>);
|
|
9
|
+
material(type: MaterialType): Material<Player, MaterialType, LocationType>;
|
|
10
|
+
beforePlay(_move: MaterialRulesMove<Player, MaterialType, LocationType>): MaterialRulesMove<Player, MaterialType, LocationType>[];
|
|
11
|
+
afterPlay(_move: MaterialRulesMove<Player, MaterialType, LocationType>): MaterialRulesMove<Player, MaterialType, LocationType>[];
|
|
12
|
+
rules(): MaterialRulesMovesBuilder<Player, MaterialType, LocationType>;
|
|
13
|
+
}
|
|
14
|
+
export interface MaterialRulesStepCreator<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> {
|
|
15
|
+
new (state: MaterialGame<Player, MaterialType, LocationType>): MaterialStepRules<Player, MaterialType, LocationType>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.MaterialStepRules = void 0;
|
|
19
|
+
var Rules_1 = require("../Rules");
|
|
20
|
+
var items_1 = require("./items");
|
|
21
|
+
var helper_1 = require("./helper");
|
|
22
|
+
var MaterialStepRules = /** @class */ (function (_super) {
|
|
23
|
+
__extends(MaterialStepRules, _super);
|
|
24
|
+
function MaterialStepRules(game) {
|
|
25
|
+
return _super.call(this, game) || this;
|
|
26
|
+
}
|
|
27
|
+
MaterialStepRules.prototype.getData = function () {
|
|
28
|
+
var _a;
|
|
29
|
+
return (_a = this.game.rule) === null || _a === void 0 ? void 0 : _a.data;
|
|
30
|
+
};
|
|
31
|
+
MaterialStepRules.prototype.material = function (type) {
|
|
32
|
+
var _a;
|
|
33
|
+
return new items_1.Material(type, Array.from(((_a = this.game.items[type]) !== null && _a !== void 0 ? _a : []).entries()).filter(function (entry) { return entry[1].quantity !== 0; }));
|
|
34
|
+
};
|
|
35
|
+
MaterialStepRules.prototype.beforePlay = function (_move) {
|
|
36
|
+
return [];
|
|
37
|
+
};
|
|
38
|
+
MaterialStepRules.prototype.afterPlay = function (_move) {
|
|
39
|
+
return [];
|
|
40
|
+
};
|
|
41
|
+
MaterialStepRules.prototype.rules = function () {
|
|
42
|
+
return new helper_1.MaterialRulesMovesBuilder(this.game);
|
|
43
|
+
};
|
|
44
|
+
return MaterialStepRules;
|
|
45
|
+
}(Rules_1.Rules));
|
|
46
|
+
exports.MaterialStepRules = MaterialStepRules;
|
|
47
|
+
//# sourceMappingURL=MaterialStepRules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaterialStepRules.js","sourceRoot":"","sources":["../../src/material/MaterialStepRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,kCAAgC;AAEhC,iCAAkC;AAClC,mCAAoD;AAEpD;IACU,qCAAsH;IAM9H,2BAAY,IAAsD;eAChE,kBAAM,IAAI,CAAC;IACb,CAAC;IAND,mCAAO,GAAP;;QACE,OAAO,MAAA,IAAI,CAAC,IAAI,CAAC,IAAI,0CAAE,IAAS,CAAA;IAClC,CAAC;IAMD,oCAAQ,GAAR,UAAS,IAAkB;;QACzB,OAAO,IAAI,gBAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,EAAvB,CAAuB,CAAC,CAAC,CAAA;IACzH,CAAC;IAED,sCAAU,GAAV,UAAW,KAA4D;QACrE,OAAO,EAAE,CAAA;IACX,CAAC;IAED,qCAAS,GAAT,UAAU,KAA4D;QACpE,OAAO,EAAE,CAAA;IACX,CAAC;IAED,iCAAK,GAAL;QACE,OAAO,IAAI,kCAAyB,CAAqC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrF,CAAC;IACH,wBAAC;AAAD,CAAC,AA1BD,CACU,aAAK,GAyBd;AA1BqB,8CAAiB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MaterialRulesStep } from './MaterialRulesStep';
|
|
2
|
+
import { MaterialRulesMove } from './moves';
|
|
3
|
+
export declare abstract class PlayerRulesStep<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends MaterialRulesStep<Player, MaterialType, LocationType> {
|
|
4
|
+
get player(): Player;
|
|
5
|
+
get nextPlayer(): Player;
|
|
6
|
+
getActivePlayer(): Player;
|
|
7
|
+
initializeMoves(): MaterialRulesMove<Player, MaterialType, LocationType>[];
|
|
8
|
+
getLegalMoves(player: Player): MaterialRulesMove<Player, MaterialType, LocationType>[];
|
|
9
|
+
abstract getPlayerMoves(): MaterialRulesMove<Player, MaterialType, LocationType>[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.PlayerRulesStep = void 0;
|
|
19
|
+
var MaterialRulesStep_1 = require("./MaterialRulesStep");
|
|
20
|
+
var PlayerRulesStep = /** @class */ (function (_super) {
|
|
21
|
+
__extends(PlayerRulesStep, _super);
|
|
22
|
+
function PlayerRulesStep() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(PlayerRulesStep.prototype, "player", {
|
|
26
|
+
get: function () {
|
|
27
|
+
// TODO: use generic to type state ?
|
|
28
|
+
return this.game.rule.player;
|
|
29
|
+
},
|
|
30
|
+
enumerable: false,
|
|
31
|
+
configurable: true
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(PlayerRulesStep.prototype, "nextPlayer", {
|
|
34
|
+
get: function () {
|
|
35
|
+
return this.game.players[(this.game.players.indexOf(this.player) + 1) % this.game.players.length];
|
|
36
|
+
},
|
|
37
|
+
enumerable: false,
|
|
38
|
+
configurable: true
|
|
39
|
+
});
|
|
40
|
+
PlayerRulesStep.prototype.getActivePlayer = function () {
|
|
41
|
+
return this.player;
|
|
42
|
+
};
|
|
43
|
+
PlayerRulesStep.prototype.initializeMoves = function () {
|
|
44
|
+
return [];
|
|
45
|
+
};
|
|
46
|
+
PlayerRulesStep.prototype.getLegalMoves = function (player) {
|
|
47
|
+
if (player !== this.getActivePlayer())
|
|
48
|
+
return [];
|
|
49
|
+
return this.getPlayerMoves();
|
|
50
|
+
};
|
|
51
|
+
return PlayerRulesStep;
|
|
52
|
+
}(MaterialRulesStep_1.MaterialRulesStep));
|
|
53
|
+
exports.PlayerRulesStep = PlayerRulesStep;
|
|
54
|
+
//# sourceMappingURL=PlayerRulesStep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlayerRulesStep.js","sourceRoot":"","sources":["../../src/material/PlayerRulesStep.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,yDAAuD;AAGvD;IACU,mCAAqD;IAD/D;;IA8BA,CAAC;IA3BC,sBAAI,mCAAM;aAAV;YACE,oCAAoC;YACpC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAK,CAAC,MAAO,CAAA;QAChC,CAAC;;;OAAA;IAED,sBAAI,uCAAU;aAAd;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACnG,CAAC;;;OAAA;IAED,yCAAe,GAAf;QACE,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED,yCAAe,GAAf;QACE,OAAO,EAAE,CAAA;IACX,CAAC;IAED,uCAAa,GAAb,UACE,MAAc;QAEd,IAAI,MAAM,KAAK,IAAI,CAAC,eAAe,EAAE;YAAE,OAAO,EAAE,CAAA;QAChD,OAAO,IAAI,CAAC,cAAc,EAAE,CAAA;IAC9B,CAAC;IAKH,sBAAC;AAAD,CAAC,AA9BD,CACU,qCAAiB,GA6B1B;AA9BqB,0CAAe"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MaterialStepRules } from './MaterialStepRules';
|
|
2
|
+
import { MaterialRulesMove } from './moves';
|
|
3
|
+
export declare abstract class PlayerTurnRule<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends MaterialStepRules<Player, MaterialType, LocationType> {
|
|
4
|
+
get player(): Player;
|
|
5
|
+
get nextPlayer(): Player;
|
|
6
|
+
getActivePlayer(): Player;
|
|
7
|
+
initializeMoves(): MaterialRulesMove<Player, MaterialType, LocationType>[];
|
|
8
|
+
getLegalMoves(player: Player): MaterialRulesMove<Player, MaterialType, LocationType>[];
|
|
9
|
+
abstract getPlayerMoves(): MaterialRulesMove<Player, MaterialType, LocationType>[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.PlayerTurnRule = void 0;
|
|
19
|
+
var MaterialStepRules_1 = require("./MaterialStepRules");
|
|
20
|
+
var PlayerTurnRule = /** @class */ (function (_super) {
|
|
21
|
+
__extends(PlayerTurnRule, _super);
|
|
22
|
+
function PlayerTurnRule() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(PlayerTurnRule.prototype, "player", {
|
|
26
|
+
get: function () {
|
|
27
|
+
// TODO: use generic to type state ?
|
|
28
|
+
return this.game.rule.player;
|
|
29
|
+
},
|
|
30
|
+
enumerable: false,
|
|
31
|
+
configurable: true
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(PlayerTurnRule.prototype, "nextPlayer", {
|
|
34
|
+
get: function () {
|
|
35
|
+
return this.game.players[(this.game.players.indexOf(this.player) + 1) % this.game.players.length];
|
|
36
|
+
},
|
|
37
|
+
enumerable: false,
|
|
38
|
+
configurable: true
|
|
39
|
+
});
|
|
40
|
+
PlayerTurnRule.prototype.getActivePlayer = function () {
|
|
41
|
+
return this.player;
|
|
42
|
+
};
|
|
43
|
+
PlayerTurnRule.prototype.initializeMoves = function () {
|
|
44
|
+
return [];
|
|
45
|
+
};
|
|
46
|
+
PlayerTurnRule.prototype.getLegalMoves = function (player) {
|
|
47
|
+
if (player !== this.getActivePlayer())
|
|
48
|
+
return [];
|
|
49
|
+
return this.getPlayerMoves();
|
|
50
|
+
};
|
|
51
|
+
return PlayerTurnRule;
|
|
52
|
+
}(MaterialStepRules_1.MaterialStepRules));
|
|
53
|
+
exports.PlayerTurnRule = PlayerTurnRule;
|
|
54
|
+
//# sourceMappingURL=PlayerTurnRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlayerTurnRule.js","sourceRoot":"","sources":["../../src/material/PlayerTurnRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,yDAAuD;AAGvD;IACU,kCAAqD;IAD/D;;IA8BA,CAAC;IA3BC,sBAAI,kCAAM;aAAV;YACE,oCAAoC;YACpC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAK,CAAC,MAAO,CAAA;QAChC,CAAC;;;OAAA;IAED,sBAAI,sCAAU;aAAd;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACnG,CAAC;;;OAAA;IAED,wCAAe,GAAf;QACE,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED,wCAAe,GAAf;QACE,OAAO,EAAE,CAAA;IACX,CAAC;IAED,sCAAa,GAAb,UACE,MAAc;QAEd,IAAI,MAAM,KAAK,IAAI,CAAC,eAAe,EAAE;YAAE,OAAO,EAAE,CAAA;QAChD,OAAO,IAAI,CAAC,cAAc,EAAE,CAAA;IAC9B,CAAC;IAKH,qBAAC;AAAD,CAAC,AA9BD,CACU,qCAAiB,GA6B1B;AA9BqB,wCAAc"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SecretInformation } from '../IncompleteInformation';
|
|
2
|
+
import { HiddenMaterialRules } from './HiddenMaterialRules';
|
|
3
|
+
import { MaterialGame } from './MaterialGame';
|
|
4
|
+
import { MaterialRulesMove, MaterialRulesMoveRandomized } from './moves';
|
|
5
|
+
import { MaterialItem } from './items';
|
|
6
|
+
export declare abstract class SecretMaterialRules<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> extends HiddenMaterialRules<Player, MaterialType, LocationType> implements SecretInformation<MaterialGame, MaterialRulesMove<Player, MaterialType, LocationType>, MaterialRulesMove<Player, MaterialType, LocationType>, Player> {
|
|
7
|
+
abstract hidingStrategies: Partial<Record<MaterialType, Partial<Record<LocationType, HidingSecretsStrategy<Player, LocationType>>>>>;
|
|
8
|
+
getPlayerView(player: Player): MaterialGame<Player, MaterialType, LocationType>;
|
|
9
|
+
getPlayerMoveView(move: MaterialRulesMoveRandomized<Player, MaterialType, LocationType>, player: Player): MaterialRulesMove<Player, MaterialType, LocationType>;
|
|
10
|
+
}
|
|
11
|
+
export declare type HidingSecretsStrategy<P extends number = number, L extends number = number> = (item: MaterialItem<P, L>, player?: P) => MaterialItem<P, L>;
|
|
12
|
+
export declare const hideItemIdToOthers: <P extends number = number, L extends number = number>(item: MaterialItem<P, L, any>, player?: P) => MaterialItem<P, L, any>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
18
|
+
var t = {};
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
22
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
23
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
24
|
+
t[p[i]] = s[p[i]];
|
|
25
|
+
}
|
|
26
|
+
return t;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.hideItemIdToOthers = exports.SecretMaterialRules = void 0;
|
|
30
|
+
var HiddenMaterialRules_1 = require("./HiddenMaterialRules");
|
|
31
|
+
var SecretMaterialRules = /** @class */ (function (_super) {
|
|
32
|
+
__extends(SecretMaterialRules, _super);
|
|
33
|
+
function SecretMaterialRules() {
|
|
34
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
35
|
+
}
|
|
36
|
+
SecretMaterialRules.prototype.getPlayerView = function (player) {
|
|
37
|
+
return this.getView(player);
|
|
38
|
+
};
|
|
39
|
+
SecretMaterialRules.prototype.getPlayerMoveView = function (move, player) {
|
|
40
|
+
return this.getMoveView(move, player);
|
|
41
|
+
};
|
|
42
|
+
return SecretMaterialRules;
|
|
43
|
+
}(HiddenMaterialRules_1.HiddenMaterialRules));
|
|
44
|
+
exports.SecretMaterialRules = SecretMaterialRules;
|
|
45
|
+
var hideItemIdToOthers = function (item, player) {
|
|
46
|
+
if (item.location.player === player)
|
|
47
|
+
return item;
|
|
48
|
+
var id = item.id, hiddenItem = __rest(item, ["id"]);
|
|
49
|
+
return hiddenItem;
|
|
50
|
+
};
|
|
51
|
+
exports.hideItemIdToOthers = hideItemIdToOthers;
|
|
52
|
+
//# sourceMappingURL=SecretMaterialRules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SecretMaterialRules.js","sourceRoot":"","sources":["../../src/material/SecretMaterialRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6DAA2D;AAK3D;IACU,uCAAuD;IADjE;;IAaA,CAAC;IAPC,2CAAa,GAAb,UAAc,MAAc;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC;IAED,+CAAiB,GAAjB,UAAkB,IAAqE,EAAE,MAAc;QACrG,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACvC,CAAC;IACH,0BAAC;AAAD,CAAC,AAbD,CACU,yCAAmB,GAY5B;AAbqB,kDAAmB;AAiBlC,IAAM,kBAAkB,GAAG,UAAuD,IAAwB,EAAE,MAAU;IAC3H,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,IAAI,CAAA;IACxC,IAAA,EAAE,GAAoB,IAAI,GAAxB,EAAK,UAAU,UAAK,IAAI,EAA5B,MAAqB,CAAF,CAAS;IAClC,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAJY,QAAA,kBAAkB,sBAI9B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MaterialMove } from '../';
|
|
2
|
+
import { MaterialItem } from '../items';
|
|
3
|
+
import { Location } from '../location';
|
|
4
|
+
export declare class MaterialMoveBuilder<Player extends number = number, MaterialType extends number = number, LocationType extends number = number> {
|
|
5
|
+
items: [number, MaterialItem<Player, LocationType>][];
|
|
6
|
+
private readonly type;
|
|
7
|
+
constructor(items: [number, MaterialItem<Player, LocationType>][], type: MaterialType);
|
|
8
|
+
moveTo(locationType: LocationType, factory: ((item: [number, MaterialItem<Player, LocationType>]) => Omit<Location<Player, LocationType>, 'type'>) | Omit<Location<Player, LocationType>, 'type'>): MaterialMove<Player, MaterialType, LocationType>[];
|
|
9
|
+
}
|