@gamepark/mythologies 1.0.3 → 1.0.5

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.
@@ -9,7 +9,7 @@ import { AmmoutEffectRule } from './rules/effects/AmmoutEffectRule';
9
9
  import { AnubisEffectRule } from './rules/effects/AnubisEffectRule';
10
10
  import { AthenaEffectRule } from './rules/effects/AthenaEffectRule';
11
11
  import { BennuEffectRule } from './rules/effects/BennuEffectRule';
12
- import { CaimanEffectRule } from './rules/effects/CaimanEffectRule';
12
+ import { CaimanEffectRule, CaimanSacrificeEffectRule } from './rules/effects/CaimanEffectRule';
13
13
  import { CentaurEffectRule, CentaurEffectSacrificeRule } from './rules/effects/CentaurEffectRule';
14
14
  import { ChimeraEffectRule } from './rules/effects/ChimeraEffectRule';
15
15
  import { CobraEffectRule, CobraSummonEffect } from './rules/effects/CobraEffectRule';
@@ -98,6 +98,7 @@ export declare class MythologiesRules extends SecretMaterialRules<PlayerColor, M
98
98
  41: typeof IllapaEffectRule;
99
99
  42: typeof IllapaSacrificeRule;
100
100
  43: typeof CaimanEffectRule;
101
+ 64: typeof CaimanSacrificeEffectRule;
101
102
  44: typeof CondorEffectRule;
102
103
  45: typeof SupayEffectRule;
103
104
  46: typeof UkukuEffectRule;
@@ -143,7 +144,7 @@ export declare class MythologiesRules extends SecretMaterialRules<PlayerColor, M
143
144
  6: (item: MaterialItem, player?: PlayerColor) => string[];
144
145
  };
145
146
  4: {
146
- 5: import("@gamepark/rules-api").HidingStrategy<number, number>;
147
+ 5: import("@gamepark/rules-api").HidingStrategy;
147
148
  17: (item: MaterialItem) => string[];
148
149
  };
