use serde::{Deserialize, Serialize};
use strum_macros::{Display, EnumString};
#[derive(
Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, EnumString, Display,
)]
pub enum CounterType {
P1P1,
M1M1,
Poison,
Loyalty,
Charge,
Quest,
Study,
Age,
Fade,
Time,
Depletion,
Storage,
Mining,
Brick,
Level,
Lore,
Page,
Dream,
Named(String),
}
pub fn parse_counter_type(s: &str) -> CounterType {
match s.to_uppercase().as_str() {
"P1P1" | "+1/+1" => CounterType::P1P1,
"M1M1" | "-1/-1" => CounterType::M1M1,
"POISON" => CounterType::Poison,
"LOYALTY" => CounterType::Loyalty,
"CHARGE" => CounterType::Charge,
"QUEST" => CounterType::Quest,
"STUDY" => CounterType::Study,
"AGE" => CounterType::Age,
"FADE" => CounterType::Fade,
"TIME" => CounterType::Time,
"DEPLETION" => CounterType::Depletion,
"STORAGE" => CounterType::Storage,
"MINING" => CounterType::Mining,
"BRICK" => CounterType::Brick,
"LEVEL" => CounterType::Level,
"LORE" => CounterType::Lore,
"PAGE" => CounterType::Page,
"DREAM" => CounterType::Dream,
other => CounterType::Named(other.to_string()),
}
}
impl CounterType {
pub fn is(&self, other: &CounterType) -> bool {
self == other
}
pub fn is_keyword_counter(&self) -> bool {
matches!(self, CounterType::Named(_))
}
}