@gamepark/skyrift 0.4.0 → 0.4.2

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.
@@ -27,7 +27,7 @@ import { StartPlayerTurnRule } from './rules/StartPlayerTurnRule';
27
27
  import { StartRoundRule } from './rules/StartRoundRule';
28
28
  import { StashPowerTokensEffectRule } from './rules/StashPowerTokensEffectRule';
29
29
  import { StealCrystalEffectRule } from './rules/StealCrystalEffectRule';
30
- import { StunCardRule } from './rules/StunCardRule';
30
+ import { StunEffectRule } from './rules/StunEffectRule';
31
31
  export declare class SkyriftRules extends SecretMaterialRules<Deck, MaterialType, LocationType> implements TimeLimit<MaterialGame<Deck, MaterialType, LocationType>, MaterialMove<Deck, MaterialType, LocationType>, Deck> {
32
32
  rules: {
33
33
  1: typeof StartRoundRule;
@@ -41,7 +41,7 @@ export declare class SkyriftRules extends SecretMaterialRules<Deck, MaterialType
41
41
  22: typeof DrawEffectRule;
42
42
  23: typeof DiscardEffectRule;
43
43
  24: typeof DestroyEffectRule;
44
- 25: typeof StunCardRule;
44
+ 25: typeof StunEffectRule;
45
45
  26: typeof ReturnCardEffectRule;
46
46
  27: typeof PutPowerTokenEffectRule;
47
47
  28: typeof StashPowerTokensEffectRule;
@@ -30,7 +30,7 @@ import { StartPlayerTurnRule } from './rules/StartPlayerTurnRule';
30
30
  import { StartRoundRule } from './rules/StartRoundRule';
31
31
  import { StashPowerTokensEffectRule } from './rules/StashPowerTokensEffectRule';
32
32
  import { StealCrystalEffectRule } from './rules/StealCrystalEffectRule';
33
- import { StunCardRule } from './rules/StunCardRule';
33
+ import { StunEffectRule } from './rules/StunEffectRule';
34
34
  export class SkyriftRules extends SecretMaterialRules {
35
35
  rules = {
36
36
  [RuleId.StartRound]: StartRoundRule,
@@ -44,7 +44,7 @@ export class SkyriftRules extends SecretMaterialRules {
44
44
  [RuleId.DrawEffect]: DrawEffectRule,
45
45
  [RuleId.DiscardEffect]: DiscardEffectRule,
46
46
  [RuleId.DestroyEffect]: DestroyEffectRule,
47
- [RuleId.StunEffect]: StunCardRule,
47
+ [RuleId.StunEffect]: StunEffectRule,
48
48
  [RuleId.ReturnCardEffect]: ReturnCardEffectRule,
49
49
  [RuleId.PutPowerTokensEffect]: PutPowerTokenEffectRule,
50
50
  [RuleId.StashPowerTokensEffect]: StashPowerTokensEffectRule,
@@ -14,7 +14,7 @@ class CallOfTheEclipseRule extends CardRule {
14
14
  return this.material(MaterialType.Card)
15
15
  .location(LocationType.PlayerHand)
16
16
  .player(this.player)
17
- .id((id) => cardProperties[id.front].suit === CardSuit.Night);
17
+ .id((id) => id.front !== undefined && cardProperties[id.front].suit === CardSuit.Night);
18
18
  }
19
19
  isPlayCardOptional() {
20
20
  return true;
@@ -1,13 +1,9 @@
1
- import { Material } from '@gamepark/rules-api';
2
1
  import { CardRule } from '../../CardRule';
3
2
  import { CardSuit } from '../../CardSuit';
4
3
  import { CardType } from '../../CardType';
5
- import { DestroyEffect } from '../../EffectTraits';
6
- declare class DoomRule extends CardRule implements DestroyEffect {
4
+ declare class DoomRule extends CardRule {
7
5
  onEnters(): void;
8
6
  onLeaves(): import("@gamepark/rules-api").MaterialMove[];
9
- getDestroyTargets(): Material;
10
- isAutoDestroy(): boolean;
11
7
  }
12
8
  export declare const Doom: {
13
9
  power: number;
@@ -10,15 +10,9 @@ class DoomRule extends CardRule {
10
10
  this.addPendingEffect(RuleId.DoomEffect);
11
11
  }
12
12
  onLeaves() {
13
- this.addPendingEffect(RuleId.DestroyEffect);
14
- return super.onLeaves();
15
- }
16
- getDestroyTargets() {
17
13
  const doomTokens = this.material(MaterialType.SpecialToken).id(SpecialTokenType.Doom).location(LocationType.CardSpecialTokens);
18
- return this.playArea.index((index) => doomTokens.parent(index).length > 0);
19
- }
20
- isAutoDestroy() {
21
- return true;
14
+ const doomedIndexes = doomTokens.getItems().map((item) => item.location.parent);
15
+ return [...this.playArea.index(doomedIndexes).moveItems((item) => ({ type: LocationType.PlayerDiscard, player: item.id.back })), ...super.onLeaves()];
22
16
  }
23
17
  }
24
18
  export const Doom = {
@@ -2,6 +2,7 @@ import { CustomMove } from '@gamepark/rules-api';
2
2
  import { DiscardEffectRule } from '../../../rules/DiscardEffectRule';
3
3
  export declare class ArmadaEffectRule extends DiscardEffectRule {
4
4
  getPlayerMoves(): import("@gamepark/rules-api").MaterialMove[];
5
+ onRuleStart(): never[];
5
6
  onDiscard(): never[];
6
7
  onCustomMove(move: CustomMove): import("@gamepark/rules-api").MaterialMove[];
7
8
  }
@@ -7,6 +7,10 @@ export class ArmadaEffectRule extends DiscardEffectRule {
7
7
  moves.push(this.customMove(CustomMoveType.Pass));
8
8
  return moves;
9
9
  }
10
+ onRuleStart() {
11
+ this.memorize(Memory.EffectCount, 0);
12
+ return [];
13
+ }
10
14
  onDiscard() {
11
15
  this.memorize(Memory.EffectCount, (count) => count + 1);
12
16
  return [];
@@ -8,14 +8,15 @@ export class DiscardEffectRule extends EffectRule {
8
8
  return this.cardRule.getDiscardCount?.() ?? 1;
9
9
  }
10
10
  onRuleStart() {
11
- this.memorize(Memory.EffectCount, 0);
12
11
  const targets = this.getTargets();
13
12
  if (!targets.length) {
14
13
  return this.endEffect();
15
14
  }
16
15
  if (this.cardRule.isAutoDiscard?.()) {
16
+ this.memorize(Memory.EffectCount, targets.length);
17
17
  return targets.moveItems((item) => ({ type: LocationType.PlayerDiscard, player: item.location.player }));
18
18
  }
19
+ this.memorize(Memory.EffectCount, this.discardCount);
19
20
  return [];
20
21
  }
21
22
  getTargets() {
@@ -34,8 +35,8 @@ export class DiscardEffectRule extends EffectRule {
34
35
  return [];
35
36
  }
36
37
  onDiscard(_move) {
37
- const count = this.memorize(Memory.EffectCount, (count) => count + 1);
38
- if (count >= this.discardCount) {
38
+ const remaining = this.memorize(Memory.EffectCount, (c) => c - 1);
39
+ if (remaining <= 0) {
39
40
  return this.endEffect();
40
41
  }
41
42
  return [];
@@ -0,0 +1,11 @@
1
+ import { ItemMove, Material, MaterialMove } from '@gamepark/rules-api';
2
+ import { StunEffect } from '../material/EffectTraits';
3
+ import { EffectRule } from './EffectRule';
4
+ export declare class StunEffectRule extends EffectRule<StunEffect> {
5
+ onRuleStart(): MaterialMove[];
6
+ getPlayerMoves(): MaterialMove[];
7
+ stunTargets(): MaterialMove[];
8
+ getTargets(): Material;
9
+ afterItemMove(move: ItemMove): MaterialMove[];
10
+ onRuleEnd(): never[];
11
+ }
@@ -0,0 +1,45 @@
1
+ import { isCreateItemType } from '@gamepark/rules-api';
2
+ import { LocationType } from '../material/LocationType';
3
+ import { MaterialType } from '../material/MaterialType';
4
+ import { Memory } from '../Memory';
5
+ import { EffectRule } from './EffectRule';
6
+ export class StunEffectRule extends EffectRule {
7
+ onRuleStart() {
8
+ this.memorize(Memory.EffectCount, []);
9
+ if (!this.getTargets().length) {
10
+ return this.endEffect();
11
+ }
12
+ if (this.cardRule.isAutoStun?.()) {
13
+ return this.stunTargets();
14
+ }
15
+ return [];
16
+ }
17
+ getPlayerMoves() {
18
+ return this.stunTargets();
19
+ }
20
+ stunTargets() {
21
+ const stunCount = this.cardRule.getStunCount?.() ?? 1;
22
+ return this.getTargets().sort((item) => item.location.x).getIndexes().map((creatureIndex) => this.material(MaterialType.StunToken).createItem({
23
+ location: { type: LocationType.CardStunTokens, parent: creatureIndex },
24
+ quantity: stunCount
25
+ }));
26
+ }
27
+ getTargets() {
28
+ const stunned = this.remind(Memory.EffectCount);
29
+ const targets = this.cardRule.getStunTargets?.() ?? this.cardRule.creatures;
30
+ return targets.index((index) => !stunned.includes(index));
31
+ }
32
+ afterItemMove(move) {
33
+ if (isCreateItemType(MaterialType.StunToken)(move) && move.item.location.type === LocationType.CardStunTokens) {
34
+ const stunned = this.memorize(Memory.EffectCount, (s) => [...s, move.item.location.parent]);
35
+ if ((!this.cardRule.isAutoStun?.() && stunned.length >= (this.cardRule.getStunTargetsCount?.() ?? 1)) || !this.getTargets().length) {
36
+ return this.endEffect();
37
+ }
38
+ }
39
+ return [];
40
+ }
41
+ onRuleEnd() {
42
+ this.forget(Memory.EffectCount);
43
+ return [];
44
+ }
45
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamepark/skyrift",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "The rules of SkyRift adapted for Game Park",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -30,5 +30,5 @@
30
30
  "es-toolkit": "^1.43.0",
31
31
  "vitest": "^4.0.15"
32
32
  },
33
- "gitHead": "ec3b43325a7424c3279b61755343aac4845c39bc"
33
+ "gitHead": "0db12bff770ff3816b402b8eb7151a34c32947f7"
34
34
  }