genius_invokation/cards/action/event/
mod.rs

1use crate::CardCost;
2
3pub use normal::NormalEventCard;
4mod normal;
5
6pub use resonance::ElementalResonanceCard;
7mod resonance;
8
9pub use food::FoodCard;
10mod food;
11
12use super::{Price, PlayingCard};
13
14#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)]
15pub enum EventCard {
16    /// Normal types of event cards, with no subtypes, might rename this variant and subtype later
17    Normal(NormalEventCard),
18    /// Elemental Resonance cards
19    Resonance(ElementalResonanceCard),
20    /// Food buff cards
21    Food(FoodCard),
22}
23
24impl PlayingCard for EventCard {
25    fn name(&self) -> &'static str {
26        match self {
27            Self::Normal(card)    => card.name(),
28            Self::Resonance(card) => card.name(),
29            Self::Food(card)      => card.name(),
30        }
31    }
32
33    fn shop_price(&self) -> Option<Price> {
34        match self {
35            Self::Normal(card)    => card.shop_price(),
36            Self::Resonance(card) => card.shop_price(),
37            Self::Food(card)      => card.shop_price(),
38        }
39    }
40
41    fn cost(&self) -> CardCost {
42        match self {
43            Self::Normal(card)    => card.cost(),
44            Self::Resonance(card) => card.cost(),
45            Self::Food(card)      => card.cost(),
46        }
47    }
48
49    fn event(&self) -> Option<EventCard> {
50        Some(*self)
51    }
52
53    impl_match_method!(
54        normal_event -> NormalEventCard { card: Self::Normal(card) },
55        resonance    -> ElementalResonanceCard { card: Self::Resonance(card) },
56        food         -> FoodCard { card: Self::Food(card) },
57    );
58}
59
60use std::cmp::Ordering;
61use super::CardOrd;
62impl CardOrd for EventCard {
63    fn cmp(&self, other: &Self) -> Ordering {
64        // Resonance < Normal < Food
65        match (self, other) {
66            (Self::Resonance(x), Self::Resonance(y)) => x.cmp(y),
67            (Self::Normal(x), Self::Normal(y))       => x.cmp(y),
68            (Self::Food(x), Self::Food(y))           => x.cmp(y),
69            (Self::Resonance(_), _) => Ordering::Less,
70            (_, Self::Resonance(_)) => Ordering::Greater,
71            (Self::Normal(_), _)    => Ordering::Less,
72            (_, Self::Normal(_))    => Ordering::Greater,
73        }
74    }
75}
76
77impl_from!(Event: EventCard => crate::ActionCard => crate::Card);