manabrew_engine/keyword/
craft.rs1use super::keyword_instance::Keyword;
6use super::keyword_with_cost::KeywordWithCost;
7
8#[derive(Debug, Clone)]
11pub struct Craft {
12 pub inner: KeywordWithCost,
13 pub mana_string: String,
15 pub exile_string: String,
17}
18
19impl Craft {
20 pub fn new(original: String) -> Self {
22 Self {
23 inner: KeywordWithCost::new(Keyword::Craft, original),
24 mana_string: "Mana?".to_string(),
25 exile_string: "Exile?".to_string(),
26 }
27 }
28
29 pub fn parse(&mut self, details: &str) {
31 let k: Vec<&str> = details.split(':').collect();
32 if !k.is_empty() {
33 self.inner.parse(k[0]);
34 self.mana_string = k[0].to_string();
35 }
36 if k.len() > 2 {
37 self.exile_string = format!(
38 "Exile {} from among permanents you control and/or cards in your graveyard",
39 k[2]
40 );
41 }
42 }
43
44 pub fn format_reminder_text(&self, reminder_text: &str) -> String {
46 let cost_desc = format!(
47 "{}, Exile this artifact, {}",
48 self.mana_string, self.exile_string
49 );
50 reminder_text.replace("%s", &cost_desc)
51 }
52
53 pub fn get_title(&self) -> String {
55 self.inner.get_title()
56 }
57}