@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
@@ -14,35 +14,10 @@ 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
17
  Object.defineProperty(exports, "__esModule", { value: true });
43
18
  exports.SacrificeEffectRule = void 0;
44
19
  var rules_api_1 = require("@gamepark/rules-api");
45
- var Entity_1 = require("../Entity");
20
+ var PermanentEffectsRule_1 = require("../../rules/effects/PermanentEffectsRule");
46
21
  var LocationType_1 = require("../LocationType");
47
22
  var MaterialType_1 = require("../MaterialType");
48
23
  var Pantheon_1 = require("../Pantheon");
@@ -56,27 +31,29 @@ var SacrificeEffectRule = (function (_super) {
56
31
  return this.getCardsToSacrifice().length > 0;
57
32
  };
58
33
  SacrificeEffectRule.prototype.playEffect = function () {
59
- if (!this.getCardsToSacrifice().length)
34
+ if (!this.getCardsAbleToSacrifice().length)
60
35
  return [];
61
36
  return _super.prototype.playEffect.call(this);
62
37
  };
63
38
  SacrificeEffectRule.prototype.getPlayerMoves = function () {
64
- var cardsToSacrifice = this.getCardsToSacrifice();
65
- var moves = cardsToSacrifice.moveItems({ type: LocationType_1.LocationType.PlayerDiscard, player: this.player });
66
- var indexes = cardsToSacrifice.getIndexes();
67
- var playerBeetles = new Pantheon_1.Pantheon(this.game, this.player).visibleEntities
68
- .id(function (id) { return id.front === Entity_1.Entity.Beetle; })
69
- .index(function (index) { return !indexes.includes(index); });
70
- return moves.concat(playerBeetles.moveItems({ type: LocationType_1.LocationType.PlayerDiscard, player: this.player }));
39
+ var cards = this.getCardsAbleToSacrifice();
40
+ var moves = cards.moveItems({ type: LocationType_1.LocationType.PlayerDiscard, player: this.player });
41
+ var indexes = cards.getIndexes();
42
+ var replaceSacrifice = new Pantheon_1.Pantheon(this.game, this.player).replaceSacrifice(cards.getItems()).index(function (index) { return !indexes.includes(index); });
43
+ return moves.concat(replaceSacrifice.moveItems({ type: LocationType_1.LocationType.PlayerDiscard, player: this.player }));
44
+ };
45
+ SacrificeEffectRule.prototype.getCardsAbleToSacrifice = function () {
46
+ var rule = new PermanentEffectsRule_1.PermanentEffectsRule(this.game);
47
+ return this.getCardsToSacrifice().filter(function (card) { return rule.canSacrifice(card); });
71
48
  };
72
49
  SacrificeEffectRule.prototype.getCardsToSacrifice = function () {
73
50
  return new Pantheon_1.Pantheon(this.game, this.player).visibleEntities;
74
51
  };
75
52
  SacrificeEffectRule.prototype.beforeItemMove = function (move) {
76
- var _a;
77
53
  if ((0, rules_api_1.isMoveItemType)(MaterialType_1.MaterialType.EntityCard)(move) && move.location.type === LocationType_1.LocationType.PlayerDiscard) {
78
54
  var card = this.material(MaterialType_1.MaterialType.EntityCard).index(move.itemIndex);
79
- return (_a = new Pantheon_1.Pantheon(this.game, this.player).onEntitySacrificed(card)).concat.apply(_a, __spreadArray([], __read(this.onSacrifice(move)), false));
55
+ new Pantheon_1.Pantheon(this.game, this.player).onEntitySacrificed(card);
56
+ return this.onSacrifice(move);
80
57
  }
81
58
  return [];
82
59
  };
@@ -53,6 +53,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
54
  exports.SimultaneousMoveEffectRule = void 0;
55
55
  var rules_api_1 = require("@gamepark/rules-api");
56
+ var TriggerEffectsRule_1 = require("../../rules/effects/TriggerEffectsRule");
56
57
  var LocationType_1 = require("../LocationType");
57
58
  var MaterialType_1 = require("../MaterialType");
58
59
  var Pantheon_1 = require("../Pantheon");
@@ -97,22 +98,25 @@ var SimultaneousMoveEffectRule = (function (_super) {
97
98
  return [this.endPlayerTurn(move.location.player)];
98
99
  };
99
100
  SimultaneousMoveEffectRule.prototype.getMovesAfterPlayersDone = function () {
100
- var e_1, _a;
101
+ var e_1, _a, _b;
101
102
  var moves = [];
103
+ var events = [];
102
104
  try {
103
- for (var _b = __values(this.game.players), _c = _b.next(); !_c.done; _c = _b.next()) {
104
- var player = _c.value;
105
+ for (var _c = __values(this.game.players), _d = _c.next(); !_d.done; _d = _c.next()) {
106
+ var player = _d.value;
105
107
  var pantheon = new Pantheon_1.Pantheon(this.game, player);
106
- moves.push.apply(moves, __spreadArray([], __read(pantheon.updateGrid()), false));
108
+ events.push.apply(events, __spreadArray([], __read(pantheon.updateGrid()), false));
109
+ moves.push.apply(moves, __spreadArray([], __read(pantheon.gainBonus()), false));
107
110
  }
108
111
  }
109
112
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
110
113
  finally {
111
114
  try {
112
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
115
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
113
116
  }
114
117
  finally { if (e_1) throw e_1.error; }
115
118
  }
119
+ (_b = new TriggerEffectsRule_1.TriggerEffectsRule(this.game)).triggerEffects.apply(_b, __spreadArray([], __read(events), false));
116
120
  moves.push.apply(moves, __spreadArray([], __read(_super.prototype.getMovesAfterPlayersDone.call(this)), false));
117
121
  return moves;
118
122
  };
@@ -4,6 +4,7 @@ import { SimultaneousEffectRule } from './Effect';
4
4
  export declare abstract class SimultaneousSacrificeEffectRule extends SimultaneousEffectRule {
5
5
  getAffectedPlayers(): PlayerColor[];
6
6
  getActivePlayerLegalMoves(player: PlayerColor): MaterialMove[];
7
+ private getCardsAbleToSacrifice;
7
8
  getCardsToSacrifice(player: PlayerColor): Material;
8
9
  beforeItemMove(move: ItemMove): MaterialMove[];
9
10
  onSacrifice(move: MoveItem): import("@gamepark/rules-api").EndPlayerTurn<number>[];
@@ -14,35 +14,10 @@ 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
17
  Object.defineProperty(exports, "__esModule", { value: true });
43
18
  exports.SimultaneousSacrificeEffectRule = void 0;
44
19
  var rules_api_1 = require("@gamepark/rules-api");
45
- var Entity_1 = require("../Entity");
20
+ var PermanentEffectsRule_1 = require("../../rules/effects/PermanentEffectsRule");
46
21
  var LocationType_1 = require("../LocationType");
47
22
  var MaterialType_1 = require("../MaterialType");
48
23
  var Pantheon_1 = require("../Pantheon");
@@ -57,22 +32,24 @@ var SimultaneousSacrificeEffectRule = (function (_super) {
57
32
  return this.game.players.filter(function (player) { return _this.getCardsToSacrifice(player).length; });
58
33
  };
59
34
  SimultaneousSacrificeEffectRule.prototype.getActivePlayerLegalMoves = function (player) {
60
- var cardsToSacrifice = this.getCardsToSacrifice(player);
61
- var moves = cardsToSacrifice.moveItems({ type: LocationType_1.LocationType.PlayerDiscard, player: player });
62
- var indexes = cardsToSacrifice.getIndexes();
63
- var playerBeetles = new Pantheon_1.Pantheon(this.game, player).visibleEntities
64
- .id(function (id) { return id.front === Entity_1.Entity.Beetle; })
65
- .index(function (index) { return !indexes.includes(index); });
66
- return moves.concat(playerBeetles.moveItems({ type: LocationType_1.LocationType.PlayerDiscard, player: player }));
35
+ var cards = this.getCardsAbleToSacrifice(player);
36
+ var moves = cards.moveItems({ type: LocationType_1.LocationType.PlayerDiscard, player: player });
37
+ var indexes = cards.getIndexes();
38
+ var replaceSacrifice = new Pantheon_1.Pantheon(this.game, player).replaceSacrifice(cards.getItems()).index(function (index) { return !indexes.includes(index); });
39
+ return moves.concat(replaceSacrifice.moveItems({ type: LocationType_1.LocationType.PlayerDiscard, player: player }));
40
+ };
41
+ SimultaneousSacrificeEffectRule.prototype.getCardsAbleToSacrifice = function (player) {
42
+ var rule = new PermanentEffectsRule_1.PermanentEffectsRule(this.game);
43
+ return this.getCardsToSacrifice(player).filter(function (card) { return rule.canSacrifice(card); });
67
44
  };
68
45
  SimultaneousSacrificeEffectRule.prototype.getCardsToSacrifice = function (player) {
69
46
  return new Pantheon_1.Pantheon(this.game, player).visibleEntities;
70
47
  };
71
48
  SimultaneousSacrificeEffectRule.prototype.beforeItemMove = function (move) {
72
- var _a;
73
49
  if ((0, rules_api_1.isMoveItemType)(MaterialType_1.MaterialType.EntityCard)(move) && move.location.type === LocationType_1.LocationType.PlayerDiscard) {
74
50
  var card = this.material(MaterialType_1.MaterialType.EntityCard).index(move.itemIndex);
75
- return (_a = new Pantheon_1.Pantheon(this.game, move.location.player).onEntitySacrificed(card)).concat.apply(_a, __spreadArray([], __read(this.onSacrifice(move)), false));
51
+ new Pantheon_1.Pantheon(this.game, move.location.player).onEntitySacrificed(card);
52
+ return this.onSacrifice(move);
76
53
  }
77
54
  return [];
78
55
  };
@@ -1,6 +1,38 @@
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
+ })();
2
17
  Object.defineProperty(exports, "__esModule", { value: true });
3
18
  exports.Banshee = void 0;
19
+ var Pantheon_1 = require("../../Pantheon");
20
+ var Effect_1 = require("../Effect");
4
21
  exports.Banshee = {
5
- invoke: [{ gem: 1 }, {}, { favor: 1 }]
22
+ invoke: [{ gem: 1 }, {}, { favor: 1 }],
23
+ effect: {
24
+ trigger: Effect_1.isPlaced,
25
+ rule: (function (_super) {
26
+ __extends(BansheeEffectRule, _super);
27
+ function BansheeEffectRule() {
28
+ return _super !== null && _super.apply(this, arguments) || this;
29
+ }
30
+ BansheeEffectRule.prototype.playEffect = function () {
31
+ var _a = this.card.location, x = _a.x, y = _a.y, player = _a.player;
32
+ var pantheon = new Pantheon_1.Pantheon(this.game, player);
33
+ return pantheon.grid[y].every(function (entity, column) { return column !== x || !entity; }) ? [pantheon.gainFavor(1)] : [];
34
+ };
35
+ return BansheeEffectRule;
36
+ }(Effect_1.AutoEffectRule))
37
+ }
6
38
  };
@@ -1,6 +1,39 @@
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
+ })();
2
17
  Object.defineProperty(exports, "__esModule", { value: true });
3
18
  exports.Brigid = void 0;
19
+ var Entity_1 = require("../../Entity");
20
+ var Pantheon_1 = require("../../Pantheon");
21
+ var Effect_1 = require("../Effect");
4
22
  exports.Brigid = {
5
- invoke: [{ favor: 2 }, { gem: 2 }, {}]
23
+ invoke: [{ favor: 2 }, { gem: 2 }, {}],
24
+ effect: {
25
+ trigger: Effect_1.isPlaced,
26
+ rule: (function (_super) {
27
+ __extends(BrigidEffectRule, _super);
28
+ function BrigidEffectRule() {
29
+ return _super !== null && _super.apply(this, arguments) || this;
30
+ }
31
+ BrigidEffectRule.prototype.playEffect = function () {
32
+ var pantheon = new Pantheon_1.Pantheon(this.game, this.player);
33
+ var gain = pantheon.visibleEntities.id(function (id) { return (0, Entity_1.isCreature)(id.front); }).length;
34
+ return gain ? [pantheon.gainGems(gain)] : [];
35
+ };
36
+ return BrigidEffectRule;
37
+ }(Effect_1.PlayerEffectRule))
38
+ }
6
39
  };
@@ -1,6 +1,42 @@
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
+ })();
2
17
  Object.defineProperty(exports, "__esModule", { value: true });
