summaryrefslogtreecommitdiff
path: root/src/command.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/command.rs')
-rw-r--r--src/command.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/command.rs b/src/command.rs
index 1ffdd35..c0315db 100644
--- a/src/command.rs
+++ b/src/command.rs
@@ -1,18 +1,18 @@
-use std::fmt;
use crate::geometry::Direction;
use crate::geometry::Point2d;
+use std::fmt;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Command {
pub worm: Option<i32>,
- pub action: Action
+ pub action: Action,
}
impl fmt::Display for Command {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.worm {
Some(worm) => write!(f, "select {};{}", worm, self.action),
- None => write!(f, "{}", self.action)
+ None => write!(f, "{}", self.action),
}
}
}
@@ -21,15 +21,12 @@ impl Command {
pub fn with_select(worm: i32, action: Action) -> Command {
Command {
worm: Some(worm),
- action
+ action,
}
}
pub fn new(action: Action) -> Command {
- Command {
- worm: None,
- action
- }
+ Command { worm: None, action }
}
}
@@ -39,6 +36,7 @@ pub enum Action {
Dig(Point2d<i8>),
Shoot(Direction),
Bomb(Point2d<i8>),
+ Snowball(Point2d<i8>),
DoNothing,
}
@@ -50,6 +48,7 @@ impl fmt::Display for Action {
Dig(p) => write!(f, "dig {} {}", p.x, p.y),
Shoot(dir) => write!(f, "shoot {}", dir),
Bomb(p) => write!(f, "banana {} {}", p.x, p.y),
+ Snowball(p) => write!(f, "snowball {} {}", p.x, p.y),
DoNothing => write!(f, "nothing"),
}
}