@gamepark/mythologies 0.7.4 → 0.7.6

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.
@@ -244,7 +244,7 @@ var MythologiesRules = (function (_super) {
244
244
  if (pendingRule) {
245
245
  this.forget(Memory_1.Memory.PendingRule);
246
246
  if (pendingRule.id === RuleId_1.RuleId.EndGame) {
247
- moves.push(this.endGame());
247
+ moves.push.apply(moves, __spreadArray(__spreadArray([], __read(new EndGameRule_1.EndGameRule(this.game).convertGems()), false), [this.endGame()], false));
248
248
  }
249
249
  else {
250
250
  moves.push(this.startPlayerTurn(RuleId_1.RuleId.PlaceCards, pendingRule.player));
@@ -22,7 +22,7 @@ var Entity_1 = require("../../Entity");
22
22
  var Pantheon_1 = require("../../Pantheon");
23
23
  var Effect_1 = require("../Effect");
24
24
  exports.Poseidon = {
25
- invoke: [{}, { gem: 2 }, { favor: 1 }],
25
+ invoke: [{}, { gem: 1 }, { favor: 1 }],
26
26
  effect: {
27
27
  trigger: function (event, _a) {
28
28
  var cardLocation = _a.cardLocation;
@@ -1,5 +1,5 @@
1
- import { PlayerTurnRule } from '@gamepark/rules-api';
2
- import { RuleId } from './RuleId';
1
+ import { MaterialMove, PlayerTurnRule } from '@gamepark/rules-api';
3
2
  export declare class EndGameRule extends PlayerTurnRule {
4
- onRuleStart(): import("@gamepark/rules-api").StartPlayerTurn<number, RuleId.ResolveEffects>[] | import("@gamepark/rules-api").EndGame[];
3
+ onRuleStart(): MaterialMove<number, number, number, number>[];
4
+ convertGems(): MaterialMove<number, number, number, number>[];
5
5
  }
@@ -14,11 +14,48 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
+ var __read = (this && this.__read) || function (o, n) {
18
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
19
+ if (!m) return o;
20
+ var i = m.call(o), r, ar = [], e;
21
+ try {
22
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
23
+ }
24
+ catch (error) { e = { error: error }; }
25
+ finally {
26
+ try {
27
+ if (r && !r.done && (m = i["return"])) m.call(i);
28
+ }
29
+ finally { if (e) throw e.error; }
30
+ }
31
+ return ar;
32
+ };
33
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
34
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
35
+ if (ar || !(i in from)) {
36
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
37
+ ar[i] = from[i];
38
+ }
39
+ }
40
+ return to.concat(ar || Array.prototype.slice.call(from));
41
+ };
42
+ var __values = (this && this.__values) || function(o) {
43
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
44
+ if (m) return m.call(o);
45
+ if (o && typeof o.length === "number") return {
46
+ next: function () {
47
+ if (o && i >= o.length) o = void 0;
48
+ return { value: o && o[i++], done: !o };
49
+ }
50
+ };
51
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
52
+ };
17
53
  Object.defineProperty(exports, "__esModule", { value: true });
18
54
  exports.EndGameRule = void 0;
19
55
  var rules_api_1 = require("@gamepark/rules-api");
20
56
  var Effect_1 = require("../material/entity/Effect");
21
57
  var MaterialType_1 = require("../material/MaterialType");
58
+ var Pantheon_1 = require("../material/Pantheon");
22
59
  var Memory_1 = require("../Memory");
23
60
  var TriggerEffectsRule_1 = require("./effects/TriggerEffectsRule");
24
61
  var RuleId_1 = require("./RuleId");
@@ -36,8 +73,32 @@ var EndGameRule = (function (_super) {
36
73
  return [this.startPlayerTurn(RuleId_1.RuleId.ResolveEffects, player)];
37
74
  }
38
75
  else {
39
- return [this.endGame()];
76
+ return __spreadArray(__spreadArray([], __read(this.convertGems()), false), [this.endGame()], false);
77
+ }
78
+ };
79
+ EndGameRule.prototype.convertGems = function () {
80
+ var e_1, _a;
81
+ var moves = [];
82
+ try {
83
+ for (var _b = __values(this.game.players), _c = _b.next(); !_c.done; _c = _b.next()) {
84
+ var player = _c.value;
85
+ var pantheon = new Pantheon_1.Pantheon(this.game, player);
86
+ var gems = pantheon.gems;
87
+ if (gems >= 3) {
88
+ var favor = Math.floor(gems / 3);
89
+ moves.push(pantheon.spendGems(favor * 3));
90
+ moves.push(pantheon.gainFavor(favor));
91
+ }
92
+ }
93
+ }
94
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
95
+ finally {
96
+ try {
97
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
98
+ }
99
+ finally { if (e_1) throw e_1.error; }
40
100
  }
101
+ return moves;
41
102
  };
42
103
  return EndGameRule;
43
104
  }(rules_api_1.PlayerTurnRule));
@@ -1,4 +1,5 @@
1
1
  import { ItemMove, MaterialMove, SimultaneousRule } from '@gamepark/rules-api';
2
+ import { EntityItem } from '../material/Entity';
2
3
  import { Mythology } from '../material/Mythology';
3
4
  import { PlayerColor } from '../PlayerColor';
4
5
  import { RuleId } from './RuleId';
@@ -9,4 +10,5 @@ export declare class PlaceTokenRule extends SimultaneousRule {
9
10
  getTopDeckCreature(mythology: Mythology): number;
10
11
  afterItemMove(move: ItemMove): import("@gamepark/rules-api").EndPlayerTurn<PlayerColor>[];
11
12
  getMovesAfterPlayersDone(): import("@gamepark/rules-api").StartRule<RuleId.DrawDestinyCard>[] | (import("@gamepark/rules-api").MoveItem<number, number, number> | import("@gamepark/rules-api").StartPlayerTurn<number, RuleId.PlaceCards>)[];
13
+ getMythologyBoardIndex(item: EntityItem): number;
12
14
  }
@@ -117,6 +117,7 @@ var PlaceTokenRule = (function (_super) {
117
117
  return [];
118
118
  };
119
119
  PlaceTokenRule.prototype.getMovesAfterPlayersDone = function () {
120
+ var _this = this;
120
121
  var tokensPlaced = this.material(MaterialType_1.MaterialType.DraftToken).location(LocationType_1.LocationType.OnEntityCard);
121
122
  if (tokensPlaced.length < this.game.players.length * 2) {
122
123
  return [this.startRule(RuleId_1.RuleId.DrawDestinyCard)];
@@ -126,11 +127,16 @@ var PlaceTokenRule = (function (_super) {
126
127
  var selectedCards = this.material(MaterialType_1.MaterialType.EntityCard).index(selectedCardsIndexes);
127
128
  var deckCardsToReveal = selectedCards.location(LocationType_1.LocationType.CreaturesDeck);
128
129
  var sanctuaryCardsToReveal = selectedCards.location(function (l) { return (l.type === LocationType_1.LocationType.SanctuaryCreatureSpot || l.type === LocationType_1.LocationType.CreaturesDeck) && l.rotation !== undefined; });
129
- return __spreadArray(__spreadArray(__spreadArray([], __read(deckCardsToReveal.rotateItems(true)), false), __read(sanctuaryCardsToReveal.rotateItems(undefined)), false), [
130
+ return __spreadArray(__spreadArray(__spreadArray([], __read(deckCardsToReveal.moveItems(function (item) { return ({ type: LocationType_1.LocationType.SanctuaryCreatureSpot, parent: _this.getMythologyBoardIndex(item) }); })), false), __read(sanctuaryCardsToReveal.rotateItems(undefined)), false), [
130
131
  this.startPlayerTurn(RuleId_1.RuleId.PlaceCards, this.material(MaterialType_1.MaterialType.FirstPlayerToken).getItem().location.player)
131
132
  ], false);
132
133
  }
133
134
  };
135
+ PlaceTokenRule.prototype.getMythologyBoardIndex = function (item) {
136
+ return this.material(MaterialType_1.MaterialType.MythologyBoard)
137
+ .id(function (id) { return id.mythology === item.id.back.mythology; })
138
+ .getIndex();
139
+ };
134
140
  return PlaceTokenRule;
135
141
  }(rules_api_1.SimultaneousRule));
136
142
  exports.PlaceTokenRule = PlaceTokenRule;
@@ -2,6 +2,10 @@ import { InvokeEffectRule } from '../../material/entity/PlaceCardEffectRule';
2
2
  import { RuleId } from '../RuleId';
3
3
  export declare class ImpunduluEffectRule extends InvokeEffectRule {
4
4
  ruleId: RuleId;
5
- playEffect(): import("@gamepark/rules-api").MaterialMove<number, number, number, number>[];
5
+ playEffect(): import("@gamepark/rules-api").StartRule<RuleId>[];
6
+ onRuleStart(): import("@gamepark/rules-api").MoveItem<number, number, number>[];
6
7
  getCardsToPlace(): import("@gamepark/rules-api").Material<number, number, number>;
8
+ get availableSanctuaryCards(): import("@gamepark/rules-api").Material<number, number, number>;
9
+ get topCreaturesDeckCard(): import("@gamepark/rules-api").Material<number, number, number>;
10
+ get mythology(): import("../../material/Mythology").Mythology;
7
11
  }
@@ -32,16 +32,50 @@ var ImpunduluEffectRule = (function (_super) {
32
32
  }
33
33
  ImpunduluEffectRule.prototype.playEffect = function () {
34
34
  var player = this.card.location.player;
35
- return new Pantheon_1.Pantheon(this.game, player).hasCrushed(this.card) ? _super.prototype.playEffect.call(this) : [];
35
+ return new Pantheon_1.Pantheon(this.game, player).hasCrushed(this.card) ? [this.startRule(this.ruleId)] : [];
36
+ };
37
+ ImpunduluEffectRule.prototype.onRuleStart = function () {
38
+ if (this.availableSanctuaryCards.length === 0) {
39
+ return [this.topCreaturesDeckCard.rotateItem(true)];
40
+ }
41
+ return [];
36
42
  };
37
43
  ImpunduluEffectRule.prototype.getCardsToPlace = function () {
38
- var pantheon = new Pantheon_1.Pantheon(this.game, this.player);
39
- var _a = this.card.location, x = _a.x, y = _a.y;
40
- var crushed = pantheon.coveredEntities.location(function (l) { return l.x === x && l.y === y; }).maxBy(function (item) { return item.location.z; });
41
- var mythology = (0, Entity_1.entityMythology)(crushed.getItem().id.front);
42
- var board = this.material(MaterialType_1.MaterialType.MythologyBoard).id(function (id) { return id.mythology === mythology; });
43
- return new Destiny_1.Destiny(this.game).cardsWithoutToken.location(LocationType_1.LocationType.SanctuaryCreatureSpot).parent(board.getIndex());
44
+ var availableSanctuaryCards = this.availableSanctuaryCards;
45
+ if (availableSanctuaryCards.length) {
46
+ return availableSanctuaryCards;
47
+ }
48
+ else {
49
+ return this.topCreaturesDeckCard;
50
+ }
44
51
  };
52
+ Object.defineProperty(ImpunduluEffectRule.prototype, "availableSanctuaryCards", {
53
+ get: function () {
54
+ var _this = this;
55
+ var board = this.material(MaterialType_1.MaterialType.MythologyBoard).id(function (id) { return id.mythology === _this.mythology; });
56
+ return new Destiny_1.Destiny(this.game).cardsWithoutToken.location(LocationType_1.LocationType.SanctuaryCreatureSpot).parent(board.getIndex());
57
+ },
58
+ enumerable: false,
59
+ configurable: true
60
+ });
61
+ Object.defineProperty(ImpunduluEffectRule.prototype, "topCreaturesDeckCard", {
62
+ get: function () {
63
+ var deck = this.material(MaterialType_1.MaterialType.EntityCard).location(LocationType_1.LocationType.CreaturesDeck).locationId(this.mythology);
64
+ return deck.maxBy(function (item) { return item.location.x; });
65
+ },
66
+ enumerable: false,
67
+ configurable: true
68
+ });
69
+ Object.defineProperty(ImpunduluEffectRule.prototype, "mythology", {
70
+ get: function () {
71
+ var pantheon = new Pantheon_1.Pantheon(this.game, this.player);
72
+ var _a = this.card.location, x = _a.x, y = _a.y;
73
+ var crushed = pantheon.coveredEntities.location(function (l) { return l.x === x && l.y === y; }).maxBy(function (item) { return item.location.z; });
74
+ return (0, Entity_1.entityMythology)(crushed.getItem().id.front);
75
+ },
76
+ enumerable: false,
77
+ configurable: true
78
+ });
45
79
  return ImpunduluEffectRule;
46
80
  }(PlaceCardEffectRule_1.InvokeEffectRule));
47
81
  exports.ImpunduluEffectRule = ImpunduluEffectRule;
@@ -33,7 +33,8 @@ var MinotaurEffectRule = (function (_super) {
33
33
  return _super.prototype.onRuleStart.call(this);
34
34
  };
35
35
  MinotaurEffectRule.prototype.getMovingCards = function (player) {
36
- var column = this.remind(Memory_1.Memory.TargetLine);
36
+ var _a;
37
+ var column = (_a = this.remind(Memory_1.Memory.TargetLine)) !== null && _a !== void 0 ? _a : this.card.location.x;
37
38
  return new Pantheon_1.Pantheon(this.game, player).visibleEntities.location(function (l) { return l.x === column; }).id(function (id) { return (0, Entity_1.isCreature)(id.front); });
38
39
  };
39
40
  MinotaurEffectRule.prototype.isLegalDestination = function (space, cardLocation) {
@@ -33,7 +33,7 @@ var ViracochaEffectRule = (function (_super) {
33
33
  };
34
34
  ViracochaEffectRule.prototype.onSacrifice = function () {
35
35
  var pantheon = new Pantheon_1.Pantheon(this.game, this.player);
36
- return [pantheon.gainGems(2), this.customMove(CustomMoveType_1.CustomMoveType.EndEffect)];
36
+ return [pantheon.gainFavor(2), this.customMove(CustomMoveType_1.CustomMoveType.EndEffect)];
37
37
  };
38
38
  return ViracochaEffectRule;
39
39
  }(SacrificeEffectRule_1.SacrificeEffectRule));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamepark/mythologies",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "description": "The rules of Mythologies adapted for Game Park",
5
5
  "sideEffects": false,
6
6
  "main": "dist/index.js",
@@ -29,5 +29,5 @@
29
29
  "i18next": "^22.0.3",
30
30
  "lodash": "^4.17.21"
31
31
  },
32
- "gitHead": "5775c7ed56e3ac920aa4e85663de4803319b542c"
32
+ "gitHead": "283e2c3c33cf6a77711ee1eb2b262a1448f0c610"
33
33
  }