3
18
  exports.Cernunnos = void 0;
19
+ var Pantheon_1 = require("../../Pantheon");
20
+ var Effect_1 = require("../Effect");
4
21
  exports.Cernunnos = {
5
- invoke: [{}, { favor: 1 }, { gem: 2 }]
22
+ invoke: [{}, { favor: 1 }, { gem: 2 }],
23
+ effect: {
24
+ trigger: Effect_1.isEndOfGame,
25
+ rule: (function (_super) {
26
+ __extends(CernunnosEffectRule, _super);
27
+ function CernunnosEffectRule() {
28
+ return _super !== null && _super.apply(this, arguments) || this;
29
+ }
30
+ CernunnosEffectRule.prototype.playEffect = function () {
31
+ var _this = this;
32
+ var pantheon = new Pantheon_1.Pantheon(this.game, this.player);
33
+ var gems = pantheon.gems;
34
+ var opponents = this.game.players.filter(function (player) { return player !== _this.player; });
35
+ var beatenOpponents = opponents.filter(function (opponent) { return new Pantheon_1.Pantheon(_this.game, opponent).gems < gems; });
36
+ var gain = beatenOpponents.length === opponents.length ? opponents.length + 2 : beatenOpponents.length;
37
+ return gain ? [pantheon.gainFavor(gain)] : [];
38
+ };
39
+ return CernunnosEffectRule;
40
+ }(Effect_1.PlayerEffectRule))
41
+ }
6
42
  };
