handle errors for exit

This commit is contained in:
2020-04-29 20:43:49 +01:00
parent 5bfcc9ab4c
commit e760027ae4
2 changed files with 45 additions and 33 deletions

View File

@@ -84,18 +84,24 @@ impl From<String> for Room {
if position.is_ok() {
let position = position.unwrap();
let exit = Exit::from(format!("{} {}", parts[1], parts[2]));
let mut transition = None;
let mut dialogue_id = None;
let chunks = parts[3..].chunks(2);
for chunk in chunks {
if chunk[0] == "FX" {
transition = Some(Transition::from(chunk[1]));
} else if chunk[0] == "DLG" {
dialogue_id = Some(chunk[1].to_string());
let exit = Exit::from_str(
&format!("{} {}", parts[1], parts[2])
);
if exit.is_ok() {
let exit = exit.unwrap();
let mut transition = None;
let mut dialogue_id = None;
let chunks = parts[3..].chunks(2);
for chunk in chunks {
if chunk[0] == "FX" {
transition = Some(Transition::from(chunk[1]));
} else if chunk[0] == "DLG" {
dialogue_id = Some(chunk[1].to_string());
}
}
exits.push(ExitInstance { position, exit, transition, dialogue_id });
}
exits.push(ExitInstance { position, exit, transition, dialogue_id });
}
} else if last_line.starts_with("END") {
let last_line = last_line.replace("END ", "");