@gamepark/mythologies 0.4.0 → 0.4.1

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.
Files changed (47) hide show
  1. package/dist/Memory.d.ts +2 -1
  2. package/dist/Memory.js +1 -0
  3. package/dist/MythologiesRules.d.ts +2 -0
  4. package/dist/MythologiesRules.js +2 -0
  5. package/dist/material/Entity.d.ts +5 -1
  6. package/dist/material/Entity.js +1 -1
  7. package/dist/material/Pantheon.d.ts +10 -6
  8. package/dist/material/Pantheon.js +92 -48
  9. package/dist/material/entity/Effect.d.ts +18 -10
  10. package/dist/material/entity/Effect.js +3 -1
  11. package/dist/material/entity/EntityDescription.d.ts +2 -0
  12. package/dist/material/entity/EntityDescription.js +6 -3
  13. package/dist/material/entity/MoveEffectRule.js +29 -1
  14. package/dist/material/entity/SacrificeEffectRule.d.ts +1 -0
  15. package/dist/material/entity/SacrificeEffectRule.js +13 -36
  16. package/dist/material/entity/SimultaneousMoveEffectRule.js +9 -5
  17. package/dist/material/entity/SimultaneousSacrificeEffectRule.d.ts +1 -0
  18. package/dist/material/entity/SimultaneousSacrificeEffectRule.js +12 -35
  19. package/dist/material/entity/celtic/Banshee.js +33 -1
  20. package/dist/material/entity/celtic/Brigid.js +34 -1
  21. package/dist/material/entity/celtic/Cernunnos.js +37 -1
  22. package/dist/material/entity/celtic/Dagda.js +43 -1
  23. package/dist/material/entity/celtic/Fairy.d.ts +2 -0
  24. package/dist/material/entity/celtic/Fairy.js +12 -0
  25. package/dist/material/entity/celtic/Kelpie.js +33 -1
  26. package/dist/material/entity/celtic/Morrigan.js +6 -1
  27. package/dist/material/entity/egyptian/Beetle.js +19 -13
  28. package/dist/material/entity/hindu/Naga.js +36 -30
  29. package/dist/material/entity/norse/Troll.js +4 -1
  30. package/dist/material/entity/zulu/Tokoloshe.js +22 -17
  31. package/dist/rules/PlaceCardsRule.js +3 -2
  32. package/dist/rules/RuleId.d.ts +2 -1
  33. package/dist/rules/RuleId.js +1 -0
  34. package/dist/rules/effects/AthenaEffectRule.js +29 -1
  35. package/dist/rules/effects/CentaurEffectRule.js +29 -1
  36. package/dist/rules/effects/FairyEffectRule.d.ts +10 -0
  37. package/dist/rules/effects/FairyEffectRule.js +55 -0
  38. package/dist/rules/effects/JiangshiEffectRule.js +5 -2
  39. package/dist/rules/effects/PermanentEffectsRule.d.ts +7 -0
  40. package/dist/rules/effects/PermanentEffectsRule.js +54 -0
  41. package/dist/rules/effects/QilinEffectRule.js +6 -5
  42. package/dist/rules/effects/ResolveEffectsRule.js +1 -1
  43. package/dist/rules/effects/ShivaEffectRule.d.ts +1 -1
  44. package/dist/rules/effects/ShivaEffectRule.js +14 -10
  45. package/dist/rules/effects/TriggerEffectsRule.d.ts +1 -1
  46. package/dist/rules/effects/TriggerEffectsRule.js +36 -18
  47. package/package.json +2 -2
@@ -52,5 +52,6 @@ export declare enum RuleId {
52
52
  ImpunduluEffect = 54,
53
53
  WerehyenaEffect = 55,
54
54
  WerehyenaCallEffect = 56,
55
- IdloziEffect = 57
55
+ IdloziEffect = 57,
56
+ FairyEffect = 58
56
57
  }
