use radix_fmt::radix_36; pub mod avatar; pub mod colour; pub mod dialogue; pub mod ending; pub mod exit; pub mod game; pub mod palette; pub mod image; pub mod item; pub mod mock; pub mod position; pub mod room; pub mod sprite; pub mod tile; pub mod variable; use avatar::Avatar; use colour::Colour; use dialogue::Dialogue; use ending::Ending; use exit::{Transition, Exit}; use game::Game; use palette::Palette; use image::Image; use item::Item; use position::Position; use room::Room; use sprite::Sprite; use tile::Tile; use variable::Variable; #[derive(Debug, Eq, PartialEq)] pub struct Instance { position: Position, id: String, // item / ending.rs id } #[derive(Debug, Eq, PartialEq)] pub struct ExitInstance { position: Position, exit: Exit, } pub trait AnimationFrames { fn to_string(&self) -> String; } impl AnimationFrames for Vec { #[inline] fn to_string(&self) -> String { let mut string = String::new(); let last_frame = self.len() - 1; for (i, frame) in self.into_iter().enumerate() { string.push_str(&frame.to_string()); if i < last_frame { string.push_str(&"\n>\n".to_string()); } } string } } fn from_base36(str: &str) -> u64 { u64::from_str_radix(str, 36).unwrap() } #[test] fn test_from_base36() { assert_eq!(from_base36("0"), 0); assert_eq!(from_base36("0z"), 35); assert_eq!(from_base36("11"), 37); } fn to_base36(input: u64) -> String { format!("{}", radix_36(input)) } #[test] fn test_to_base36() { assert_eq!(to_base36(37), "11"); }