Format Rust code using rustfmt

This commit is contained in:
github-actions[bot] 2020-04-18 15:58:30 +00:00 committed by GitHub
parent 9a5c4df2b1
commit cba6c16414
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 956 additions and 394 deletions

View File

@ -1,4 +1,4 @@
use crate::{AnimationFrames, Image, Position, optional_data_line, ToBase36, from_base36};
use crate::{from_base36, optional_data_line, AnimationFrames, Image, Position, ToBase36};
/// avatar is a "sprite" in the game data but with a specific id
#[derive(Debug, Eq, PartialEq)]
@ -12,7 +12,11 @@ pub struct Avatar {
impl Avatar {
fn room_position_line(&self) -> String {
format!("\nPOS {} {}", self.room_id.to_base36(), self.position.to_string())
format!(
"\nPOS {} {}",
self.room_id.to_base36(),
self.position.to_string()
)
}
fn colour_line(&self) -> String {
@ -58,11 +62,18 @@ impl From<String> for Avatar {
let animation_frames: String = lines.join("\n");
let animation_frames: Vec<&str> = animation_frames.split(">").collect();
let animation_frames: Vec<Image> = animation_frames.iter().map(|&frame| {
Image::from(frame.to_string())
}).collect();
let animation_frames: Vec<Image> = animation_frames
.iter()
.map(|&frame| Image::from(frame.to_string()))
.collect();
Avatar { animation_frames, name, room_id, position , colour_id }
Avatar {
animation_frames,
name,
room_id,
position,
colour_id,
}
}
}
@ -81,14 +92,15 @@ impl ToString for Avatar {
#[test]
fn test_avatar_from_string() {
let output = Avatar::from(
include_str!("test-resources/avatar").to_string()
);
let output = Avatar::from(include_str!("test-resources/avatar").to_string());
assert_eq!(output, crate::mock::avatar());
}
#[test]
fn test_avatar_to_string() {
assert_eq!(crate::mock::avatar().to_string(), include_str!("test-resources/avatar"));
assert_eq!(
crate::mock::avatar().to_string(),
include_str!("test-resources/avatar")
);
}

View File

@ -1,32 +1,26 @@
extern crate bitsy_parser;
use std::{env, fs};
use bitsy_parser::game::Game;
use bitsy_parser::image::Image;
use std::{env, fs};
/// replaces the player avatar with a smiley face.
fn main() {
let input_file = env::args().nth(1)
let input_file = env::args()
.nth(1)
.expect("No input path specified. Usage: `smiley infile outfile`");
let output_file = env::args().nth(2)
let output_file = env::args()
.nth(2)
.expect("No output path specified. Usage: `smiley infile outfile`");
let mut game = Game::from(fs::read_to_string(input_file).unwrap());
game.avatar.animation_frames = vec![
Image {
game.avatar.animation_frames = vec![Image {
pixels: vec![
0,0,1,1,1,1,0,0,
0,1,1,1,1,1,1,0,
1,1,0,1,1,0,1,1,
1,1,0,1,1,0,1,1,
1,1,1,1,1,1,1,1,
1,1,0,1,1,0,1,1,
0,1,1,0,0,1,1,0,
0,0,1,1,1,1,0,0,
]
}
];
0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0,
1, 1, 1, 1, 0, 0,
],
}];
fs::write(output_file, &game.to_string())
.expect("Failed to write to output file");
fs::write(output_file, &game.to_string()).expect("Failed to write to output file");
}

View File

@ -24,19 +24,27 @@ impl ToString for Colour {
}
}
#[test]
fn test_colour_from_string() {
assert_eq!(
Colour::from("0,255,0".to_string()),
Colour { red: 0, green: 255, blue: 0 }
Colour {
red: 0,
green: 255,
blue: 0
}
);
}
#[test]
fn test_colour_to_string() {
assert_eq!(
Colour { red: 22, green: 33, blue: 44 }.to_string(),
Colour {
red: 22,
green: 33,
blue: 44
}
.to_string(),
"22,33,44".to_string()
);
}

View File

@ -25,7 +25,10 @@ impl ToString for Dialogue {
fn test_dialogue_from_string() {
assert_eq!(
Dialogue::from("DLG h\nhello\ngoodbye".to_string()),
Dialogue { id: "h".to_string(), contents: "hello\ngoodbye".to_string()}
Dialogue {
id: "h".to_string(),
contents: "hello\ngoodbye".to_string()
}
)
}
@ -35,7 +38,8 @@ fn test_dialogue_to_string() {
Dialogue {
id: "y".to_string(),
contents: "This is a bit of dialogue,\nblah blah\nblah blah".to_string()
}.to_string(),
}
.to_string(),
"DLG y\nThis is a bit of dialogue,\nblah blah\nblah blah".to_string()
);
}

View File