@@ -57,4 +57,5 @@ var RuleId;
57
57
  RuleId[RuleId["WerehyenaEffect"] = 55] = "WerehyenaEffect";
58
58
  RuleId[RuleId["WerehyenaCallEffect"] = 56] = "WerehyenaCallEffect";
59
59
  RuleId[RuleId["IdloziEffect"] = 57] = "IdloziEffect";
60
+ RuleId[RuleId["FairyEffect"] = 58] = "FairyEffect";
60
61
  })(RuleId = exports.RuleId || (exports.RuleId = {}));
@@ -25,6 +25,31 @@ var __values = (this && this.__values) || function(o) {
25
25
  };
26
26
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
27
27
  };
28
+ var __read = (this && this.__read) || function (o, n) {
29
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
30
+ if (!m) return o;
31
+ var i = m.call(o), r, ar = [], e;
32
+ try {
33
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
34
+ }
35
+ catch (error) { e = { error: error }; }
36
+ finally {
37
+ try {
38
+ if (r && !r.done && (m = i["return"])) m.call(i);
39
+ }
40
+ finally { if (e) throw e.error; }
41
+ }
42
+ return ar;
43
+ };
44
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
45
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
46
+ if (ar || !(i in from)) {
47
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
48
+ ar[i] = from[i];
49
+ }
50
+ }
51
+ return to.concat(ar || Array.prototype.slice.call(from));
52
+ };
28
53
  Object.defineProperty(exports, "__esModule", { value: true });
29
54
  exports.AthenaEffectRule = void 0;
30
55
  var CustomMoveType_1 = require("../../CustomMoveType");
@@ -33,6 +58,7 @@ var LocationType_1 = require("../../material/LocationType");
33
58
  var MaterialType_1 = require("../../material/MaterialType");
34
59
  var Pantheon_1 = require("../../material/Pantheon");
35
60
  var RuleId_1 = require("../RuleId");