@@ -1,6 +1,48 @@
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
+ })();
2
17
  Object.defineProperty(exports, "__esModule", { value: true });
3
18
  exports.Dagda = void 0;
19
+ var Pantheon_1 = require("../../Pantheon");
20
+ var Effect_1 = require("../Effect");
4
21
  exports.Dagda = {
5
- invoke: [{ gem: 2, favor: 1 }, { favor: 2 }, {}]
22
+ invoke: [{ gem: 2, favor: 1 }, { favor: 2 }, {}],
23
+ effect: {
24
+ trigger: function (event, dagda, game) {
25
+ var player = dagda.getItem().location.player;
26
+ switch (event.type) {
27
+ case Effect_1.TriggerEventType.EntitySacrificed:
28
+ case Effect_1.TriggerEventType.EntityCrushed:
29
+ return event.card.location.player === player && new Pantheon_1.Pantheon(game, player).isOpponentOngoingEffect();
30
+ case Effect_1.TriggerEventType.EntitiesMoved:
31
+ return event.player === player && new Pantheon_1.Pantheon(game, player).isOpponentOngoingEffect();
32
+ default:
33
+ return false;
34
+ }
35
+ },
36
+ rule: (function (_super) {
37
+ __extends(DagdaEffectRule, _super);
38
+ function DagdaEffectRule() {
39
+ return _super !== null && _super.apply(this, arguments) || this;
40
+ }
41
+ DagdaEffectRule.prototype.playEffect = function () {
42
+ var player = this.card.location.player;
43
+ return [new Pantheon_1.Pantheon(this.game, player).gainFavor(1)];
44
+ };
45
+ return DagdaEffectRule;
46
+ }(Effect_1.AutoEffectRule))
47
+ }
6
48
  };
