Skip to main content

manabrew_engine/keyword/
suspend.rs

1//! Suspend keyword implementation.
2//!
3//! Ported from Java's `Suspend.java` in `forge/game/keyword/`.
4
5use super::keyword_instance::Keyword;
6use super::keyword_with_cost_and_amount::KeywordWithCostAndAmount;
7
8/// Suspend keyword data.
9/// Pay cost and exile with time counters. Remove one each upkeep.
10/// When the last is removed, cast without paying mana cost.
11#[derive(Debug, Clone)]
12pub struct Suspend {
13    pub inner: KeywordWithCostAndAmount,
14    /// Whether this suspend has no cost and no amount (intrinsic suspend).
15    pub without_cost_and_amount: bool,
16}
17
18impl Suspend {
19    /// Create a new Suspend keyword.
20    pub fn new(original: String) -> Self {
21        Self {
22            inner: KeywordWithCostAndAmount::new(Keyword::Suspend, original),
23            without_cost_and_amount: false,
24        }
25    }
26
27    /// Parse the details string.
28    pub fn parse(&mut self, details: &str) {
29        if details.is_empty() {
30            self.without_cost_and_amount = true;
31        } else {
32            self.inner.parse(details);
33        }
34    }
35
36    /// Get the display title.
37    pub fn get_title(&self) -> String {
38        if self.without_cost_and_amount {
39            self.inner.base.keyword.display_name().to_string()
40        } else {
41            self.inner.get_title()
42        }
43    }
44
45    /// Format reminder text.
46    pub fn format_reminder_text(&self, reminder_text: &str) -> String {
47        if self.without_cost_and_amount {
48            "At the beginning of its owner's upkeep, remove a time counter from that card. When the last is removed, the player plays it without paying its mana cost. If it's a creature, it has haste.".to_string()
49        } else {
50            self.inner.format_reminder_text(reminder_text)
51        }
52    }
53}