@manabrew/protocol 0.0.1 → 1.0.1
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.
- package/README.md +27 -0
- package/dist/deck/index.d.ts +84 -0
- package/dist/deck/index.js +2 -0
- package/dist/display/index.d.ts +12 -0
- package/dist/display/index.js +3 -0
- package/dist/game/index.d.ts +136 -0
- package/dist/game/index.js +2 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +20 -0
- package/dist/lobby/index.d.ts +43 -0
- package/dist/lobby/index.js +2 -0
- package/dist/prompts/chooseAction.d.ts +20 -0
- package/dist/prompts/chooseAction.js +2 -0
- package/dist/prompts/chooseAttackers.d.ts +15 -0
- package/dist/prompts/chooseAttackers.js +2 -0
- package/dist/prompts/chooseBlockers.d.ts +17 -0
- package/dist/prompts/chooseBlockers.js +2 -0
- package/dist/prompts/chooseBoardTargets.d.ts +16 -0
- package/dist/prompts/chooseBoardTargets.js +2 -0
- package/dist/prompts/chooseBoolean.d.ts +10 -0
- package/dist/prompts/chooseBoolean.js +2 -0
- package/dist/prompts/chooseCards.d.ts +12 -0
- package/dist/prompts/chooseCards.js +2 -0
- package/dist/prompts/chooseColor.d.ts +13 -0
- package/dist/prompts/chooseColor.js +2 -0
- package/dist/prompts/chooseCombatDamageAssignment.d.ts +12 -0
- package/dist/prompts/chooseCombatDamageAssignment.js +2 -0
- package/dist/prompts/chooseDamageAssignmentOrder.d.ts +10 -0
- package/dist/prompts/chooseDamageAssignmentOrder.js +2 -0
- package/dist/prompts/chooseFromSelection.d.ts +16 -0
- package/dist/prompts/chooseFromSelection.js +2 -0
- package/dist/prompts/chooseNumber.d.ts +10 -0
- package/dist/prompts/chooseNumber.js +2 -0
- package/dist/prompts/common.d.ts +98 -0
- package/dist/prompts/common.js +2 -0
- package/dist/prompts/diceRolled.d.ts +18 -0
- package/dist/prompts/diceRolled.js +2 -0
- package/dist/prompts/gameOver.d.ts +1 -0
- package/dist/prompts/gameOver.js +3 -0
- package/dist/prompts/index.d.ts +24 -0
- package/dist/prompts/index.js +39 -0
- package/dist/prompts/mulligan.d.ts +8 -0
- package/dist/prompts/mulligan.js +3 -0
- package/dist/prompts/mulliganPutBack.d.ts +10 -0
- package/dist/prompts/mulliganPutBack.js +2 -0
- package/dist/prompts/payManaCost.d.ts +19 -0
- package/dist/prompts/payManaCost.js +2 -0
- package/dist/prompts/promptInput.d.ts +58 -0
- package/dist/prompts/promptInput.js +2 -0
- package/dist/prompts/promptOutput.d.ts +73 -0
- package/dist/prompts/promptOutput.js +2 -0
- package/dist/prompts/reorder.d.ts +15 -0
- package/dist/prompts/reorder.js +2 -0
- package/dist/prompts/reveal.d.ts +12 -0
- package/dist/prompts/reveal.js +2 -0
- package/dist/prompts/scry.d.ts +12 -0
- package/dist/prompts/scry.js +2 -0
- package/dist/transport/envelope.d.ts +16 -0
- package/dist/transport/envelope.js +2 -0
- package/dist/transport/index.d.ts +2 -0
- package/dist/transport/index.js +19 -0
- package/dist/transport/messages.d.ts +29 -0
- package/dist/transport/messages.js +2 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +6 -0
- package/package.json +32 -3
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @manabrew/protocol
|
|
2
|
+
|
|
3
|
+
TypeScript types for the [Manabrew](https://manabrew.app) wire protocol — the
|
|
4
|
+
engine↔client message contract used by the Manabrew Magic: The Gathering client.
|
|
5
|
+
|
|
6
|
+
The types are generated from the Rust source of truth
|
|
7
|
+
([`manabrew-protocol`](https://crates.io/crates/manabrew-protocol)) and published
|
|
8
|
+
in lockstep with it, so both sides of the wire always agree.
|
|
9
|
+
|
|
10
|
+
- Protocol reference: <https://docs.manabrew.app/protocol/>
|
|
11
|
+
- Repository: <https://github.com/witchesofthehill/manabrew>
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @manabrew/protocol
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import type { Prompt, PromptInput, PromptOutput } from "@manabrew/protocol";
|
|
23
|
+
import { VERSION, PROTOCOL_VERSION } from "@manabrew/protocol";
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`VERSION` is the package version; `PROTOCOL_VERSION` is the integer wire version
|
|
27
|
+
a client must match to interoperate.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { PlaymatSettings } from "../game/index";
|
|
2
|
+
export type CardBackFaceSummary = {
|
|
3
|
+
name: string;
|
|
4
|
+
manaCost: string;
|
|
5
|
+
typeLine: string;
|
|
6
|
+
oracleText: string;
|
|
7
|
+
uris: CardImageUris;
|
|
8
|
+
};
|
|
9
|
+
export type CardImageUris = {
|
|
10
|
+
small: string;
|
|
11
|
+
normal: string;
|
|
12
|
+
large: string;
|
|
13
|
+
png: string;
|
|
14
|
+
art_crop: string;
|
|
15
|
+
border_crop: string;
|
|
16
|
+
};
|
|
17
|
+
export type CardPart = {
|
|
18
|
+
name: string;
|
|
19
|
+
component: CardPartComponent;
|
|
20
|
+
};
|
|
21
|
+
export type CardPartComponent = "token" | "combo_piece" | "meld_part" | "meld_result";
|
|
22
|
+
export type Deck = {
|
|
23
|
+
version?: string;
|
|
24
|
+
id?: string;
|
|
25
|
+
name: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
color?: string;
|
|
28
|
+
format?: DeckFormat;
|
|
29
|
+
cards: Array<DeckCard>;
|
|
30
|
+
sideboard: Array<DeckCard>;
|
|
31
|
+
attractions?: Array<DeckCard>;
|
|
32
|
+
contraptions?: Array<DeckCard>;
|
|
33
|
+
schemes?: Array<DeckCard>;
|
|
34
|
+
planes?: Array<DeckCard>;
|
|
35
|
+
commanders?: Array<DeckCard>;
|
|
36
|
+
companion?: DeckCard;
|
|
37
|
+
maybeboard?: Array<DeckCard>;
|
|
38
|
+
draft?: boolean;
|
|
39
|
+
labels?: Array<DeckLabel>;
|
|
40
|
+
coverCardName?: string;
|
|
41
|
+
coverCardFace?: number;
|
|
42
|
+
playmat?: string;
|
|
43
|
+
playmatSettings?: PlaymatSettings;
|
|
44
|
+
stackPositions?: Record<string, {
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
}>;
|
|
48
|
+
tokens?: Array<DeckCard>;
|
|
49
|
+
};
|
|
50
|
+
export type DeckCard = {
|
|
51
|
+
identity: DeckCardIdentity;
|
|
52
|
+
uris: CardImageUris;
|
|
53
|
+
allParts?: Array<CardPart>;
|
|
54
|
+
color: string;
|
|
55
|
+
colorIdentity: Array<string>;
|
|
56
|
+
manaCost: string;
|
|
57
|
+
cmc: number;
|
|
58
|
+
types: Array<string>;
|
|
59
|
+
subtypes: Array<string>;
|
|
60
|
+
supertypes: Array<string>;
|
|
61
|
+
keywords?: Array<string>;
|
|
62
|
+
power?: string;
|
|
63
|
+
toughness?: string;
|
|
64
|
+
text: string;
|
|
65
|
+
layout?: string;
|
|
66
|
+
isDoubleFaced?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Back face of a transform / modal_dfc card, captured at deck import.
|
|
69
|
+
* Absent on single-faced cards and on decks saved before it existed.
|
|
70
|
+
*/
|
|
71
|
+
backFace?: CardBackFaceSummary;
|
|
72
|
+
};
|
|
73
|
+
export type DeckCardIdentity = {
|
|
74
|
+
id: string;
|
|
75
|
+
name: string;
|
|
76
|
+
setCode: string;
|
|
77
|
+
cardNumber: string;
|
|
78
|
+
foil?: boolean;
|
|
79
|
+
};
|
|
80
|
+
export type DeckFormat = "standard" | "pioneer" | "modern" | "legacy" | "vintage" | "pauper" | "commander" | "brawl" | "oathbreaker" | "draft" | "sealed";
|
|
81
|
+
export type DeckLabel = {
|
|
82
|
+
name: string;
|
|
83
|
+
color?: string;
|
|
84
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { TargetRef } from "../prompts/common";
|
|
2
|
+
export type CardDto = {
|
|
3
|
+
id: string;
|
|
4
|
+
identity: CardIdentity;
|
|
5
|
+
color: string;
|
|
6
|
+
manaCost: string;
|
|
7
|
+
cmc: number;
|
|
8
|
+
types: Array<string>;
|
|
9
|
+
subtypes: Array<string>;
|
|
10
|
+
supertypes: Array<string>;
|
|
11
|
+
power: string | null;
|
|
12
|
+
toughness: string | null;
|
|
13
|
+
basePower?: number;
|
|
14
|
+
baseToughness?: number;
|
|
15
|
+
text: string;
|
|
16
|
+
controllerId: string;
|
|
17
|
+
ownerId: string;
|
|
18
|
+
tapped: boolean;
|
|
19
|
+
isCrewed: boolean;
|
|
20
|
+
isAttacking: boolean;
|
|
21
|
+
attackingPlayerId?: string;
|
|
22
|
+
attackTargetId?: string;
|
|
23
|
+
keywords: Array<string>;
|
|
24
|
+
counters: Record<string, number>;
|
|
25
|
+
damage: number;
|
|
26
|
+
summoningSick: boolean;
|
|
27
|
+
isCopy: boolean;
|
|
28
|
+
isDoubleFaced: boolean;
|
|
29
|
+
isTransformed: boolean;
|
|
30
|
+
isFaceDown: boolean;
|
|
31
|
+
isBestowed: boolean;
|
|
32
|
+
phasedOut: boolean;
|
|
33
|
+
exerted: boolean;
|
|
34
|
+
isRingBearer: boolean;
|
|
35
|
+
attachedTo?: string;
|
|
36
|
+
attachmentIds: Array<string>;
|
|
37
|
+
mergedCardIds: Array<string>;
|
|
38
|
+
flashbackCost?: string;
|
|
39
|
+
kickerCost?: string;
|
|
40
|
+
effectiveManaCost?: string;
|
|
41
|
+
madnessCost?: string;
|
|
42
|
+
isMadnessExiled: boolean;
|
|
43
|
+
isPlotted: boolean;
|
|
44
|
+
isWarpExiled: boolean;
|
|
45
|
+
foil: boolean;
|
|
46
|
+
wouldDieInCombat: boolean;
|
|
47
|
+
};
|
|
48
|
+
export type CardIdentity = {
|
|
49
|
+
name: string;
|
|
50
|
+
setCode: string;
|
|
51
|
+
cardNumber: string;
|
|
52
|
+
isToken: boolean;
|
|
53
|
+
};
|
|
54
|
+
export type CardView = {
|
|
55
|
+
"visibility": "visible";
|
|
56
|
+
} & CardDto | {
|
|
57
|
+
"visibility": "hidden";
|
|
58
|
+
id: string;
|
|
59
|
+
};
|
|
60
|
+
export type CombatAssignmentDto = {
|
|
61
|
+
blockerId: string;
|
|
62
|
+
attackerId: string;
|
|
63
|
+
};
|
|
64
|
+
export type DayTime = "neither" | "day" | "night";
|
|
65
|
+
export type GameViewDto = {
|
|
66
|
+
gameId: string;
|
|
67
|
+
turn: number;
|
|
68
|
+
step: StepKind;
|
|
69
|
+
combatAssignments: Array<CombatAssignmentDto>;
|
|
70
|
+
activePlayerId: string;
|
|
71
|
+
priorityPlayerId: string;
|
|
72
|
+
players: Array<PlayerDto>;
|
|
73
|
+
zones: Array<ZoneDto>;
|
|
74
|
+
stack: Array<StackObjectDto>;
|
|
75
|
+
gameOver: boolean;
|
|
76
|
+
winnerId: string | null;
|
|
77
|
+
monarchId: string | null;
|
|
78
|
+
initiativeHolderId: string | null;
|
|
79
|
+
dayTime: DayTime;
|
|
80
|
+
};
|
|
81
|
+
export type Mana = {
|
|
82
|
+
color: ManaColor;
|
|
83
|
+
amount: number;
|
|
84
|
+
};
|
|
85
|
+
export type ManaColor = "W" | "U" | "B" | "R" | "G" | "C";
|
|
86
|
+
export type PlayerCounterKind = "poison" | "energy" | "experience" | "radiation" | "ticket";
|
|
87
|
+
export type PlayerDto = {
|
|
88
|
+
id: string;
|
|
89
|
+
name: string;
|
|
90
|
+
status: PlayerStatus;
|
|
91
|
+
isHuman: boolean;
|
|
92
|
+
life: number;
|
|
93
|
+
counters: {
|
|
94
|
+
[key in PlayerCounterKind]?: number;
|
|
95
|
+
};
|
|
96
|
+
manaPool: {
|
|
97
|
+
[key in ManaColor]?: number;
|
|
98
|
+
};
|
|
99
|
+
commanderDamage: Record<string, number>;
|
|
100
|
+
hasCityBlessing: boolean;
|
|
101
|
+
ringLevel: number;
|
|
102
|
+
speed: number;
|
|
103
|
+
};
|
|
104
|
+
export type PlayerStatus = "playing" | "lost" | "conceded";
|
|
105
|
+
export type PlaymatSettings = {
|
|
106
|
+
opacity?: number;
|
|
107
|
+
texture?: number;
|
|
108
|
+
borderWidth?: number;
|
|
109
|
+
borderColor?: string;
|
|
110
|
+
fit?: string;
|
|
111
|
+
offsetX?: number;
|
|
112
|
+
offsetY?: number;
|
|
113
|
+
zoom?: number;
|
|
114
|
+
blur?: number;
|
|
115
|
+
brightness?: number;
|
|
116
|
+
color?: string;
|
|
117
|
+
};
|
|
118
|
+
export type StackObjectDto = {
|
|
119
|
+
id: string;
|
|
120
|
+
sourceId: string;
|
|
121
|
+
controllerId: string;
|
|
122
|
+
identity: CardIdentity;
|
|
123
|
+
text: string;
|
|
124
|
+
isPermanentSpell: boolean;
|
|
125
|
+
isCasting: boolean;
|
|
126
|
+
targets: Array<TargetRef>;
|
|
127
|
+
};
|
|
128
|
+
export type StepKind = "untap" | "upkeep" | "draw" | "main1" | "combatBegin" | "combatDeclareAttackers" | "combatDeclareBlockers" | "combatFirstStrikeDamage" | "combatDamage" | "combatEnd" | "main2" | "endOfTurn" | "cleanup";
|
|
129
|
+
export type TargetingIntent = "damage" | "destroy" | "sacrifice" | "exile" | "bounce" | "mill" | "discard" | "counter" | "tap" | "untap" | "copy" | "buff" | "debuff" | "heal" | "loseLife" | "reveal" | "draw" | "fetch" | "gainControl" | "fight" | "attach" | "attack" | "block" | "hostile" | "friendly";
|
|
130
|
+
export type ZoneDto = {
|
|
131
|
+
zone: ZoneKind;
|
|
132
|
+
ownerId: string;
|
|
133
|
+
cards: Array<CardView>;
|
|
134
|
+
count: number;
|
|
135
|
+
};
|
|
136
|
+
export type ZoneKind = "battlefield" | "hand" | "library" | "graveyard" | "exile" | "command";
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// AUTO-GENERATED by `cargo run -p manabrew-protocol --bin gen-protocol`. Do not edit.
|
|
18
|
+
__exportStar(require("./prompts"), exports);
|
|
19
|
+
__exportStar(require("./transport"), exports);
|
|
20
|
+
__exportStar(require("./version"), exports);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Deck } from "../deck/index";
|
|
2
|
+
export type DraftConfig = {
|
|
3
|
+
set_code?: string;
|
|
4
|
+
cube_id?: string;
|
|
5
|
+
cube_name?: string;
|
|
6
|
+
rounds: number;
|
|
7
|
+
picks_per_pass: number;
|
|
8
|
+
seed?: number;
|
|
9
|
+
fill_with_bots: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type EngineKind = "Manabrew" | "Forge" | "Ironsmith";
|
|
12
|
+
export type GameFormat = "Any" | "Standard" | "Pioneer" | "Modern" | "Legacy" | "Vintage" | "Pauper" | "Commander" | "Brawl" | "Oathbreaker" | "Draft" | "Sealed";
|
|
13
|
+
export type PlayerDeckInfo = {
|
|
14
|
+
username: string;
|
|
15
|
+
deck_name: string;
|
|
16
|
+
deck: Deck;
|
|
17
|
+
commander_name?: string;
|
|
18
|
+
avatar?: string;
|
|
19
|
+
};
|
|
20
|
+
export type ResumeRoomRequest = {
|
|
21
|
+
room_id: string;
|
|
22
|
+
resume_token: string;
|
|
23
|
+
room_name: string;
|
|
24
|
+
max_players: number;
|
|
25
|
+
format: GameFormat;
|
|
26
|
+
hosted: boolean;
|
|
27
|
+
engine: EngineKind;
|
|
28
|
+
official_key?: string;
|
|
29
|
+
password?: string;
|
|
30
|
+
reconnect_timeout_s?: number;
|
|
31
|
+
draft_config?: DraftConfig;
|
|
32
|
+
sealed_config?: SealedConfig;
|
|
33
|
+
player_order: Array<string>;
|
|
34
|
+
player_decks: Array<PlayerDeckInfo>;
|
|
35
|
+
starting_life: number;
|
|
36
|
+
bot_players: Array<string>;
|
|
37
|
+
game_id: string;
|
|
38
|
+
};
|
|
39
|
+
export type SealedConfig = {
|
|
40
|
+
set_code: string;
|
|
41
|
+
num_boosters: number;
|
|
42
|
+
base_seed?: number;
|
|
43
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AvailableAction } from "./common";
|
|
2
|
+
import type { StepKind } from "../game/index";
|
|
3
|
+
export type ChooseActionInput = {
|
|
4
|
+
actions: Array<AvailableAction>;
|
|
5
|
+
};
|
|
6
|
+
export type ChooseActionOutput = {
|
|
7
|
+
"type": "pass";
|
|
8
|
+
until?: PassUntil;
|
|
9
|
+
exhaustStack: boolean;
|
|
10
|
+
} | {
|
|
11
|
+
"type": "restoreSnapshot";
|
|
12
|
+
checkpointId: number;
|
|
13
|
+
} | {
|
|
14
|
+
"type": "act";
|
|
15
|
+
actionId: string;
|
|
16
|
+
};
|
|
17
|
+
export type PassUntil = {
|
|
18
|
+
playerId: string;
|
|
19
|
+
phase: StepKind;
|
|
20
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AttackAssignment } from "./common";
|
|
2
|
+
import type { AttackTargetDto } from "./common";
|
|
3
|
+
export type AttackerOptionDto = {
|
|
4
|
+
attackerId: string;
|
|
5
|
+
validTargetIds: Array<string>;
|
|
6
|
+
mustAttack: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type ChooseAttackersInput = {
|
|
9
|
+
attackers: Array<AttackerOptionDto>;
|
|
10
|
+
attackTargets: Array<AttackTargetDto>;
|
|
11
|
+
};
|
|
12
|
+
export type ChooseAttackersOutput = {
|
|
13
|
+
"type": "declareAttackers";
|
|
14
|
+
assignments: Array<AttackAssignment>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BlockAssignment } from "./common";
|
|
2
|
+
export type BlockableAttackerDto = {
|
|
3
|
+
attackerId: string;
|
|
4
|
+
validBlockerIds: Array<string>;
|
|
5
|
+
minBlockers: number;
|
|
6
|
+
maxBlockers?: number;
|
|
7
|
+
mustBeBlocked: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type ChooseBlockersInput = {
|
|
10
|
+
attackers: Array<BlockableAttackerDto>;
|
|
11
|
+
availableBlockerIds: Array<string>;
|
|
12
|
+
error?: string;
|
|
13
|
+
};
|
|
14
|
+
export type ChooseBlockersOutput = {
|
|
15
|
+
"type": "declareBlockers";
|
|
16
|
+
assignments: Array<BlockAssignment>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PromptPresentation } from "./common";
|
|
2
|
+
import type { TargetRef } from "./common";
|
|
3
|
+
import type { TargetingIntent } from "../game/index";
|
|
4
|
+
export type ChooseBoardTargetsInput = {
|
|
5
|
+
presentation: PromptPresentation;
|
|
6
|
+
candidates: Array<TargetRef>;
|
|
7
|
+
hostile: boolean;
|
|
8
|
+
intent: TargetingIntent;
|
|
9
|
+
minTargets: number;
|
|
10
|
+
maxTargets: number;
|
|
11
|
+
chosenTargets: number;
|
|
12
|
+
};
|
|
13
|
+
export type ChooseBoardTargetsOutput = {
|
|
14
|
+
"type": "boardTargets";
|
|
15
|
+
chosen: Array<TargetRef>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CardDto } from "../game/index";
|
|
2
|
+
import type { PromptPresentation } from "./common";
|
|
3
|
+
export type ChooseCardsInput = {
|
|
4
|
+
presentation: PromptPresentation;
|
|
5
|
+
cards: Array<CardDto>;
|
|
6
|
+
min: number;
|
|
7
|
+
max: number;
|
|
8
|
+
};
|
|
9
|
+
export type ChooseCardsOutput = {
|
|
10
|
+
"type": "chooseCardsDecision";
|
|
11
|
+
chosenCardIds: Array<string>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PromptPresentation } from "./common";
|
|
2
|
+
export type ChooseColorInput = {
|
|
3
|
+
presentation: PromptPresentation;
|
|
4
|
+
validColors: Array<string>;
|
|
5
|
+
amount: number;
|
|
6
|
+
repeatAllowed: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type ChooseColorOutput = {
|
|
9
|
+
"type": "colorDecision";
|
|
10
|
+
chosenColors: {
|
|
11
|
+
[key in string]?: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CombatDamageAssignmentEntry } from "./common";
|
|
2
|
+
export type ChooseCombatDamageAssignmentInput = {
|
|
3
|
+
attackerId: string;
|
|
4
|
+
blockerIds: Array<string>;
|
|
5
|
+
defenderId?: string;
|
|
6
|
+
totalDamage: number;
|
|
7
|
+
attackerHasDeathtouch: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type ChooseCombatDamageAssignmentOutput = {
|
|
10
|
+
"type": "combatDamageAssignmentDecision";
|
|
11
|
+
assignments: Array<CombatDamageAssignmentEntry>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CardDto } from "../game/index";
|
|
2
|
+
export type ChooseDamageAssignmentOrderInput = {
|
|
3
|
+
attackerId: string;
|
|
4
|
+
blockerIds: Array<string>;
|
|
5
|
+
blockerCards: Array<CardDto>;
|
|
6
|
+
};
|
|
7
|
+
export type ChooseDamageAssignmentOrderOutput = {
|
|
8
|
+
"type": "damageAssignmentOrderDecision";
|
|
9
|
+
orderedBlockerIds: Array<string>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PromptPresentation } from "./common";
|
|
2
|
+
export type ChooseFromSelectionInput = {
|
|
3
|
+
presentation: PromptPresentation;
|
|
4
|
+
options: Array<SelectionOption>;
|
|
5
|
+
minTotal: number;
|
|
6
|
+
maxTotal: number;
|
|
7
|
+
};
|
|
8
|
+
export type ChooseFromSelectionOutput = {
|
|
9
|
+
"type": "selectionDecision";
|
|
10
|
+
chosenIndices: Array<number>;
|
|
11
|
+
};
|
|
12
|
+
export type SelectionOption = {
|
|
13
|
+
label: string;
|
|
14
|
+
weight: number;
|
|
15
|
+
canRepeat: boolean;
|
|
16
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { Mana } from "../game/index";
|
|
2
|
+
import type { TargetingIntent } from "../game/index";
|
|
3
|
+
export type ActivatableAbilityInfo = {
|
|
4
|
+
cardId: string;
|
|
5
|
+
abilityIndex: number;
|
|
6
|
+
description: string;
|
|
7
|
+
isManaAbility: boolean;
|
|
8
|
+
cost?: string;
|
|
9
|
+
producedMana?: Array<Mana>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Mirrors the engine's `AlternativeCost` (itself a mirror of Java's).
|
|
13
|
+
*/
|
|
14
|
+
export type AlternativeCostKind = "flashback" | "spectacle" | "evoke" | "dash" | "blitz" | "escape" | "overload" | "madness" | "foretell" | "emerge" | "suspend" | "morph" | "megamorph" | "bestow" | "warp" | "sacrificeAlt" | "plot" | "awaken" | "disturb" | "harmonize" | "freerunning" | "impending" | "mayhem" | "moreThanMeetsTheEye" | "mutate" | "prowl" | "sneak" | "surge" | "webSlinging" | "plotted";
|
|
15
|
+
export type AttackAssignment = {
|
|
16
|
+
attackerId: string;
|
|
17
|
+
targetId: string;
|
|
18
|
+
};
|
|
19
|
+
export type AttackTargetDto = {
|
|
20
|
+
id: string;
|
|
21
|
+
label: string;
|
|
22
|
+
kind: AttackTargetKind;
|
|
23
|
+
};
|
|
24
|
+
export type AttackTargetKind = "player" | "planeswalker" | "battle";
|
|
25
|
+
export type AvailableAction = {
|
|
26
|
+
id: string;
|
|
27
|
+
} & ({
|
|
28
|
+
"type": "cast";
|
|
29
|
+
cardId: string;
|
|
30
|
+
mode: PlayCardMode;
|
|
31
|
+
label: string;
|
|
32
|
+
} | {
|
|
33
|
+
"type": "activateAbility";
|
|
34
|
+
} & ActivatableAbilityInfo | {
|
|
35
|
+
"type": "undoMana";
|
|
36
|
+
cardId: string;
|
|
37
|
+
});
|
|
38
|
+
export type BlockAssignment = {
|
|
39
|
+
blockerId: string;
|
|
40
|
+
attackerId: string;
|
|
41
|
+
};
|
|
42
|
+
export type CombatDamageAssignmentEntry = {
|
|
43
|
+
assigneeId: string;
|
|
44
|
+
damage: number;
|
|
45
|
+
};
|
|
46
|
+
export type PaymentAction = {
|
|
47
|
+
id: string;
|
|
48
|
+
} & ({
|
|
49
|
+
"type": "activateManaAbility";
|
|
50
|
+
} & ActivatableAbilityInfo | {
|
|
51
|
+
"type": "undoMana";
|
|
52
|
+
cardId: string;
|
|
53
|
+
} | {
|
|
54
|
+
"type": "useResource";
|
|
55
|
+
cardId: string;
|
|
56
|
+
resource: PaymentResourceKind;
|
|
57
|
+
} | {
|
|
58
|
+
"type": "releaseResource";
|
|
59
|
+
cardId: string;
|
|
60
|
+
resource: PaymentResourceKind;
|
|
61
|
+
} | {
|
|
62
|
+
"type": "payLife";
|
|
63
|
+
amount: number;
|
|
64
|
+
});
|
|
65
|
+
export type PaymentResourceKind = "convoke" | "improvise" | "delve";
|
|
66
|
+
/**
|
|
67
|
+
* Mirrors the engine's `PlayCardMode`.
|
|
68
|
+
*/
|
|
69
|
+
export type PlayCardMode = {
|
|
70
|
+
"type": "normal";
|
|
71
|
+
} | {
|
|
72
|
+
"type": "backFaceLand";
|
|
73
|
+
} | {
|
|
74
|
+
"type": "roomRightSplit";
|
|
75
|
+
} | {
|
|
76
|
+
"type": "alternative";
|
|
77
|
+
cost: AlternativeCostKind;
|
|
78
|
+
} | {
|
|
79
|
+
"type": "staticAlternative";
|
|
80
|
+
} | {
|
|
81
|
+
"type": "foretellExile";
|
|
82
|
+
} | {
|
|
83
|
+
"type": "unlockDoor";
|
|
84
|
+
};
|
|
85
|
+
export type PromptPresentation = {
|
|
86
|
+
title: string;
|
|
87
|
+
description?: string;
|
|
88
|
+
text?: string;
|
|
89
|
+
sourceCardId?: string;
|
|
90
|
+
targets: Array<TargetRef>;
|
|
91
|
+
};
|
|
92
|
+
export type TargetKind = "player" | "card" | "spell";
|
|
93
|
+
export type TargetRef = {
|
|
94
|
+
kind: TargetKind;
|
|
95
|
+
id: string;
|
|
96
|
+
intent?: TargetingIntent;
|
|
97
|
+
oracle?: string;
|
|
98
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PromptPresentation } from "./common";
|
|
2
|
+
export type DiceRollEntry = {
|
|
3
|
+
label?: string;
|
|
4
|
+
playerId?: string;
|
|
5
|
+
naturalResults: Array<number>;
|
|
6
|
+
finalResults: Array<number>;
|
|
7
|
+
ignoredRolls: Array<number>;
|
|
8
|
+
highlighted: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type DiceRolledInput = {
|
|
11
|
+
presentation: PromptPresentation;
|
|
12
|
+
sides: number;
|
|
13
|
+
rolls: Array<DiceRollEntry>;
|
|
14
|
+
sourceCardName?: string;
|
|
15
|
+
};
|
|
16
|
+
export type DiceRolledOutput = {
|
|
17
|
+
"type": "diceRolledAcknowledged";
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type GameOverInput = Record<string, never>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from "./chooseAction";
|
|
2
|
+
export * from "./chooseAttackers";
|
|
3
|
+
export * from "./chooseBlockers";
|
|
4
|
+
export * from "./chooseBoardTargets";
|
|
5
|
+
export * from "./chooseBoolean";
|
|
6
|
+
export * from "./chooseCards";
|
|
7
|
+
export * from "./chooseColor";
|
|
8
|
+
export * from "./chooseCombatDamageAssignment";
|
|
9
|
+
export * from "./chooseDamageAssignmentOrder";
|
|
10
|
+
export * from "./chooseFromSelection";
|
|
11
|
+
export * from "./chooseNumber";
|
|
12
|
+
export * from "./common";
|
|
13
|
+
export * from "./diceRolled";
|
|
14
|
+
export * from "./gameOver";
|
|
15
|
+
export * from "./mulligan";
|
|
16
|
+
export * from "./mulliganPutBack";
|
|
17
|
+
export * from "./payManaCost";
|
|
18
|
+
export * from "./promptInput";
|
|
19
|
+
export * from "./promptOutput";
|
|
20
|
+
export * from "./reorder";
|
|
21
|
+
export * from "./reveal";
|
|
22
|
+
export * from "./scry";
|
|
23
|
+
import type { PromptInput } from "./promptInput";
|
|
24
|
+
export type PromptType = PromptInput["type"];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// AUTO-GENERATED by `cargo run -p manabrew-protocol --bin gen-protocol`. Do not edit.
|
|
18
|
+
__exportStar(require("./chooseAction"), exports);
|
|
19
|
+
__exportStar(require("./chooseAttackers"), exports);
|
|
20
|
+
__exportStar(require("./chooseBlockers"), exports);
|
|
21
|
+
__exportStar(require("./chooseBoardTargets"), exports);
|
|
22
|
+
__exportStar(require("./chooseBoolean"), exports);
|
|
23
|
+
__exportStar(require("./chooseCards"), exports);
|
|
24
|
+
__exportStar(require("./chooseColor"), exports);
|
|
25
|
+
__exportStar(require("./chooseCombatDamageAssignment"), exports);
|
|
26
|
+
__exportStar(require("./chooseDamageAssignmentOrder"), exports);
|
|
27
|
+
__exportStar(require("./chooseFromSelection"), exports);
|
|
28
|
+
__exportStar(require("./chooseNumber"), exports);
|
|
29
|
+
__exportStar(require("./common"), exports);
|
|
30
|
+
__exportStar(require("./diceRolled"), exports);
|
|
31
|
+
__exportStar(require("./gameOver"), exports);
|
|
32
|
+
__exportStar(require("./mulligan"), exports);
|
|
33
|
+
__exportStar(require("./mulliganPutBack"), exports);
|
|
34
|
+
__exportStar(require("./payManaCost"), exports);
|
|
35
|
+
__exportStar(require("./promptInput"), exports);
|
|
36
|
+
__exportStar(require("./promptOutput"), exports);
|
|
37
|
+
__exportStar(require("./reorder"), exports);
|
|
38
|
+
__exportStar(require("./reveal"), exports);
|
|
39
|
+
__exportStar(require("./scry"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CardDto } from "../game/index";
|
|
2
|
+
export type MulliganPutBackInput = {
|
|
3
|
+
handCardIds: Array<string>;
|
|
4
|
+
cards: Array<CardDto>;
|
|
5
|
+
count: number;
|
|
6
|
+
};
|
|
7
|
+
export type MulliganPutBackOutput = {
|
|
8
|
+
"type": "mulliganPutBackDecision";
|
|
9
|
+
cardIds: Array<string>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PaymentAction } from "./common";
|
|
2
|
+
import type { PromptPresentation } from "./common";
|
|
3
|
+
export type PayManaCostInput = {
|
|
4
|
+
presentation: PromptPresentation;
|
|
5
|
+
cardId: string;
|
|
6
|
+
cardName: string;
|
|
7
|
+
manaCost: string;
|
|
8
|
+
canConfirmFromPool: boolean;
|
|
9
|
+
actions: Array<PaymentAction>;
|
|
10
|
+
};
|
|
11
|
+
export type PayManaCostOutput = {
|
|
12
|
+
"type": "act";
|
|
13
|
+
actionId: string;
|
|
14
|
+
} | {
|
|
15
|
+
"type": "pay";
|
|
16
|
+
auto: boolean;
|
|
17
|
+
} | {
|
|
18
|
+
"type": "cancel";
|
|
19
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ChooseActionInput } from "./chooseAction";
|
|
2
|
+
import type { ChooseAttackersInput } from "./chooseAttackers";
|
|
3
|
+
import type { ChooseBlockersInput } from "./chooseBlockers";
|
|
4
|
+
import type { ChooseBoardTargetsInput } from "./chooseBoardTargets";
|
|
5
|
+
import type { ChooseBooleanInput } from "./chooseBoolean";
|
|
6
|
+
import type { ChooseCardsInput } from "./chooseCards";
|
|
7
|
+
import type { ChooseColorInput } from "./chooseColor";
|
|
8
|
+
import type { ChooseCombatDamageAssignmentInput } from "./chooseCombatDamageAssignment";
|
|
9
|
+
import type { ChooseDamageAssignmentOrderInput } from "./chooseDamageAssignmentOrder";
|
|
10
|
+
import type { ChooseFromSelectionInput } from "./chooseFromSelection";
|
|
11
|
+
import type { ChooseNumberInput } from "./chooseNumber";
|
|
12
|
+
import type { DiceRolledInput } from "./diceRolled";
|
|
13
|
+
import type { GameOverInput } from "./gameOver";
|
|
14
|
+
import type { MulliganInput } from "./mulligan";
|
|
15
|
+
import type { MulliganPutBackInput } from "./mulliganPutBack";
|
|
16
|
+
import type { PayManaCostInput } from "./payManaCost";
|
|
17
|
+
import type { ReorderInput } from "./reorder";
|
|
18
|
+
import type { RevealCardsInput } from "./reveal";
|
|
19
|
+
import type { ScryInput } from "./scry";
|
|
20
|
+
export type PromptInput = {
|
|
21
|
+
"type": "mulligan";
|
|
22
|
+
} & MulliganInput | {
|
|
23
|
+
"type": "mulliganPutBack";
|
|
24
|
+
} & MulliganPutBackInput | {
|
|
25
|
+
"type": "chooseAction";
|
|
26
|
+
} & ChooseActionInput | {
|
|
27
|
+
"type": "chooseAttackers";
|
|
28
|
+
} & ChooseAttackersInput | {
|
|
29
|
+
"type": "chooseBlockers";
|
|
30
|
+
} & ChooseBlockersInput | {
|
|
31
|
+
"type": "chooseBoardTargets";
|
|
32
|
+
} & ChooseBoardTargetsInput | {
|
|
33
|
+
"type": "chooseBoolean";
|
|
34
|
+
} & ChooseBooleanInput | {
|
|
35
|
+
"type": "chooseFromSelection";
|
|
36
|
+
} & ChooseFromSelectionInput | {
|
|
37
|
+
"type": "gameOver";
|
|
38
|
+
} & GameOverInput | {
|
|
39
|
+
"type": "revealCards";
|
|
40
|
+
} & RevealCardsInput | {
|
|
41
|
+
"type": "scry";
|
|
42
|
+
} & ScryInput | {
|
|
43
|
+
"type": "chooseColor";
|
|
44
|
+
} & ChooseColorInput | {
|
|
45
|
+
"type": "chooseNumber";
|
|
46
|
+
} & ChooseNumberInput | {
|
|
47
|
+
"type": "chooseDamageAssignmentOrder";
|
|
48
|
+
} & ChooseDamageAssignmentOrderInput | {
|
|
49
|
+
"type": "chooseCombatDamageAssignment";
|
|
50
|
+
} & ChooseCombatDamageAssignmentInput | {
|
|
51
|
+
"type": "payManaCost";
|
|
52
|
+
} & PayManaCostInput | {
|
|
53
|
+
"type": "chooseCards";
|
|
54
|
+
} & ChooseCardsInput | {
|
|
55
|
+
"type": "reorder";
|
|
56
|
+
} & ReorderInput | {
|
|
57
|
+
"type": "diceRolled";
|
|
58
|
+
} & DiceRolledInput;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ChooseActionOutput } from "./chooseAction";
|
|
2
|
+
import type { ChooseAttackersOutput } from "./chooseAttackers";
|
|
3
|
+
import type { ChooseBlockersOutput } from "./chooseBlockers";
|
|
4
|
+
import type { ChooseBoardTargetsOutput } from "./chooseBoardTargets";
|
|
5
|
+
import type { ChooseBooleanOutput } from "./chooseBoolean";
|
|
6
|
+
import type { ChooseCardsOutput } from "./chooseCards";
|
|
7
|
+
import type { ChooseColorOutput } from "./chooseColor";
|
|
8
|
+
import type { ChooseCombatDamageAssignmentOutput } from "./chooseCombatDamageAssignment";
|
|
9
|
+
import type { ChooseDamageAssignmentOrderOutput } from "./chooseDamageAssignmentOrder";
|
|
10
|
+
import type { ChooseFromSelectionOutput } from "./chooseFromSelection";
|
|
11
|
+
import type { ChooseNumberOutput } from "./chooseNumber";
|
|
12
|
+
import type { DiceRolledOutput } from "./diceRolled";
|
|
13
|
+
import type { MulliganOutput } from "./mulligan";
|
|
14
|
+
import type { MulliganPutBackOutput } from "./mulliganPutBack";
|
|
15
|
+
import type { PayManaCostOutput } from "./payManaCost";
|
|
16
|
+
import type { ReorderOutput } from "./reorder";
|
|
17
|
+
import type { RevealCardsOutput } from "./reveal";
|
|
18
|
+
import type { ScryOutput } from "./scry";
|
|
19
|
+
export type PromptOutput = {
|
|
20
|
+
"type": "mulligan";
|
|
21
|
+
"output": MulliganOutput;
|
|
22
|
+
} | {
|
|
23
|
+
"type": "mulliganPutBack";
|
|
24
|
+
"output": MulliganPutBackOutput;
|
|
25
|
+
} | {
|
|
26
|
+
"type": "chooseAction";
|
|
27
|
+
"output": ChooseActionOutput;
|
|
28
|
+
} | {
|
|
29
|
+
"type": "chooseAttackers";
|
|
30
|
+
"output": ChooseAttackersOutput;
|
|
31
|
+
} | {
|
|
32
|
+
"type": "chooseBlockers";
|
|
33
|
+
"output": ChooseBlockersOutput;
|
|
34
|
+
} | {
|
|
35
|
+
"type": "chooseBoardTargets";
|
|
36
|
+
"output": ChooseBoardTargetsOutput;
|
|
37
|
+
} | {
|
|
38
|
+
"type": "chooseBoolean";
|
|
39
|
+
"output": ChooseBooleanOutput;
|
|
40
|
+
} | {
|
|
41
|
+
"type": "chooseFromSelection";
|
|
42
|
+
"output": ChooseFromSelectionOutput;
|
|
43
|
+
} | {
|
|
44
|
+
"type": "revealCards";
|
|
45
|
+
"output": RevealCardsOutput;
|
|
46
|
+
} | {
|
|
47
|
+
"type": "scry";
|
|
48
|
+
"output": ScryOutput;
|
|
49
|
+
} | {
|
|
50
|
+
"type": "chooseColor";
|
|
51
|
+
"output": ChooseColorOutput;
|
|
52
|
+
} | {
|
|
53
|
+
"type": "chooseNumber";
|
|
54
|
+
"output": ChooseNumberOutput;
|
|
55
|
+
} | {
|
|
56
|
+
"type": "chooseDamageAssignmentOrder";
|
|
57
|
+
"output": ChooseDamageAssignmentOrderOutput;
|
|
58
|
+
} | {
|
|
59
|
+
"type": "chooseCombatDamageAssignment";
|
|
60
|
+
"output": ChooseCombatDamageAssignmentOutput;
|
|
61
|
+
} | {
|
|
62
|
+
"type": "payManaCost";
|
|
63
|
+
"output": PayManaCostOutput;
|
|
64
|
+
} | {
|
|
65
|
+
"type": "chooseCards";
|
|
66
|
+
"output": ChooseCardsOutput;
|
|
67
|
+
} | {
|
|
68
|
+
"type": "reorder";
|
|
69
|
+
"output": ReorderOutput;
|
|
70
|
+
} | {
|
|
71
|
+
"type": "diceRolled";
|
|
72
|
+
"output": DiceRolledOutput;
|
|
73
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CardDto } from "../game/index";
|
|
2
|
+
import type { PromptPresentation } from "./common";
|
|
3
|
+
export type ReorderInput = {
|
|
4
|
+
presentation: PromptPresentation;
|
|
5
|
+
items: Array<ReorderItem>;
|
|
6
|
+
};
|
|
7
|
+
export type ReorderItem = {
|
|
8
|
+
id: string;
|
|
9
|
+
card: CardDto;
|
|
10
|
+
oracle?: string;
|
|
11
|
+
};
|
|
12
|
+
export type ReorderOutput = {
|
|
13
|
+
"type": "reorderDecision";
|
|
14
|
+
orderedIds: Array<string>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CardDto } from "../game/index";
|
|
2
|
+
import type { PromptPresentation } from "./common";
|
|
3
|
+
import type { ZoneKind } from "../game/index";
|
|
4
|
+
export type RevealCardsInput = {
|
|
5
|
+
presentation: PromptPresentation;
|
|
6
|
+
cards: Array<CardDto>;
|
|
7
|
+
zone: ZoneKind;
|
|
8
|
+
ownerPlayerId: string;
|
|
9
|
+
};
|
|
10
|
+
export type RevealCardsOutput = {
|
|
11
|
+
"type": "revealCardsAcknowledged";
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CardDto } from "../game/index";
|
|
2
|
+
import type { PromptPresentation } from "./common";
|
|
3
|
+
export type ScryDestination = "libraryTop" | "libraryBottom" | "graveyard" | "exile" | "hand";
|
|
4
|
+
export type ScryInput = {
|
|
5
|
+
presentation: PromptPresentation;
|
|
6
|
+
cards: Array<CardDto>;
|
|
7
|
+
zones: Array<ScryDestination>;
|
|
8
|
+
};
|
|
9
|
+
export type ScryOutput = {
|
|
10
|
+
"type": "scryDecision";
|
|
11
|
+
zoneCardIds: Array<Array<string>>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PromptInput } from "../prompts";
|
|
2
|
+
export interface PromptRequestEnvelope {
|
|
3
|
+
promptId?: string;
|
|
4
|
+
decidingPlayerId?: string;
|
|
5
|
+
sourceCardId?: string;
|
|
6
|
+
}
|
|
7
|
+
export type PromptRequest<TInput extends {
|
|
8
|
+
type: string;
|
|
9
|
+
}> = PromptRequestEnvelope & {
|
|
10
|
+
input: TInput;
|
|
11
|
+
};
|
|
12
|
+
type DistributeRequest<TInput extends {
|
|
13
|
+
type: string;
|
|
14
|
+
}> = TInput extends unknown ? PromptRequest<TInput> : never;
|
|
15
|
+
export type Prompt = DistributeRequest<PromptInput>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// AUTO-GENERATED by `cargo run -p manabrew-protocol --bin gen-protocol`. Do not edit.
|
|
18
|
+
__exportStar(require("./messages"), exports);
|
|
19
|
+
__exportStar(require("./envelope"), exports);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { GameViewDto } from "../game/index";
|
|
2
|
+
import type { PromptInput } from "../prompts/promptInput";
|
|
3
|
+
import type { PromptOutput } from "../prompts/promptOutput";
|
|
4
|
+
export type AgentPrompt = {
|
|
5
|
+
promptId: number;
|
|
6
|
+
decidingPlayerId: string;
|
|
7
|
+
sourceCardId?: string;
|
|
8
|
+
input: PromptInput;
|
|
9
|
+
};
|
|
10
|
+
export type ClientToServerMessage = {
|
|
11
|
+
"kind": "response";
|
|
12
|
+
promptId: number;
|
|
13
|
+
action: PromptOutput;
|
|
14
|
+
} | {
|
|
15
|
+
"kind": "directive";
|
|
16
|
+
directive: DirectiveInput;
|
|
17
|
+
};
|
|
18
|
+
export type DirectiveInput = {
|
|
19
|
+
"type": "concede";
|
|
20
|
+
};
|
|
21
|
+
export type ProtocolError = {
|
|
22
|
+
code: ProtocolErrorCode;
|
|
23
|
+
message: string;
|
|
24
|
+
promptId?: number;
|
|
25
|
+
};
|
|
26
|
+
export type ProtocolErrorCode = "stalePrompt" | "wrongPlayer" | "wrongPromptType" | "unknownActionId" | "invalidShape";
|
|
27
|
+
export type StateUpdate = {
|
|
28
|
+
gameView: GameViewDto;
|
|
29
|
+
};
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PROTOCOL_VERSION = exports.VERSION = void 0;
|
|
4
|
+
// AUTO-GENERATED by `cargo run -p manabrew-protocol --bin gen-protocol`. Do not edit.
|
|
5
|
+
exports.VERSION = "1.0.1";
|
|
6
|
+
exports.PROTOCOL_VERSION = 1;
|
package/package.json
CHANGED
|
@@ -1,9 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manabrew/protocol",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"license": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "TypeScript types for the Manabrew wire protocol — the engine↔client message contract for the Manabrew Magic: The Gathering client.",
|
|
5
|
+
"license": "AGPL-3.0-or-later",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/witchesofthehill/manabrew.git",
|
|
9
|
+
"directory": "packages/protocol"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://docs.manabrew.app/protocol/",
|
|
12
|
+
"bugs": "https://github.com/witchesofthehill/manabrew/issues",
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"types": "dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./*": {
|
|
21
|
+
"types": "./dist/*.d.ts",
|
|
22
|
+
"default": "./dist/*.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc -p tsconfig.json"
|
|
31
|
+
},
|
|
6
32
|
"publishConfig": {
|
|
7
33
|
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"typescript": "^5.6.0"
|
|
8
37
|
}
|
|
9
38
|
}
|