Skip to content

Shared types

The prompt protocol is built from a small set of reusable structures. Instead of redefining them on every prompt page, they’re collected here — each prompt’s arguments link back to the entries it uses.

Every block below is generated from the same source as the engine bindings (ts-rs for TypeScript, the manabrew-protocol crate for Rust), so it can’t drift from what’s actually on the wire.

The title/description header most modal prompts open with.

interface PromptPresentation {
title: string;
description?: string;
text?: string;
sourceCardId?: string;
targets: Array<TargetRef>;
}

References: TargetRef

A typed reference to a player, card, or spell. The kind tag tells the client which id space id belongs to.

type TargetRef =
| { kind: "player"; id: string }
| { kind: "card"; id: string }
| { kind: "spell"; id: string };

The zones a scry-style prompt can sort cards into.

type ScryDestination =
| "libraryTop"
| "libraryBottom"
| "graveyard"
| "exile"
| "hand";

One player’s dice result.

interface DiceRollEntry {
label?: string;
playerId?: string;
naturalResults: Array<number>;
finalResults: Array<number>;
ignoredRolls: Array<number>;
highlighted: boolean;
}

One legal action offered by chooseAction: cast a spell, activate an ability, or undo a mana activation.

type AvailableAction = { id: string } & (
| { type: "cast"; cardId: string; mode: string; modeLabel: string }
| ({ type: "activateAbility" } & ActivatableAbilityInfo)
| { type: "undoMana"; cardId: string }
| { type: "delve"; cardId: string }
| { type: "undelve"; cardId: string }
);

References: ActivatableAbilityInfo

A mana ability the player can activate while paying a cost (payManaCost).

interface ActivatableAbilityInfo {
cardId: string;
abilityIndex: number;
description: string;
isManaAbility: boolean;
cost?: string;
producedMana?: Array<Mana>;
}

References: Mana

A creature that can attack, with the set of targets it may attack (chooseAttackers).

interface AttackerOptionDto {
attackerId: string;
validTargetIds: Array<string>;
}

Something an attacker can be declared against — a player, planeswalker, or battle.

interface AttackTargetDto {
id: string;
label: string;
kind: AttackTargetKind;
}

References: AttackTargetKind

Which kind of thing an AttackTargetDto is.

type AttackTargetKind = "player" | "planeswalker" | "battle";

An incoming attacker and how it may be blocked (chooseBlockers).

interface BlockableAttackerDto {
attackerId: string;
validBlockerIds: Array<string>;
minBlockers: number;
maxBlockers?: number;
mustBeBlocked: boolean;
}