add wall property to tile; why did I make "avatar" a tile? smh

This commit is contained in:
Max Bradbury 2021-05-19 10:26:37 +01:00
parent 3f76ee4f03
commit 0abc64946e
3 changed files with 13 additions and 4 deletions

View File

@ -1 +0,0 @@
images = ["avatar"]

View File

@ -0,0 +1,2 @@
images = ["block"]
wall = false

View File

@ -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<String>,
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<String>,
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);
}
}