@gamepark/mythologies 1.0.2 → 1.0.3

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.
@@ -10,8 +10,8 @@ export declare class Pantheon extends MaterialRulesPart {
10
10
  get coveredEntities(): Material<number, number, number>;
11
11
  get grid(): (Entity | undefined)[][];
12
12
  private get indexGrid();
13
- get legalSpacesToSummon(): XYCoordinates[];
14
- isLegalSpaceToSummon(space: XYCoordinates): boolean;
13
+ getLegalSpacesToSummon(entity: Entity): XYCoordinates[];
14
+ isLegalSpaceToSummon(space: XYCoordinates, entity?: Entity): boolean;
15
15
  getFavorTax(space: XYCoordinates): number;
16
16
  getGemTax(space: XYCoordinates): number;
17
17
  get legalSpaces(): XYCoordinates[];
@@ -38,14 +38,15 @@ export class Pantheon extends MaterialRulesPart {
38
38
  return entity.length > 0 ? entity.getIndex() : null;
39
39
  }));
40
40
  }
41
- get legalSpacesToSummon() {
42
- return this.legalSpaces.filter((space) => this.isLegalSpaceToSummon(space));
41
+ getLegalSpacesToSummon(entity) {
42
+ return this.legalSpaces.filter((space) => this.isLegalSpaceToSummon(space, entity));
43
43
  }
44
- isLegalSpaceToSummon(space) {
44
+ isLegalSpaceToSummon(space, entity) {
45
45
  const opponents = this.game.players.filter((player) => player !== this.player);
46
46
  const favorTax = sumBy(opponents, (opponent) => new Pantheon(this.game, opponent).getFavorTax(space));
47
47
  const gemTax = sumBy(opponents, (opponent) => new Pantheon(this.game, opponent).getGemTax(space));
48
- return (!favorTax || this.favor >= favorTax) && (!gemTax || this.gems >= gemTax);
48
+ const totalGemCost = gemTax + (isGod(entity) ? 4 : 0);
49
+ return (!favorTax || this.favor >= favorTax) && (!totalGemCost || this.gems >= totalGemCost);
49
50
  }
50
51
  getFavorTax(space) {
51
52
  return sumBy(this.visibleEntities.getItems(), (card) => sumBy(getEffects(card.id.front), (effect) => effect.favorTax?.(space, card) ?? 0));
@@ -217,7 +218,7 @@ export class Pantheon extends MaterialRulesPart {
217
218
  const gemTax = new Pantheon(this.game, player).getGemTax(move.location);
218
219
  if (gemTax > 0) {
219
220
  const gems = this.material(MaterialType.GemToken).location(LocationType.PlayerGems).player(this.player);
220
- moves.push(gems.moveItem({ type: LocationType.PlayerFavor, player }, gemTax));
221
+ moves.push(gems.moveItem({ type: LocationType.PlayerGems, player }, gemTax));
221
222
  }
222
223
  }
223
224
  }
@@ -13,5 +13,5 @@ export declare abstract class PlaceCardEffectRule extends PlayerEffectRule {
13
13
  }
14
14
  export declare abstract class SummonEffectRule extends PlaceCardEffectRule {
15
15
  isSummon: boolean;
16
- getAvailableDestinations(): XYCoordinates[];
16
+ getAvailableDestinations(cardIndex: number): XYCoordinates[];
17
17
  }
@@ -52,7 +52,8 @@ export class PlaceCardEffectRule extends PlayerEffectRule {
52
52
  }
53
53
  export class SummonEffectRule extends PlaceCardEffectRule {
54
54
  isSummon = true;
55
- getAvailableDestinations() {
56
- return new Pantheon(this.game, this.player).legalSpacesToSummon;
55
+ getAvailableDestinations(cardIndex) {
56
+ const entity = this.material(MaterialType.EntityCard).getItem(cardIndex).id.front;
57
+ return new Pantheon(this.game, this.player).getLegalSpacesToSummon(entity);
57
58
  }
58
59
  }
@@ -1,6 +1,5 @@
1
1
  import { isMoveItemType, PlayerTurnRule } from '@gamepark/rules-api';
2
2
  import { CustomMoveType } from '../CustomMoveType';
3
- import { isGod } from '../material/Entity';
4
3
  import { isTriggeredEffect, TriggerEventType } from '../material/entity/Effect';
5
4
  import { getEffects } from '../material/entity/EntityDescription';
6
5
  import { LocationType } from '../material/LocationType';
@@ -17,8 +16,9 @@ export class PlaceCardsRule extends PlayerTurnRule {
17
16
  const moves = this.infiniteEffects.map((effect) => this.customMove(CustomMoveType.PlayEffect, effect));
18
17
  const cards = this.material(MaterialType.EntityCard).location(LocationType.PlayerSelectedCards).player(this.player);
19
18
  if (cards.length) {
20
- const cardsICanSummon = new Pantheon(this.game, this.player).gems < 4 ? cards.id((id) => !isGod(id.front)) : cards;
21
- for (const { x, y } of new Pantheon(this.game, this.player).legalSpacesToSummon) {
19
+ const pantheon = new Pantheon(this.game, this.player);
20
+ for (const { x, y } of pantheon.legalSpaces) {
21
+ const cardsICanSummon = cards.id((id) => pantheon.isLegalSpaceToSummon({ x, y }, id.front));
22
22
  moves.push(...cardsICanSummon.moveItems({ type: LocationType.Pantheon, x, y, player: this.player }));
23
23
  }
24
24
  moves.push(...cards.moveItems({ type: LocationType.PlayerDiscard, player: this.player }));
@@ -5,5 +5,5 @@ export declare class AnubisEffectRule extends SummonEffectRule {
5
5
  ruleId: RuleId;
6
6
  times: number;
7
7
  getCardsToPlace(): Material;
8
- getAvailableDestinations(): import("@gamepark/rules-api").XYCoordinates[];
8
+ getAvailableDestinations(cardIndex: number): import("@gamepark/rules-api").XYCoordinates[];
9
9
  }
@@ -8,7 +8,7 @@ export class AnubisEffectRule extends SummonEffectRule {
8
8
  getCardsToPlace() {
9
9
  return this.material(MaterialType.EntityCard).location(LocationType.PlayerDiscard);
10
10
  }
11
- getAvailableDestinations() {
12
- return super.getAvailableDestinations().filter((space) => space.y === 2);
11
+ getAvailableDestinations(cardIndex) {
12
+ return super.getAvailableDestinations(cardIndex).filter((space) => space.y === 2);
13
13
  }
14
14
  }
@@ -1,7 +1,7 @@
1
1
  import { MoveKind } from '@gamepark/rules-api';
2
2
  import { CustomMoveType } from '../../CustomMoveType';
3
3
  import { Entity, isCreature } from '../../material/Entity';
4
- import { isPlaced, isTriggeredEffect } from '../../material/entity/Effect';
4
+ import { isTriggeredEffect } from '../../material/entity/Effect';
5
5
  import { getEffects } from '../../material/entity/EntityDescription';
6
6
  import { PlayerEffectRule } from '../../material/entity/PlayerEffectRule';
7
7
  import { MaterialType } from '../../material/MaterialType';
@@ -10,14 +10,15 @@ import { RuleId } from '../RuleId';
10
10
  export class QilinEffectRule extends PlayerEffectRule {
11
11
  ruleId = RuleId.QilinEffect;
12
12
  getPlayerMoves() {
13
+ const { triggerEvent } = this.getEffect();
13
14
  const cardsToCopy = [];
14
15
  for (const player of this.game.players) {
15
16
  if (player !== this.player) {
16
17
  cardsToCopy.push(...new Pantheon(this.game, player).visibleEntities
17
18
  .location((l) => l.x === this.card.location.x)
18
- .id((id) => isCreature(id.front) &&
19
- id.front !== Entity.Qilin &&
20
- getEffects(id.front).some((effect) => isTriggeredEffect(effect) && effect.trigger === isPlaced))
19
+ .filter((card, cardIndex) => isCreature(card.id.front) &&
20
+ card.id.front !== Entity.Qilin &&
21
+ getEffects(card.id.front).some((effect) => isTriggeredEffect(effect) && effect.trigger(triggerEvent, { cardIndex, cardLocation: card.location, game: this.game })))
21
22
  .getIndexes());
22
23
  }
23
24
  }
@@ -25,10 +26,13 @@ export class QilinEffectRule extends PlayerEffectRule {
25
26
  }
26
27
  onCustomMove(move) {
27
28
  if (move.type === CustomMoveType.ChooseEntityCard) {
28
- const card = this.material(MaterialType.EntityCard).getItem(move.data);
29
+ const { triggerEvent } = this.getEffect();
30
+ const cardIndex = move.data;
31
+ const card = this.material(MaterialType.EntityCard).getItem(cardIndex);
32
+ const context = { cardIndex, cardLocation: card.location, game: this.game };
29
33
  const effect = getEffects(card.id.front)
30
34
  .filter(isTriggeredEffect)
31
- .find((effect) => effect.trigger === isPlaced);
35
+ .find((effect) => effect.trigger(triggerEvent, context));
32
36
  const moves = new effect.rule(this.game).playEffect();
33
37
  if (!moves.some((move) => move.kind === MoveKind.RulesMove)) {
34
38
  moves.push(this.customMove(CustomMoveType.EndEffect));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamepark/mythologies",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "The rules of Mythologies adapted for Game Park",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -27,5 +27,6 @@
27
27
  "devDependencies": {
28
28
  "@gamepark/rules-api": "~7.2.0",
29
29
  "es-toolkit": "^1.44.0"
30
- }
30
+ },
31
+ "gitHead": "5979bb8560edd48228052e30e8097060c49e6ff8"
31
32
  }