mtg_data/
keyword_action.rs

1#[derive(idris_derive::Idris)]
2#[idris(repr = usize)]
3#[derive(serde::Serialize, serde::Deserialize)]
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
5#[cfg_attr(feature = "ts_export", derive(ts_rs::TS))]
6pub enum KeywordAction {
7    Abandon,
8    Activate,
9    Adapt,
10    Amass,
11    Assemble,
12    Attach,
13    Behold,
14    Bolster,
15    Cast,
16    Clash,
17    Cloak,
18    CollectEvidence,
19    Conjure,
20    Connive,
21    Convert,
22    Counter,
23    Create,
24    Destroy,
25    Detain,
26    Discard,
27    Discover,
28    Double,
29    Endure,
30    Exchange,
31    Exert,
32    Exile,
33    Explore,
34    Fateseal,
35    Fight,
36    Food,
37    Forage,
38    Goad,
39    Heist,
40    Incubate,
41    Investigate,
42    Learn,
43    Manifest,
44    ManifestDread,
45    Meld,
46    Mill,
47    Monstrosity,
48    OpenAnAttraction,
49    Planeswalk,
50    Play,
51    Plot,
52    Populate,
53    Proliferate,
54    Regenerate,
55    Reveal,
56    RoleToken,
57    RollToVisitYourAttractions,
58    Sacrifice,
59    Scry,
60    Seek,
61    SetInMotion,
62    Shuffle,
63    Support,
64    Surveil,
65    Suspect,
66    Tap,
67    TimeTravel,
68    Transform,
69    Treasure,
70    Untap,
71    VentureIntoTheDungeon,
72    Vote,
73}
74
75impl std::str::FromStr for KeywordAction {
76    type Err = crate::ParsingError;
77    fn from_str(s: &str) -> Result<Self, Self::Err> {
78        match s {
79            "abandon" => Ok(Self::Abandon),
80            "activate" => Ok(Self::Activate),
81            "adapt" => Ok(Self::Adapt),
82            "amass" => Ok(Self::Amass),
83            "assemble" => Ok(Self::Assemble),
84            "attach" => Ok(Self::Attach),
85            "behold" => Ok(Self::Behold),
86            "bolster" => Ok(Self::Bolster),
87            "cast" => Ok(Self::Cast),
88            "clash" => Ok(Self::Clash),
89            "cloak" => Ok(Self::Cloak),
90            "collect evidence" => Ok(Self::CollectEvidence),
91            "conjure" => Ok(Self::Conjure),
92            "connive" => Ok(Self::Connive),
93            "convert" => Ok(Self::Convert),
94            "counter" => Ok(Self::Counter),
95            "create" => Ok(Self::Create),
96            "destroy" => Ok(Self::Destroy),
97            "detain" => Ok(Self::Detain),
98            "discard" => Ok(Self::Discard),
99            "discover" => Ok(Self::Discover),
100            "double" => Ok(Self::Double),
101            "endure" => Ok(Self::Endure),
102            "exchange" => Ok(Self::Exchange),
103            "exert" => Ok(Self::Exert),
104            "exile" => Ok(Self::Exile),
105            "explore" => Ok(Self::Explore),
106            "fateseal" => Ok(Self::Fateseal),
107            "fight" => Ok(Self::Fight),
108            "food" => Ok(Self::Food),
109            "forage" => Ok(Self::Forage),
110            "goad" => Ok(Self::Goad),
111            "heist" => Ok(Self::Heist),
112            "incubate" => Ok(Self::Incubate),
113            "investigate" => Ok(Self::Investigate),
114            "learn" => Ok(Self::Learn),
115            "manifest" => Ok(Self::Manifest),
116            "manifest dread" => Ok(Self::ManifestDread),
117            "meld" => Ok(Self::Meld),
118            "mill" => Ok(Self::Mill),
119            "monstrosity" => Ok(Self::Monstrosity),
120            "open an attraction" => Ok(Self::OpenAnAttraction),
121            "planeswalk" => Ok(Self::Planeswalk),
122            "play" => Ok(Self::Play),
123            "plot" => Ok(Self::Plot),
124            "populate" => Ok(Self::Populate),
125            "proliferate" => Ok(Self::Proliferate),
126            "regenerate" => Ok(Self::Regenerate),
127            "reveal" => Ok(Self::Reveal),
128            "role token" => Ok(Self::RoleToken),
129            "roll to visit your attractions" => Ok(Self::RollToVisitYourAttractions),
130            "sacrifice" => Ok(Self::Sacrifice),
131            "scry" => Ok(Self::Scry),
132            "seek" => Ok(Self::Seek),
133            "set in motion" => Ok(Self::SetInMotion),
134            "shuffle" => Ok(Self::Shuffle),
135            "support" => Ok(Self::Support),
136            "surveil" => Ok(Self::Surveil),
137            "suspect" => Ok(Self::Suspect),
138            "tap" => Ok(Self::Tap),
139            "time travel" => Ok(Self::TimeTravel),
140            "transform" => Ok(Self::Transform),
141            "treasure" => Ok(Self::Treasure),
142            "untap" => Ok(Self::Untap),
143            "venture into the dungeon" => Ok(Self::VentureIntoTheDungeon),
144            "vote" => Ok(Self::Vote),
145            _ => Err(crate::ParsingError {
146                item: "KeywordAction",
147                message: "provided source does not match",
148            }),
149        }
150    }
151}
152
153impl KeywordAction {
154    pub fn as_str(&self) -> &'static str {
155        match self {
156            Self::Abandon => "abandon",
157            Self::Activate => "activate",
158            Self::Adapt => "adapt",
159            Self::Amass => "amass",
160            Self::Assemble => "assemble",
161            Self::Attach => "attach",
162            Self::Behold => "behold",
163            Self::Bolster => "bolster",
164            Self::Cast => "cast",
165            Self::Clash => "clash",
166            Self::Cloak => "cloak",
167            Self::CollectEvidence => "collect evidence",
168            Self::Conjure => "conjure",
169            Self::Connive => "connive",
170            Self::Convert => "convert",
171            Self::Counter => "counter",
172            Self::Create => "create",
173            Self::Destroy => "destroy",
174            Self::Detain => "detain",
175            Self::Discard => "discard",
176            Self::Discover => "discover",
177            Self::Double => "double",
178            Self::Endure => "endure",
179            Self::Exchange => "exchange",
180            Self::Exert => "exert",
181            Self::Exile => "exile",
182            Self::Explore => "explore",
183            Self::Fateseal => "fateseal",
184            Self::Fight => "fight",
185            Self::Food => "food",
186            Self::Forage => "forage",
187            Self::Goad => "goad",
188            Self::Heist => "heist",
189            Self::Incubate => "incubate",
190            Self::Investigate => "investigate",
191            Self::Learn => "learn",
192            Self::Manifest => "manifest",
193            Self::ManifestDread => "manifest dread",
194            Self::Meld => "meld",
195            Self::Mill => "mill",
196            Self::Monstrosity => "monstrosity",
197            Self::OpenAnAttraction => "open an attraction",
198            Self::Planeswalk => "planeswalk",
199            Self::Play => "play",
200            Self::Plot => "plot",
201            Self::Populate => "populate",
202            Self::Proliferate => "proliferate",
203            Self::Regenerate => "regenerate",
204            Self::Reveal => "reveal",
205            Self::RoleToken => "role token",
206            Self::RollToVisitYourAttractions => "roll to visit your attractions",
207            Self::Sacrifice => "sacrifice",
208            Self::Scry => "scry",
209            Self::Seek => "seek",
210            Self::SetInMotion => "set in motion",
211            Self::Shuffle => "shuffle",
212            Self::Support => "support",
213            Self::Surveil => "surveil",
214            Self::Suspect => "suspect",
215            Self::Tap => "tap",
216            Self::TimeTravel => "time travel",
217            Self::Transform => "transform",
218            Self::Treasure => "treasure",
219            Self::Untap => "untap",
220            Self::VentureIntoTheDungeon => "venture into the dungeon",
221            Self::Vote => "vote",
222        }
223    }
224}
225
226impl std::fmt::Display for KeywordAction {
227    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
228        write!(f, "{}", self.as_str())
229    }
230}
231
232impl KeywordAction {
233    pub fn all() -> impl Iterator<Item = Self> {
234        [
235            Self::Abandon,
236            Self::Activate,
237            Self::Adapt,
238            Self::Amass,
239            Self::Assemble,
240            Self::Attach,
241            Self::Behold,
242            Self::Bolster,
243            Self::Cast,
244            Self::Clash,
245            Self::Cloak,
246            Self::CollectEvidence,
247            Self::Conjure,
248            Self::Connive,
249            Self::Convert,
250            Self::Counter,
251            Self::Create,
252            Self::Destroy,
253            Self::Detain,
254            Self::Discard,
255            Self::Discover,
256            Self::Double,
257            Self::Endure,
258            Self::Exchange,
259            Self::Exert,
260            Self::Exile,
261            Self::Explore,
262            Self::Fateseal,
263            Self::Fight,
264            Self::Food,
265            Self::Forage,
266            Self::Goad,
267            Self::Heist,
268            Self::Incubate,
269            Self::Investigate,
270            Self::Learn,
271            Self::Manifest,
272            Self::ManifestDread,
273            Self::Meld,
274            Self::Mill,
275            Self::Monstrosity,
276            Self::OpenAnAttraction,
277            Self::Planeswalk,
278            Self::Play,
279            Self::Plot,
280            Self::Populate,
281            Self::Proliferate,
282            Self::Regenerate,
283            Self::Reveal,
284            Self::RoleToken,
285            Self::RollToVisitYourAttractions,
286            Self::Sacrifice,
287            Self::Scry,
288            Self::Seek,
289            Self::SetInMotion,
290            Self::Shuffle,
291            Self::Support,
292            Self::Surveil,
293            Self::Suspect,
294            Self::Tap,
295            Self::TimeTravel,
296            Self::Transform,
297            Self::Treasure,
298            Self::Untap,
299            Self::VentureIntoTheDungeon,
300            Self::Vote,
301        ].into_iter()
302    }
303}