summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorTom Barrett <tombarrett@siu.edu>2017-11-23 04:35:03 -0600
committerTom Barrett <tombarrett@siu.edu>2017-11-23 04:35:03 -0600
commitaed9ad18c72c016da7894328710e9996c5629c0a (patch)
treebac1f73fef4845ea7729801f085aa599120f5abd /src/main.rs
parent72ea9deb1cf959602a038e5141a86228186a35b3 (diff)
-added giving a destination to units
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs20
1 files changed, 13 insertions, 7 deletions
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();