summaryrefslogtreecommitdiff
path: root/src/engine/command.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/command.rs')
-rw-r--r--src/engine/command.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/engine/command.rs b/src/engine/command.rs
index b350d65..7a2594d 100644
--- a/src/engine/command.rs
+++ b/src/engine/command.rs
@@ -5,6 +5,7 @@ use super::geometry::Point;
pub enum Command {
Nothing,
Build(Point, BuildingType),
+ Deconstruct(Point)
}
impl fmt::Display for Command {
@@ -12,6 +13,7 @@ impl fmt::Display for Command {
match *self {
Command::Nothing => write!(f, ""),
Command::Build(p, b) => write!(f, "{},{},{}", p.x, p.y, b as u8),
+ Command::Deconstruct(p) => write!(f, "3,{},{}", p.x, p.y),
}
}
}
@@ -22,18 +24,18 @@ pub enum BuildingType {
Defence = 0,
Attack = 1,
Energy = 2,
+ Tesla = 4,
}
impl BuildingType {
- pub fn all() -> [BuildingType; 3] {
+ pub fn all() -> [BuildingType; 4] {
use self::BuildingType::*;
- [Defence, Attack, Energy]
+ [Defence, Attack, Energy, Tesla]
}
- fn count() -> u8 { BuildingType::Energy as u8 + 1 }
pub fn from_u8(id: u8) -> Option<BuildingType> {
use std::mem;
- if id < Self::count() { Some(unsafe { mem::transmute(id) }) } else { None }
+ if id < 4 && id != 3 { Some(unsafe { mem::transmute(id) }) } else { None }
}
}