@@ -0,0 +1,2 @@
1
+ import { EntityDescription } from '../EntityDescription';
2
+ export declare const Fairy: EntityDescription;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Fairy = void 0;
4
+ var FairyEffectRule_1 = require("../../../rules/effects/FairyEffectRule");
5
+ var Effect_1 = require("../Effect");
6
+ exports.Fairy = {
7
+ invoke: [{ favor: 1 }, { gem: 1 }, {}],
8
+ effect: {
9
+ trigger: Effect_1.isPlaced,
10
+ rule: FairyEffectRule_1.FairyEffectRule
11
+ }
12
+ };
@@ -1,6 +1,38 @@
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
+ })();
2
17
  Object.defineProperty(exports, "__esModule", { value: true });
3
18
  exports.Kelpie = void 0;
19
+ var Pantheon_1 = require("../../Pantheon");
20
+ var Effect_1 = require("../Effect");
4
21
  exports.Kelpie = {
5
- invoke: [{}, { gem: 1, favor: 1 }, { favor: 1 }]
22
+ invoke: [{}, { gem: 1, favor: 1 }, { favor: 1 }],
23
+ effect: {
24
+ trigger: Effect_1.isPlaced,
25
+ rule: (function (_super) {
26
+ __extends(KelpieEffectRule, _super);
27
+ function KelpieEffectRule() {
28
+ return _super !== null && _super.apply(this, arguments) || this;
29
+ }
30
+ KelpieEffectRule.prototype.playEffect = function () {
31
+ var _a = this.card.location, x = _a.x, player = _a.player;
32
+ var pantheon = new Pantheon_1.Pantheon(this.game, player);
33
+ return pantheon.grid.every(function (line) { return line[x] !== undefined; }) ? [pantheon.gainGems(2)] : [];
34
+ };
35
+ return KelpieEffectRule;
36
+ }(Effect_1.AutoEffectRule))
37
+ }
6
38
  };