@ -16,7 +16,8 @@ impl From<String> for Ending {
id_dialogue[1]
} else {
""
}.to_string();
}
.to_string();
Ending { id, dialogue }
}
@ -46,7 +47,8 @@ fn test_ending_to_string() {
Ending {
id: "7".to_string(),
dialogue: "This is another long ending. So long, farewell, etc.".to_string()
}.to_string(),
}
.to_string(),
"END 7\nThis is another long ending. So long, farewell, etc.".to_string()
);
}

View File

@ -1,4 +1,4 @@
use crate::{Position, from_base36, ToBase36};
use crate::{from_base36, Position, ToBase36};
#[derive(Debug, Eq, PartialEq)]
pub enum Transition {
@ -41,14 +41,16 @@ impl ToString for Transition {
Transition::SlideLeft => " FX slide_l",
Transition::SlideRight => " FX slide_r",
Transition::None => "",
}.to_string()
}
.to_string()
}
}
#[derive(Debug, Eq, PartialEq)]
pub struct Exit {
/// destination
pub room_id: u64, /// id
pub room_id: u64,
/// id
pub position: Position,
pub effect: Transition,
}
@ -66,7 +68,11 @@ impl From<String> for Exit {
Transition::None
};
Exit { room_id, position, effect }
Exit {
room_id,
position,
effect,
}
}
}
@ -85,7 +91,11 @@ impl ToString for Exit {
fn test_exit_from_string() {
assert_eq!(
Exit::from("a 12,13".to_string()),
Exit { room_id: 10, position: Position { x: 12, y: 13 }, effect: Transition::None }
Exit {
room_id: 10,
position: Position { x: 12, y: 13 },
effect: Transition::None
}
);
}
@ -93,14 +103,23 @@ fn test_exit_from_string() {
fn test_exit_from_string_with_fx() {
assert_eq!(
Exit::from("a 12,13 FX slide_u".to_string()),
Exit { room_id: 10, position: Position { x: 12, y: 13 }, effect: Transition::SlideUp }
Exit {
room_id: 10,
position: Position { x: 12, y: 13 },
effect: Transition::SlideUp
}
);
}
#[test]
fn test_exit_to_string() {
assert_eq!(
Exit { room_id: 8, position: Position { x: 5, y: 6 }, effect: Transition::None}.to_string(),
Exit {
room_id: 8,
position: Position { x: 5, y: 6 },
effect: Transition::None
}
.to_string(),
"8 5,6".to_string()
);
}
@ -112,7 +131,8 @@ fn test_exit_to_string_with_fx() {
room_id: 8,
position: Position { x: 5, y: 6 },
effect: Transition::FadeToWhite
}.to_string(),
}
.to_string(),
"8 5,6 FX fade_w".to_string()
);
}

View File

