@gamepark/mythologies 0.7.6 → 0.8.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.
@@ -13,6 +13,7 @@ export declare class Pantheon extends MaterialRulesPart {
13
13
  get legalSpacesToInvoke(): XYCoordinates[];
14
14
  isLegalSpaceToInvoke(space: XYCoordinates): boolean;
15
15
  getFavorTax(space: XYCoordinates): number;
16
+ getGemTax(space: XYCoordinates): number;
16
17
  get legalSpaces(): XYCoordinates[];
17
18
  isLegalSpace({ x, y }: XYCoordinates, grid?: (Entity | undefined)[][]): boolean;
18
19
  isFreeSpace({ x, y }: XYCoordinates): boolean;
@@ -133,13 +133,19 @@ var Pantheon = (function (_super) {
133
133
  var _this = this;
134
134
  var opponents = this.game.players.filter(function (player) { return player !== _this.player; });
135
135
  var favorTax = (0, lodash_1.sumBy)(opponents, function (opponent) { return new Pantheon(_this.game, opponent).getFavorTax(space); });
136
- return this.favor >= favorTax;
136
+ var gemTax = (0, lodash_1.sumBy)(opponents, function (opponent) { return new Pantheon(_this.game, opponent).getGemTax(space); });
137
+ return (!favorTax || this.favor >= favorTax) && (!gemTax || this.gems >= gemTax);
137
138
  };
138
139
  Pantheon.prototype.getFavorTax = function (space) {
139
140
  return (0, lodash_1.sumBy)(this.visibleEntities.getItems(), function (card) {
140
141
  return (0, lodash_1.sumBy)((0, EntityDescription_1.getEffects)(card.id.front), function (effect) { var _a, _b, _c; return (_c = (_b = (_a = effect).favorTax) === null || _b === void 0 ? void 0 : _b.call(_a, space, card)) !== null && _c !== void 0 ? _c : 0; });
141
142
  });
142
143
  };
144
+ Pantheon.prototype.getGemTax = function (space) {
145
+ return (0, lodash_1.sumBy)(this.visibleEntities.getItems(), function (card) {
146
+ return (0, lodash_1.sumBy)((0, EntityDescription_1.getEffects)(card.id.front), function (effect) { var _a, _b, _c; return (_c = (_b = (_a = effect).gemTax) === null || _b === void 0 ? void 0 : _b.call(_a, space, card)) !== null && _c !== void 0 ? _c : 0; });
147
+ });
148
+ };
143
149
  Object.defineProperty(Pantheon.prototype, "legalSpaces", {
144
150
  get: function () {
145
151
  var _this = this;
@@ -361,15 +367,20 @@ var Pantheon = (function (_super) {
361
367
  var entity = card.id.front;
362
368
  if (!entity)
363
369
  return [];
364
- var favor = this.material(MaterialType_1.MaterialType.FavorToken).location(LocationType_1.LocationType.PlayerFavor).player(this.player);
365
370
  try {
366
371
  for (var _b = __values(this.game.players), _c = _b.next(); !_c.done; _c = _b.next()) {
367
372
  var player = _c.value;
368
373
  if (player !== this.player) {
369
374
  var favorTax = new Pantheon(this.game, player).getFavorTax(move.location);
370
375
  if (favorTax > 0) {
376
+ var favor = this.material(MaterialType_1.MaterialType.FavorToken).location(LocationType_1.LocationType.PlayerFavor).player(this.player);
371
377
  moves.push(favor.moveItem({ type: LocationType_1.LocationType.PlayerFavor, player: player }, favorTax));
372
378
  }
379
+ var gemTax = new Pantheon(this.game, player).getGemTax(move.location);
380
+ if (gemTax > 0) {
381
+ var gems = this.material(MaterialType_1.MaterialType.GemToken).location(LocationType_1.LocationType.PlayerGems).player(this.player);
382
+ moves.push(gems.moveItem({ type: LocationType_1.LocationType.PlayerFavor, player: player }, gemTax));
383
+ }
373
384
  }
374
385
  }
375
386
  }
@@ -19,6 +19,7 @@ export type PermanentEffect = {
19
19
  preventCrush?: (card: EntityItem, effectCard: EntityItem) => boolean;
20
20
  replaceSacrifice?: (card: EntityItem, effectCard: EntityItem) => boolean;
21
21
  favorTax?: (space: XYCoordinates, card: EntityItem) => number;
22
+ gemTax?: (space: XYCoordinates, card: EntityItem) => number;
22
23
  sacrificeInsteadOfMove?: boolean;
23
24
  };
24
25
  export type Effect = TriggeredEffect | PermanentEffect;
@@ -14,5 +14,6 @@ export declare abstract class MoveEffectRule extends PlayerEffectRule {
14
14
  onCardMoved(_move: MoveItem): MaterialMove[];
15
15
  onCardSacrificed(move: MoveItem): MaterialMove[];
16
16
  onCustomMove(move: CustomMove): MaterialMove<number, number, number, number>[];
17
+ onEndEffect(): MaterialMove[];
17
18
  onRuleEnd(): never[];
18
19
  }
@@ -116,14 +116,17 @@ var MoveEffectRule = (function (_super) {
116
116
  return [this.customMove(CustomMoveType_1.CustomMoveType.EndEffect)];
117
117
  };
118
118
  MoveEffectRule.prototype.onCustomMove = function (move) {
119
- var _a;
120
119
  if (move.type === CustomMoveType_1.CustomMoveType.EndEffect) {
121
- var pantheon = new Pantheon_1.Pantheon(this.game, this.player);
122
- (_a = new TriggerEffectsRule_1.TriggerEffectsRule(this.game)).triggerEffects.apply(_a, __spreadArray([], __read(pantheon.updateGrid()), false));
123
- return pantheon.gainBonus();
120
+ return this.onEndEffect();
124
121
  }
125
122
  return [];
126
123
  };
124
+ MoveEffectRule.prototype.onEndEffect = function () {
125
+ var _a;
126
+ var pantheon = new Pantheon_1.Pantheon(this.game, this.player);
127
+ (_a = new TriggerEffectsRule_1.TriggerEffectsRule(this.game)).triggerEffects.apply(_a, __spreadArray([], __read(pantheon.updateGrid()), false));
128
+ return pantheon.gainBonus();
129
+ };
127
130
  MoveEffectRule.prototype.onRuleEnd = function () {
128
131
  this.forget(Memory_1.Memory.EntityMoved);
129
132
  return [];
@@ -1,43 +1,9 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.ChangE = void 0;
19
- var LocationType_1 = require("../../LocationType");
20
- var MaterialType_1 = require("../../MaterialType");
21
- var Effect_1 = require("../Effect");
22
4
  exports.ChangE = {
23
5
  invoke: [{ gem: 1, favor: 2 }, { gem: 2 }, {}],
24
6
  effect: {
25
- trigger: function (event, _a) {
26
- var cardLocation = _a.cardLocation;
27
- return event.type === Effect_1.TriggerEventType.EntityPlaced && event.invoked && cardLocation.player !== event.location.player && cardLocation.y === event.location.y;
28
- },
29
- rule: (function (_super) {
30
- __extends(ChangeEEffectRule, _super);
31
- function ChangeEEffectRule() {
32
- return _super !== null && _super.apply(this, arguments) || this;
33
- }
34
- ChangeEEffectRule.prototype.playEffect = function () {
35
- var playerInvoked = this.getEffect().triggerEvent.location.player;
36
- var gems = this.material(MaterialType_1.MaterialType.GemToken).location(LocationType_1.LocationType.PlayerGems).player(playerInvoked);
37
- return gems.getQuantity() > 0 ? [gems.moveItem({ type: LocationType_1.LocationType.PlayerGems, player: this.player }, 1)] : [];
38
- };
39
- return ChangeEEffectRule;
40
- }(Effect_1.AutoEffectRule)),
41
- auto: true
7
+ gemTax: function (space, changE) { return (space.y === changE.location.y ? 1 : 0); }
42
8
  }
43
9
  };
@@ -6,4 +6,5 @@ export declare class SphinxEffectRule extends MoveEffectRule {
6
6
  getMovingCards(): Material;
7
7
  isLegalDestination(space: XYCoordinates, cardLocation: Location): boolean;
8
8
  onCardMoved(move: MoveItem): import("@gamepark/rules-api").MaterialMove<number, number, number, number>[];
9
+ onEndEffect(): import("@gamepark/rules-api").MaterialMove<number, number, number, number>[];
9
10
  }
@@ -14,13 +14,41 @@ 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
+ };
17
42
  Object.defineProperty(exports, "__esModule", { value: true });
18
43
  exports.SphinxEffectRule = void 0;
19
44
  var CustomMoveType_1 = require("../../CustomMoveType");
45
+ var Effect_1 = require("../../material/entity/Effect");
20
46
  var MoveEffectRule_1 = require("../../material/entity/MoveEffectRule");
21
47
  var MaterialType_1 = require("../../material/MaterialType");
22
48
  var Pantheon_1 = require("../../material/Pantheon");
49
+ var Memory_1 = require("../../Memory");
23
50
  var RuleId_1 = require("../RuleId");
51
+ var TriggerEffectsRule_1 = require("./TriggerEffectsRule");
24
52
  var SphinxEffectRule = (function (_super) {
25
53
  __extends(SphinxEffectRule, _super);
26
54
  function SphinxEffectRule() {
@@ -36,11 +64,24 @@ var SphinxEffectRule = (function (_super) {
36
64
  return space.x === cardLocation.x;
37
65
  };
38
66
  SphinxEffectRule.prototype.onCardMoved = function (move) {
67
+ this.memorize(Memory_1.Memory.EntityMoved, move.itemIndex);
39
68
  var entity = this.material(MaterialType_1.MaterialType.EntityCard).getItem(move.itemIndex).id.front;
40
69
  var moves = new Pantheon_1.Pantheon(this.game, this.player).getInvokeGains(entity, move.location.y);
41
70
  moves.push(this.customMove(CustomMoveType_1.CustomMoveType.EndEffect));
42
71
  return moves;
43
72
  };
73
+ SphinxEffectRule.prototype.onEndEffect = function () {
74
+ var _a;
75
+ var pantheon = new Pantheon_1.Pantheon(this.game, this.player);
76
+ var effects = pantheon.updateGrid();
77
+ var movedCard = this.remind(Memory_1.Memory.EntityMoved);
78
+ if (movedCard !== undefined) {
79
+ this.forget(Memory_1.Memory.EntityMoved);
80
+ effects.push({ type: Effect_1.TriggerEventType.EntitiesMoved, player: this.player, entities: [movedCard] });
81
+ }
82
+ (_a = new TriggerEffectsRule_1.TriggerEffectsRule(this.game)).triggerEffects.apply(_a, __spreadArray([], __read(effects), false));
83
+ return pantheon.gainBonus();
84
+ };
44
85
  return SphinxEffectRule;
45
86
  }(MoveEffectRule_1.MoveEffectRule));
46
87
  exports.SphinxEffectRule = SphinxEffectRule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamepark/mythologies",
3
- "version": "0.7.6",
3
+ "version": "0.8.0",
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": "283e2c3c33cf6a77711ee1eb2b262a1448f0c610"
32
+ "gitHead": "b1f0590fe690cfda4ede6e89c084f0830d1de33c"
33
33
  }