buckshot_roulette_gameplay_engine/
shell.rs

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
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ShellType {
    Live,
    Blank,
}

#[derive(Debug, Clone, Copy)]
pub enum ShotgunDamage {
    Blank,
    RegularShot(bool),
    SawedShot(bool),
}

#[derive(Debug, Clone)]
pub struct Shell(ShellType);

impl Shell {
    pub fn new(shell_type: ShellType) -> Self {
        Shell(shell_type)
    }

    pub fn invert(&mut self) {
        match self.0 {
            ShellType::Live => self.0 = ShellType::Blank,
            ShellType::Blank => self.0 = ShellType::Live,
        }
    }

    pub fn fire(self) -> bool {
        self.0 == ShellType::Live
    }

    pub fn shell_type(&self) -> ShellType {
        self.0
    }
}