summaryrefslogtreecommitdiff
path: root/src/engine
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2018-08-29 20:52:15 +0200
committerJustin Worthe <justin@worthe-it.co.za>2018-08-29 20:52:15 +0200
commite5a09e11e8a99440d22d9f4cbde97f0e3d6fca7b (patch)
treedf158f70c71ba911747d520e0c731a96f7586dc6 /src/engine
parent5c33043385cf540de90f54d07225517aff01df01 (diff)
Added targeted waiting to evaluated moves
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/bitwise_engine.rs2
-rw-r--r--src/engine/command.rs25
2 files changed, 26 insertions, 1 deletions
diff --git a/src/engine/bitwise_engine.rs b/src/engine/bitwise_engine.rs
index 873b6e5..d54ccc0 100644
--- a/src/engine/bitwise_engine.rs
+++ b/src/engine/bitwise_engine.rs
@@ -333,7 +333,7 @@ impl Player {
}
pub fn can_build_iron_curtain(&self) -> bool {
- self.iron_curtain_available && self.iron_curtain_remaining == 0 && self.energy >= IRON_CURTAIN_PRICE
+ self.iron_curtain_available && self.iron_curtain_remaining == 0
}
pub fn unoccupied_cell_count(&self) -> usize { self.occupied.count_zeros() as usize }
diff --git a/src/engine/command.rs b/src/engine/command.rs
index d026bca..764e3cb 100644
--- a/src/engine/command.rs
+++ b/src/engine/command.rs
@@ -1,4 +1,5 @@
use std::fmt;
+use super::constants::*;
use super::geometry::Point;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -18,6 +19,19 @@ impl fmt::Display for Command {
}
}
+impl Command {
+ pub fn cant_build_yet(&self, energy: u16) -> bool {
+ use self::Command::*;
+
+ match self {
+ Nothing => false,
+ Build(_, b) => b.cant_build_yet(energy),
+ IronCurtain => energy < IRON_CURTAIN_PRICE
+ }
+ }
+}
+
+
#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BuildingType {
@@ -38,4 +52,15 @@ impl BuildingType {
if id <= 4 && id != 3 { Some(unsafe { mem::transmute(id) }) } else { None }
}
+ pub fn cant_build_yet(&self, energy: u16) -> bool {
+ use self::BuildingType::*;
+
+ let required = match self {
+ Defence => DEFENCE_PRICE,
+ Attack => MISSILE_PRICE,
+ Energy => ENERGY_PRICE,
+ Tesla => TESLA_PRICE
+ };
+ energy < required
+ }
}