61
+ var TriggerEffectsRule_1 = require("./TriggerEffectsRule");
36
62
  var AthenaEffectRule = (function (_super) {
37
63
  __extends(AthenaEffectRule, _super);
38
64
  function AthenaEffectRule() {
@@ -93,9 +119,11 @@ var AthenaEffectRule = (function (_super) {
93
119
  return piles;
94
120
  };
95
121
  AthenaEffectRule.prototype.onCustomMove = function (move) {
122
+ var _a;
96
123
  if (move.type === CustomMoveType_1.CustomMoveType.EndEffect) {
97
124
  var pantheon = new Pantheon_1.Pantheon(this.game, this.player);
98
- return pantheon.updateGrid();
125
+ (_a = new TriggerEffectsRule_1.TriggerEffectsRule(this.game)).triggerEffects.apply(_a, __spreadArray([], __read(pantheon.updateGrid()), false));
126
+ return pantheon.gainBonus();
99
127
  }
100
128
  return [];
101
129
  };
@@ -14,6 +14,31 @@ 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.CentaurEffectSacrificeRule = exports.CentaurEffectRule = void 0;
19
44
  var rules_api_1 = require("@gamepark/rules-api");
@@ -24,6 +49,7 @@ var MaterialType_1 = require("../../material/MaterialType");
24
49
  var Pantheon_1 = require("../../material/Pantheon");
25
50
  var Memory_1 = require("../../Memory");
26
51
  var RuleId_1 = require("../RuleId");
52
+ var TriggerEffectsRule_1 = require("./TriggerEffectsRule");
27
53
  var CentaurEffectRule = (function (_super) {
28
54
  __extends(CentaurEffectRule, _super);
29
55
  function CentaurEffectRule() {
@@ -39,10 +65,12 @@ var CentaurEffectRule = (function (_super) {
39
65
  return (0, rules_api_1.areAdjacentSquares)(space, cardLocation);
40
66
  };
41
67
  CentaurEffectRule.prototype.endEffect = function () {
68
+ var _a;
42
69
  var players = this.playersHavingToSacrifice;
43
70
  if (players.length) {
44
71
  var pantheon = new Pantheon_1.Pantheon(this.game, this.player);
45
- return pantheon.updateGrid().concat(this.startSimultaneousRule(RuleId_1.RuleId.CentaurEffectSacrifice, players));
72
+ (_a = new TriggerEffectsRule_1.TriggerEffectsRule(this.game)).triggerEffects.apply(_a, __spreadArray([], __read(pantheon.updateGrid()), false));
73
+ return pantheon.gainBonus().concat(this.startSimultaneousRule(RuleId_1.RuleId.CentaurEffectSacrifice, players));
46
74
  }
47
75
  else {
48
76
  return _super.prototype.endEffect.call(this);
@@ -0,0 +1,10 @@
1
+ import { MaterialMove } from '@gamepark/rules-api';
2
+ import { SacrificeEffectRule } from '../../material/entity/SacrificeEffectRule';
3
+ import { RuleId } from '../RuleId';
4
+ export declare class FairyEffectRule extends SacrificeEffectRule {
5
+ ruleId: RuleId;
6
+ playEffect(): MaterialMove[];
7
+ getCardsToSacrifice(): import("@gamepark/rules-api").Material<number, number, number>;
8
+ onSacrifice(): MaterialMove<number, number, number, number>[];
9
+ onRuleEnd(): never[];
10
+ }
@@ -0,0 +1,55 @@
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.FairyEffectRule = void 0;
19
+ var CustomMoveType_1 = require("../../CustomMoveType");
20
+ var SacrificeEffectRule_1 = require("../../material/entity/SacrificeEffectRule");
21
+ var MaterialType_1 = require("../../material/MaterialType");
22
+ var Pantheon_1 = require("../../material/Pantheon");
23
+ var Memory_1 = require("../../Memory");
24
+ var RuleId_1 = require("../RuleId");
25
+ var FairyEffectRule = (function (_super) {
26
+ __extends(FairyEffectRule, _super);
27
+ function FairyEffectRule() {
28
+ var _this = _super !== null && _super.apply(this, arguments) || this;
29
+ _this.ruleId = RuleId_1.RuleId.FairyEffect;
30
+ return _this;
31
+ }
32
+ FairyEffectRule.prototype.playEffect = function () {
33
+ var _a = this.card.location, x = _a.x, y = _a.y;
34
+ var targets = new Pantheon_1.Pantheon(this.game, this.player).visibleEntities.location(function (l) { return l.y === y && l.x !== x; }).sort(function (item) { return item.location.x; }).getIndexes();
35
+ this.memorize(Memory_1.Memory.FairyTargets, targets);
36
+ return _super.prototype.playEffect.call(this);
37
+ };
38
+ FairyEffectRule.prototype.getCardsToSacrifice = function () {
39
+ return this.material(MaterialType_1.MaterialType.EntityCard).index(this.remind(Memory_1.Memory.FairyTargets)[0]);
40
+ };
41
+ FairyEffectRule.prototype.onSacrifice = function () {
42
+ var moves = [new Pantheon_1.Pantheon(this.game, this.player).gainGems(2)];
43
+ var targets = this.memorize(Memory_1.Memory.FairyTargets, function (targets) { return targets.slice(1); });
44
+ if (!targets.length) {
45
+ moves.push(this.customMove(CustomMoveType_1.CustomMoveType.EndEffect));
46
+ }
47
+ return moves;
48
+ };
49
+ FairyEffectRule.prototype.onRuleEnd = function () {
50
+ this.forget(Memory_1.Memory.FairyTargets);
51
+ return [];
52
+ };
53
+ return FairyEffectRule;
54
+ }(SacrificeEffectRule_1.SacrificeEffectRule));
55
+ exports.FairyEffectRule = FairyEffectRule;
@@ -47,6 +47,7 @@ var LocationType_1 = require("../../material/LocationType");
47
47
  var MaterialType_1 = require("../../material/MaterialType");
48
48
  var Pantheon_1 = require("../../material/Pantheon");
49
49
  var RuleId_1 = require("../RuleId");
50
+ var PermanentEffectsRule_1 = require("./PermanentEffectsRule");
50
51
  var JiangshiEffectRule = (function (_super) {
51
52
  __extends(JiangshiEffectRule, _super);
52
53
  function JiangshiEffectRule() {
@@ -58,7 +59,8 @@ var JiangshiEffectRule = (function (_super) {
58
59
  var _this = this;
59
60
  var location = this.card.location;
60
61
  var pantheon = new Pantheon_1.Pantheon(this.game, this.player);
61
- var piles = pantheon.getPiles(function (space) { return space.y === location.y; });
62
+ var rule = new PermanentEffectsRule_1.PermanentEffectsRule(this.game);
63
+ var piles = pantheon.getPiles(function (space) { return space.y === location.y; }).filter(function (pile) { return rule.canSacrifice(pile.maxBy(function (item) { return item.location.z; }).getItem()); });
62
64
  return piles.map(function (pile) { return pile.moveItemsAtOnce({ type: LocationType_1.LocationType.PlayerDiscard, player: _this.player }); });
63
65
  };
64
66
  JiangshiEffectRule.prototype.beforeItemMove = function (move) {
@@ -67,7 +69,8 @@ var JiangshiEffectRule = (function (_super) {
67
69
  var topCard = this.material(MaterialType_1.MaterialType.EntityCard)
68
70
  .index(move.indexes)
69
71
  .maxBy(function (item) { return item.location.z; });
70
- return __spreadArray(__spreadArray([pantheon.gainGems(2)], __read(pantheon.onEntitySacrificed(topCard)), false), __read(this.endEffect()), false);
72
+ pantheon.onEntitySacrificed(topCard);
73
+ return __spreadArray([pantheon.gainGems(2)], __read(this.endEffect()), false);
71
74
  }
72
75
  return [];
73
76
  };
@@ -0,0 +1,7 @@
1
+ import { MaterialRulesPart } from '@gamepark/rules-api';
2
+ import { EntityItem } from '../../material/Entity';
3
+ export declare class PermanentEffectsRule extends MaterialRulesPart {
4
+ canSacrifice(card: EntityItem): boolean;
5
+ canCrush(card: EntityItem): boolean;
6
+ canMove(card: EntityItem): boolean;
7
+ }
@@ -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.PermanentEffectsRule = void 0;
19
+ var rules_api_1 = require("@gamepark/rules-api");
20
+ var Effect_1 = require("../../material/entity/Effect");
21
+ var EntityDescription_1 = require("../../material/entity/EntityDescription");
22
+ var Pantheon_1 = require("../../material/Pantheon");
23
+ var PermanentEffectsRule = (function (_super) {
24
+ __extends(PermanentEffectsRule, _super);
25
+ function PermanentEffectsRule() {
26
+ return _super !== null && _super.apply(this, arguments) || this;
27
+ }
28
+ PermanentEffectsRule.prototype.canSacrifice = function (card) {
29
+ var _this = this;
30
+ return !this.game.players.some(function (player) {
31
+ return new Pantheon_1.Pantheon(_this.game, player).visibleEntities
32
+ .getItems()
33
+ .some(function (effectCard) { return (0, EntityDescription_1.getEffects)(effectCard.id.front).some(function (effect) { var _a; return !(0, Effect_1.isTriggeredEffect)(effect) && ((_a = effect.preventSacrifice) === null || _a === void 0 ? void 0 : _a.call(effect, card, effectCard)); }); });
34
+ });
35
+ };
36
+ PermanentEffectsRule.prototype.canCrush = function (card) {
37
+ var _this = this;
38
+ return !this.game.players.some(function (player) {
39
+ return new Pantheon_1.Pantheon(_this.game, player).visibleEntities
40
+ .getItems()
41
+ .some(function (effectCard) { return (0, EntityDescription_1.getEffects)(effectCard.id.front).some(function (effect) { var _a; return !(0, Effect_1.isTriggeredEffect)(effect) && ((_a = effect.preventCrush) === null || _a === void 0 ? void 0 : _a.call(effect, card, effectCard)); }); });
42
+ });
43
+ };
44
+ PermanentEffectsRule.prototype.canMove = function (card) {
45
+ var _this = this;
46
+ return !this.game.players.some(function (player) {
47
+ return new Pantheon_1.Pantheon(_this.game, player).visibleEntities
48
+ .getItems()
49
+ .some(function (effectCard) { return (0, EntityDescription_1.getEffects)(effectCard.id.front).some(function (effect) { var _a; return !(0, Effect_1.isTriggeredEffect)(effect) && ((_a = effect.preventMove) === null || _a === void 0 ? void 0 : _a.call(effect, card, effectCard)); }); });
50
+ });
51
+ };
52
+ return PermanentEffectsRule;
53
+ }(rules_api_1.MaterialRulesPart));
54
+ exports.PermanentEffectsRule = PermanentEffectsRule;
@@ -78,10 +78,9 @@ var QilinEffectRule = (function (_super) {
78
78
  cardsToCopy.push.apply(cardsToCopy, __spreadArray([], __read(new Pantheon_1.Pantheon(this.game, player).visibleEntities
79
79
  .location(function (l) { return l.x === _this.card.location.x; })
80
80
  .id(function (id) {
81
- var _a;
82
- var entity = id.front;
83
- var trigger = (_a = EntityDescription_1.entities[entity].effect) === null || _a === void 0 ? void 0 : _a.trigger;
84
- return (0, Entity_1.isCreature)(entity) && trigger === Effect_1.isPlaced && entity !== Entity_1.Entity.Qilin;
81
+ return (0, Entity_1.isCreature)(id.front) &&
82
+ id.front !== Entity_1.Entity.Qilin &&
83
+ (0, EntityDescription_1.getEffects)(id.front).some(function (effect) { return (0, Effect_1.isTriggeredEffect)(effect) && effect.trigger === Effect_1.isPlaced; });
85
84
  })
86
85
  .getIndexes()), false));
87
86
  }
@@ -99,7 +98,9 @@ var QilinEffectRule = (function (_super) {
99
98
  QilinEffectRule.prototype.onCustomMove = function (move) {
100
99
  if (move.type === CustomMoveType_1.CustomMoveType.ChooseEntityCard) {
101
100
  var card = this.material(MaterialType_1.MaterialType.EntityCard).getItem(move.data);
102
- var effect = EntityDescription_1.entities[card.id.front].effect;
101
+ var effect = (0, EntityDescription_1.getEffects)(card.id.front)
102
+ .filter(Effect_1.isTriggeredEffect)
103
+ .find(function (effect) { return effect.trigger === Effect_1.isPlaced; });
103
104
  var moves = new effect.rule(this.game).playEffect();
104
105
  if (!moves.some(function (move) { return move.kind === rules_api_1.MoveKind.RulesMove; })) {
105
106
  moves.push(this.customMove(CustomMoveType_1.CustomMoveType.EndEffect));
@@ -58,7 +58,7 @@ var ResolveEffectsRule = (function (_super) {
58
58
  ResolveEffectsRule.prototype.playEffect = function (pendingEffect) {
59
59
  this.memorize(Memory_1.Memory.OngoingEffect, pendingEffect);
60
60
  var card = this.material(MaterialType_1.MaterialType.EntityCard).getItem(pendingEffect.cardIndex);
61
- var effect = EntityDescription_1.entities[card.id.front].effect;
61
+ var effect = (0, EntityDescription_1.getEffects)(card.id.front)[pendingEffect.effectIndex];
62
62
  if (effect.trigger === Effect_1.oncePerTurn) {
63
63
  this.memorize(Memory_1.Memory.OncePerTurn, function (indexes) {
64
64
  if (indexes === void 0) { indexes = []; }
@@ -5,6 +5,6 @@ export declare class ShivaEffectRule extends PlayerEffectRule {
5
5
  ruleId: RuleId;
6
6
  canPlayEffect(cardIndex: number): boolean;
7
7
  onRuleStart(): MaterialMove[];
8
- getPlayerMoves(): MaterialMove[];
8
+ getPlayerMoves(player?: number): MaterialMove[];
9
9
  beforeItemMove(move: ItemMove): MaterialMove<number, number, number, number>[];
10
10
  }
@@ -47,6 +47,7 @@ var LocationType_1 = require("../../material/LocationType");
47
47
  var MaterialType_1 = require("../../material/MaterialType");
48
48
  var Pantheon_1 = require("../../material/Pantheon");
49
49
  var RuleId_1 = require("../RuleId");
50
+ var PermanentEffectsRule_1 = require("./PermanentEffectsRule");
50
51
  var ShivaEffectRule = (function (_super) {
51
52
  __extends(ShivaEffectRule, _super);
52
53
  function ShivaEffectRule() {
@@ -55,20 +56,22 @@ var ShivaEffectRule = (function (_super) {
55
56
  return _this;
56
57
  }
57
58
  ShivaEffectRule.prototype.canPlayEffect = function (cardIndex) {
58
- var pantheon = new Pantheon_1.Pantheon(this.game, this.player);
59
- var cards = pantheon.allCards;
60
- var location = cards.getItem(cardIndex).location;
61
- return pantheon.gems > 0 && cards.location(function (l) { return (0, rules_api_1.areAdjacentSquares)(l, location); }).length > 0;
59
+ var player = this.material(MaterialType_1.MaterialType.EntityCard).getItem(cardIndex).location.player;
60
+ var pantheon = new Pantheon_1.Pantheon(this.game, player);
61
+ return pantheon.gems > 0 && this.getPlayerMoves(player).length > 0;
62
62
  };
63
63
  ShivaEffectRule.prototype.onRuleStart = function () {
64
64
  return [new Pantheon_1.Pantheon(this.game, this.player).spendGems(1)];
65
65
  };
66
- ShivaEffectRule.prototype.getPlayerMoves = function () {
67
- var _this = this;
66
+ ShivaEffectRule.prototype.getPlayerMoves = function (player) {
67
+ if (player === void 0) { player = this.player; }
68
68
  var location = this.card.location;
69
- var pantheon = new Pantheon_1.Pantheon(this.game, this.player);
70
- var piles = pantheon.getPiles(function (space) { return (0, rules_api_1.areAdjacentSquares)(space, location); });
71
- return piles.map(function (pile) { return pile.moveItemsAtOnce({ type: LocationType_1.LocationType.PlayerDiscard, player: _this.player }); });
69
+ var pantheon = new Pantheon_1.Pantheon(this.game, player);
70
+ var rule = new PermanentEffectsRule_1.PermanentEffectsRule(this.game);
71
+ var piles = pantheon
72
+ .getPiles(function (space) { return (0, rules_api_1.areAdjacentSquares)(space, location); })
73
+ .filter(function (pile) { return rule.canSacrifice(pile.maxBy(function (item) { return item.location.z; }).getItem()); });
74
+ return piles.map(function (pile) { return pile.moveItemsAtOnce({ type: LocationType_1.LocationType.PlayerDiscard, player: player }); });
72
75
  };
73
76
  ShivaEffectRule.prototype.beforeItemMove = function (move) {
74
77
  if ((0, rules_api_1.isMoveItemTypeAtOnce)(MaterialType_1.MaterialType.EntityCard)(move) && move.location.type === LocationType_1.LocationType.PlayerDiscard) {
@@ -76,7 +79,8 @@ var ShivaEffectRule = (function (_super) {
76
79
  var topCard = this.material(MaterialType_1.MaterialType.EntityCard)
77
80
  .index(move.indexes)
78
81
  .maxBy(function (item) { return item.location.z; });
79
- return __spreadArray(__spreadArray([pantheon.gainFavor(move.indexes.length)], __read(pantheon.onEntitySacrificed(topCard)), false), __read(this.endEffect()), false);
82
+ pantheon.onEntitySacrificed(topCard);
83
+ return __spreadArray([pantheon.gainFavor(move.indexes.length)], __read(this.endEffect()), false);
80
84
  }
81
85
  return [];
82
86
  };
@@ -6,6 +6,6 @@ export declare class TriggerEffectsRule extends MaterialRulesPart {
6
6
  triggerPlayerEffects(player: PlayerColor, ...triggerEvents: TriggerEvent[]): void;
7
7
  getPlayerEffects(player: PlayerColor, ...triggerEvents: TriggerEvent[]): PendingEffect<TriggerEvent>[];
8
8
  triggerCardEffect(card: Material, triggerEvent: TriggerEvent): void;
9
- getCardEffect(card: Material, triggerEvent: TriggerEvent): PendingEffect[];
9
+ getCardEffects(card: Material, triggerEvent: TriggerEvent): PendingEffect[];
10
10
  private getPlayersByEffectPriorityOrder;
11
11
  }
@@ -53,6 +53,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
54
  exports.TriggerEffectsRule = void 0;
55
55
  var rules_api_1 = require("@gamepark/rules-api");
56
+ var Effect_1 = require("../../material/entity/Effect");
56
57
  var EntityDescription_1 = require("../../material/entity/EntityDescription");
57
58
  var MaterialType_1 = require("../../material/MaterialType");
58
59
  var Pantheon_1 = require("../../material/Pantheon");
@@ -94,55 +95,72 @@ var TriggerEffectsRule = (function (_super) {
94
95
  }
95
96
  };
96
97
  TriggerEffectsRule.prototype.getPlayerEffects = function (player) {
97
- var e_2, _a, e_3, _b;
98
+ var e_2, _a, e_3, _b, e_4, _c;
98
99
  var triggerEvents = [];
99
100
  for (var _i = 1; _i < arguments.length; _i++) {
100
101
  triggerEvents[_i - 1] = arguments[_i];
101
102
  }
102
103
  var pendingEffects = [];
103
104
  var pantheon = new Pantheon_1.Pantheon(this.game, player);
104
- var cards = pantheon.visibleEntities;
105
+ var material = this.material(MaterialType_1.MaterialType.EntityCard);
106
+ var cards = pantheon.visibleEntities.getIndexes();
105
107
  try {
106
108
  for (var triggerEvents_1 = __values(triggerEvents), triggerEvents_1_1 = triggerEvents_1.next(); !triggerEvents_1_1.done; triggerEvents_1_1 = triggerEvents_1.next()) {
107
- var triggerEvent = triggerEvents_1_1.value;
109
+ var event = triggerEvents_1_1.value;
110
+ if (event.type === Effect_1.TriggerEventType.EntityCrushed && material.getItem(event.cardIndex).location.player === player && !cards.includes(event.cardIndex)) {
111
+ cards.push(event.cardIndex);
112
+ }
113
+ }
114
+ }
115
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
116
+ finally {
117
+ try {
118
+ if (triggerEvents_1_1 && !triggerEvents_1_1.done && (_a = triggerEvents_1.return)) _a.call(triggerEvents_1);
119
+ }
120
+ finally { if (e_2) throw e_2.error; }
121
+ }
122
+ try {
123
+ for (var triggerEvents_2 = __values(triggerEvents), triggerEvents_2_1 = triggerEvents_2.next(); !triggerEvents_2_1.done; triggerEvents_2_1 = triggerEvents_2.next()) {
124
+ var triggerEvent = triggerEvents_2_1.value;
108
125
  try {
109
- for (var _c = (e_3 = void 0, __values(cards.getIndexes())), _d = _c.next(); !_d.done; _d = _c.next()) {
110
- var cardIndex = _d.value;
111
- pendingEffects.push.apply(pendingEffects, __spreadArray([], __read(this.getCardEffect(cards.index(cardIndex), triggerEvent)), false));
126
+ for (var cards_1 = (e_4 = void 0, __values(cards)), cards_1_1 = cards_1.next(); !cards_1_1.done; cards_1_1 = cards_1.next()) {
127
+ var cardIndex = cards_1_1.value;
128
+ var card = material.index(cardIndex);
129
+ pendingEffects.push.apply(pendingEffects, __spreadArray([], __read(this.getCardEffects(card, triggerEvent)), false));
112
130
  }
113
131
  }
114
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
132
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
115
133
  finally {
116
134
  try {
117
- if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
135
+ if (cards_1_1 && !cards_1_1.done && (_c = cards_1.return)) _c.call(cards_1);
118
136
  }
119
- finally { if (e_3) throw e_3.error; }
137
+ finally { if (e_4) throw e_4.error; }
120
138
  }
121
139
  }
122
140
  }
123
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
141
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
124
142
  finally {
125
143
  try {
126
- if (triggerEvents_1_1 && !triggerEvents_1_1.done && (_a = triggerEvents_1.return)) _a.call(triggerEvents_1);
144
+ if (triggerEvents_2_1 && !triggerEvents_2_1.done && (_b = triggerEvents_2.return)) _b.call(triggerEvents_2);
127
145
  }
128
- finally { if (e_2) throw e_2.error; }
146
+ finally { if (e_3) throw e_3.error; }
129
147
  }
130
148
  return pendingEffects;
131
149
  };
132
150
  TriggerEffectsRule.prototype.triggerCardEffect = function (card, triggerEvent) {
133
- var pendingEffects = this.getCardEffect(card, triggerEvent);
151
+ var pendingEffects = this.getCardEffects(card, triggerEvent);
134
152
  if (pendingEffects.length) {
135
153
  this.remind(Memory_1.Memory.PendingEffects).unshift(pendingEffects);
136
154
  }
137
155
  };
138
- TriggerEffectsRule.prototype.getCardEffect = function (card, triggerEvent) {
156
+ TriggerEffectsRule.prototype.getCardEffects = function (card, triggerEvent) {
139
157
  var pendingEffects = [];
140
158
  var cardIndex = card.getIndex();
141
159
  var cardItem = card.getItem();
142
- if (cardItem.id.front) {
143
- var effect = EntityDescription_1.entities[cardItem.id.front].effect;
144
- if (effect === null || effect === void 0 ? void 0 : effect.trigger(triggerEvent, card, this.game)) {
145
- pendingEffects.push({ cardIndex: cardIndex, triggerEvent: triggerEvent, auto: !!effect.auto });
160
+ for (var effectIndex = 0; effectIndex < (0, EntityDescription_1.getEffects)(cardItem.id.front).length; effectIndex++) {
161
+ var effect = (0, EntityDescription_1.getEffects)(cardItem.id.front)[effectIndex];
162
+ if ((0, Effect_1.isTriggeredEffect)(effect) && effect.trigger(triggerEvent, card, this.game)) {
163
+ pendingEffects.push({ cardIndex: cardIndex, effectIndex: effectIndex, triggerEvent: triggerEvent, auto: !!effect.auto });
146
164
  }
147
165
  }
148
166
  return pendingEffects;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamepark/mythologies",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
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": "d1fe28d9163e93c887671815f4d48d64776adb30"
32
+ "gitHead": "d8c1359afbcb56757b75fda229d3a030a64b4d8b"
33
33
  }