@champions-digital-game/mod-sdk 0.48.0 → 0.49.0

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.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Manual adjustments (`Command adjust`, issue #791): a player corrects the game state by hand from the pause menu,
3
+ * after a bug or a misclick.
4
+ *
5
+ * **Not an RRG rule.** Like `concede`, this is a digital-implementation affordance, so its behavior is our decision,
6
+ * written down here rather than implied. One policy runs through every kind:
7
+ *
8
+ * - **The adjustment itself is not a game event.** It opens no interrupt or response window of its own: placing damage
9
+ * here is not damage dealt (no toughness, retaliate, "after X takes damage"), threat placed or removed here is no
10
+ * scheme or thwart (no crisis, patrol, acceleration, "after threat is placed"), a status card removed here is not
11
+ * announced as discarded, and a form change here has no "when/after you change form" window. A correction should put
12
+ * the table where it should have been, not set off card text a second time.
13
+ * - **Player-action limits and costs are skipped.** The once-per-round form change and its costs, "cannot be healed",
14
+ * "cannot ready", crisis and patrol: they govern what a player may *do*, and this is a repair, not a play.
15
+ * - **The game's standing rules still follow from the new state**, because the engine keeps them as invariants and
16
+ * would apply them anyway: a character at zero hit points is defeated (its When Defeated and its leave-play windows
17
+ * resolve as for any defeat), a side scheme left with no threat is defeated, a main scheme at its target threat is
18
+ * completed, a uses card emptied of its counters is discarded, a vulnerable character given a stun or confuse is
19
+ * discarded, and a card discarded from play goes through `discardFromPlay` (its "when this leaves play" interrupts,
20
+ * its attachments with it; a "cannot leave play" card stays and the refusal is logged, and discarding a permanent
21
+ * card is refused outright). Status card
22
+ * capacity (one of each, steady two, stalwart none), counter limits and sustained damage caps hold too: giving a
23
+ * status card a character cannot hold is refused, and placed damage or counters stop at the cap, as the
24
+ * state checks between frames would otherwise shed them again.
25
+ * - **Drawing is drawing** (`drawCards`): an emptied deck resets with its encounter card, a drawn obligation enters
26
+ * play, and "after this card enters your hand" answers, exactly as a card effect's draw does.
27
+ *
28
+ * Every adjustment logs `manualAdjustment` first, then the ordinary events of what it changed. A refused adjustment is
29
+ * an `EngineError` and changes nothing.
30
+ */
31
+ import type { Command } from "./commands.js";
32
+ import { type Ctx } from "./ctx.js";
33
+ import { type EngineError } from "./errors.js";
34
+ type AdjustCommand = Command & {
35
+ type: "adjust";
36
+ };
37
+ export declare function adjust(ctx: Ctx, command: AdjustCommand): EngineError | null;
38
+ export {};
@@ -394,6 +394,12 @@ export type CampaignGameQuery =
394
394
  {
395
395
  readonly kind: "cardsThatEnteredPlay";
396
396
  readonly query: TargetQuery;
397
+ /**
398
+ * Each card once, however often it entered play: a card that left play and came back is still one physical card.
399
+ * MC10 p. 5's Experimental Weapons are one copy each, and a weapon discarded and revealed again from the reshuffled
400
+ * encounter deck must not be recorded (and carried into the next scenario) twice. Absent: every entry is kept.
401
+ */
402
+ readonly distinct?: true;
397
403
  }
398
404
  /** MC60 p. 13: "Record the title of each unique ally and support that was removed from the game in the campaign log." */
399
405
  | {
@@ -279,6 +279,17 @@ export type Command =
279
279
  | {
280
280
  readonly type: "concede";
281
281
  readonly playerId: PlayerId;
282
+ }
283
+ /**
284
+ * A manual correction of the game state, from the pause menu, after a bug or a misclick (issue #791). **Not an RRG
285
+ * rule**: like `concede`, a digital-implementation affordance, and a command for the same reason, so a `GameLog`
286
+ * replays it (saves, rewind, replays). `playerId` is the seat that made it; `adjustment` says what it does
287
+ * (`Adjustment`, applied by `adjust.ts`, which documents what each kind does and does not set off).
288
+ */
289
+ | {
290
+ readonly type: "adjust";
291
+ readonly playerId: PlayerId;
292
+ readonly adjustment: Adjustment;
282
293
  } | {
283
294
  readonly type: "resolveChoice";
284
295
  readonly playerId: PlayerId;
@@ -286,3 +297,70 @@ export type Command =
286
297
  readonly selectedOptionIds: readonly string[];
287
298
  };
288
299
  export type CommandType = Command["type"];
300
+ /** A status card a manual adjustment gives or removes. */
301
+ export type AdjustableStatus = "stunned" | "confused" | "tough";
302
+ /**
303
+ * What one manual adjustment (`Command adjust`) does. Amounts are whole numbers and never 0: a positive amount places,
304
+ * a negative one removes (never below 0). See `adjust.ts` for which game rules still follow each kind.
305
+ */
306
+ export type Adjustment =
307
+ /** `playerId` draws `count` cards, as drawing normally does (an emptied deck resets, a drawn obligation enters play). */
308
+ {
309
+ readonly kind: "draw";
310
+ readonly playerId: PlayerId;
311
+ readonly count: number;
312
+ }
313
+ /** A card in a player's hand goes to its discard pile. */
314
+ | {
315
+ readonly kind: "discardFromHand";
316
+ readonly instanceId: InstanceId;
317
+ }
318
+ /** A card in play (not an identity, villain or main scheme) is discarded, its attachments with it. */
319
+ | {
320
+ readonly kind: "discardFromPlay";
321
+ readonly instanceId: InstanceId;
322
+ }
323
+ /** Damage placed on (positive) or removed from (negative) a character. */
324
+ | {
325
+ readonly kind: "damage";
326
+ readonly instanceId: InstanceId;
327
+ readonly amount: number;
328
+ }
329
+ /** Threat placed on (positive) or removed from (negative) a main or side scheme. */
330
+ | {
331
+ readonly kind: "threat";
332
+ readonly instanceId: InstanceId;
333
+ readonly amount: number;
334
+ }
335
+ /** Counters of `counterType` placed on (positive) or removed from (negative) a card in play. */
336
+ | {
337
+ readonly kind: "counters";
338
+ readonly instanceId: InstanceId;
339
+ readonly counterType: string;
340
+ readonly amount: number;
341
+ }
342
+ /** One status card given to (`present: true`) or removed from (`present: false`) a character. */
343
+ | {
344
+ readonly kind: "status";
345
+ readonly instanceId: InstanceId;
346
+ readonly status: AdjustableStatus;
347
+ readonly present: boolean;
348
+ } | {
349
+ readonly kind: "exhaust";
350
+ readonly instanceId: InstanceId;
351
+ } | {
352
+ readonly kind: "ready";
353
+ readonly instanceId: InstanceId;
354
+ }
355
+ /**
356
+ * The player's identity turns to its other form, with no once-per-round limit and no form-change cost. `to` as for
357
+ * `Command changeForm`: required for a three-sided identity changing from alter-ego.
358
+ */
359
+ | {
360
+ readonly kind: "changeForm";
361
+ readonly playerId: PlayerId;
362
+ readonly to?: "alterEgo" | {
363
+ readonly heroForm: number;
364
+ };
365
+ };
366
+ export type AdjustmentKind = Adjustment["kind"];
@@ -35,6 +35,14 @@ export declare function changeIdentityForm(ctx: Ctx, playerId: PlayerId, to: "he
35
35
  */
36
36
  export declare function swapIdentity(ctx: Ctx, playerId: PlayerId): boolean;
37
37
  export declare function endGame(ctx: Ctx, outcome: GameOutcome): void;
38
+ /**
39
+ * The rest of RRG 1.8 "Player Elimination" (p. 34) step 5 for a hand `eliminatePlayer` left cards in (an ability still
40
+ * resolving had chosen them; #816): each card still in an eliminated player's hand goes to their discard pile, as the
41
+ * elimination's own sweep would have sent it. Returns true when it moved any. Called by `runFlow` with an empty stack,
42
+ * so the ability that held them, and anything it pushed, has resolved; and by `endGame` before `gameEnded`, since
43
+ * nothing more resolves once the game is over.
44
+ */
45
+ export declare function discardEliminatedHands(ctx: Ctx): boolean;
38
46
  export declare function shuffleZone(ctx: Ctx, zone: ZoneId, ids: readonly InstanceId[]): readonly InstanceId[];
39
47
  /**
40
48
  * Exhausts a card. `sourceInstanceId` is the card whose effect exhausts it (Sonic Boom's "exhaust each character you
@@ -709,6 +717,12 @@ export declare function settlePaidForEffects(ctx: Ctx, frameId: FrameId, effects
709
717
  * May 16, 2024): the attack on event frame `attackFrameId`, whose source is `sourceId`, is being initiated. Every
710
718
  * effect still waiting on the first attack of that card is retimed to `endOfEvent` on it, so it applies to this attack
711
719
  * only and ends as the attack finishes.
720
+ *
721
+ * An effect an earlier attack of the same card already claimed ends here instead: a second attack of that card is not
722
+ * "that attack". The earlier attack's frame can still be on the stack, waiting beneath its "(attack)" ability until the
723
+ * whole ability has resolved (`waitBeneathAbility`, owner ruling Q47), as when Berserker Barrage repeats its ability
724
+ * (FFG ruling, Wolverine, rrg-1-0-to-1-4/54-wolverine.md: "if you repeat its ability, the new attack will not have
725
+ * piercing"; #811). Ended, not retimed back: the earlier attack was made, so a later cancel cannot hand it on.
712
726
  */
713
727
  export declare function startFirstAttackEffects(ctx: Ctx, sourceId: InstanceId, attackFrameId: FrameId): void;
714
728
  /** "That attack" on a resource ability: the paid-for card's `playCard` frame, or the ability's effects frame, finished. */
@@ -3,7 +3,7 @@ import type { CampaignCardFace, CampaignWindow, LogWrite } from "./campaign.js";
3
3
  import type { RulesCardType } from "./card-types.js";
4
4
  import type { ChoiceId, EncounterDeckId, FrameId, GameAreaId, InstanceId, PlayerId } from "./ids.js";
5
5
  import type { CardPosition, ChoiceBehalf, PendingChoice, UnavailableOptions } from "./choices.js";
6
- import type { DelegableCostPart } from "./commands.js";
6
+ import type { Adjustment, DelegableCostPart } from "./commands.js";
7
7
  import type { GroupId } from "./ids.js";
8
8
  import type { SharedEvent, SharedPodState, SharedResult } from "./pod.js";
9
9
  import type { AccusationGuess, FacedownRole, Form, GameOutcome, GameStep, MainSchemeAdvancedBy, ZoneId } from "./state.js";
@@ -358,6 +358,8 @@ export type GameEvent = {
358
358
  * to its owner when it moves to a card no other player controls (RRG 1.8 "Ownership and Control", p. 31).
359
359
  */
360
360
  readonly reason: "firstPlayer" | "effect" | "attachedTo";
361
+ /** The host the upgrade was attached to when this was logged (reason `attachedTo`; absent in older logs). */
362
+ readonly hostInstanceId?: InstanceId;
361
363
  }
362
364
  /** A player became a card's owner by taking it (RRG 1.8 "Ownership and Control", p. 31; docs/phase7-wave2.md §3.10). */
363
365
  | {
@@ -1028,6 +1030,11 @@ export type GameEvent = {
1028
1030
  readonly instanceId: InstanceId;
1029
1031
  readonly status: "stunned" | "confused" | "tough";
1030
1032
  readonly reason: StatusDiscardCause;
1033
+ /**
1034
+ * Which activity a `cancelledSchemeOrThwart` removal cancelled, read from the character's role when it happened
1035
+ * (an ally treated as a minion schemes, so it cancels a scheme). Absent in older logs.
1036
+ */
1037
+ readonly cancelled?: "thwart" | "scheme";
1031
1038
  } | {
1032
1039
  readonly type: "threatPlaced";
1033
1040
  readonly schemeInstanceId: InstanceId;
@@ -2668,6 +2675,16 @@ export type GameEvent = {
2668
2675
  readonly type: "campaignCardRemoved";
2669
2676
  readonly instanceId: InstanceId;
2670
2677
  readonly card: CampaignCardFace;
2678
+ }
2679
+ /**
2680
+ * A manual adjustment began (`Command adjust`, issue #791): `playerId` corrected the game state by hand. Logged first,
2681
+ * so the events that follow (a `damagePlaced`, a `cardDiscarded`, a defeat) read as its result. Not a game event:
2682
+ * nothing in the rules answers it.
2683
+ */
2684
+ | {
2685
+ readonly type: "manualAdjustment";
2686
+ readonly playerId: PlayerId;
2687
+ readonly adjustment: Adjustment;
2671
2688
  } | {
2672
2689
  readonly type: "gameEnded";
2673
2690
  readonly outcome: GameOutcome;
@@ -1,4 +1,4 @@
1
- export declare const ENGINE_VERSION = "0.48.0";
1
+ export declare const ENGINE_VERSION = "0.49.0";
2
2
  export type { PlayerId, InstanceId, ChoiceId, EncounterDeckId, FrameId, GroupId, TeamId } from "./ids.js";
3
3
  export { playerId, instanceId, choiceId, encounterDeckId, frameId, groupId, teamId } from "./ids.js";
4
4
  export type { GroupRef, PodNeutralArea, PodNeutralSetup, PodSetup, PodState, SharedEvent, SharedPodState, SharedResult, SharedThreatCause, } from "./pod.js";
@@ -26,7 +26,7 @@ export type { PlayCost, PlayCostContribution } from "./actions.js";
26
26
  export { PAID_FOR_SLOT, additionalPlayCostOf, basicPowerCost, basicPowerDivisionTotal, costAsDetermined, handDiscardCandidates, inPlayCostCandidates, minimumChosenX, playCostOf, playCostWith, playableOutsideHand, } from "./actions.js";
27
27
  export { encounterSearchCostCandidates } from "./encounter-search-cost.js";
28
28
  export { asIfInHandPermissions, asIfInHandPlayOf, deckTopPermission, deckTopPlayOf, type AsIfInHandPermission, type DeckTopPermission, } from "./actions.js";
29
- export type { Command, CommandType, Payment, ResourceAbilityUse, SpentCardAbilityUse } from "./commands.js";
29
+ export type { AdjustableStatus, Adjustment, AdjustmentKind, Command, CommandType, Payment, ResourceAbilityUse, SpentCardAbilityUse, } from "./commands.js";
30
30
  export type { GameEvent, GameEventType } from "./events.js";
31
31
  export type { EngineError, EngineErrorCode, IllegalDeck } from "./errors.js";
32
32
  /** Deck legality (RRG 1.8 Appendix I) and playability in this build: two separate questions. */
@@ -39,7 +39,7 @@ export { addPools, combineRequirements, countUsableAs, declaredPool, EMPTY_POOL,
39
39
  export type { AttachmentBound, LastingDuration, LastingEffect, LastingEffectBody, LastingReach, LastingScope, } from "./lasting.js";
40
40
  export { allyLimitFor, cannotEnterPlay, enterPlayBarMessage, cannotFlip, cannotLeavePlay, cardAbilitiesCannotRemove, resourceIconsInPlay, canDivideBasicPower, cannotBeDealtDamage, cannotTakeDamage, evenlyDividesBasicPower, playDestinationsOf, countSchemeIcons, damageTakenAfterConstants, damageTakenAllowance, damageTakenBeforeSustainedCap, damageTakenBreakdown, damageSourceCard, phaseDamageAllowance, maxSustainedDamageOf, sustainedDamageAllowance, excessDamageBonus, formChangeCostsFor, grantedIcons, grantedLabeledAbilities, iconsBlankedOn, iconsInPlay, iconsOn, losesIcon, mayThwartWithAtk, mustDefendWithAlly, nonSchemeIcons, notDefeatedWithoutThreat, playerSideSchemeLimit, restrictedLimitFor, restrictedStanding, schemeThreatDestination, threatCannotBeRemoved, } from "./rules.js";
41
41
  export type { ConsequentialDamage, DamageSourceInfo, FormChangeCost, GrantedAbility } from "./rules.js";
42
- export { hasKeyword, isPermanent, keywordsOf, keywordTotal, printedFormTypes, printedKeywordsOf, statusActive, } from "./keywords.js";
42
+ export { hasKeyword, heldStatusCapacity, isPermanent, keywordsOf, keywordTotal, printedFormTypes, printedKeywordsOf, statusActive, } from "./keywords.js";
43
43
  export { linkedKeywordNames, linkedKeywordsOf } from "./linked.js";
44
44
  export { counterRoom } from "./counter-limit.js";
45
45
  export { tuckLimitOf, tuckRoom } from "./tuck-limit.js";
@@ -587,7 +587,11 @@ export declare function waitBeneathAbility(ctx: Ctx, frame: AttackFrame): void;
587
587
  * resolves on from the frame as it is on the stack after this.
588
588
  */
589
589
  export declare function pushAttackedByAbility(ctx: Ctx, frame: Frame<"event">): boolean;
590
- /** The attack of `frame`'s "(attack)" ability that is waiting for it: the one made last, when there are several. */
590
+ /**
591
+ * The attack of `frame`'s "(attack)" ability that is waiting for it: the one made last, when there are several. Not one
592
+ * its player's elimination ended (`attackerEliminated`, `eliminated-attack.ts`): damage the rest of the ability deals is
593
+ * no longer that attack's.
594
+ */
591
595
  export declare function waitingAbilityAttack(state: GameState, deps: EngineDeps, frame: Frame<"effects">): AttackFrame | undefined;
592
596
  /**
593
597
  * What makes a `dealDamage` event of the waiting attack's ability that attack's damage to the enemy `targetId`
@@ -0,0 +1,32 @@
1
+ /**
2
+ * RRG 1.8 "Player Elimination" (p. 34): "If a player is eliminated in the middle of an attack, that attack ends." An
3
+ * attack of the eliminated identity on the stack at the elimination is marked (`Frame<"event">.attackerEliminated`,
4
+ * `eliminatePlayer` in `defeat.ts`), and the mark ends it wherever it stands:
5
+ *
6
+ * - **Before its damage step**: `applyPlayerAttack` deals nothing (`resolve/event.ts`).
7
+ * - **At its response step**, reached from its own apply step or, for an "(attack)" ability's attack waiting beneath the
8
+ * ability (`attack-ability.ts`), once the ability has finished: `endEliminatedAttack`. The attack is logged as ended
9
+ * (`playerAttackEnded`) and none of its remaining results resolve: no `characterAttacked` for the enemies a waiting
10
+ * attack attacked (so no retaliate), no "resolved" line and no response window for the attack itself ("after … attacks
11
+ * [and defeats]"). Damage it had already dealt stays dealt, so the conditions of that damage handed to the attack's
12
+ * window (`joinedResponses`, "after … takes damage") still open; its "at the end of this attack" effects still
13
+ * resolve, as for an attack that ended early (RRG 1.8 "Delayed Effect", p. 16).
14
+ * - **A `characterAttacked` of the attack not yet applied** (`partOfEliminatedAttack`): a basic attack pushes it with
15
+ * its damage, and an elimination while that damage resolves leaves it on the stack. It is taken off unapplied.
16
+ *
17
+ * A new attack begun after the elimination is not marked and resolves (owner call, #816; `attackOfEliminatedResolves`).
18
+ * A mark set during the attack's own response window (the attack has already resolved; its step 8 responses are being
19
+ * used) changes nothing.
20
+ */
21
+ import { type Ctx } from "../ctx.js";
22
+ import type { Frame } from "./frames.js";
23
+ import type { GameState } from "../state.js";
24
+ /** An attack frame its player's elimination ended (`attackerEliminated`). */
25
+ export declare function endedByElimination(frame: Frame<"event">): boolean;
26
+ /**
27
+ * Ends an attack frame at its response step (see the file header). Leaves it at `done`, holding only the damage
28
+ * conditions it was handed, so the `done` stage opens their window, runs its end-of-attack effects and pops it.
29
+ */
30
+ export declare function endEliminatedAttack(ctx: Ctx, frame: Frame<"event">): void;
31
+ /** A `characterAttacked` waiting to join the window of an attack its player's elimination ended. */
32
+ export declare function partOfEliminatedAttack(state: GameState, frame: Frame<"event">): boolean;
@@ -430,6 +430,13 @@ export type StackFrame =
430
430
  * finishes: no instruction made it, so it attacked only the enemies the ability's damage instructions named.
431
431
  */
432
432
  readonly attackBegun?: true;
433
+ /**
434
+ * On a player's `attack` event: its attacker's player was eliminated while this attack was underway (on the stack),
435
+ * so it ends (RRG 1.8 "Player Elimination", p. 34: "If a player is eliminated in the middle of an attack, that
436
+ * attack ends"; `eliminatePlayer`). An attack its identity begins after that, as the rest of an ability that is
437
+ * resolved in full, is not marked and resolves (owner call, #816; `applyPlayerAttack`).
438
+ */
439
+ readonly attackerEliminated?: true;
433
440
  /**
434
441
  * On an attack whose damage is all prevented (`modifyAttack.preventAllDamage` with a `bind`,
435
442
  * docs/phase7-wave9.md §3.4): where each instance the prevention stops is recorded, as this frame's vars
@@ -543,6 +550,13 @@ export type StackFrame =
543
550
  * `pending` are offered again, and the tier ends with a round in which nobody picks.
544
551
  */
545
552
  readonly pickedThisRound?: true;
553
+ /**
554
+ * The cards this window has played as events from a hand (or as if from a hand), by instance, in play order.
555
+ * Each play moved the card out of the hand, so one found in a hand again when the picked abilities have resolved
556
+ * came back (Morphogenetics returning the event it answered) and is a fresh copy: it is offered again for the
557
+ * same occurrence (`returnedToHandCandidates`). Absent until the window plays one.
558
+ */
559
+ readonly eventsPlayed?: readonly InstanceId[];
546
560
  /**
547
561
  * Interrupt windows only: the optional abilities that were live as the window opened and listen for this kind
548
562
  * of event (`hearersOf`), by key, whether or not their whole condition was met then. One of them whose
@@ -175,6 +175,14 @@ export type TriggerEventBody = {
175
175
  * this attack" budget (all about the attacked character) do not apply to it.
176
176
  */
177
177
  readonly notAttacked?: true;
178
+ /**
179
+ * The card whose effect redirected that damage (`notAttacked`; Psychic Misdirection), when it is a card of a player
180
+ * (`modifyAttack.damageTo` records it, enemy-activation.ts). The damage keeps the attacker as its source, but a
181
+ * defeat it causes is the redirecting card's: its `characterDefeated.sourceInstanceId` and defeating player are
182
+ * that card and its controller, so "after you defeat an enemy" hears it (FFG ruling January 24, 2025: Psychic
183
+ * Misdirection is an extension of your identity, so your identity defeated the enemy).
184
+ */
185
+ readonly redirectedBy?: InstanceId;
178
186
  /**
179
187
  * A share of an attack's damage dealt to a character that is not the attacked character: indirect damage assigned
180
188
  * to another character (RRG 1.8 "Indirect Damage", p. 24: "Only the defending character, or the attacked player's