Skip to main content

manabrew_engine/keyword/
kicker.rs

1//! Kicker keyword implementation.
2//!
3//! Ported from Java's `Kicker.java` in `forge/game/keyword/`.
4
5use super::keyword_instance::Keyword;
6use super::keyword_with_cost::KeywordWithCost;
7
8/// Kicker keyword data.
9/// You may pay an additional cost as you cast this spell.
10/// Supports single and double kicker.
11#[derive(Debug, Clone)]
12pub struct Kicker {
13    pub inner: KeywordWithCost,
14    /// Optional second kicker cost (for double kicker cards).
15    pub cost2: Option<String>,
16}
17
18impl Kicker {
19    /// Create a new Kicker keyword.
20    pub fn new(original: String) -> Self {
21        Self {
22            inner: KeywordWithCost::new(Keyword::Kicker, original),
23            cost2: None,
24        }
25    }
26
27    /// Parse the details string.
28    pub fn parse(&mut self, details: &str) {
29        let parts: Vec<&str> = details.split(':').collect();
30        self.inner.parse(parts[0]);
31        if parts.len() > 1 {
32            self.cost2 = Some(parts[1].to_string());
33        }
34    }
35
36    /// Format reminder text.
37    pub fn format_reminder_text(&self, reminder_text: &str) -> String {
38        if let Some(ref cost2) = self.cost2 {
39            format!(
40                "You may pay an additional {} and/or {} as you cast this spell.",
41                self.inner.cost_string, cost2
42            )
43        } else {
44            self.inner.format_reminder_text(reminder_text)
45        }
46    }
47
48    /// Get the display title.
49    pub fn get_title(&self) -> String {
50        self.inner.get_title()
51    }
52}