manabrew_engine/keyword/
partner.rs1use super::keyword_instance::{Keyword, KeywordInstanceData};
6
7#[derive(Debug, Clone)]
11pub struct Partner {
12 pub base: KeywordInstanceData,
13 pub with: Option<String>,
15}
16
17impl Partner {
18 pub fn new(keyword: Keyword, original: String) -> Self {
20 Self {
21 base: KeywordInstanceData::new(keyword, original),
22 with: None,
23 }
24 }
25
26 pub fn parse(&mut self, details: &str) {
28 if !details.is_empty() {
29 self.with = Some(details.to_string());
30 }
31 }
32
33 pub fn get_title(&self) -> String {
35 if let Some(ref with) = self.with {
36 format!("Partner \u{2014} {}", with)
37 } else {
38 self.base.keyword.display_name().to_string()
39 }
40 }
41
42 pub fn format_reminder_text(&self, reminder_text: &str) -> String {
44 if self.with.is_some() {
45 "You can have two commanders if both have this ability.".to_string()
46 } else {
47 reminder_text.to_string()
48 }
49 }
50}