summaryrefslogtreecommitdiff
path: root/src/server/construction.rs
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-02-14 12:05:57 -0600
committertom barrett <spalf0@gmail.com>2019-02-14 12:05:57 -0600
commit35b43264c09405c987b48de78b6ca19f29dc7849 (patch)
treee57fd46c3147d4ab1227d8688ebb23778dd3d21c /src/server/construction.rs
parent284cac8f4034f15e7edeba5c8232a770fc082e20 (diff)
simplified receive pattern even more and moved all controls to the module
Diffstat (limited to 'src/server/construction.rs')
-rw-r--r--src/server/construction.rs15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/server/construction.rs b/src/server/construction.rs
index d45135c..50a193a 100644
--- a/src/server/construction.rs
+++ b/src/server/construction.rs
@@ -9,7 +9,7 @@ use crate::mass::{Mass, MassType};
use crate::modules::construction::Construction;
use crate::modules::construction::ConstructionStatus;
use crate::modules::types::ModuleType;
-use crate::server::connection::{receive, ServerConnection};
+use crate::server::connection::ServerConnection;
use crate::storage::Storage;
#[derive(Serialize, Deserialize, Debug, Clone)]
@@ -28,22 +28,13 @@ impl ServerConnection {
..
} = ship.mass_type
{
- let construction = construction.as_mut().unwrap();
let construction_data = get_construction_data(storage, construction);
let send = serde_json::to_string(&construction_data).unwrap() + "\n";
self.open = self.stream.write(send.as_bytes()).is_ok();
- match receive(&mut self.buff_r) {
- Some(recv) => {
- if let "c" = recv.as_str() {
- if construction_data.has_enough {
- construction.toggle();
- }
- }
- }
- None => self.open = false,
- }
+ let recv = self.receive();
+ construction.give_recv(recv, &construction_data);
if construction_data.status == ConstructionStatus::Constructed {
storage.take_items(ItemType::Iron, constants::SHIP_CONSTRUCTION_IRON_COST);