149
150
  10: {
@@ -13,7 +13,7 @@ import { AmmoutEffectRule } from './rules/effects/AmmoutEffectRule';
13
13
  import { AnubisEffectRule } from './rules/effects/AnubisEffectRule';
14
14
  import { AthenaEffectRule } from './rules/effects/AthenaEffectRule';
15
15
  import { BennuEffectRule } from './rules/effects/BennuEffectRule';
16
- import { CaimanEffectRule } from './rules/effects/CaimanEffectRule';
16
+ import { CaimanEffectRule, CaimanSacrificeEffectRule } from './rules/effects/CaimanEffectRule';
17
17
  import { CentaurEffectRule, CentaurEffectSacrificeRule } from './rules/effects/CentaurEffectRule';
18
18
  import { ChimeraEffectRule } from './rules/effects/ChimeraEffectRule';
19
19
  import { CobraEffectRule, CobraSummonEffect } from './rules/effects/CobraEffectRule';
@@ -103,6 +103,7 @@ export class MythologiesRules extends SecretMaterialRules {
103
103
  [RuleId.IllapaEffect]: IllapaEffectRule,
104
104
  [RuleId.IllapaSacrifice]: IllapaSacrificeRule,
105
105
  [RuleId.CaimanEffect]: CaimanEffectRule,
106
+ [RuleId.CaimanSacrificeEffect]: CaimanSacrificeEffectRule,
106
107
  [RuleId.CondorEffect]: CondorEffectRule,
107
108
  [RuleId.SupayEffect]: SupayEffectRule,
108
109
  [RuleId.UkukuEffect]: UkukuEffectRule,
@@ -169,18 +170,27 @@ export class MythologiesRules extends SecretMaterialRules {
169
170
  beforeItemMove(move) {
170
171
  if (!this.game.rule)
171
172
  return [];
173
+ const consequences = super.beforeItemMove(move);
172
174
  if (isMoveItemType(MaterialType.GemToken)(move) && move.location.type === LocationType.PlayerGems) {
173
175
  const gem = this.material(MaterialType.GemToken).getItem(move.itemIndex).location;
174
176
  const player = gem.player;
175
177
  if (gem.type === LocationType.PantheonLineBonus && player === move.location.player) {
178
+ const firstEffect = this.remind(Memory.PendingEffects)[0];
176
179
  new TriggerEffectsRule(this.game).triggerEffects({ type: TriggerEventType.LineEvent, eventType: LineEventType.BonusGain, player, y: gem.y });
180
+ if (this.remind(Memory.PendingEffects)[0] !== firstEffect) {
181
+ consequences.push(...new ResolveEffectsRule(this.game).startEffectsResolution());
182
+ }
177
183
  }
178
184
  }
179
185
  if (isMoveItemType(MaterialType.FavorToken)(move) && move.location.type === LocationType.PlayerFavor) {
180
186
  const favor = this.material(MaterialType.FavorToken).getItem(move.itemIndex).location;
181
187
  const player = favor.player;
182
188
  if (favor.type === LocationType.PantheonColumnBonus && player === move.location.player) {
189
+ const firstEffect = this.remind(Memory.PendingEffects)[0];
183
190
  new TriggerEffectsRule(this.game).triggerEffects({ type: TriggerEventType.ColumnEvent, eventType: LineEventType.BonusGain, player, x: favor.x });
191
+ if (this.remind(Memory.PendingEffects)[0] !== firstEffect) {
192
+ consequences.push(...new ResolveEffectsRule(this.game).startEffectsResolution());
193
+ }
184
194
  }
185
195
  }
186
196
  if (isMoveItemType(MaterialType.EntityCard)(move) && move.location.type === LocationType.PlayerDiscard) {
@@ -195,7 +205,7 @@ export class MythologiesRules extends SecretMaterialRules {
195
205
  new Pantheon(this.game, firstCard.location.player).onPileSacrificed(move.indexes);
196
206
  }
197
207
  }
198
- return super.beforeItemMove(move);
208
+ return consequences;
199
209
  }
200
210
  getAutomaticMoves() {
201
211
  if (!this.remind(Memory.OngoingEffect) &&
@@ -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(cardIndex: number): 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,8 +54,4 @@ export class PlaceCardEffectRule extends PlayerEffectRule {
52
54
  }
53
55
  export class SummonEffectRule extends PlaceCardEffectRule {
54
56
  isSummon = true;
55
- getAvailableDestinations(cardIndex) {
56
- const entity = this.material(MaterialType.EntityCard).getItem(cardIndex).id.front;
57
- return new Pantheon(this.game, this.player).getLegalSpacesToSummon(entity);
58
- }
59
57
  }
@@ -1,14 +1,16 @@
1
1
  import { CyclopsEffectRule } from '../../../rules/effects/CyclopsEffectRule';
2
+ import { PlaceCardsRule } from '../../../rules/PlaceCardsRule';
2
3
  import { LineEventType, TriggerEventType } from '../Effect';
3
4
  export const Cyclops = {
4
5
  summon: [{ favor: 1 }, { gem: 1 }, {}],
5
6
  effect: {
6
- trigger: (event, { cardLocation, game }) => {
7
+ trigger: (event, { cardLocation, game, cardIndex }) => {
7
8
  const { x, y, player } = cardLocation;
8
9
  return (((event.type === TriggerEventType.ColumnEvent && event.x === x) || (event.type === TriggerEventType.LineEvent && event.y === y)) &&
9
10
  event.eventType === LineEventType.BonusGain &&
10
11
  event.player === player &&
11
- new CyclopsEffectRule(game).getBonus(event).length > 0);
12
+ new CyclopsEffectRule(game).getBonus(event).length > 0 &&
13
+ new PlaceCardsRule(game).isOncePerTurnAvailable(cardIndex));
12
14
  },
13
15
  rule: CyclopsEffectRule
14
16
  }
@@ -58,5 +58,6 @@ export declare enum RuleId {
58
58
  LeprechaunEffect = 60,
59
59
  SelkieEffect = 61,
60
60
  DullahanEffect = 62,
61
- GarudaSacrifice = 63
61
+ GarudaSacrifice = 63,
62
+ CaimanSacrificeEffect = 64
62
63
  }
@@ -60,4 +60,5 @@ export var RuleId;
60
60
  RuleId[RuleId["SelkieEffect"] = 61] = "SelkieEffect";
61
61
  RuleId[RuleId["DullahanEffect"] = 62] = "DullahanEffect";
62
62
  RuleId[RuleId["GarudaSacrifice"] = 63] = "GarudaSacrifice";
63
+ RuleId[RuleId["CaimanSacrificeEffect"] = 64] = "CaimanSacrificeEffect";
63
64
  })(RuleId || (RuleId = {}));
@@ -1,7 +1,16 @@
1
- import { MoveItem } from '@gamepark/rules-api';
1
+ import { CustomMove, MaterialMove } from '@gamepark/rules-api';
2
+ import { PlayerEffectRule } from '../../material/entity/PlayerEffectRule';
2
3
  import { SacrificeEffectRule } from '../../material/entity/SacrificeEffectRule';
3
4
  import { RuleId } from '../RuleId';
4
- export declare class CaimanEffectRule extends SacrificeEffectRule {
5
+ export declare class CaimanEffectRule extends PlayerEffectRule {
5
6
  ruleId: RuleId;
6
- onSacrifice(move: MoveItem): (import("@gamepark/rules-api").CustomMove | import("@gamepark/rules-api").CreateItem<number, number, number> | MoveItem<number, number, number>)[];
7
+ getPlayerMoves(): CustomMove[];
8
+ onCustomMove(move: CustomMove): MaterialMove[];
9
+ }
10
+ export declare class CaimanSacrificeEffectRule extends SacrificeEffectRule {
11
+ ruleId: RuleId;
12
+ onRuleStart(): CustomMove[] | import("@gamepark/rules-api").MoveItem<number, number, number>[];
13
+ getCardsToSacrifice(): import("@gamepark/rules-api").Material<number, number, number>;
14
+ onSacrifice(): MaterialMove[];
15
+ onRuleEnd(): never[];
7
16
  }
@@ -1,23 +1,58 @@
1
1
  import { CustomMoveType } from '../../CustomMoveType';
2
2
  import { entityMythology } from '../../material/Entity';
3
+ import { PlayerEffectRule } from '../../material/entity/PlayerEffectRule';
3
4
  import { SacrificeEffectRule } from '../../material/entity/SacrificeEffectRule';
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
- export class CaimanEffectRule extends SacrificeEffectRule {
9
+ export class CaimanEffectRule extends PlayerEffectRule {
9
10
  ruleId = RuleId.CaimanEffect;
10
- onSacrifice(move) {
11
- const card = this.material(MaterialType.EntityCard).getItem(move.itemIndex);
12
- const mythology = entityMythology(card.id.front);
13
- const pantheon = new Pantheon(this.game, this.player);
14
- const others = pantheon.visibleEntities
15
- .location((l) => l.x !== card.location.x || l.y !== card.location.y)
16
- .id((id) => entityMythology(id.front) === mythology);
17
- return [
18
- ...others.moveItems({ type: LocationType.PlayerDiscard, player: this.player }),
19
- pantheon.gainGems(1 + others.length),
20
- this.customMove(CustomMoveType.EndEffect)
21
- ];
11
+ getPlayerMoves() {
12
+ return this.material(MaterialType.MythologyBoard)
13
+ .getItems()
14
+ .map((item) => this.customMove(CustomMoveType.ChooseMythology, item.id.mythology));
15
+ }
16
+ onCustomMove(move) {
17
+ if (move.type === CustomMoveType.ChooseMythology) {
18
+ this.memorize(Memory.TargetMythology, move.data);
19
+ return [this.startRule(RuleId.CaimanSacrificeEffect)];
20
+ }
21
+ return super.onCustomMove(move);
22
+ }
23
+ }
24
+ export class CaimanSacrificeEffectRule extends SacrificeEffectRule {
25
+ ruleId = RuleId.CaimanSacrificeEffect;
26
+ onRuleStart() {
27
+ const mythology = this.remind(Memory.TargetMythology);
28
+ const indexes = new Pantheon(this.game, this.player).visibleEntities.id((id) => entityMythology(id.front) === mythology).getIndexes();
29
+ if (!indexes.length)
30
+ return [this.customMove(CustomMoveType.EndEffect)];
31
+ this.memorize(Memory.TargetEntities, indexes);
32
+ this.memorize(Memory.EffectCount, indexes.length);
33
+ const moves = this.getPlayerMoves();
34
+ if (moves.length === indexes.length) {
35
+ return moves;
36
+ }
37
+ return [];
38
+ }
39
+ getCardsToSacrifice() {
40
+ const indexes = this.remind(Memory.TargetEntities);
41
+ return this.material(MaterialType.EntityCard).index(indexes);
42
+ }
43
+ onSacrifice() {
44
+ const moves = [];
45
+ moves.push(new Pantheon(this.game, this.player).gainGems(1));
46
+ const remaining = this.memorize(Memory.EffectCount, (count) => count - 1);
47
+ if (!remaining) {
48
+ moves.push(this.customMove(CustomMoveType.EndEffect));
49
+ }
50
+ return moves;
51
+ }
52
+ onRuleEnd() {
53
+ this.forget(Memory.TargetEntities);
54
+ this.forget(Memory.EffectCount);
55
+ this.forget(Memory.TargetMythology);
56
+ return [];
22
57
  }
23
58
  }
@@ -39,6 +39,7 @@ export class ResolveEffectsRule extends PlayerTurnRule {
39
39
  throw new Error('Unexpected state: start ResolveEffectsRule without pending effects');
40
40
  }
41
41
  if (pendingEffects.type === PendingEffectsType.SummonGain) {
42
+ this.memorize(Memory.PendingEffects, (effects) => effects.slice(1));
42
43
  return [...new Pantheon(this.game, this.player).getSummonGains(pendingEffects.entity, pendingEffects.line), this.customMove(CustomMoveType.EndEffect)];
43
44
  }
44
45
  const moves = this.getPlayerMoves();
@@ -93,6 +94,7 @@ export class ResolveEffectsRule extends PlayerTurnRule {
93
94
  pendingEffects.lines = pendingEffects.lines.filter((line) => line !== item.location.y);
94
95
  }
95
96
  if (this.getPlayerMoves().length === 0) {
97
+ this.memorize(Memory.PendingEffects, (effects) => effects.slice(1));
96
98
  return [this.customMove(CustomMoveType.EndEffect)];
97
99
  }
98
100
  }
@@ -136,9 +138,6 @@ export class ResolveEffectsRule extends PlayerTurnRule {
136
138
  if (this.remind(Memory.OngoingEffect) !== undefined) {
137
139
  this.forget(Memory.OngoingEffect);
138
140
  }
139
- else {
140
- this.memorize(Memory.PendingEffects, (effects) => effects.slice(1));
141
- }
142
141
  if (this.remind(Memory.PendingEffects).length) {
143
142
  moves.push(...this.startEffectsResolution());
144
143
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamepark/mythologies",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "The rules of Mythologies adapted for Game Park",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -28,5 +28,5 @@
28
28
  "@gamepark/rules-api": "~7.2.0",
29
29
  "es-toolkit": "^1.44.0"
30
30
  },
31
- "gitHead": "5979bb8560edd48228052e30e8097060c49e6ff8"
31
+ "gitHead": "806e4b2d4bb686c0216d8629056df3dbb6008d08"
32
32
  }