From aed9ad18c72c016da7894328710e9996c5629c0a Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Thu, 23 Nov 2017 04:35:03 -0600 Subject: -added giving a destination to units --- src/main.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 7044467..f847253 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,18 +41,24 @@ fn main() { let mut list = List::new(map.impassable.to_vec()); loop{ - match main.getch() { + let order = match main.getch() { Some(Input::Character(c)) => { match c { - 'h' => cursor.location.1 -= 1, - 'l' => cursor.location.1 += 1, - 'k' => cursor.location.0 -= 1, - 'j' => cursor.location.0 += 1, + 'h' => {cursor.location.1 -= 1; None} + 'l' => {cursor.location.1 += 1; None} + 'k' => {cursor.location.0 -= 1; None} + 'j' => {cursor.location.0 += 1; None} 'q' => break, - _ => (), + 'o' => Some(cursor.location), + _ => None, } }, - _ => () + _ => None + }; + + match order { + None => (), + Some(location) => (list.give_destination(location)), } list.action(); -- cgit v1.2.3