diff --git a/src/game.rs b/src/game.rs index e8887ba..f38d93d 100644 --- a/src/game.rs +++ b/src/game.rs @@ -4,6 +4,8 @@ use std::str::FromStr; use std::collections::HashMap; use std::borrow::BorrowMut; use crate::image::Image; +use std::fmt; +use std::fmt::Display; /// in very early versions of Bitsy, room tiles were defined as single alphanumeric characters - /// so there was a maximum of 36 unique tiles. later versions are comma-separated. @@ -77,6 +79,18 @@ pub enum NotFound { Tile, } +impl Display for NotFound { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f,"Not found: {} data", match self { + &NotFound::Anything => "game", + &NotFound::Avatar => "avatar", + &NotFound::Room => "room", + &NotFound::Sprite => "sprite", + &NotFound::Tile => "tile", + }) + } +} + #[derive(Clone, Debug, PartialEq)] pub struct Game { pub name: String,