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