genius_invokation/cards/action/
cost.rs

1use crate::Element;
2
3#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)]
4pub struct CardCost {
5    dice: DiceCost,
6    amount: u8,
7    energy: u8,
8}
9
10#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)]
11pub enum DiceCost {
12    /// Any dice can be used for this card
13    Any,
14    /// All dice used must be of the same element
15    Same,
16    /// The dice used must be of a given specific element
17    Exact(Element)
18}
19
20impl CardCost {
21    /// For cards that cost nothing
22    pub(crate) const ZERO: Self = Self { dice: DiceCost::Same, amount: 0, energy: 0 };
23
24    /// For cards that cost one die of any element
25    pub(crate) const ONE: Self = Self { dice: DiceCost::Same, amount: 1, energy: 0 };
26
27    /// For cards that cost any two dice of any type
28    pub(crate) const ANY2: Self = Self { dice: DiceCost::Any, amount: 2, energy: 0 };
29
30    /// For cards that cost two dice of the same type
31    pub(crate) const MATCH2: Self = Self { dice: DiceCost::Same, amount: 2, energy: 0 };
32
33    /// For cards that cost three dice of the same type
34    pub(crate) const MATCH3: Self = Self { dice: DiceCost::Same, amount: 3, energy: 0 };
35
36    pub(crate) const fn new(dice: DiceCost, amount: u8, energy: u8) -> Self {
37        Self { dice, amount, energy }
38    }
39
40    /// Retrieves which type of dice is required to play the given card
41    pub fn dice_type(&self) -> DiceCost {
42        self.dice
43    }
44
45    /// The amount of dice required to play the given card
46    pub fn amount(&self) -> u8 {
47        self.amount
48    }
49
50    /// The amount of character energy required to play this card
51    /// 
52    /// Most cards don't require energy, which means zero
53    pub fn energy(&self) -> u8 {
54        self.energy
55    }
56}
57