@gamepark/mythologies 1.0.7 → 1.0.9

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.
@@ -139,7 +139,7 @@ export declare class MythologiesRules extends SecretMaterialRules<PlayerColor, M
139
139
  hidingStrategies: {
140
140
  2: {
141
141
  2: import("@gamepark/rules-api").HidingStrategy<number, number>;
142
- 3: import("@gamepark/rules-api").HidingStrategy<number, number>;
142
+ 3: (item: MaterialItem) => string[];
143
143
  7: (item: MaterialItem, player?: PlayerColor) => string[];
144
144
  6: (item: MaterialItem, player?: PlayerColor) => string[];
145
145
  };
@@ -144,7 +144,7 @@ export class MythologiesRules extends SecretMaterialRules {
144
144
  hidingStrategies = {
145
145
  [MaterialType.EntityCard]: {
146
146
  [LocationType.GodsDeck]: hideFront,
147
- [LocationType.CreaturesDeck]: hideFront,
147
+ [LocationType.CreaturesDeck]: (item) => (item.location.rotation ? [] : ['id.front']),
148
148
  [LocationType.SanctuaryGodSpot]: (item, player) => ((item.location.rotation ?? player) === player ? [] : ['id.front']),
149
149
  [LocationType.SanctuaryCreatureSpot]: (item, player) => ((item.location.rotation ?? player) === player ? [] : ['id.front'])
150
150
  },
@@ -25,10 +25,10 @@ export declare class Pantheon extends MaterialRulesPart {
25
25
  loseFavor(quantity?: number): import("@gamepark/rules-api").DeleteItem<number>;
26
26
  onCardPlaced(move: MoveItem): MaterialMove[];
27
27
  get isSummon(): boolean;
28
- updateGrid(gridAfter?: (number | null)[][]): TriggerEvent[];
28
+ updateGrid(gridAfter?: (number | null)[][], ...additionalEvents: TriggerEvent[]): void;
29
29
  private getEntitiesMoved;
30
30
  private getEntitiesCrushed;
31
- triggerBonusGains(grid?: (number | null)[][], gridBefore?: (number | null)[][] | null): void;
31
+ triggerBonusGains(grid?: (number | null)[][]): void;
32
32
  gainLineBonus(y: number): MoveItem<number, number, number>[];
33
33
  gainColumnBonus(x: number): MoveItem<number, number, number>[];
34
34
  getBonusGem(y: number): Material<number, number, number>;
@@ -97,25 +97,18 @@ export class Pantheon extends MaterialRulesPart {
97
97
  const grid = this.indexGrid;
98
98
  const crush = grid[move.location.y][move.location.x] !== null;
99
99
  grid[move.location.y][move.location.x] = move.itemIndex;
100
- const triggerEffectsRule = new TriggerEffectsRule(this.game);
101
- triggerEffectsRule.triggerCardEffect(move.itemIndex, location, { type: TriggerEventType.SelfPlaced, crush }, entity);
100
+ new TriggerEffectsRule(this.game).triggerCardEffect(move.itemIndex, location, { type: TriggerEventType.SelfPlaced, crush }, entity);
102
101
  const summoned = this.isSummon;
103
102
  if (summoned) {
104
103
  moves.push(...this.onSummon(move));
105
104
  }
106
- const gridBefore = this.remind(Memory.PlayerGrid, this.player);
107
- const triggerEvents = this.updateGrid(grid);
108
- triggerEvents.push({ type: TriggerEventType.EntityPlaced, cardIndex: move.itemIndex, entity, location, summoned: summoned });
109
- if (triggerEvents.length) {
110
- triggerEffectsRule.triggerEffects(...triggerEvents);
111
- }
112
- this.triggerBonusGains(grid, gridBefore);
105
+ this.updateGrid(grid, { type: TriggerEventType.EntityPlaced, cardIndex: move.itemIndex, entity, location, summoned: summoned });
113
106
  return moves;
114
107
  }
115
108
  get isSummon() {
116
109
  return new MythologiesRules(this.game).delegate().isSummon;
117
110
  }
118
- updateGrid(gridAfter = this.indexGrid) {
111
+ updateGrid(gridAfter = this.indexGrid, ...additionalEvents) {
119
112
  const gridBefore = this.remind(Memory.PlayerGrid, this.player) ?? this.indexGrid;
120
113
  this.memorize(Memory.PlayerGrid, gridAfter, this.player);
121
114
  const triggerEvents = [];
@@ -137,7 +130,11 @@ export class Pantheon extends MaterialRulesPart {
137
130
  triggerEvents.push({ type: TriggerEventType.ColumnEvent, eventType: LineEventType.Completed, player: this.player, x });
138
131
  }
139
132
  }
140
- return triggerEvents;
133
+ triggerEvents.push(...additionalEvents);
134
+ if (triggerEvents.length) {
135
+ new TriggerEffectsRule(this.game).triggerEffects(...triggerEvents);
136
+ }
137
+ this.triggerBonusGains(gridAfter);
141
138
  }
142
139
  getEntitiesMoved(before, after) {
143
140
  const entities = [];
@@ -164,11 +161,13 @@ export class Pantheon extends MaterialRulesPart {
164
161
  }
165
162
  return entities;
166
163
  }
167
- triggerBonusGains(grid = this.indexGrid, gridBefore) {
164
+ triggerBonusGains(grid = this.indexGrid) {
165
+ const pendingEffects = this.remind(Memory.PendingEffects);
166
+ const pendingBonusGains = pendingEffects.filter((e) => e.type === PendingEffectsType.BonusGains && e.player === this.player);
168
167
  const effect = { type: PendingEffectsType.BonusGains, player: this.player, lines: [], columns: [] };
169
168
  const fullLines = range(0, 3).filter((y) => !grid[y].includes(null));
170
169
  for (const y of fullLines) {
171
- if (gridBefore && gridBefore[y].every((item) => item !== null))
170
+ if (pendingBonusGains.some((e) => e.lines.includes(y)))
172
171
  continue;
173
172
  if (this.getBonusGem(y).length) {
174
173
  effect.lines.push(y);
@@ -176,14 +175,14 @@ export class Pantheon extends MaterialRulesPart {
176
175
  }
177
176
  const fullColumns = range(0, 3).filter((x) => grid.every((line) => line[x] !== null));
178
177
  for (const x of fullColumns) {
179
- if (gridBefore && gridBefore.every((line) => line[x] !== null))
178
+ if (pendingBonusGains.some((e) => e.columns.includes(x)))
180
179
  continue;
181
180
  if (this.getBonusFavor(x).length) {
182
181
  effect.columns.push(x);
183
182
  }
184
183
  }
185
184
  if (effect.lines.length || effect.columns.length) {
186
- this.remind(Memory.PendingEffects).unshift(effect);
185
+ pendingEffects.unshift(effect);
187
186
  }
188
187
  }
189
188
  gainLineBonus(y) {
@@ -1,7 +1,6 @@
1
1
  import { isMoveItemType } from '@gamepark/rules-api';
2
2
  import { isEqual } from 'es-toolkit';
3
3
  import { CustomMoveType } from '../../CustomMoveType';
4
- import { TriggerEffectsRule } from '../../rules/effects/TriggerEffectsRule';
5
4
  import { LocationType } from '../LocationType';
6
5
  import { MaterialType } from '../MaterialType';
7
6
  import { Pantheon } from '../Pantheon';
@@ -67,7 +66,6 @@ export class MoveEffectRule extends PlayerEffectRule {
67
66
  return super.onEndEffect();
68
67
  }
69
68
  updateGridAfterMoves() {
70
- const pantheon = new Pantheon(this.game, this.player);
71
- new TriggerEffectsRule(this.game).triggerEffects(...pantheon.updateGrid());
69
+ new Pantheon(this.game, this.player).updateGrid();
72
70
  }
73
71
  }
@@ -20,7 +20,9 @@ export class SimultaneousEffectRule extends SimultaneousRule {
20
20
  playersToActivate.push(player);
21
21
  }
22
22
  }
23
- moves.push(this.startSimultaneousRule(this.ruleId, playersToActivate));
23
+ if (playersToActivate.length) {
24
+ moves.push(this.startSimultaneousRule(this.ruleId, playersToActivate));
25
+ }
24
26
  return moves;
25
27
  }
26
28
  onRuleStart() {
@@ -53,12 +53,8 @@ export class SimultaneousMoveEffectRule extends SimultaneousEffectRule {
53
53
  return super.getMovesAfterPlayersDone();
54
54
  }
55
55
  updatePlayersGrids() {
56
- const events = [];
57
- const triggerEffectsRule = new TriggerEffectsRule(this.game);
58
- for (const player of triggerEffectsRule.getPlayersByEffectPriorityOrder()) {
59
- const pantheon = new Pantheon(this.game, player);
60
- events.push(...pantheon.updateGrid());
56
+ for (const player of new TriggerEffectsRule(this.game).getPlayersByEffectPriorityOrder()) {
57
+ new Pantheon(this.game, player).updateGrid();
61
58
  }
62
- triggerEffectsRule.triggerEffects(...events);
63
59
  }
64
60
  }
@@ -4,7 +4,6 @@ import { LocationType } from '../../material/LocationType';
4
4
  import { Pantheon } from '../../material/Pantheon';
5
5
  import { Memory } from '../../Memory';
6
6
  import { RuleId } from '../RuleId';
7
- import { TriggerEffectsRule } from './TriggerEffectsRule';
8
7
  export class AthenaEffectRule extends PlayerEffectRule {
9
8
  ruleId = RuleId.AthenaEffect;
10
9
  onRuleStart() {
@@ -37,8 +36,7 @@ export class AthenaEffectRule extends PlayerEffectRule {
37
36
  return moves;
38
37
  }
39
38
  onEndEffect() {
40
- const pantheon = new Pantheon(this.game, this.player);
41
- new TriggerEffectsRule(this.game).triggerEffects(...pantheon.updateGrid());
39
+ new Pantheon(this.game, this.player).updateGrid();
42
40
  return super.onEndEffect();
43
41
  }
44
42
  onRuleEnd() {
@@ -4,6 +4,7 @@ import { MoveEffectRule } from '../../material/entity/MoveEffectRule';
4
4
  import { SimultaneousSacrificeEffectRule } from '../../material/entity/SimultaneousSacrificeEffectRule';
5
5
  import { MaterialType } from '../../material/MaterialType';
6
6
  import { Memory } from '../../Memory';
7
+ import { ResolveEffectsRule } from './ResolveEffectsRule';
7
8
  import { RuleId } from '../RuleId';
8
9
  export class CentaurEffectRule extends MoveEffectRule {
9
10
  ruleId = RuleId.CentaurEffect;
@@ -16,7 +17,11 @@ export class CentaurEffectRule extends MoveEffectRule {
16
17
  onEndEffect() {
17
18
  this.memorize(Memory.EntityMoved, true);
18
19
  this.updateGridAfterMoves();
19
- return new CentaurEffectSacrificeRule(this.game).playEffect();
20
+ const moves = new CentaurEffectSacrificeRule(this.game).playEffect();
21
+ if (!moves.length) {
22
+ moves.push(...new ResolveEffectsRule(this.game).onEndEffect());
23
+ }
24
+ return moves;
20
25
  }
21
26
  onCardSacrificed(move) {
22
27
  if (this.remind(Memory.EntityMoved)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamepark/mythologies",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
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": "206c518eab1522346aa611cf57e3333f42aae2a7"
31
+ "gitHead": "446a49e4bc4b4ed6e4e5cfbda5cca97f544101df"
32
32
  }