genius_invokation/cards/action/support/
mod.rs1use crate::CardCost;
2
3pub use companion::CompanionCard;
4mod companion;
5
6pub use location::LocationCard;
7mod location;
8
9pub use item::ItemCard;
10mod item;
11
12use super::{Price, PlayingCard};
13
14#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)]
15pub enum SupportCard {
16 Companion(CompanionCard),
17 Location(LocationCard),
18 Item(ItemCard),
19}
20
21impl PlayingCard for SupportCard {
22 fn name(&self) -> &'static str {
23 match self {
24 Self::Companion(card) => card.name(),
25 Self::Location(card) => card.name(),
26 Self::Item(card) => card.name(),
27 }
28 }
29
30 fn shop_price(&self) -> Option<Price> {
31 match self {
32 Self::Companion(card) => card.shop_price(),
33 Self::Location(card) => card.shop_price(),
34 Self::Item(card) => card.shop_price(),
35 }
36 }
37
38 fn cost(&self) -> CardCost {
39 match self {
40 Self::Companion(card) => card.cost(),
41 Self::Location(card) => card.cost(),
42 Self::Item(card) => card.cost(),
43 }
44 }
45
46 fn support(&self) -> Option<SupportCard> {
47 Some(*self)
48 }
49
50 impl_match_method!(
51 companion -> CompanionCard { card: Self::Companion(card) },
52 location -> LocationCard { card: Self::Location(card) },
53 item -> ItemCard { card: Self::Item(card) },
54 );
55}
56
57use std::cmp::Ordering;
58use super::CardOrd;
59impl CardOrd for SupportCard {
60 fn cmp(&self, other: &Self) -> Ordering {
61 match (self, other) {
63 (Self::Location(x), Self::Location(y)) => x.cmp(y),
64 (Self::Companion(x), Self::Companion(y)) => x.cmp(y),
65 (Self::Item(x), Self::Item(y)) => x.cmp(y),
66 (Self::Location(_), _) => Ordering::Less,
67 (_, Self::Location(_)) => Ordering::Greater,
68 (Self::Companion(_), _) => Ordering::Less,
69 (_, Self::Companion(_)) => Ordering::Greater,
70 }
71 }
72}
73
74impl_from!(Support: SupportCard => crate::ActionCard => crate::Card);