genius_invokation/cards/action/
card_trait.rs1use super::Price;
2use crate::*;
3
4macro_rules! impl_method {
5 ($($type:ident : $article:ident $name:ident ,)+) => {
6 $(
7 #[doc = "Attempts to parse `self` as "]
8 #[doc = stringify!($article)]
9 #[doc = stringify!($name)]
10 #[doc = "card. Returns None if this card is of another type/subtype"]
11 fn $name(&self) -> Option<$type> { None }
12 )+
13 };
14}
15
16pub trait PlayingCard: sealed::Trait {
17 fn name(&self) -> &'static str;
19
20 fn cost(&self) -> CardCost;
22
23 fn shop_price(&self) -> Option<Price>;
31
32 impl_method!(
33 EquipmentCard: an equipment,
34 EventCard: an event,
35 SupportCard: a support,
36 ArtifactCard: an artifact,
37 TalentCard: a talent,
38 WeaponCard: a weapon,
39 FoodCard: a food,
40 CompanionCard: a companion,
41 ItemCard: an item,
42 LocationCard: a location,
43 ElementalResonanceCard: a resonance,
44 );
45
46 fn normal_event(&self) -> Option<NormalEventCard> { None }
49
50}
51
52mod sealed {
53 use crate::*;
54 pub trait Trait {}
55
56 macro_rules! impl_trait {
57 ($($card:ident)+) => {
58 $(
59 impl Trait for $card {}
60 )+
61 };
62 }
63
64 impl_trait!(ActionCard
65 EquipmentCard ArtifactCard TalentCard WeaponCard
66 EventCard FoodCard NormalEventCard ElementalResonanceCard
67 SupportCard CompanionCard ItemCard LocationCard
68 );
69}