@@ -2,5 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Morrigan = void 0;
4
4
  exports.Morrigan = {
5
- invoke: [{ favor: 1 }, {}, { favor: 2 }]
5
+ invoke: [{ favor: 1 }, {}, { favor: 2 }],
6
+ effect: {
7
+ preventSacrifice: function (card, effectCard) { return card.location.y === effectCard.location.y; },
8
+ preventMove: function (card, effectCard) { return card.location.y === effectCard.location.y; },
9
+ preventCrush: function (card, effectCard) { return card.location.y === effectCard.location.y; }
10
+ }
6
11
  };
@@ -16,21 +16,27 @@ var __extends = (this && this.__extends) || (function () {
16
16
  })();
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.Beetle = void 0;
19
+ var Entity_1 = require("../../Entity");
19
20
  var Pantheon_1 = require("../../Pantheon");
20
21
  var Effect_1 = require("../Effect");
21
22
  exports.Beetle = {
22
23
  invoke: [{ favor: 1 }, { gem: 1 }, {}],
23
- effect: {
24
- trigger: Effect_1.isSacrificed,
25
- rule: (function (_super) {
26
- __extends(BeetleEffectRule, _super);
27
- function BeetleEffectRule() {
28
- return _super !== null && _super.apply(this, arguments) || this;
29
- }
30
- BeetleEffectRule.prototype.playEffect = function () {
31
- return [new Pantheon_1.Pantheon(this.game, this.player).gainGems(2)];
32
- };
33
- return BeetleEffectRule;
34
- }(Effect_1.PlayerEffectRule))
35
- }
24
+ effects: [
25
+ {
26
+ replaceSacrifice: function (card) { return (0, Entity_1.isCreature)(card.id.front); }
27
+ },
28
+ {
29
+ trigger: Effect_1.isSacrificed,
30
+ rule: (function (_super) {
31
+ __extends(BeetleEffectRule, _super);
32
+ function BeetleEffectRule() {
33
+ return _super !== null && _super.apply(this, arguments) || this;
34
+ }
35
+ BeetleEffectRule.prototype.playEffect = function () {
36
+ return [new Pantheon_1.Pantheon(this.game, this.player).gainGems(2)];
37
+ };
38
+ return BeetleEffectRule;
39
+ }(Effect_1.PlayerEffectRule))
40
+ }
41
+ ]
36
42
  };
