allow empty dialogues (needs fixing)

This commit is contained in:
Max Bradbury 2020-04-14 00:32:24 +01:00
parent a7c81f7f6c
commit cc347dbf99
1 changed files with 7 additions and 1 deletions

View File

@ -8,9 +8,15 @@ pub struct Ending {
impl From<String> for Ending {
fn from(string: String) -> Ending {
let string = string.replace("END ", "");
// todo this is wrong - we shouldn't be splitting on lines
let id_dialogue: Vec<&str> = string.lines().collect();
let id = id_dialogue[0].to_string();
let dialogue = id_dialogue[1].to_string();
let dialogue = if id_dialogue.len() > 1 {
id_dialogue[1]
} else {
""
}.to_string();
Ending { id, dialogue }
}