From 19f01e05d8cb7cd22e019ccef80fa27553f37270 Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Mon, 6 Apr 2020 14:21:58 +0100 Subject: [PATCH] handle exits --- src/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1f63097..ee6aeec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -640,7 +640,7 @@ fn room_from_string(string: String) -> Room { let mut name = None; let mut palette = "0".to_string(); let mut items: HashMap = HashMap::new(); - let exits: HashMap = HashMap::new(); + let mut exits: HashMap = HashMap::new(); let endings: HashMap = HashMap::new(); loop { @@ -661,7 +661,12 @@ fn room_from_string(string: String) -> Room { item_id.to_string() ); } else if last_line.starts_with("EXT") { + let last_line = last_line.replace("EXT ", ""); + let parts: Vec<&str> = last_line.split(' ').collect(); + let position = position_from_string(parts[0].to_string()); + let exit = exit_from_string(format!("{} {}", parts[1], parts[2])); + exits.insert(position, exit); } else if last_line.starts_with("END") { } else { @@ -675,7 +680,7 @@ fn room_from_string(string: String) -> Room { name, tiles: vec![], items: Default::default(), - exits: Default::default(), + exits, endings: Default::default() } }