Skip to main content

manabrew_protocol/prompts/
common.rs

1use serde::{Deserialize, Serialize};
2use ts_rs::TS;
3
4use crate::game::{Mana, RoomDoor, TargetingIntent};
5
6#[derive(Debug, Clone, Serialize, Deserialize, TS)]
7#[serde(rename_all = "camelCase")]
8#[ts(export, export_to = "prompts/common.ts")]
9pub struct PromptPresentation {
10    pub title: String,
11    #[serde(default, skip_serializing_if = "Option::is_none")]
12    #[ts(optional)]
13    pub description: Option<String>,
14    #[serde(default, skip_serializing_if = "Option::is_none")]
15    #[ts(optional)]
16    pub text: Option<String>,
17    #[serde(default)]
18    pub targets: Vec<TargetRef>,
19}
20
21/// Mirrors the engine's `AlternativeCost` (itself a mirror of Java's).
22#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
23#[serde(rename_all = "camelCase")]
24#[ts(export, export_to = "prompts/common.ts")]
25pub enum AlternativeCostKind {
26    Flashback,
27    BeamMeUp,
28    Spectacle,
29    Evoke,
30    Dash,
31    Blitz,
32    Escape,
33    Overload,
34    Madness,
35    Foretell,
36    Emerge,
37    Suspend,
38    Morph,
39    Megamorph,
40    Bestow,
41    Warp,
42    SacrificeAlt,
43    Plot,
44    Awaken,
45    Disturb,
46    Harmonize,
47    Freerunning,
48    Impending,
49    Mayhem,
50    #[serde(rename = "moreThanMeetsTheEye")]
51    MTMtE,
52    Mutate,
53    Prowl,
54    Sneak,
55    Surge,
56    WebSlinging,
57    Plotted,
58    Prototype,
59}
60
61/// Mirrors the engine's `PlayCardMode`.
62#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
63#[serde(
64    tag = "type",
65    rename_all = "camelCase",
66    rename_all_fields = "camelCase"
67)]
68#[ts(export, export_to = "prompts/common.ts")]
69pub enum PlayCardMode {
70    Normal,
71    BackFaceLand,
72    RoomRightSplit,
73    Adventure,
74    Alternative { cost: AlternativeCostKind },
75    StaticAlternative,
76    ForetellExile,
77    UnlockDoor { door: RoomDoor },
78}
79
80#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
81#[serde(rename_all = "camelCase")]
82#[ts(export, export_to = "prompts/common.ts")]
83pub enum LevelUpKind {
84    Class,
85    Creature,
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize, TS)]
89#[serde(rename_all = "camelCase")]
90#[ts(export, export_to = "prompts/common.ts")]
91pub struct ActivatableAbilityInfo {
92    pub card_id: String,
93    pub ability_index: usize,
94    pub description: String,
95    pub is_mana_ability: bool,
96    #[serde(default, skip_serializing_if = "Option::is_none")]
97    #[ts(optional)]
98    pub level_up: Option<LevelUpKind>,
99    #[serde(default, skip_serializing_if = "Option::is_none")]
100    #[ts(optional)]
101    pub cost: Option<String>,
102    #[serde(default, skip_serializing_if = "Option::is_none")]
103    #[ts(optional)]
104    pub produced_mana: Option<Vec<Mana>>,
105}
106
107#[derive(Debug, Clone, Serialize, Deserialize, TS)]
108#[serde(
109    tag = "type",
110    rename_all = "camelCase",
111    rename_all_fields = "camelCase"
112)]
113#[ts(export, export_to = "prompts/common.ts")]
114pub enum AvailableActionKind {
115    Cast {
116        card_id: String,
117        mode: PlayCardMode,
118        label: String,
119        #[serde(default, skip_serializing_if = "Option::is_none")]
120        #[ts(optional)]
121        face_index: Option<u8>,
122    },
123    ActivateAbility(ActivatableAbilityInfo),
124    UndoMana {
125        card_id: String,
126    },
127}
128
129#[derive(Debug, Clone, Serialize, Deserialize, TS)]
130#[ts(export, export_to = "prompts/common.ts")]
131pub struct AvailableAction {
132    pub id: String,
133    #[serde(flatten)]
134    #[ts(flatten)]
135    pub kind: AvailableActionKind,
136}
137
138#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
139#[serde(rename_all = "camelCase")]
140#[ts(export, export_to = "prompts/common.ts")]
141pub enum PaymentResourceKind {
142    Convoke,
143    Improvise,
144    Delve,
145    Waterbend,
146}
147
148#[derive(Debug, Clone, Serialize, Deserialize, TS)]
149#[serde(
150    tag = "type",
151    rename_all = "camelCase",
152    rename_all_fields = "camelCase"
153)]
154#[ts(export, export_to = "prompts/common.ts")]
155pub enum PaymentActionKind {
156    ActivateManaAbility(ActivatableAbilityInfo),
157    UndoMana {
158        card_id: String,
159    },
160    UseResource {
161        card_id: String,
162        resource: PaymentResourceKind,
163    },
164    ReleaseResource {
165        card_id: String,
166        resource: PaymentResourceKind,
167    },
168    PayLife {
169        amount: u32,
170    },
171}
172
173#[derive(Debug, Clone, Serialize, Deserialize, TS)]
174#[ts(export, export_to = "prompts/common.ts")]
175pub struct PaymentAction {
176    pub id: String,
177    #[serde(flatten)]
178    #[ts(flatten)]
179    pub kind: PaymentActionKind,
180}
181
182#[derive(Debug, Clone, Serialize, Deserialize, TS)]
183#[serde(rename_all = "camelCase")]
184#[ts(export, export_to = "prompts/common.ts")]
185pub enum AttackTargetKind {
186    Player,
187    Planeswalker,
188    Battle,
189}
190
191#[derive(Debug, Clone, Serialize, Deserialize, TS)]
192#[serde(rename_all = "camelCase")]
193#[ts(export, export_to = "prompts/common.ts")]
194pub struct AttackTargetDto {
195    pub id: String,
196    pub label: String,
197    pub kind: AttackTargetKind,
198}
199
200#[derive(Debug, Clone, Serialize, Deserialize, TS)]
201#[serde(rename_all = "camelCase")]
202#[ts(export, export_to = "prompts/common.ts")]
203pub struct BlockAssignment {
204    pub blocker_id: String,
205    pub attacker_id: String,
206}
207
208#[derive(Debug, Clone, Serialize, Deserialize, TS)]
209#[serde(rename_all = "camelCase")]
210#[ts(export, export_to = "prompts/common.ts")]
211pub struct AttackAssignment {
212    pub attacker_id: String,
213    pub target_id: String,
214}
215
216#[derive(Debug, Clone, Serialize, Deserialize, TS)]
217#[serde(rename_all = "camelCase")]
218#[ts(export, export_to = "prompts/common.ts")]
219pub struct CombatDamageAssignmentEntry {
220    pub assignee_id: String,
221    pub damage: i32,
222}
223
224#[derive(Debug, Clone, Serialize, Deserialize, TS)]
225#[serde(
226    tag = "kind",
227    rename_all = "camelCase",
228    rename_all_fields = "camelCase"
229)]
230#[ts(export, export_to = "prompts/common.ts")]
231pub enum TargetAnyChoice {
232    Player { player_id: String },
233    Card { card_id: String },
234    None,
235}
236
237#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
238#[serde(rename_all = "camelCase")]
239#[ts(export, export_to = "prompts/common.ts")]
240pub enum TargetKind {
241    Player,
242    Card,
243    Spell,
244}
245
246#[derive(Debug, Clone, Serialize, Deserialize, TS)]
247#[serde(rename_all = "camelCase")]
248#[ts(export, export_to = "prompts/common.ts")]
249pub struct TargetRef {
250    pub kind: TargetKind,
251    pub id: String,
252    #[serde(default, skip_serializing_if = "Option::is_none")]
253    #[ts(optional)]
254    pub intent: Option<TargetingIntent>,
255    #[serde(default, skip_serializing_if = "Option::is_none")]
256    #[ts(optional)]
257    pub oracle: Option<String>,
258}