Skip to main content

manabrew_protocol/prompts/
common.rs

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