tidyup
This commit is contained in:
parent
a0d109c0b8
commit
2955a81296
71
src/game.rs
71
src/game.rs
|
@ -142,9 +142,7 @@ impl Game {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let dialogue_segments =
|
let dialogue_segments = format!("\n\nDLG{}", extra.trim_matches('\n'));
|
||||||
format!("\n\nDLG{}", extra.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);
|
||||||
|
@ -167,7 +165,9 @@ impl Game {
|
||||||
let mut sprites: Vec<Sprite> = Vec::new();
|
let mut sprites: Vec<Sprite> = Vec::new();
|
||||||
let mut items: Vec<Item> = Vec::new();
|
let mut items: Vec<Item> = Vec::new();
|
||||||
|
|
||||||
for segment in segments[1..].to_owned() {
|
let segments = segments[1..].to_owned();
|
||||||
|
|
||||||
|
for segment in segments {
|
||||||
let segment = segment.to_string();
|
let segment = segment.to_string();
|
||||||
|
|
||||||
if segment.starts_with("# BITSY VERSION") {
|
if segment.starts_with("# BITSY VERSION") {
|
||||||
|
@ -334,6 +334,7 @@ impl Game {
|
||||||
|
|
||||||
new_id + 1
|
new_id + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
/// adds a tile safely and returns the new tile ID
|
/// adds a tile safely and returns the new tile ID
|
||||||
pub fn add_tile(&mut self, mut tile: Tile) -> u64 {
|
pub fn add_tile(&mut self, mut tile: Tile) -> u64 {
|
||||||
let new_id = self.new_tile_id();
|
let new_id = self.new_tile_id();
|
||||||
|
@ -449,68 +450,6 @@ mod test {
|
||||||
assert_eq!(game.tiles.len(), 3);
|
assert_eq!(game.tiles.len(), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_bitsy_omnibus() {
|
|
||||||
let acceptable_failures: Vec<String> = vec![
|
|
||||||
// fails because of sprite colours but also because a tile contains "NaN"
|
|
||||||
"src/test-resources/omnibus/DA88C287.bitsy.txt".to_string(),
|
|
||||||
// SET instead of ROOM? todo investigate
|
|
||||||
"src/test-resources/omnibus/1998508E.bitsy.txt".to_string(),
|
|
||||||
"src/test-resources/omnibus/046871F8.bitsy.txt".to_string(),
|
|
||||||
// not sure about this one but it uses room wall array
|
|
||||||
"src/test-resources/omnibus/748F77B5.bitsy.txt".to_string(),
|
|
||||||
// bad game data
|
|
||||||
"src/test-resources/omnibus/14C48FA0.bitsy.txt".to_string(),
|
|
||||||
"src/test-resources/omnibus/C63A0633.bitsy.txt".to_string(),
|
|
||||||
"src/test-resources/omnibus/C63A0633.bitsy.txt".to_string(),
|
|
||||||
"src/test-resources/omnibus/013B3CDE.bitsy.txt".to_string(), // NaN in image
|
|
||||||
// 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(),
|
|
||||||
// has an ending position of -1
|
|
||||||
"src/test-resources/omnibus/593BD9A6.bitsy.txt".to_string(),
|
|
||||||
// extra line between dialogues
|
|
||||||
"src/test-resources/omnibus/DB59A848.bitsy.txt".to_string(),
|
|
||||||
// something going on with dialogues? todo investigate
|
|
||||||
"src/test-resources/omnibus/807805CC.bitsy.txt".to_string(),
|
|
||||||
"src/test-resources/omnibus/C36E27E5.bitsy.txt".to_string(),
|
|
||||||
"src/test-resources/omnibus/354DA56F.bitsy.txt".to_string(),
|
|
||||||
// this avatar has `ITM 0 1` - can the player start with an item? todo investigate
|
|
||||||
"src/test-resources/omnibus/CC5085BE.bitsy.txt".to_string(),
|
|
||||||
"src/test-resources/omnibus/20D06BD1.bitsy.txt".to_string(),
|
|
||||||
];
|
|
||||||
|
|
||||||
let mut passes = 0;
|
|
||||||
let mut skips = 0;
|
|
||||||
|
|
||||||
let files = std::fs::read_dir("src/test-resources/omnibus");
|
|
||||||
|
|
||||||
if !files.is_ok() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for file in files.unwrap() {
|
|
||||||
let path = file.unwrap().path();
|
|
||||||
let nice_name = format!("{}", path.display());
|
|
||||||
|
|
||||||
if !nice_name.contains("bitsy") || acceptable_failures.contains(&nice_name) {
|
|
||||||
skips += 1;
|
|
||||||
// println!("Skipping: {}", nice_name);
|
|
||||||
println!("Skipped. {} passes, {} skips.", passes, skips);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("Testing: {}...", path.display());
|
|
||||||
let game_data = std::fs::read_to_string(path).unwrap();
|
|
||||||
let game = Game::from(game_data.clone()).unwrap();
|
|
||||||
assert_eq!(
|
|
||||||
game.to_string().trim_matches('\n'),
|
|
||||||
game_data.trim_matches('\n')
|
|
||||||
);
|
|
||||||
passes += 1;
|
|
||||||
println!("Success! {} passes, {} skips.", passes, skips);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_arabic() {
|
fn test_arabic() {
|
||||||
let game = Game::from(include_str!("test-resources/arabic.bitsy").to_string()).unwrap();
|
let game = Game::from(include_str!("test-resources/arabic.bitsy").to_string()).unwrap();
|
||||||
|
|
Loading…
Reference in New Issue