summaryrefslogtreecommitdiff
path: root/src/command.rs
blob: bca0f38a0e9f249d6de1dc72b1cab84992e7e343 (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, Hash)]
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"),
        }
    }
}