fix ending from string (allow "END " in dialogue, and multi-line dialogues)
This commit is contained in:
parent
7a8ec4e5d2
commit
d955f4ee71
|
@ -7,17 +7,9 @@ pub struct Ending {
|
||||||
|
|
||||||
impl From<String> for Ending {
|
impl From<String> for Ending {
|
||||||
fn from(string: String) -> Ending {
|
fn from(string: String) -> Ending {
|
||||||
let string = string.replace("END ", "");
|
let lines: Vec<&str> = string.lines().collect();
|
||||||
// todo this is wrong - we shouldn't be splitting on lines
|
let id = lines[0].replace("END ", "").to_string();
|
||||||
let id_dialogue: Vec<&str> = string.lines().collect();
|
let dialogue = lines[1..].join("");
|
||||||
let id = id_dialogue[0].to_string();
|
|
||||||
|
|
||||||
let dialogue = if id_dialogue.len() > 1 {
|
|
||||||
id_dialogue[1]
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
.to_string();
|
|
||||||
|
|
||||||
Ending { id, dialogue }
|
Ending { id, dialogue }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue