Skip to main content

manabrew_engine/keyword/
modular.rs

1//! Modular keyword implementation.
2//!
3//! Ported from Java's `Modular.java` in `forge/game/keyword/`.
4
5use super::keyword_instance::Keyword;
6use super::keyword_with_amount::KeywordWithAmount;
7
8/// Modular keyword data.
9/// This creature enters with +1/+1 counters. When it dies, you may put
10/// its +1/+1 counters on target artifact creature.
11/// Has a special "Sunburst" variant.
12#[derive(Debug, Clone)]
13pub struct Modular {
14    pub inner: KeywordWithAmount,
15    /// Whether this is the Sunburst variant.
16    pub sunburst: bool,
17}
18
19impl Modular {
20    /// Create a new Modular keyword.
21    pub fn new(original: String) -> Self {
22        Self {
23            inner: KeywordWithAmount::new(Keyword::Modular, original),
24            sunburst: false,
25        }
26    }
27
28    /// Parse the details string.
29    pub fn parse(&mut self, details: &str) {
30        if details == "Sunburst" {
31            self.sunburst = true;
32        } else {
33            self.inner.parse(details);
34        }
35    }
36
37    /// Get the display title.
38    pub fn get_title(&self) -> String {
39        if self.sunburst {
40            "Modular\u{2014}Sunburst".to_string()
41        } else {
42            self.inner.get_title()
43        }
44    }
45
46    /// Get the amount string.
47    pub fn get_amount_string(&self) -> String {
48        if self.sunburst {
49            "Sunburst".to_string()
50        } else {
51            self.inner.get_amount_string()
52        }
53    }
54
55    /// Format reminder text.
56    pub fn format_reminder_text(&self, reminder_text: &str) -> String {
57        if self.sunburst {
58            "This enters with a +1/+1 counter on it for each color of mana spent to cast it. When it dies, you may put its +1/+1 counters on target artifact creature.".to_string()
59        } else {
60            self.inner.format_reminder_text(reminder_text)
61        }
62    }
63}