@gamepark/mythologies 1.0.6 → 1.0.8

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.
@@ -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
  }
@@ -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
  }
@@ -1,4 +1,4 @@
1
- import { range, uniq } from 'es-toolkit';
1
+ import { uniq } from 'es-toolkit';
2
2
  import { entityMythology } from '../../Entity';
3
3
  import { Mythology } from '../../Mythology';
4
4
  import { Pantheon } from '../../Pantheon';
@@ -13,10 +13,8 @@ export const Osiris = {
13
13
  const pantheon = new Pantheon(this.game, this.player);
14
14
  const grid = pantheon.grid;
15
15
  const mythologiesPerLine = grid.map((line) => line.filter((space) => space !== undefined).map(entityMythology));
16
- const otherMythologies = Math.max(...range(0, 3).map((skipY) => {
17
- const mythologies = uniq(mythologiesPerLine.flatMap((mythologies, y) => (y !== skipY ? mythologies : [])));
18
- return mythologies.filter((mythology) => mythology !== Mythology.Egyptian).length;
19
- }));
16
+ const allMythologies = uniq(mythologiesPerLine.flat()).filter((m) => m !== Mythology.Egyptian);
17
+ const otherMythologies = allMythologies.filter((m) => mythologiesPerLine.filter((line) => line.includes(m)).length >= 2).length;
20
18
  return otherMythologies > 0 ? [pantheon.gainFavor(otherMythologies * 2)] : [];
21
19
  }
22
20
  }
@@ -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() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamepark/mythologies",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
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": "7ed053c2f24dabb62f2448977f9ce938defb76bf"
31
32
  }