summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-02-13 13:25:00 -0600
committertom barrett <spalf0@gmail.com>2019-02-13 13:25:00 -0600
commit284cac8f4034f15e7edeba5c8232a770fc082e20 (patch)
tree8f73230bae89c3bf796e47f7c52ac84f7015bd09 /src/client
parent070485e093dc540a5db9650d438cffe3d18d3883 (diff)
added engine fuel and simplified/unified txrx from server
Diffstat (limited to 'src/client')
-rw-r--r--src/client/engines.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/client/engines.rs b/src/client/engines.rs
index 8f83998..60ffcfd 100644
--- a/src/client/engines.rs
+++ b/src/client/engines.rs
@@ -9,6 +9,8 @@ use std::net::TcpStream;
use std::thread::sleep;
use std::time::Duration;
+use crate::server::engines::EnginesData;
+
pub fn client_engines(mut stream: TcpStream, mut buff_r: BufReader<TcpStream>) {
let stdout = stdout();
let mut stdout = stdout.lock().into_raw_mode().unwrap();
@@ -17,13 +19,14 @@ pub fn client_engines(mut stream: TcpStream, mut buff_r: BufReader<TcpStream>) {
loop {
let mut recv = String::new();
buff_r.read_line(&mut recv).unwrap();
- let has_target = serde_json::from_str(&recv.replace("\n", "")).unwrap();
+ let engines_data: EnginesData = serde_json::from_str(&recv.replace("\n", "")).unwrap();
writeln!(
stdout,
- "{}{}use numpad to freely move",
+ "{}{}{}Fuel\nuse numpad to freely move",
termion::clear::All,
- termion::cursor::Goto(1, 1)
+ termion::cursor::Goto(1, 1),
+ engines_data.fuel
)
.unwrap();
write!(stdout, "{}+ : speedup", termion::cursor::Goto(1, 2)).unwrap();
@@ -31,7 +34,7 @@ pub fn client_engines(mut stream: TcpStream, mut buff_r: BufReader<TcpStream>) {
write!(stdout, "{}s : stop", termion::cursor::Goto(1, 4)).unwrap();
write!(stdout, "{}q : quit", termion::cursor::Goto(1, 5)).unwrap();
- if has_target {
+ if engines_data.has_target {
write!(
stdout,
"{}c : mimic targets velocity vector",