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
use crate::actions::Action;

pub struct Warrior {
    pub path_clear: bool,
    pub action: Option<Action>,
}

impl Warrior {
    pub fn new(path_clear: bool) -> Warrior {
        Warrior {
            path_clear,
            action: None,
        }
    }

    pub fn walk(&mut self) {
        if self.action.is_some() {
            println!("Warrior already performed action!");
            return;
        }

        self.action = Some(Action::Walk);
    }

    pub fn path_clear(&self) -> bool {
        self.path_clear
    }

    pub fn attack(&mut self) {
        if self.action.is_some() {
            println!("Warrior already performed action!");
            return;
        }

        self.action = Some(Action::Attack);
    }
}