From 0abc64946e49fc33803d877faa249521878b438c Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Wed, 19 May 2021 10:26:37 +0100 Subject: [PATCH] add wall property to tile; why did I make "avatar" a tile? smh --- src/test-resources/basic/tiles/avatar.toml | 1 - src/test-resources/basic/tiles/block.toml | 2 ++ src/tile.rs | 14 +++++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) delete mode 100644 src/test-resources/basic/tiles/avatar.toml create mode 100644 src/test-resources/basic/tiles/block.toml diff --git a/src/test-resources/basic/tiles/avatar.toml b/src/test-resources/basic/tiles/avatar.toml deleted file mode 100644 index 3ac6a9c..0000000 --- a/src/test-resources/basic/tiles/avatar.toml +++ /dev/null @@ -1 +0,0 @@ -images = ["avatar"] diff --git a/src/test-resources/basic/tiles/block.toml b/src/test-resources/basic/tiles/block.toml new file mode 100644 index 0000000..1e33ec9 --- /dev/null +++ b/src/test-resources/basic/tiles/block.toml @@ -0,0 +1,2 @@ +images = ["block"] +wall = false diff --git a/src/tile.rs b/src/tile.rs index 10763f9..15754e7 100644 --- a/src/tile.rs +++ b/src/tile.rs @@ -9,6 +9,7 @@ pub struct Tile { /// todo should there be animation options? reverse, random, etc? /// todo do we need a "current frame" property or leave that up to the player implementation? pub images: Vec, + pub wall: bool, } impl Tile { @@ -19,13 +20,14 @@ impl Tile { &read_to_string(path).unwrap() ).unwrap(); - Tile { name, images: intermediate.images } + Tile { name, images: intermediate.images, wall: intermediate.wall } } } #[derive(Debug, Eq, PartialEq, Serialize, Deserialize)] struct IntermediateTile { images: Vec, + wall: bool, } #[cfg(test)] @@ -35,9 +37,15 @@ mod test { #[test] fn from_file() { - let path = PathBuf::from("src/test-resources/basic/tiles/avatar.toml"); + let path = PathBuf::from("src/test-resources/basic/tiles/block.toml"); let output = Tile::from_file(path); - let expected = Tile { name: "avatar".into(), images: vec!["avatar".to_string()] }; + + let expected = Tile { + name: "block".into(), + images: vec!["block".to_string()], + wall: false + }; + assert_eq!(output, expected); } }