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