allow trailing spaces in dialogues
This commit is contained in:
parent
2e5d063371
commit
8b05645c6b
16
src/game.rs
16
src/game.rs
|
@ -35,7 +35,7 @@ pub struct Game {
|
||||||
|
|
||||||
impl From<String> for Game {
|
impl From<String> for Game {
|
||||||
fn from(string: String) -> Game {
|
fn from(string: String) -> Game {
|
||||||
let mut string = format!("{}\n\n", string.trim());
|
let mut string = format!("{}\n\n", string.trim_matches('\n'));
|
||||||
|
|
||||||
if string.starts_with("# BITSY VERSION") {
|
if string.starts_with("# BITSY VERSION") {
|
||||||
string = format!("\n\n{}", string);
|
string = format!("\n\n{}", string);
|
||||||
|
@ -76,7 +76,11 @@ impl From<String> for Game {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let dialogue_segments = format!("\n\nDLG {}", dialogues_endings_variables.trim());
|
let dialogue_segments = format!(
|
||||||
|
"\n\nDLG{}",
|
||||||
|
dialogues_endings_variables.trim_matches('\n')
|
||||||
|
);
|
||||||
|
|
||||||
let dialogue_segments: Vec<&str> = dialogue_segments.split("\n\nDLG").collect();
|
let dialogue_segments: Vec<&str> = dialogue_segments.split("\n\nDLG").collect();
|
||||||
for segment in dialogue_segments[1..].to_owned() {
|
for segment in dialogue_segments[1..].to_owned() {
|
||||||
let segment = format!("DLG{}", segment);
|
let segment = format!("DLG{}", segment);
|
||||||
|
@ -369,12 +373,6 @@ fn test_bitsy_omnibus() {
|
||||||
// this one has font data appended to the end of the game data - is this valid?
|
// this one has font data appended to the end of the game data - is this valid?
|
||||||
"src/test-resources/omnibus/4B4EB988.bitsy.txt".to_string(),
|
"src/test-resources/omnibus/4B4EB988.bitsy.txt".to_string(),
|
||||||
|
|
||||||
// one of the dialogues has a trailing space - todo this should be allowed I think
|
|
||||||
"src/test-resources/omnibus/11018B25.bitsy.txt".to_string(),
|
|
||||||
"src/test-resources/omnibus/FEC6E602.bitsy.txt".to_string(),
|
|
||||||
"src/test-resources/omnibus/3E8C3022.bitsy.txt".to_string(),
|
|
||||||
"src/test-resources/omnibus/F08D7D88.bitsy.txt".to_string(),
|
|
||||||
|
|
||||||
// has an ending position of -1
|
// has an ending position of -1
|
||||||
"src/test-resources/omnibus/593BD9A6.bitsy.txt".to_string(),
|
"src/test-resources/omnibus/593BD9A6.bitsy.txt".to_string(),
|
||||||
|
|
||||||
|
@ -410,7 +408,7 @@ fn test_bitsy_omnibus() {
|
||||||
println!("Testing: {}...", path.display());
|
println!("Testing: {}...", path.display());
|
||||||
let game_data = std::fs::read_to_string(path).unwrap();
|
let game_data = std::fs::read_to_string(path).unwrap();
|
||||||
let game = Game::from(game_data.clone());
|
let game = Game::from(game_data.clone());
|
||||||
assert_eq!(game.to_string().trim(), game_data.trim());
|
assert_eq!(game.to_string().trim_matches('\n'), game_data.trim_matches('\n'));
|
||||||
passes += 1;
|
passes += 1;
|
||||||
println!("Success! {} passes, {} skips.", passes, skips);
|
println!("Success! {} passes, {} skips.", passes, skips);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue