summaryrefslogtreecommitdiff
path: root/src/command.rs
blob: a510120a8e7ba006e303e2092be46e32463eb9ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use std::fmt;
use crate::geometry::Direction;

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Command {
    Move(i8, i8),
    Dig(i8, i8),
    Shoot(Direction),
    DoNothing,
}

impl fmt::Display for Command {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        use Command::*;
        match self {
            Move(x, y) => write!(f, "move {} {}", x, y),
            Dig(x, y) => write!(f, "dig {} {}", x, y),
            Shoot(dir) => write!(f, "shoot {}", dir),
            DoNothing => write!(f, "nothing"),
        }
    }
}