@ -1,4 +1,7 @@
use crate::{Avatar, Dialogue, Ending, Font, Item, Palette, Room, Sprite, TextDirection, Tile, Variable, optional_data_line, ToBase36};
use crate::{
optional_data_line, Avatar, Dialogue, Ending, Font, Item, Palette, Room, Sprite, TextDirection,
Tile, ToBase36, Variable,
};
#[derive(Debug, Eq, PartialEq)]
pub struct Version {
@ -10,7 +13,10 @@ impl Version {
fn from(str: &str) -> Version {
let parts: Vec<&str> = str.split(".").collect();
assert_eq!(parts.len(), 2);
Version { major: parts[0].parse().unwrap(), minor: parts[1].parse().unwrap() }
Version {
major: parts[0].parse().unwrap(),
minor: parts[1].parse().unwrap(),
}
}
}
@ -76,10 +82,8 @@ impl From<String> for Game {
}
}
let dialogue_segments = format!(
"\n\nDLG{}",
dialogues_endings_variables.trim_matches('\n')
);
let dialogue_segments =
format!("\n\nDLG{}", dialogues_endings_variables.trim_matches('\n'));
let dialogue_segments: Vec<&str> = dialogue_segments.split("\n\nDLG").collect();
for segment in dialogue_segments[1..].to_owned() {
@ -181,7 +185,7 @@ impl ToString for Game {
// then SPR A (avatar), then all the non-numeric IDs
fn is_string_numeric(str: String) -> bool {
for c in str.chars() {
if ! c.is_numeric() {
if !c.is_numeric() {
return false;
}
}
@ -198,7 +202,7 @@ impl ToString for Game {
segments.push(self.avatar.to_string());
for sprite in &self.sprites {
if ! is_string_numeric(sprite.id.to_base36()) {
if !is_string_numeric(sprite.id.to_base36()) {
segments.push(sprite.to_string());
}
}
@ -233,7 +237,7 @@ impl ToString for Game {
impl Game {
pub fn tile_ids(&self) -> Vec<u64> {
self.tiles.iter().map(|tile| {tile.id}).collect()
self.tiles.iter().map(|tile| tile.id).collect()
}
/// first available tile ID.
@ -264,7 +268,10 @@ impl Game {
}
fn version_line(&self) -> String {
format!("\n# BITSY VERSION {}.{}", self.version.major, self.version.minor)
format!(
"\n# BITSY VERSION {}.{}",
self.version.major, self.version.minor
)
}
fn room_format_line(&self) -> String {
@ -284,15 +291,17 @@ impl Game {
}
fn text_direction_line(&self) -> &str {
if self.text_direction == TextDirection::RightToLeft {"\n\nTEXT_DIRECTION RTL"} else {""}
if self.text_direction == TextDirection::RightToLeft {
"\n\nTEXT_DIRECTION RTL"
} else {
""
}
}
}
#[test]
fn test_game_from_string() {
let output = Game::from(
include_str!["test-resources/default.bitsy"].to_string()
);
let output = Game::from(include_str!["test-resources/default.bitsy"].to_string());
let expected = crate::mock::game_default();
@ -317,7 +326,7 @@ fn test_new_tile_id() {
assert_eq!(crate::mock::game_default().new_tile_id(), 0);
let mut game = crate::mock::game_default();
let mut tiles : Vec<Tile> = Vec::new();
let mut tiles: Vec<Tile> = Vec::new();
for n in 0..9 {
if n != 4 {
@ -356,34 +365,26 @@ fn test_bitsy_omnibus() {
let acceptable_failures: Vec<String> = vec![
// fails because of sprite colours but also because a tile contains "NaN"
"src/test-resources/omnibus/DA88C287.bitsy.txt".to_string(),
// SET instead of ROOM? todo investigate
"src/test-resources/omnibus/1998508E.bitsy.txt".to_string(),
"src/test-resources/omnibus/046871F8.bitsy.txt".to_string(),
// not sure about this one but it uses room wall array
"src/test-resources/omnibus/748F77B5.bitsy.txt".to_string(),
// bad game data
"src/test-resources/omnibus/14C48FA0.bitsy.txt".to_string(),
"src/test-resources/omnibus/C63A0633.bitsy.txt".to_string(),
"src/test-resources/omnibus/C63A0633.bitsy.txt".to_string(),
"src/test-resources/omnibus/013B3CDE.bitsy.txt".to_string(), // NaN in image
// this one has font data appended to the end of the game data - is this valid?
"src/test-resources/omnibus/4B4EB988.bitsy.txt".to_string(),
// has an ending position of -1
"src/test-resources/omnibus/593BD9A6.bitsy.txt".to_string(),
// extra line between dialogues
"src/test-resources/omnibus/DB59A848.bitsy.txt".to_string(),
// something going on with dialogues? todo investigate
"src/test-resources/omnibus/807805CC.bitsy.txt".to_string(),
"src/test-resources/omnibus/C36E27E5.bitsy.txt".to_string(),
"src/test-resources/omnibus/354DA56F.bitsy.txt".to_string(),
// this avatar has `ITM 0 1` - can the player start with an item? todo investigate
"src/test-resources/omnibus/CC5085BE.bitsy.txt".to_string(),
"src/test-resources/omnibus/20D06BD1.bitsy.txt".to_string(),
@ -394,7 +395,7 @@ fn test_bitsy_omnibus() {
let files = std::fs::read_dir("src/test-resources/omnibus");
if ! files.is_ok() {
if !files.is_ok() {
return;
}
@ -402,7 +403,7 @@ fn test_bitsy_omnibus() {
let path = file.unwrap().path();
let nice_name = format!("{}", path.display());
if ! nice_name.contains("bitsy") || acceptable_failures.contains(&nice_name) {
if !nice_name.contains("bitsy") || acceptable_failures.contains(&nice_name) {
skips += 1;
// println!("Skipping: {}", nice_name);
println!("Skipped. {} passes, {} skips.", passes, skips);
@ -412,7 +413,10 @@ fn test_bitsy_omnibus() {
println!("Testing: {}...", path.display());
let game_data = std::fs::read_to_string(path).unwrap();
let game = Game::from(game_data.clone());
assert_eq!(game.to_string().trim_matches('\n'), game_data.trim_matches('\n'));
assert_eq!(
game.to_string().trim_matches('\n'),
game_data.trim_matches('\n')
);
passes += 1;
println!("Success! {} passes, {} skips.", passes, skips);
}

View File

@ -10,9 +10,10 @@ impl From<String> for Image {
let pixels: Vec<&str> = string.split("").collect();
// the above seems to add an extra "" at the start and end of the vec, so strip them below
let pixels = &pixels[1..(pixels.len() - 1)];
let pixels: Vec<u32> = pixels.iter().map(|&pixel| {
pixel.parse::<u32>().unwrap()
}).collect();
let pixels: Vec<u32> = pixels
.iter()
.map(|&pixel| pixel.parse::<u32>().unwrap())
.collect();
Image { pixels }
}
@ -43,15 +44,10 @@ fn test_image_from_string() {
let expected = Image {
pixels: vec![
1,1,1,1,1,1,1,1,
1,1,0,0,1,1,1,1,
1,0,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
]
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
],
};
assert_eq!(output, expected)

View File

@ -1,4 +1,4 @@
use crate::{AnimationFrames, Image, from_base36, ToBase36, optional_data_line};
use crate::{from_base36, optional_data_line, AnimationFrames, Image, ToBase36};
#[derive(Debug, Eq, PartialEq)]
pub struct Item {
@ -50,11 +50,18 @@ impl From<String> for Item {
// todo dedupe
let animation_frames = lines[1..].join("");
let animation_frames: Vec<&str> = animation_frames.split(">").collect();
let animation_frames: Vec<Image> = animation_frames.iter().map(|&frame| {
Image::from(frame.to_string())
}).collect();
let animation_frames: Vec<Image> = animation_frames
.iter()
.map(|&frame| Image::from(frame.to_string()))
.collect();
Item { id, name, animation_frames, dialogue_id, colour_id }
Item {
id,
name,
animation_frames,
dialogue_id,
colour_id,
}
}
}

View File

@ -5,15 +5,15 @@ pub mod colour;
pub mod dialogue;
pub mod ending;
pub mod exit;
pub mod text;
pub mod game;
pub mod palette;
pub mod image;
pub mod item;
pub mod mock;
pub mod palette;
pub mod position;
pub mod room;
pub mod sprite;
pub mod text;
pub mod tile;
pub mod variable;
@ -21,18 +21,18 @@ use avatar::Avatar;
use colour::Colour;
use dialogue::Dialogue;
use ending::Ending;
use exit::{Transition, Exit};
use text::{Font, TextDirection};
use exit::{Exit, Transition};
use game::{Game, Version};
use palette::Palette;
use image::Image;
use item::Item;
use palette::Palette;
use position::Position;
use room::Room;
use sprite::Sprite;
use std::fmt::Display;
use text::{Font, TextDirection};
use tile::Tile;
use variable::Variable;
use std::fmt::Display;
#[derive(Debug, Eq, PartialEq)]
pub struct Instance {

View File

@ -6,30 +6,20 @@ pub mod image {
pub(crate) fn chequers_1() -> Image {
Image {
pixels: vec![
1, 0, 1, 0, 1, 0, 1, 0,
1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1,
0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0,
0, 1, 0, 1, 0, 1, 0, 1,
1, 0, 1, 0, 1, 0, 1, 0,
0, 1, 0, 1, 0, 1, 0, 1,
1, 0, 1, 0, 1, 0, 1, 0,
0, 1, 0, 1, 0, 1, 0, 1,
1, 0, 1, 0, 1, 0, 1, 0,
0, 1, 0, 1, 0, 1, 0, 1,
]
],
}
}
pub fn chequers_2() -> Image {
Image {
pixels: vec![
0,1,0,1,0,1,0,1,
1,0,1,0,1,0,1,0,
0,1,0,1,0,1,0,1,
1,0,1,0,1,0,1,0,
0,1,0,1,0,1,0,1,
1,0,1,0,1,0,1,0,
0,1,0,1,0,1,0,1,
1,0,1,0,1,0,1,0,
]
0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0,
1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1,
1, 0, 1, 0, 1, 0, 1, 0,
],
}
}
}
@ -39,27 +29,17 @@ pub fn avatar() -> Avatar {
animation_frames: vec![
Image {
pixels: vec![
0,0,0,0,0,0,0,0,
0,0,1,1,1,1,0,0,
0,1,1,1,1,1,1,0,
1,1,1,0,1,1,1,0,
1,0,0,1,1,0,0,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
0,1,1,1,1,1,1,0,
]
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1,
1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0,
],
},
Image {
pixels: vec![
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,1,1,1,1,0,
1,1,1,0,1,1,1,0,
1,0,0,1,1,0,0,1,
1,1,1,1,1,1,1,1,
0,1,1,1,0,1,1,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, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1,
1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0,
],
},
],
name: None,
@ -74,21 +54,14 @@ pub fn tile_default() -> Tile {
id: 10,
name: None,
wall: None,
animation_frames: vec![
Image {
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,
]
}
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,
],
colour_id: None
}],
colour_id: None,
}
}
@ -96,20 +69,13 @@ pub fn sprite() -> Sprite {
Sprite {
id: 10,
name: Some("hatch".to_string()),
animation_frames: vec![
Image {
animation_frames: vec![Image {
pixels: vec![
0,0,0,0,0,0,0,0,
0,1,1,1,1,0,0,0,
0,1,0,0,1,0,0,0,
0,0,1,1,1,1,0,0,
0,0,1,1,1,1,0,0,
0,1,0,1,1,1,1,0,
0,1,0,1,1,1,1,0,
0,1,1,0,1,1,1,1,
]
}
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1,
1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0,
0, 1, 1, 0, 1, 1, 1, 1,
],
}],
dialogue_id: Some("SPR_0".to_string()),
room_id: Some(4),
position: Some(Position { x: 9, y: 7 }),
@ -120,23 +86,16 @@ pub fn sprite() -> Sprite {
pub fn item() -> Item {
Item {
id: 6,
animation_frames: vec![
Image {
animation_frames: vec![Image {
pixels: vec![
0,1,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,0,1,0,0,
0,0,1,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,0,1,0,
]
}
0, 1, 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,
0, 1, 0, 0, 0, 0, 1, 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, 0, 1, 0,
],
}],
name: Some("door".to_string()),
dialogue_id: Some("ITM_2".to_string()),
colour_id: None
colour_id: None,
}
}
@ -146,43 +105,297 @@ pub fn room() -> Room {
palette_id: Some(9),
name: Some("cellar 7".to_string()),
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(),"1l".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),
"y".to_string(),"x".to_string(),"0".to_string(),"0".to_string(),"1j".to_string(),"0".to_string(),"0".to_string(),"1j".to_string(),"1l".to_string(),"0".to_string(),"1j".to_string(),"0".to_string(),"0".to_string(),"1j".to_string(),"0".to_string(),"0".to_string(),
"y".to_string(),"y".to_string(),"x".to_string(),"k".to_string(),"k".to_string(),"1c".to_string(),"1x".to_string(),"1y".to_string(),"1m".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),"0".to_string(),
"y".to_string(),"y".to_string(),"y".to_string(),"x".to_string(),"k".to_string(),"s".to_string(),"s".to_string(),"s".to_string(),"k".to_string(),"k".to_string(),"k".to_string(),"k".to_string(),"k".to_string(),"1g".to_string(),"1f".to_string(),"k".to_string(),
"k".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"1i".to_string(),"1u".to_string(),"1u".to_string(),"1u".to_string(),"1v".to_string(),"11".to_string(),"19".to_string(),"1b".to_string(),"1a".to_string(),"1e".to_string(),"10".to_string(),"k".to_string(),
"k".to_string(),"z".to_string(),"z".to_string(),"11".to_string(),"12".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"10".to_string(),"17".to_string(),"z".to_string(),"18".to_string(),"1e".to_string(),"12".to_string(),"k".to_string(),
"k".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"1k".to_string(),"14".to_string(),"15".to_string(),"16".to_string(),"1h".to_string(),"z".to_string(),"k".to_string(),
"k".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"10".to_string(),"1d".to_string(),"1v".to_string(),"1r".to_string(),"1s".to_string(),"1r".to_string(),"1q".to_string(),"1z".to_string(),"k".to_string(),
"k".to_string(),"z".to_string(),"z".to_string(),"12".to_string(),"10".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"1i".to_string(),"1n".to_string(),"1o".to_string(),"1o".to_string(),"1o".to_string(),"1p".to_string(),"z".to_string(),"k".to_string(),
"k".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"10".to_string(),"z".to_string(),"z".to_string(),"k".to_string(),
"k".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"11".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"k".to_string(),
"k".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"z".to_string(),"12".to_string(),"z".to_string(),"z".to_string(),"10".to_string(),"12".to_string(),"k".to_string(),
"k".to_string(),"k".to_string(),"k".to_string(),"k".to_string(),"k".to_string(),"k".to_string(),"k".to_string(),"k".to_string(),"k".to_string(),"k".to_string(),"k".to_string(),"k".to_string(),"k".to_string(),"k".to_string(),"k".to_string(),"k".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(),"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(),"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(),
"0".to_string(),
"0".to_string(),
"0".to_string(),
"0".to_string(),
"0".to_string(),
"1l".to_string(),
"0".to_string(),
"0".to_string(),
"0".to_string(),
"0".to_string(),
"0".to_string(),
"0".to_string(),
"0".to_string(),
"y".to_string(),
"x".to_string(),
"0".to_string(),
"0".to_string(),
"1j".to_string(),
"0".to_string(),
"0".to_string(),
"1j".to_string(),
"1l".to_string(),
"0".to_string(),
"1j".to_string(),
"0".to_string(),
"0".to_string(),
"1j".to_string(),
"0".to_string(),
"0".to_string(),
"y".to_string(),
"y".to_string(),
"x".to_string(),
"k".to_string(),
"k".to_string(),
"1c".to_string(),
"1x".to_string(),
"1y".to_string(),
"1m".to_string(),
"0".to_string(),
"0".to_string(),
"0".to_string(),
"0".to_string(),
"0".to_string(),
"0".to_string(),
"0".to_string(),
"y".to_string(),
"y".to_string(),
"y".to_string(),
"x".to_string(),
"k".to_string(),
"s".to_string(),
"s".to_string(),
"s".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"1g".to_string(),
"1f".to_string(),
"k".to_string(),
"k".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"1i".to_string(),
"1u".to_string(),
"1u".to_string(),
"1u".to_string(),
"1v".to_string(),
"11".to_string(),
"19".to_string(),
"1b".to_string(),
"1a".to_string(),
"1e".to_string(),
"10".to_string(),
"k".to_string(),
"k".to_string(),
"z".to_string(),
"z".to_string(),
"11".to_string(),
"12".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"10".to_string(),
"17".to_string(),
"z".to_string(),
"18".to_string(),
"1e".to_string(),
"12".to_string(),
"k".to_string(),
"k".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"1k".to_string(),
"14".to_string(),
"15".to_string(),
"16".to_string(),
"1h".to_string(),
"z".to_string(),
"k".to_string(),
"k".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"10".to_string(),
"1d".to_string(),
"1v".to_string(),
"1r".to_string(),
"1s".to_string(),
"1r".to_string(),
"1q".to_string(),
"1z".to_string(),
"k".to_string(),
"k".to_string(),
"z".to_string(),
"z".to_string(),
"12".to_string(),
"10".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"1i".to_string(),
"1n".to_string(),
"1o".to_string(),
"1o".to_string(),
"1o".to_string(),
"1p".to_string(),
"z".to_string(),
"k".to_string(),
"k".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"10".to_string(),
"z".to_string(),
"z".to_string(),
"k".to_string(),
"k".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"11".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"k".to_string(),
"k".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"z".to_string(),
"12".to_string(),
"z".to_string(),
"z".to_string(),
"10".to_string(),
"12".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".to_string(),
"k".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(),
"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(),
"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![
Instance {position: Position { x: 11, y: 5}, id: "d".to_string()},
Instance {position: Position { x: 8, y: 3}, id: "e".to_string()},
Instance {position: Position { x: 1, y: 0}, id: "5".to_string()},
Instance {position: Position { x: 2, y: 1}, id: "6".to_string()},
Instance {position: Position { x: 3, y: 2}, id: "6".to_string()},
],
exits: vec![
ExitInstance {
position: Position { x: 3, y: 3},
exit: Exit {
room_id: 3,
position: Position { x: 10, y: 6},
effect: Transition::None
}
Instance {
position: Position { x: 11, y: 5 },
id: "d".to_string(),
},
Instance {
position: Position { x: 8, y: 3 },
id: "e".to_string(),
},
Instance {
position: Position { x: 1, y: 0 },
id: "5".to_string(),
},
Instance {
position: Position { x: 2, y: 1 },
id: "6".to_string(),
},
Instance {
position: Position { x: 3, y: 2 },
id: "6".to_string(),
},
],
endings: vec![
Instance{position: Position { x: 8, y: 7 }, id: "undefined".to_string()},
],
exits: vec![ExitInstance {
position: Position { x: 3, y: 3 },
exit: Exit {
room_id: 3,
position: Position { x: 10, y: 6 },
effect: Transition::None,
},
}],
endings: vec![Instance {
position: Position { x: 8, y: 7 },
id: "undefined".to_string(),
}],
walls: vec![],
}
}
@ -195,115 +408,336 @@ pub fn game_default() -> Game {
font: Font::AsciiSmall,
custom_font: None,
text_direction: TextDirection::LeftToRight,
palettes: vec![
Palette {
palettes: vec![Palette {
id: 0,
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 },
]
}
Colour {
red: 0,
green: 82,
blue: 204,
},
Colour {
red: 128,
green: 159,
blue: 255,
},
Colour {
red: 255,
green: 255,
blue: 255,
},
],
rooms: vec![
Room {
}],
rooms: vec![Room {
id: 0,
palette_id: Some(0),
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(),
"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![],
walls: vec![]
}
],
tiles: vec![
self::tile_default(),
],
walls: vec![],
}],
tiles: vec![self::tile_default()],
avatar: Avatar {
animation_frames: vec![
Image {
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,
]
}
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,
],
}],
name: None,
room_id: 0,
position: Position { x: 4, y: 4 },
colour_id: None,
},
sprites: vec![
Sprite {
sprites: vec![Sprite {
id: 10,
name: None,
animation_frames: vec![
Image {
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,
]
}
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_id: Some("SPR_0".to_string()),
room_id: Some(0),
position: Some(Position { x: 8, y: 12 }),
colour_id: None,
}
],
items: vec![
Item {
}],
items: vec![Item {
id: 0,
animation_frames: vec![
Image {
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,
]
},
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_id: Some("ITM_0".to_string()),
colour_id: None
},
],
colour_id: None,
}],
dialogues: vec![
Dialogue {
id: "SPR_0".to_string(),
@ -315,8 +749,9 @@ pub fn game_default() -> Game {
},
],
endings: vec![],
variables: vec![
Variable { id: "a".to_string(), initial_value: "42".to_string() }
],
variables: vec![Variable {
id: "a".to_string(),
initial_value: "42".to_string(),
}],
}
}

View File

@ -21,9 +21,10 @@ impl From<String> for Palette {
let colour_start_index = if name.is_some() { 2 } else { 1 };
let colours = lines[colour_start_index..].iter().map(|&line| {
Colour::from(line.to_string())
}).collect();
let colours = lines[colour_start_index..]
.iter()
.map(|&line| Colour::from(line.to_string()))
.collect();
Palette { id, name, colours }
}
@ -50,17 +51,27 @@ impl ToString for Palette {
#[test]
fn test_palette_from_string() {
let output = Palette::from(
"PAL 1\nNAME lamplight\n45,45,59\n66,60,39\n140,94,1".to_string()
);
let output = Palette::from("PAL 1\nNAME lamplight\n45,45,59\n66,60,39\n140,94,1".to_string());
let expected = Palette {
id: 1,
name: Some("lamplight".to_string()),
colours: vec![
Colour {red: 45, green: 45, blue: 59},
Colour {red: 66, green: 60, blue: 39},
Colour {red: 140, green: 94, blue: 1 },
Colour {
red: 45,
green: 45,
blue: 59,
},
Colour {
red: 66,
green: 60,
blue: 39,
},
Colour {
red: 140,
green: 94,
blue: 1,
},
],
};
@ -69,17 +80,27 @@ fn test_palette_from_string() {
#[test]
fn test_palette_from_string_no_name() {
let output = Palette::from(
"PAL 9\n45,45,59\n66,60,39\n140,94,1".to_string()
);
let output = Palette::from("PAL 9\n45,45,59\n66,60,39\n140,94,1".to_string());
let expected = Palette {
id: 9,
name: None,
colours: vec![
Colour {red: 45, green: 45, blue: 59},
Colour {red: 66, green: 60, blue: 39},
Colour {red: 140, green: 94, blue: 1 },
Colour {
red: 45,
green: 45,
blue: 59,
},
Colour {
red: 66,
green: 60,
blue: 39,
},
Colour {
red: 140,
green: 94,
blue: 1,
},
],
};
@ -92,11 +113,24 @@ fn test_palette_to_string() {
id: 16,
name: Some("moss".to_string()),
colours: vec![
Colour {red: 1, green: 2, blue: 3 },
Colour {red: 255, green: 254, blue: 253},
Colour {red: 126, green: 127, blue: 128},
]
}.to_string();
Colour {
red: 1,
green: 2,
blue: 3,
},
Colour {
red: 255,
green: 254,
blue: 253,
},
Colour {
red: 126,
green: 127,
blue: 128,
},
],
}
.to_string();
let expected = "PAL g\nNAME moss\n1,2,3\n255,254,253\n126,127,128".to_string();
assert_eq!(output, expected);
}

View File

@ -31,7 +31,10 @@ impl ToString for Position {
#[test]
fn test_position_from_string() {
assert_eq!(Position::from("4,12".to_string()).unwrap(), Position { x: 4, y: 12 });
assert_eq!(
Position::from("4,12".to_string()).unwrap(),
Position { x: 4, y: 12 }
);
}
#[test]

View File

@ -1,4 +1,4 @@
use crate::{Exit, ExitInstance, Instance, Position, from_base36, ToBase36, optional_data_line};
use crate::{from_base36, optional_data_line, Exit, ExitInstance, Instance, Position, ToBase36};
#[derive(Debug, Eq, PartialEq)]
pub struct Room {
@ -66,7 +66,10 @@ impl From<String> for Room {
let position = item_position[1];
let position = Position::from(position.to_string()).unwrap();
items.push(Instance { position, id: item_id.to_string() });
items.push(Instance {
position,
id: item_id.to_string(),
});
} else if last_line.starts_with("EXT") {
let last_line = last_line.replace("EXT ", "");
let parts: Vec<&str> = last_line.split(' ').collect();
@ -81,7 +84,10 @@ impl From<String> for Room {
let position = ending_position[1].to_string();
let position = Position::from(position).unwrap();
endings.push(Instance { position, id: ending });
endings.push(Instance {
position,
id: ending,
});
} else {
lines.push(last_line);
break;
@ -95,7 +101,8 @@ impl From<String> for Room {
for line in lines.into_iter() {
let line: Vec<&str> = if line.contains(",") {
line.split(",").collect()
} else { // old room format
} else {
// old room format
line.split("").collect()
};
@ -108,7 +115,16 @@ impl From<String> for Room {
exits.reverse();
endings.reverse();
Room { id, palette_id, name, tiles, items, exits, endings, walls }
Room {
id,
palette_id,
name,
tiles,
items,
exits,
endings,
walls,
}
}
}
@ -138,25 +154,27 @@ impl ToString for Room {
tiles.pop(); // remove trailing newline
for instance in &self.items {
items.push_str(
&format!("\nITM {} {}", instance.id, instance.position.to_string())
);
items.push_str(&format!(
"\nITM {} {}",
instance.id,
instance.position.to_string()
));
}
for instance in &self.exits {
exits.push_str(
&format!(
exits.push_str(&format!(
"\nEXT {} {}",
instance.position.to_string(),
instance.exit.to_string(),
)
);
));
}
for instance in &self.endings {
endings.push_str(
&format!("\nEND {} {}", instance.id, instance.position.to_string())
);
endings.push_str(&format!(
"\nEND {} {}",
instance.id,
instance.position.to_string()
));
}
format!(
@ -175,14 +193,15 @@ impl ToString for Room {
#[test]
fn test_room_to_string() {
assert_eq!(crate::mock::room().to_string(), include_str!("test-resources/room").to_string());
assert_eq!(
crate::mock::room().to_string(),
include_str!("test-resources/room").to_string()
);
}
#[test]
fn test_room_walls_array() {
let output = Room::from(
include_str!("test-resources/room-with-walls").to_string()
);
let output = Room::from(include_str!("test-resources/room-with-walls").to_string());
assert_eq!(output.walls, vec![10, 15]);
}

View File

@ -1,4 +1,4 @@
use crate::{AnimationFrames, Image, Position, from_base36, ToBase36, optional_data_line};
use crate::{from_base36, optional_data_line, AnimationFrames, Image, Position, ToBase36};
#[derive(Debug, Eq, PartialEq)]
pub struct Sprite {
@ -22,7 +22,11 @@ impl Sprite {
fn room_position_line(&self) -> String {
if self.room_id.is_some() && self.position.is_some() {
format!("\nPOS {} {}", self.room_id.unwrap().to_base36(), self.position.as_ref().unwrap().to_string())
format!(
"\nPOS {} {}",
self.room_id.unwrap().to_base36(),
self.position.as_ref().unwrap().to_string()
)
} else {
"".to_string()
}
@ -72,11 +76,20 @@ impl From<String> for Sprite {
// todo dedupe
let animation_frames = lines[1..].join("");
let animation_frames: Vec<&str> = animation_frames.split(">").collect();
let animation_frames: Vec<Image> = animation_frames.iter().map(|&frame| {
Image::from(frame.to_string())
}).collect();
let animation_frames: Vec<Image> = animation_frames
.iter()
.map(|&frame| Image::from(frame.to_string()))
.collect();
Sprite { id, name, animation_frames, dialogue_id, room_id, position, colour_id }
Sprite {
id,
name,
animation_frames,
dialogue_id,
room_id,
position,
colour_id,
}
}
}
@ -97,9 +110,7 @@ impl ToString for Sprite {
#[test]
fn test_sprite_from_string() {
let output = Sprite::from(
include_str!("test-resources/sprite").to_string()
);
let output = Sprite::from(include_str!("test-resources/sprite").to_string());
let expected = crate::mock::sprite();

View File

@ -1,4 +1,4 @@
use crate::{AnimationFrames, Image, from_base36, ToBase36, optional_data_line};
use crate::{from_base36, optional_data_line, AnimationFrames, Image, ToBase36};
#[derive(Debug, Eq, PartialEq)]
pub struct Tile {
@ -59,11 +59,18 @@ impl From<String> for Tile {
let animation_frames = lines[1..].join("");
let animation_frames: Vec<&str> = animation_frames.split(">").collect();
let animation_frames: Vec<Image> = animation_frames.iter().map(|&frame| {
Image::from(frame.to_string())
}).collect();
let animation_frames: Vec<Image> = animation_frames
.iter()
.map(|&frame| Image::from(frame.to_string()))
.collect();
Tile { id, name, wall, animation_frames, colour_id }
Tile {
id,
name,
wall,
animation_frames,
colour_id,
}
}
}
@ -89,12 +96,10 @@ fn test_tile_from_string() {
id: 35,
name: Some("concrete 1".to_string()),
wall: Some(true),
animation_frames: vec![
Image {
pixels: vec![1; 64]
}
],
colour_id: None
animation_frames: vec![Image {
pixels: vec![1; 64],
}],
colour_id: None,
};
assert_eq!(output, expected);
@ -110,8 +115,9 @@ fn test_tile_to_string() {
crate::mock::image::chequers_1(),
crate::mock::image::chequers_2(),
],
colour_id: None
}.to_string();
colour_id: None,
}
.to_string();
let expected = include_str!("test-resources/tile-chequers").to_string();

View File

@ -25,13 +25,20 @@ impl ToString for Variable {
fn test_variable_from_string() {
assert_eq!(
Variable::from("VAR a\n42".to_string()),
Variable { id: "a".to_string(), initial_value: "42".to_string()}
Variable {
id: "a".to_string(),
initial_value: "42".to_string()
}
);
}
#[test]
fn test_variable_to_string() {
let output = Variable { id: "c".to_string(), initial_value: "57".to_string() }.to_string();
let output = Variable {
id: "c".to_string(),
initial_value: "57".to_string(),
}
.to_string();
let expected = "VAR c\n57".to_string();
assert_eq!(output, expected);
}