summaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2018-06-05 02:21:04 -0500
committertom barrett <spalf0@gmail.com>2018-06-05 02:21:04 -0500
commitf6c9fbea8f535febaf51dc08c353e985aa73988d (patch)
tree7168eeb42589b8e425b895a423fdcd4c83c64ae6 /src/server
parentd2b75c42c1c494c2796188a5d600dddb913f5a5d (diff)
frail implementation of mining
Diffstat (limited to 'src/server')
-rw-r--r--src/server/mining.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/server/mining.rs b/src/server/mining.rs
index c64f03e..91210f8 100644
--- a/src/server/mining.rs
+++ b/src/server/mining.rs
@@ -14,8 +14,8 @@ use server::connection::ServerConnection;
pub struct MiningData {
pub has_astroid_target : bool,
pub is_within_range : bool,
- pub range : f64,
pub status : bool,
+ pub range : f64,
}
impl ServerConnection {
@@ -23,6 +23,7 @@ impl ServerConnection {
let mut ship = masses.remove(&self.name).unwrap();
let ship_clone = ship.clone();
let mut connection_good = true;
+ let mut item = None;
if let MassType::Ship{ref mut mining, ref navigation, ..} = ship.mass_type {
let mut mining = mining.as_mut().unwrap();
@@ -51,6 +52,27 @@ impl ServerConnection {
}
Err(_error) => (),
}
+
+ if !mining_data.is_within_range {
+ mining.off();
+ }
+ else {
+ if mining.status && mining.ready {
+ mining.take();
+ match navigation.target_name.clone() {
+ Some(name) => {
+ let target = masses.get_mut(&name).unwrap();
+ item = target.take("Iron");
+ }
+ _ => (),
+ }
+ }
+ }
+ }
+
+ match item {
+ Some(item) => ship.give(item),
+ None => (),
}
masses.insert(self.name.clone(), ship);