From 88430f31c73f469086b68f2b77d1e1ba5f9178e7 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Mon, 22 Apr 2019 21:50:00 +0200 Subject: More minimal game state I'd prefer to start with just the state that I need, and progressively readd the bits that I've skipped as I find I need them, or as the competition evolves. --- src/command.rs | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) (limited to 'src/command.rs') diff --git a/src/command.rs b/src/command.rs index 06dd400..99de608 100644 --- a/src/command.rs +++ b/src/command.rs @@ -1,4 +1,5 @@ use std::fmt; +use crate::geometry::Direction; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Command { @@ -19,43 +20,3 @@ impl fmt::Display for Command { } } } - -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum Direction { - North, - NorthEast, - East, - SouthEast, - South, - SouthWest, - West, - NorthWest, -} - -impl fmt::Display for Direction { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use Direction::*; - let s = match self { - North => "N", - NorthEast => "NE", - East => "E", - SouthEast => "SE", - South => "S", - SouthWest => "SW", - West => "W", - NorthWest => "NW", - }; - f.write_str(s) - } -} - -impl Direction { - pub fn is_diagonal(&self) -> bool { - use Direction::*; - - match self { - NorthEast | SouthEast | SouthWest | NorthWest => true, - _ => false, - } - } -} -- cgit v1.2.3