@gamepark/its-a-wonderful-world 2.4.0 → 2.5.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/ItsAWonderfulWorld.d.ts +4 -2
- package/dist/ItsAWonderfulWorld.js +16 -4
- package/dist/canUndo.js +4 -0
- package/dist/moves/StartPhase.js +25 -1
- package/package.json +10 -6
|
@@ -20,7 +20,8 @@ export default class ItsAWonderfulWorld extends SimultaneousGame<GameState, Move
|
|
|
20
20
|
constructor(options: ItsAWonderfulWorldOptions);
|
|
21
21
|
isTurnToPlay(playerId: EmpireName): boolean;
|
|
22
22
|
isOver(): boolean;
|
|
23
|
-
|
|
23
|
+
getAutomaticMoves(): Move[];
|
|
24
|
+
getAutomaticMove(): Move | undefined;
|
|
24
25
|
getLegalMoves(empire: EmpireName): Move[];
|
|
25
26
|
play(move: Move): void;
|
|
26
27
|
getScore(empire: EmpireName): number;
|
|
@@ -36,7 +37,7 @@ export default class ItsAWonderfulWorld extends SimultaneousGame<GameState, Move
|
|
|
36
37
|
giveTime(playerId: EmpireName): number;
|
|
37
38
|
}
|
|
38
39
|
export declare function setupPlayers(options: ItsAWonderfulWorldOptions): Player[];
|
|
39
|
-
export declare function getPredictableAutomaticMoves(state: GameState | GameView): Move & MoveView |
|
|
40
|
+
export declare function getPredictableAutomaticMoves(state: GameState | GameView): Move & MoveView | undefined;
|
|
40
41
|
export declare function getLegalMoves(player: Player, phase: Phase): Move[];
|
|
41
42
|
export declare function getCost(card: number): (Resource | Character)[];
|
|
42
43
|
export declare function getRemainingCost(construction: Construction): {
|
|
@@ -44,6 +45,7 @@ export declare function getRemainingCost(construction: Construction): {
|
|
|
44
45
|
space: number;
|
|
45
46
|
}[];
|
|
46
47
|
export declare function getSpacesMissingItem(construction: Construction, predicate: (item: Resource | Character) => boolean): number[];
|
|
48
|
+
export declare function couldPlaceResource(construction: Construction, resource: Resource): boolean;
|
|
47
49
|
export declare function getNextProductionStep(game: GameState | GameView): Resource.Energy | Resource.Science | Resource.Gold | Resource.Exploration | undefined;
|
|
48
50
|
export declare function canBuild(player: Player, card: number): boolean;
|
|
49
51
|
export declare function canPay(player: Player, cost: (Resource | Character)[]): boolean;
|
|
@@ -95,7 +95,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
95
95
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
96
96
|
};
|
|
97
97
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
98
|
-
exports.placeAvailableCubesMoves = exports.constructionsThatMayReceiveCubes = exports.isOver = exports.countCharacters = exports.isActive = exports.isPlaceItemOnCard = exports.getMovesToBuild = exports.canPay = exports.canBuild = exports.getNextProductionStep = exports.getSpacesMissingItem = exports.getRemainingCost = exports.getCost = exports.getLegalMoves = exports.getPredictableAutomaticMoves = exports.setupPlayers = exports.numberOfRounds = exports.numberOfCardsToDraft = void 0;
|
|
98
|
+
exports.placeAvailableCubesMoves = exports.constructionsThatMayReceiveCubes = exports.isOver = exports.countCharacters = exports.isActive = exports.isPlaceItemOnCard = exports.getMovesToBuild = exports.canPay = exports.canBuild = exports.getNextProductionStep = exports.couldPlaceResource = exports.getSpacesMissingItem = exports.getRemainingCost = exports.getCost = exports.getLegalMoves = exports.getPredictableAutomaticMoves = exports.setupPlayers = exports.numberOfRounds = exports.numberOfCardsToDraft = void 0;
|
|
99
99
|
var rules_api_1 = require("@gamepark/rules-api");
|
|
100
100
|
var lodash_shuffle_1 = __importDefault(require("lodash.shuffle"));
|
|
101
101
|
var canUndo_1 = __importDefault(require("./canUndo"));
|
|
@@ -167,6 +167,10 @@ var ItsAWonderfulWorld = (function (_super) {
|
|
|
167
167
|
ItsAWonderfulWorld.prototype.isOver = function () {
|
|
168
168
|
return isOver(this.state);
|
|
169
169
|
};
|
|
170
|
+
ItsAWonderfulWorld.prototype.getAutomaticMoves = function () {
|
|
171
|
+
var move = this.getAutomaticMove();
|
|
172
|
+
return move ? [move] : [];
|
|
173
|
+
};
|
|
170
174
|
ItsAWonderfulWorld.prototype.getAutomaticMove = function () {
|
|
171
175
|
var e_1, _a;
|
|
172
176
|
switch (this.state.phase) {
|
|
@@ -410,7 +414,7 @@ function getPredictableAutomaticMoves(state) {
|
|
|
410
414
|
}
|
|
411
415
|
var _loop_1 = function (resource) {
|
|
412
416
|
if (!player.draftArea.some(function (card) { return (0, Developments_1.getCardDetails)(card).constructionCost[resource]; })
|
|
413
|
-
&& !player.constructionArea.some(function (construction) { return
|
|
417
|
+
&& !player.constructionArea.some(function (construction) { return couldPlaceResource(construction, resource); })) {
|
|
414
418
|
return { value: (0, PlaceResource_1.placeResourceOnEmpireMove)(player.empire, resource) };
|
|
415
419
|
}
|
|
416
420
|
};
|
|
@@ -438,6 +442,7 @@ function getPredictableAutomaticMoves(state) {
|
|
|
438
442
|
}
|
|
439
443
|
finally { if (e_2) throw e_2.error; }
|
|
440
444
|
}
|
|
445
|
+
return;
|
|
441
446
|
}
|
|
442
447
|
exports.getPredictableAutomaticMoves = getPredictableAutomaticMoves;
|
|
443
448
|
function getLegalMoves(player, phase) {
|
|
@@ -496,8 +501,7 @@ function getCost(card) {
|
|
|
496
501
|
}
|
|
497
502
|
exports.getCost = getCost;
|
|
498
503
|
function getRemainingCost(construction) {
|
|
499
|
-
|
|
500
|
-
return Array.of.apply(Array, __spreadArray(__spreadArray([], __read(Resource_1.resources), false), __read(Character_1.characters), false)).flatMap(function (item) { return Array(development.constructionCost[item] || 0).fill(item); })
|
|
504
|
+
return getCost(construction.card)
|
|
501
505
|
.map(function (item, index) { return ({ item: item, space: index }); })
|
|
502
506
|
.filter(function (item) { return !construction.costSpaces[item.space]; });
|
|
503
507
|
}
|
|
@@ -506,6 +510,14 @@ function getSpacesMissingItem(construction, predicate) {
|
|
|
506
510
|
return getRemainingCost(construction).filter(function (cost) { return predicate(cost.item); }).map(function (cost) { return cost.space; });
|
|
507
511
|
}
|
|
508
512
|
exports.getSpacesMissingItem = getSpacesMissingItem;
|
|
513
|
+
function couldPlaceResource(construction, resource) {
|
|
514
|
+
return Array.from(getCost(construction.card).entries())
|
|
515
|
+
.some(function (_a) {
|
|
516
|
+
var _b = __read(_a, 2), space = _b[0], item = _b[1];
|
|
517
|
+
return resource === item && (!construction.costSpaces[space] || construction.costSpaces[space] === Resource_1.default.Krystallium);
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
exports.couldPlaceResource = couldPlaceResource;
|
|
509
521
|
function getNextProductionStep(game) {
|
|
510
522
|
switch (game.productionStep) {
|
|
511
523
|
case Resource_1.default.Materials:
|
package/dist/canUndo.js
CHANGED
|
@@ -27,6 +27,10 @@ function canUndo(state, action, consecutiveActions) {
|
|
|
27
27
|
return !consecutiveActions.some(function (action) { return action.playerId === playerId && ((0, TellYouAreReady_1.isTellYouAreReady)(action.move) || (0, ItsAWonderfulWorld_1.isPlaceItemOnCard)(action.move, move.card)); });
|
|
28
28
|
case MoveType_1.default.PlaceResource:
|
|
29
29
|
if ((0, PlaceResource_1.isPlaceResourceOnConstruction)(move)) {
|
|
30
|
+
if (action.consequences.some(function (consequence) { return (0, PlaceResource_1.isPlaceResource)(consequence); })
|
|
31
|
+
&& consecutiveActions.some(function (action) { return action.playerId === playerId && (0, PlaceResource_1.isPlaceResourceOnConstruction)(action.move) && action.move.resource === Resource_1.default.Krystallium; })) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
30
34
|
if (actionCompletedCardConstruction(action, move.card)) {
|
|
31
35
|
return !consecutiveActions.some(function (action) { return action.playerId === playerId && ((0, TellYouAreReady_1.isTellYouAreReady)(action.move) || (0, ItsAWonderfulWorld_1.isPlaceItemOnCard)(action.move)); });
|
|
32
36
|
}
|
package/dist/moves/StartPhase.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __values = (this && this.__values) || function(o) {
|
|
3
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
+
if (m) return m.call(o);
|
|
5
|
+
if (o && typeof o.length === "number") return {
|
|
6
|
+
next: function () {
|
|
7
|
+
if (o && i >= o.length) o = void 0;
|
|
8
|
+
return { value: o && o[i++], done: !o };
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
@@ -12,8 +23,21 @@ var startPhaseMove = function (phase) { return ({
|
|
|
12
23
|
}); };
|
|
13
24
|
exports.startPhaseMove = startPhaseMove;
|
|
14
25
|
function startPhase(state, move) {
|
|
26
|
+
var e_1, _a;
|
|
15
27
|
state.phase = move.phase;
|
|
16
|
-
|
|
28
|
+
try {
|
|
29
|
+
for (var _b = __values(state.players), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
30
|
+
var player = _c.value;
|
|
31
|
+
player.ready = false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
35
|
+
finally {
|
|
36
|
+
try {
|
|
37
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
38
|
+
}
|
|
39
|
+
finally { if (e_1) throw e_1.error; }
|
|
40
|
+
}
|
|
17
41
|
if (move.phase === Phase_1.default.Draft) {
|
|
18
42
|
delete state.productionStep;
|
|
19
43
|
state.round++;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gamepark/its-a-wonderful-world",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "It's a Wonderful World rules for Game Park",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,15 +12,19 @@
|
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@gamepark/rules-api": "~5.10.0"
|
|
17
|
-
},
|
|
18
15
|
"scripts": {
|
|
19
16
|
"build": "tsc",
|
|
20
17
|
"prepublishOnly": "tsc"
|
|
21
18
|
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@gamepark/rules-api": "~5.14.0",
|
|
21
|
+
"lodash.shuffle": "^4.2.0"
|
|
22
|
+
},
|
|
22
23
|
"devDependencies": {
|
|
23
|
-
"
|
|
24
|
+
"@gamepark/rules-api": "~5.14.0",
|
|
25
|
+
"@types/lodash.shuffle": "^4.2.7",
|
|
26
|
+
"i18next": "^21.3.2",
|
|
27
|
+
"lodash.shuffle": "^4.2.0"
|
|
24
28
|
},
|
|
25
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "b0035e7f8861377552de5df50ead1cff617dd1e1"
|
|
26
30
|
}
|