diff --git a/src/game.rs b/src/game.rs index b89b94f..786b93b 100644 --- a/src/game.rs +++ b/src/game.rs @@ -230,7 +230,7 @@ impl Game { if ! avatar_exists { return Err(NotFound::Avatar); } - + Ok( Game { name, @@ -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()] + ) + } }