@gamepark/mythologies 1.0.2 → 1.0.4

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
  }
@@ -119,7 +119,6 @@ export class Trial extends MaterialRulesPart {
119
119
  getTrialLeftReward(mythology) {
120
120
  switch (mythology) {
121
121
  case Mythology.Greek:
122
- case Mythology.Norse:
123
122
  case Mythology.Egyptian:
124
123
  case Mythology.Inca:
125
124
  return 1;
@@ -13,5 +13,4 @@ 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[];
17
16
  }
@@ -1,7 +1,6 @@
1
1
  import { isMoveItemType } from '@gamepark/rules-api';
2
2
  import { CustomMoveType } from '../../CustomMoveType';
3
3
  import { Memory } from '../../Memory';
4
- import { isGod } from '../Entity';
5
4
  import { LocationType } from '../LocationType';
6
5
  import { MaterialType } from '../MaterialType';
7
6
  import { Pantheon } from '../Pantheon';
@@ -32,8 +31,11 @@ export class PlaceCardEffectRule extends PlayerEffectRule {
32
31
  getPlayerMoves(cardIndex = this.getEffect().cardIndex) {
33
32
  const player = this.material(MaterialType.EntityCard).getItem(cardIndex).location.player;
34
33
  const cards = this.getCardsToPlace(cardIndex);
35
- const cardsICanPlace = new Pantheon(this.game, player).gems < 4 ? cards.id((id) => !isGod(id.front)) : cards;
36
- return this.getAvailableDestinations(cardIndex).flatMap(({ x, y }) => cardsICanPlace.moveItems({ type: LocationType.Pantheon, player, x, y }));
34
+ const pantheon = new Pantheon(this.game, player);
35
+ return this.getAvailableDestinations(cardIndex).flatMap(({ x, y }) => {
36
+ const cardsICanPlace = cards.id((id) => pantheon.isLegalSpaceToSummon({ x, y }, id.front));
37
+ return cardsICanPlace.moveItems({ type: LocationType.Pantheon, player, x, y });
38
+ });
37
39
  }
38
40
  getAvailableDestinations(_cardIndex) {
39
41
  return new Pantheon(this.game, this.player).legalSpaces;
@@ -52,7 +54,4 @@ export class PlaceCardEffectRule extends PlayerEffectRule {
52
54
  }
53
55
  export class SummonEffectRule extends PlaceCardEffectRule {
54
56
  isSummon = true;
55
- getAvailableDestinations() {
56
- return new Pantheon(this.game, this.player).legalSpacesToSummon;
57
- }
58
57
  }
@@ -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
  }
@@ -4,4 +4,5 @@ import { RuleId } from '../RuleId';
4
4
  export declare class CaimanEffectRule extends SacrificeEffectRule {
5
5
  ruleId: RuleId;
6
6
  onSacrifice(move: MoveItem): (import("@gamepark/rules-api").CustomMove | import("@gamepark/rules-api").CreateItem<number, number, number> | MoveItem<number, number, number>)[];
7
+ onRuleEnd(): never[];
7
8
  }
@@ -4,20 +4,29 @@ import { SacrificeEffectRule } from '../../material/entity/SacrificeEffectRule';
4
4
  import { LocationType } from '../../material/LocationType';
5
5
  import { MaterialType } from '../../material/MaterialType';
6
6
  import { Pantheon } from '../../material/Pantheon';
7
+ import { Memory } from '../../Memory';
7
8
  import { RuleId } from '../RuleId';
8
9
  export class CaimanEffectRule extends SacrificeEffectRule {
9
10
  ruleId = RuleId.CaimanEffect;
10
11
  onSacrifice(move) {
12
+ if (this.remind(Memory.EffectCount)) {
13
+ return [];
14
+ }
11
15
  const card = this.material(MaterialType.EntityCard).getItem(move.itemIndex);
12
16
  const mythology = entityMythology(card.id.front);
13
17
  const pantheon = new Pantheon(this.game, this.player);
14
18
  const others = pantheon.visibleEntities
15
19
  .location((l) => l.x !== card.location.x || l.y !== card.location.y)
16
20
  .id((id) => entityMythology(id.front) === mythology);
21
+ this.memorize(Memory.EffectCount, 1 + others.length);
17
22
  return [
18
23
  ...others.moveItems({ type: LocationType.PlayerDiscard, player: this.player }),
19
24
  pantheon.gainGems(1 + others.length),
20
25
  this.customMove(CustomMoveType.EndEffect)
21
26
  ];
22
27
  }
28
+ onRuleEnd() {
29
+ this.forget(Memory.EffectCount);
30
+ return [];
31
+ }
23
32
  }
@@ -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.4",
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": "6333853529378cbbf1535c58e13a015919adf186"
31
32
  }