From 9dfaaa0173fb44faebd82d46db03956b250bddf5 Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Sun, 12 Apr 2020 14:38:07 +0100 Subject: [PATCH] game module --- README.md | 6 +- src/game.rs | 182 +++++++++++++++++++++++++++++ src/lib.rs | 327 +--------------------------------------------------- src/mock.rs | 146 ++++++++++++++++++++++- 4 files changed, 330 insertions(+), 331 deletions(-) create mode 100644 src/game.rs diff --git a/README.md b/README.md index c928fe8..c04c85d 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,7 @@ a library for parsing Bitsy game data. ### tidy up -split into multiple files - -move tests to their own suite - -migrate to idiomatic rust etc. +* refactor the more shonky bits to idiomatic rust ### documentation diff --git a/src/game.rs b/src/game.rs new file mode 100644 index 0000000..b02e5c4 --- /dev/null +++ b/src/game.rs @@ -0,0 +1,182 @@ +use crate::{Avatar, Dialogue, Ending, Item, Palette, Room, Sprite, Tile, Variable, mock}; + +#[derive(Debug, PartialEq)] +pub struct Game { + pub(crate) name: String, + pub(crate) version: f64, + pub(crate) room_format: u8, + pub(crate) palettes: Vec, + pub(crate) rooms: Vec, + pub(crate) tiles: Vec, + pub(crate) avatar: Avatar, + pub(crate) sprites: Vec, + pub(crate) items: Vec, + pub(crate) dialogues: Vec, + pub(crate) endings: Vec, + pub(crate) variables: Vec, +} + +impl From for Game { + fn from(string: String) -> Game { + // dialogues and endings can have 2+ line breaks inside, so deal with these separately + // otherwise, everything can be split on a double line break (\n\n) + let mut dialogues: Vec = Vec::new(); + let mut endings: Vec = Vec::new(); + let mut variables: Vec = Vec::new(); + let main_split: Vec<&str> = string.split("\n\nDLG").collect(); + let main = main_split[0].to_string(); + let mut dialogues_endings_variables: String = main_split[1..].join("\n\nDLG"); + + let variable_segments = dialogues_endings_variables.clone(); + let variable_segments: Vec<&str> = variable_segments.split("\n\nVAR").collect(); + if variable_segments.len() > 0 { + dialogues_endings_variables = variable_segments[0].to_string(); + let variable_segments = variable_segments[1..].to_owned(); + + for segment in variable_segments { + let segment = format!("VAR{}", segment); + variables.push(Variable::from(segment)); + } + } + + let ending_segments = dialogues_endings_variables.clone(); + let ending_segments: Vec<&str> = ending_segments.split("\n\nEND").collect(); + if ending_segments.len() > 0 { + dialogues_endings_variables = ending_segments[0].to_string(); + let ending_segments = ending_segments[1..].to_owned(); + + for segment in ending_segments { + let segment = format!("END{}", segment); + endings.push(Ending::from(segment)); + } + } + + let dialogue_segments = format!("\n\nDLG {}", dialogues_endings_variables.trim()); + let dialogue_segments: Vec<&str> = dialogue_segments.split("\n\nDLG").collect(); + for segment in dialogue_segments[1..].to_owned() { + let segment = format!("DLG{}", segment); + dialogues.push(Dialogue::from(segment)); + } + + let segments: Vec<&str> = main.split("\n\n").collect(); + + let name = segments[0].to_string(); + let mut version: f64 = 1.0; + let mut room_format: u8 = 1; + let mut palettes: Vec = Vec::new(); + let mut rooms: Vec = Vec::new(); + let mut tiles: Vec = Vec::new(); + let mut avatar: Option = None; // unwrap this later + let mut sprites: Vec = Vec::new(); + let mut items: Vec = Vec::new(); + + for segment in segments[1..].to_owned() { + let segment = segment.to_string(); + + if segment.starts_with("# BITSY VERSION") { + version = segment.replace("# BITSY VERSION ", "").parse().unwrap(); + } else if segment.starts_with("! ROOM_FORMAT") { + room_format = segment.replace("! ROOM_FORMAT ", "").parse().unwrap(); + } else if segment.starts_with("PAL") { + palettes.push(Palette::from(segment)); + } else if segment.starts_with("ROOM") { + rooms.push(Room::from(segment)); + } else if segment.starts_with("TIL") { + tiles.push(Tile::from(segment)); + } else if segment.starts_with("SPR A") { + avatar = Some(Avatar::from(segment)); + } else if segment.starts_with("SPR") { + sprites.push(Sprite::from(segment)); + } else if segment.starts_with("ITM") { + items.push(Item::from(segment)); + } + } + + assert!(avatar.is_some()); + let avatar = avatar.unwrap(); + + Game { + name, + version, + room_format, + palettes, + rooms, + tiles, + avatar, + sprites, + items, + dialogues, + endings, + variables, + } + } +} + +impl ToString for Game { + #[inline] + fn to_string(&self) -> String { + let mut segments: Vec = Vec::new(); + + // todo refactor + + for palette in &self.palettes { + segments.push(palette.to_string()); + } + + for room in &self.rooms { + segments.push(room.to_string()); + } + + for tile in &self.tiles { + segments.push(tile.to_string()); + } + + segments.push(self.avatar.to_string()); + + for sprite in &self.sprites { + segments.push(sprite.to_string()); + } + + for item in &self.items { + segments.push(item.to_string()); + } + + for dialogue in &self.dialogues { + segments.push(dialogue.to_string()); + } + + for ending in &self.endings { + segments.push(ending.to_string()); + } + + for variable in &self.variables { + segments.push(variable.to_string()); + } + + format!( + "{}\n\n# BITSY VERSION {}\n\n! ROOM_FORMAT {}\n\n{}\n\n", + &self.name, + &self.version, + &self.room_format, + segments.join("\n\n"), + ) + } +} + +#[test] +fn test_game_from_string() { + let output = Game::from( + include_str!["../test/resources/default.bitsy"].to_string() + ); + + let expected = mock::game_default(); + + assert_eq!(output, expected); +} + +#[test] +fn test_game_to_string() { + let output = mock::game_default().to_string(); + let expected = include_str!["../test/resources/default.bitsy"].to_string(); + assert_eq!(output, expected); +} diff --git a/src/lib.rs b/src/lib.rs index 7115514..47672b1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ pub mod colour; pub mod dialogue; pub mod ending; pub mod exit; +pub mod game; pub mod palette; pub mod image; pub mod item; @@ -18,6 +19,7 @@ use colour::Colour; use dialogue::Dialogue; use ending::Ending; use exit::Exit; +use game::Game; use palette::Palette; use image::Image; use item::Item; @@ -39,166 +41,6 @@ pub struct ExitInstance { exit: Exit, } -#[derive(Debug, PartialEq)] -pub struct Game { - name: String, - version: f64, - room_format: u8, - palettes: Vec, - rooms: Vec, - tiles: Vec, - avatar: Avatar, - sprites: Vec, - items: Vec, - dialogues: Vec, - endings: Vec, - variables: Vec, -} - -fn example_game_default() -> Game { - Game { - name: "Write your game's title here".to_string(), - version: 6.5, - room_format: 1, - palettes: vec![ - Palette { - id: "0".to_string(), - name: None, - colours: vec![ - Colour {red: 0, green: 82, blue: 204 }, - Colour {red: 128, green: 159, blue: 255 }, - Colour {red: 255, green: 255, blue: 255 }, - ] - } - ], - rooms: vec![ - Room { - id: "0".to_string(), - palette: "0".to_string(), - name: None, - tiles: vec![ - "0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(), - "0".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"0".to_string(), - "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), - "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), - "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), - "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), - "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), - "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), - "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), - "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), - "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), - "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), - "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), - "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), - "0".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"0".to_string(), - "0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(), - ], - items: vec![], - exits: vec![], - endings: vec![] - } - ], - tiles: vec![ - Tile { - id: "a".to_string(), - name: None, - wall: false, - animation_frames: vec![ - Image { - pixels: vec![ - 1,1,1,1,1,1,1,1, - 1,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,1, - 1,0,0,1,1,0,0,1, - 1,0,0,1,1,0,0,1, - 1,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,1, - 1,1,1,1,1,1,1,1, - ] - } - ] - } - ], - avatar: Avatar { - animation_frames: vec![ - Image { - pixels: vec![ - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,1,1,1,1,0, - 1,0,1,1,1,1,0,1, - 0,0,1,0,0,1,0,0, - 0,0,1,0,0,1,0,0, - ] - } - ], - room: "0".to_string(), - position: Position { x: 4, y: 4 } - }, - sprites: vec![ - Sprite { - id: "a".to_string(), - name: None, - animation_frames: vec![ - Image { - pixels: vec![ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,0,1,0,0,0,1, - 0,1,1,1,0,0,0,1, - 0,1,1,1,0,0,1,0, - 0,1,1,1,1,1,0,0, - 0,0,1,1,1,1,0,0, - 0,0,1,0,0,1,0,0, - ] - } - ], - dialogue: Some("SPR_0".to_string()), - room: "0".to_string(), - position: Position { x: 8, y: 12 } - } - ], - items: vec![ - Item { - id: "0".to_string(), - animation_frames: vec![ - Image { - pixels: vec![ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,0,0, - 0,0,1,0,0,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0, - ] - }, - ], - name: Some("tea".to_string()), - dialogue: Some("ITM_0".to_string()) - }, - ], - dialogues: vec![ - Dialogue { - id: "SPR_0".to_string(), - contents: "I'm a cat".to_string(), - }, - Dialogue { - id: "ITM_0".to_string(), - contents: "You found a nice warm cup of tea".to_string(), - }, - ], - endings: vec![], - variables: vec![ - Variable { id: "a".to_string(), initial_value: "42".to_string() } - ], - } -} - pub trait AnimationFrames { fn to_string(&self) -> String; } @@ -220,168 +62,3 @@ impl AnimationFrames for Vec { string } } - -impl From for Game { - fn from(string: String) -> Game { - // dialogues and endings can have 2+ line breaks inside, so deal with these separately - // otherwise, everything can be split on a double line break (\n\n) - let mut dialogues: Vec = Vec::new(); - let mut endings: Vec = Vec::new(); - let mut variables: Vec = Vec::new(); - let main_split: Vec<&str> = string.split("\n\nDLG").collect(); - let main = main_split[0].to_string(); - let mut dialogues_endings_variables: String = main_split[1..].join("\n\nDLG"); - - let variable_segments = dialogues_endings_variables.clone(); - let variable_segments: Vec<&str> = variable_segments.split("\n\nVAR").collect(); - if variable_segments.len() > 0 { - dialogues_endings_variables = variable_segments[0].to_string(); - let variable_segments = variable_segments[1..].to_owned(); - - for segment in variable_segments { - let segment = format!("VAR{}", segment); - variables.push(Variable::from(segment)); - } - } - - let ending_segments = dialogues_endings_variables.clone(); - let ending_segments: Vec<&str> = ending_segments.split("\n\nEND").collect(); - if ending_segments.len() > 0 { - dialogues_endings_variables = ending_segments[0].to_string(); - let ending_segments = ending_segments[1..].to_owned(); - - for segment in ending_segments { - let segment = format!("END{}", segment); - endings.push(Ending::from(segment)); - } - } - - let dialogue_segments = format!("\n\nDLG {}", dialogues_endings_variables.trim()); - let dialogue_segments: Vec<&str> = dialogue_segments.split("\n\nDLG").collect(); - for segment in dialogue_segments[1..].to_owned() { - let segment = format!("DLG{}", segment); - dialogues.push(Dialogue::from(segment)); - } - - let segments: Vec<&str> = main.split("\n\n").collect(); - - let name = segments[0].to_string(); - let mut version: f64 = 1.0; - let mut room_format: u8 = 1; - let mut palettes: Vec = Vec::new(); - let mut rooms: Vec = Vec::new(); - let mut tiles: Vec = Vec::new(); - let mut avatar: Option = None; // unwrap this later - let mut sprites: Vec = Vec::new(); - let mut items: Vec = Vec::new(); - - for segment in segments[1..].to_owned() { - let segment = segment.to_string(); - - if segment.starts_with("# BITSY VERSION") { - version = segment.replace("# BITSY VERSION ", "").parse().unwrap(); - } else if segment.starts_with("! ROOM_FORMAT") { - room_format = segment.replace("! ROOM_FORMAT ", "").parse().unwrap(); - } else if segment.starts_with("PAL") { - palettes.push(Palette::from(segment)); - } else if segment.starts_with("ROOM") { - rooms.push(Room::from(segment)); - } else if segment.starts_with("TIL") { - tiles.push(Tile::from(segment)); - } else if segment.starts_with("SPR A") { - avatar = Some(Avatar::from(segment)); - } else if segment.starts_with("SPR") { - sprites.push(Sprite::from(segment)); - } else if segment.starts_with("ITM") { - items.push(Item::from(segment)); - } - } - - assert!(avatar.is_some()); - let avatar = avatar.unwrap(); - - Game { - name, - version, - room_format, - palettes, - rooms, - tiles, - avatar, - sprites, - items, - dialogues, - endings, - variables, - } - } -} - -#[test] -fn test_game_from_string() { - let output = Game::from( - include_str!["../test/resources/default.bitsy"].to_string() - ); - - let expected = example_game_default(); - - assert_eq!(output, expected); -} - -impl ToString for Game { - #[inline] - fn to_string(&self) -> String { - let mut segments: Vec = Vec::new(); - - // todo refactor - - for palette in &self.palettes { - segments.push(palette.to_string()); - } - - for room in &self.rooms { - segments.push(room.to_string()); - } - - for tile in &self.tiles { - segments.push(tile.to_string()); - } - - segments.push(self.avatar.to_string()); - - for sprite in &self.sprites { - segments.push(sprite.to_string()); - } - - for item in &self.items { - segments.push(item.to_string()); - } - - for dialogue in &self.dialogues { - segments.push(dialogue.to_string()); - } - - for ending in &self.endings { - segments.push(ending.to_string()); - } - - for variable in &self.variables { - segments.push(variable.to_string()); - } - - format!( - "{}\n\n# BITSY VERSION {}\n\n! ROOM_FORMAT {}\n\n{}\n\n", - &self.name, - &self.version, - &self.room_format, - segments.join("\n\n"), - ) - } -} - -#[test] -fn test_game_to_string() { - let output = example_game_default().to_string(); - let expected = include_str!["../test/resources/default.bitsy"].to_string(); - assert_eq!(output, expected); -} diff --git a/src/mock.rs b/src/mock.rs index 5839d4f..e158b0c 100644 --- a/src/mock.rs +++ b/src/mock.rs @@ -1,4 +1,4 @@ -use crate::{Avatar, Exit, Image, Item, Position, Room, Sprite, Instance, ExitInstance}; +use crate::*; pub mod image { use crate::Image; @@ -157,3 +157,147 @@ pub fn room() -> Room { ], } } + +pub(crate) fn game_default() -> Game { + Game { + name: "Write your game's title here".to_string(), + version: 6.5, + room_format: 1, + palettes: vec![ + Palette { + id: "0".to_string(), + name: None, + colours: vec![ + Colour {red: 0, green: 82, blue: 204 }, + Colour {red: 128, green: 159, blue: 255 }, + Colour {red: 255, green: 255, blue: 255 }, + ] + } + ], + rooms: vec![ + Room { + id: "0".to_string(), + palette: "0".to_string(), + name: None, + tiles: vec![ + "0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(), + "0".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"0".to_string(), + "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), + "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), + "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), + "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), + "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), + "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), + "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), + "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), + "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), + "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), + "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), + "0".to_string(),"a".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"a".to_string(),"0".to_string(), + "0".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"a".to_string(),"0".to_string(), + "0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(), + ], + items: vec![], + exits: vec![], + endings: vec![] + } + ], + tiles: vec![ + Tile { + id: "a".to_string(), + name: None, + wall: false, + animation_frames: vec![ + Image { + pixels: vec![ + 1,1,1,1,1,1,1,1, + 1,0,0,0,0,0,0,1, + 1,0,0,0,0,0,0,1, + 1,0,0,1,1,0,0,1, + 1,0,0,1,1,0,0,1, + 1,0,0,0,0,0,0,1, + 1,0,0,0,0,0,0,1, + 1,1,1,1,1,1,1,1, + ] + } + ] + } + ], + avatar: Avatar { + animation_frames: vec![ + Image { + pixels: vec![ + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,1,1,1,1,0, + 1,0,1,1,1,1,0,1, + 0,0,1,0,0,1,0,0, + 0,0,1,0,0,1,0,0, + ] + } + ], + room: "0".to_string(), + position: Position { x: 4, y: 4 } + }, + sprites: vec![ + Sprite { + id: "a".to_string(), + name: None, + animation_frames: vec![ + Image { + pixels: vec![ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,0,1,0,0,0,1, + 0,1,1,1,0,0,0,1, + 0,1,1,1,0,0,1,0, + 0,1,1,1,1,1,0,0, + 0,0,1,1,1,1,0,0, + 0,0,1,0,0,1,0,0, + ] + } + ], + dialogue: Some("SPR_0".to_string()), + room: "0".to_string(), + position: Position { x: 8, y: 12 } + } + ], + items: vec![ + Item { + id: "0".to_string(), + animation_frames: vec![ + Image { + pixels: vec![ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,0,0, + 0,0,1,0,0,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0, + ] + }, + ], + name: Some("tea".to_string()), + dialogue: Some("ITM_0".to_string()) + }, + ], + dialogues: vec![ + Dialogue { + id: "SPR_0".to_string(), + contents: "I'm a cat".to_string(), + }, + Dialogue { + id: "ITM_0".to_string(), + contents: "You found a nice warm cup of tea".to_string(), + }, + ], + endings: vec![], + variables: vec![ + Variable { id: "a".to_string(), initial_value: "42".to_string() } + ], + } +}