@@ -27,42 +27,48 @@ var __values = (this && this.__values) || function(o) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.Naga = void 0;
30
+ var rules_api_1 = require("@gamepark/rules-api");
30
31
  var LocationType_1 = require("../../LocationType");
31
32
  var MaterialType_1 = require("../../MaterialType");
32
33
  var Effect_1 = require("../Effect");
33
34
  exports.Naga = {
34
35
  invoke: [{}, { gem: 2 }, { gem: 1 }],
35
- effect: {
36
- trigger: Effect_1.isCrushed,
37
- rule: (function (_super) {
38
- __extends(NagaEffectRule, _super);
39
- function NagaEffectRule() {
40
- return _super !== null && _super.apply(this, arguments) || this;
41
- }
42
- NagaEffectRule.prototype.playEffect = function () {
43
- var e_1, _a;
44
- var _this = this;
45
- var moves = [];
46
- var opponents = this.game.players.filter(function (player) { return player !== _this.player; });
47
- try {
48
- for (var opponents_1 = __values(opponents), opponents_1_1 = opponents_1.next(); !opponents_1_1.done; opponents_1_1 = opponents_1.next()) {
49
- var opponent = opponents_1_1.value;
50
- var favor = this.material(MaterialType_1.MaterialType.FavorToken).location(LocationType_1.LocationType.PlayerFavor).player(opponent);
51
- if (favor.getQuantity()) {
52
- moves.push(favor.deleteItem(1));
53
- }
54
- }
36
+ effects: [
37
+ {
38
+ preventMove: function (card, naga) { return naga.location.player === card.location.player && (0, rules_api_1.areAdjacentSquares)(naga.location, card.location); }
39
+ },
40
+ {
41
+ trigger: Effect_1.isCrushed,
42
+ rule: (function (_super) {
43
+ __extends(NagaEffectRule, _super);
44
+ function NagaEffectRule() {
45
+ return _super !== null && _super.apply(this, arguments) || this;
55
46
  }
56
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
57
- finally {
47
+ NagaEffectRule.prototype.playEffect = function () {
48
+ var e_1, _a;
49
+ var _this = this;
50
+ var moves = [];
51
+ var opponents = this.game.players.filter(function (player) { return player !== _this.player; });
58
52
  try {
59
- if (opponents_1_1 && !opponents_1_1.done && (_a = opponents_1.return)) _a.call(opponents_1);
53
+ for (var opponents_1 = __values(opponents), opponents_1_1 = opponents_1.next(); !opponents_1_1.done; opponents_1_1 = opponents_1.next()) {
54
+ var opponent = opponents_1_1.value;
55
+ var favor = this.material(MaterialType_1.MaterialType.FavorToken).location(LocationType_1.LocationType.PlayerFavor).player(opponent);
56
+ if (favor.getQuantity()) {
57
+ moves.push(favor.deleteItem(1));
58
+ }
59
+ }
60
60
  }
61
- finally { if (e_1) throw e_1.error; }
62
- }
63
- return moves;
64
- };
65
- return NagaEffectRule;
66
- }(Effect_1.PlayerEffectRule))
67
- }
61
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
62
+ finally {
63
+ try {
64
+ if (opponents_1_1 && !opponents_1_1.done && (_a = opponents_1.return)) _a.call(opponents_1);
65
+ }
66
+ finally { if (e_1) throw e_1.error; }
67
+ }
68
+ return moves;
69
+ };
70
+ return NagaEffectRule;
71
+ }(Effect_1.PlayerEffectRule))
72
+ }
73
+ ]
68
74
  };
@@ -2,5 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Troll = void 0;
4
4
  exports.Troll = {
5
- invoke: [{}, { gem: 1 }, { favor: 1 }]
5
+ invoke: [{}, { gem: 1 }, { favor: 1 }],
6
+ effect: {
7
+ favorTax: function (space, troll) { return (space.x === troll.location.x && space.y === troll.location.y ? 1 : 0); }
8
+ }
6
9
  };
@@ -21,21 +21,26 @@ var Pantheon_1 = require("../../Pantheon");
21
21
  var Effect_1 = require("../Effect");
22
22
  exports.Tokoloshe = {
23
23
  invoke: [{}, { gem: 3 }, { favor: 2 }],
24
- effect: {
25
- trigger: Effect_1.isEndOfMyTurn,
26
- rule: (function (_super) {
27
- __extends(TokolosheEffectRule, _super);
28
- function TokolosheEffectRule() {
29
- return _super !== null && _super.apply(this, arguments) || this;
30
- }
31
- TokolosheEffectRule.prototype.playEffect = function () {
32
- var _a = this.card.location, x = _a.x, y = _a.y, player = _a.player;
33
- var pantheon = new Pantheon_1.Pantheon(this.game, player);
34
- var creatures = pantheon.visibleEntities.location(function (l) { return l.y === y && l.x !== x; }).id(function (id) { return (0, Entity_1.isCreature)(id.front); });
35
- var loss = Math.min(pantheon.favor, creatures.length);
36
- return loss ? [pantheon.loseFavor(loss)] : [];
37
- };
38
- return TokolosheEffectRule;
39
- }(Effect_1.AutoEffectRule))
40
- }
24
+ effects: [
25
+ {
26
+ trigger: Effect_1.isEndOfMyTurn,
27
+ rule: (function (_super) {
28
+ __extends(TokolosheEffectRule, _super);
29
+ function TokolosheEffectRule() {
30
+ return _super !== null && _super.apply(this, arguments) || this;
31
+ }
32
+ TokolosheEffectRule.prototype.playEffect = function () {
33
+ var _a = this.card.location, x = _a.x, y = _a.y, player = _a.player;
34
+ var pantheon = new Pantheon_1.Pantheon(this.game, player);
35
+ var creatures = pantheon.visibleEntities.location(function (l) { return l.y === y && l.x !== x; }).id(function (id) { return (0, Entity_1.isCreature)(id.front); });
36
+ var loss = Math.min(pantheon.favor, creatures.length);
37
+ return loss ? [pantheon.loseFavor(loss)] : [];
38
+ };
39
+ return TokolosheEffectRule;
40
+ }(Effect_1.AutoEffectRule))
41
+ },
42
+ {
43
+ preventCrush: function (card) { return card.id.front === Entity_1.Entity.Tokoloshe; }
44
+ }
45
+ ]
41
46
  };
@@ -110,8 +110,9 @@ var PlaceCardsRule = (function (_super) {
110
110
  var pendingEffect = new TriggerEffectsRule_1.TriggerEffectsRule(this.game).getPlayerEffects(this.player, { type: Effect_1.TriggerEventType.Infinite });
111
111
  return pendingEffect.filter(function (pendingEffect) {
112
112
  var card = _this.material(MaterialType_1.MaterialType.EntityCard).getItem(pendingEffect.cardIndex);
113
- var effect = EntityDescription_1.entities[card.id.front].effect;
114
- return _this.isOncePerTurnAvailable(pendingEffect.cardIndex) && new effect.rule(_this.game).canPlayEffect(pendingEffect.cardIndex);
113
+ var effect = (0, EntityDescription_1.getEffects)(card.id.front)[pendingEffect.effectIndex];
114
+ var canPlayEffect = (0, Effect_1.isTriggeredEffect)(effect) && new effect.rule(_this.game).canPlayEffect(pendingEffect.cardIndex);
115
+ return canPlayEffect && _this.isOncePerTurnAvailable(pendingEffect.cardIndex);
115
116
  });
116
117
  },
117
118
  enumerable: false,