From 6e9b91d8456adf66a43178bf3295cc77e4f286c6 Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Mon, 6 Apr 2020 20:35:01 +0100 Subject: [PATCH] handle room endings --- src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 37fd66d..f8eb1a3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -735,7 +735,13 @@ fn room_from_string(string: String) -> Room { exits.insert(position, exit); } else if last_line.starts_with("END") { + let last_line = last_line.replace("END ", ""); + let ending_position: Vec<&str> = last_line.split(' ').collect(); + let ending= ending_position[0].to_string(); + let position = ending_position[1].to_string(); + let position = position_from_string(position); + endings.insert(position, ending); } else { lines.push(last_line); break; } @@ -748,7 +754,7 @@ fn room_from_string(string: String) -> Room { tiles: vec![], items, exits, - endings: Default::default() + endings } }