Skip to main content

manabrew_engine/keyword/
trample.rs

1//! Trample keyword implementation.
2//!
3//! Ported from Java's `Trample.java` in `forge/game/keyword/`.
4
5use super::keyword_instance::Keyword;
6use super::keyword_with_type::KeywordWithType;
7
8/// Trample keyword data.
9/// This creature can deal excess combat damage to the player or planeswalker
10/// it's attacking. Has a "trample over planeswalkers" variant.
11#[derive(Debug, Clone)]
12pub struct Trample {
13    pub inner: KeywordWithType,
14}
15
16impl Trample {
17    /// Create a new Trample keyword.
18    pub fn new(original: String) -> Self {
19        Self {
20            inner: KeywordWithType::new(Keyword::Trample, original),
21        }
22    }
23
24    /// Parse the details string.
25    pub fn parse(&mut self, details: &str) {
26        self.inner.parse(details);
27    }
28
29    /// Get the display title.
30    pub fn get_title(&self) -> String {
31        if !self.inner.type_str.is_empty() {
32            "Trample over planeswalkers".to_string()
33        } else {
34            "Trample".to_string()
35        }
36    }
37
38    /// Format reminder text.
39    pub fn format_reminder_text(&self, reminder_text: &str) -> String {
40        if !self.inner.type_str.is_empty() {
41            "This creature can deal excess combat damage to the controller of the planeswalker it's attacking.".to_string()
42        } else {
43            reminder_text.to_string()
44        }
45    }
46}