don't try to get tiles with ID of zero; test this
This commit is contained in:
parent
5de02c5950
commit
93a50e6b86
14
src/game.rs
14
src/game.rs
|
@ -318,6 +318,12 @@ impl Game {
|
|||
let mut tile_ids = room.unwrap().tiles.clone();
|
||||
tile_ids.sort();
|
||||
tile_ids.dedup();
|
||||
// remove 0 as this isn't a real tile
|
||||
let zero_index = tile_ids.iter()
|
||||
.position(|i| i == &"0".to_string());
|
||||
if zero_index.is_some() {
|
||||
tile_ids.remove(zero_index.unwrap());
|
||||
}
|
||||
// remove Ok once this function returns a result
|
||||
Ok(self.get_tiles_by_ids(tile_ids))
|
||||
}
|
||||
|
@ -679,4 +685,12 @@ mod test {
|
|||
game.version = Some(Version { major: 5, minor: 0 });
|
||||
assert!(game.to_string().contains("# BITSY VERSION 5.0"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_tiles_for_room() {
|
||||
assert_eq!(
|
||||
crate::mock::game_default().get_tiles_for_room("0".to_string()).unwrap(),
|
||||
vec![&crate::mock::tile_default()]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue