use super::Price;
use crate::*;
macro_rules! impl_method {
($($type:ident : $article:ident $name:ident ,)+) => {
$(
#[doc = "Attempts to parse `self` as "]
#[doc = stringify!($article)]
#[doc = stringify!($name)]
#[doc = "card. Returns None if this card is of another type/subtype"]
fn $name(&self) -> Option<$type> { None }
)+
};
}
pub trait PlayingCard: sealed::Trait {
fn name(&self) -> &'static str;
fn cost(&self) -> CardCost;
fn shop_price(&self) -> Option<Price>;
impl_method!(
EquipmentCard: an equipment,
EventCard: an event,
SupportCard: a support,
ArtifactCard: an artifact,
TalentCard: a talent,
WeaponCard: a weapon,
FoodCard: a food,
CompanionCard: a companion,
ItemCard: an item,
LocationCard: a location,
ElementalResonanceCard: a resonance,
);
fn normal_event(&self) -> Option<NormalEventCard> { None }
}
mod sealed {
use crate::*;
pub trait Trait {}
macro_rules! impl_trait {
($($card:ident)+) => {
$(
impl Trait for $card {}
)+
};
}
impl_trait!(ActionCard
EquipmentCard ArtifactCard TalentCard WeaponCard
EventCard FoodCard NormalEventCard ElementalResonanceCard
SupportCard CompanionCard ItemCard LocationCard
);
}