handle exits

This commit is contained in:
Max Bradbury 2020-04-06 14:21:58 +01:00
parent b9fecbe8fa
commit 19f01e05d8
1 changed files with 7 additions and 2 deletions

View File

@ -640,7 +640,7 @@ fn room_from_string(string: String) -> Room {
let mut name = None; let mut name = None;
let mut palette = "0".to_string(); let mut palette = "0".to_string();
let mut items: HashMap<Position, String> = HashMap::new(); let mut items: HashMap<Position, String> = HashMap::new();
let exits: HashMap<Position, Exit> = HashMap::new(); let mut exits: HashMap<Position, Exit> = HashMap::new();
let endings: HashMap<Position, Ending> = HashMap::new(); let endings: HashMap<Position, Ending> = HashMap::new();
loop { loop {
@ -661,7 +661,12 @@ fn room_from_string(string: String) -> Room {
item_id.to_string() item_id.to_string()
); );
} else if last_line.starts_with("EXT") { } 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 if last_line.starts_with("END") {
} else { } else {
@ -675,7 +680,7 @@ fn room_from_string(string: String) -> Room {
name, name,
tiles: vec![], tiles: vec![],
items: Default::default(), items: Default::default(),
exits: Default::default(), exits,
endings: Default::default() endings: Default::default()
} }
} }