From bf5b3a8d20bbcb12207fb4be633b219a35446741 Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Thu, 18 Jun 2020 17:46:30 +0100 Subject: [PATCH] remove avatar (treat it as sprite) --- src/game.rs | 10 +------- src/mock.rs | 66 +++++++++++++++++++++++++++-------------------------- 2 files changed, 35 insertions(+), 41 deletions(-) diff --git a/src/game.rs b/src/game.rs index 60b2efd..19d3e7d 100644 --- a/src/game.rs +++ b/src/game.rs @@ -78,7 +78,6 @@ pub struct Game { pub palettes: Vec, pub rooms: Vec, pub tiles: Vec, - pub avatar: Sprite, pub sprites: Vec, pub items: Vec, pub dialogues: Vec, @@ -167,8 +166,6 @@ impl Game { 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(Sprite::from(segment)); } else if segment.starts_with("SPR ") { sprites.push(Sprite::from(segment)); } else if segment.starts_with("ITM ") { @@ -187,9 +184,7 @@ impl Game { } } - // todo return a custom error instead - assert!(avatar.is_some()); - let avatar = avatar.unwrap(); + // todo check if SPR A (avatar) exists Ok( Game { @@ -203,7 +198,6 @@ impl Game { palettes, rooms, tiles, - avatar, sprites, items, dialogues, @@ -278,8 +272,6 @@ impl ToString for Game { } } - segments.push(self.avatar.to_string().replace("SPR a", "SPR A")); - for sprite in &self.sprites { if !is_string_numeric(sprite.id.clone()) { segments.push(sprite.to_string()); diff --git a/src/mock.rs b/src/mock.rs index 1a5b8c2..eebfa5a 100644 --- a/src/mock.rs +++ b/src/mock.rs @@ -767,38 +767,40 @@ pub fn game_default() -> Game { walls: vec![], }], tiles: vec![self::tile_default()], - avatar: Sprite { - id: "A".to_string(), - 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, - ], - }], - name: None, - room_id: Some("0".to_string()), - position: Option::from(Position { x: 4, y: 4 }), - colour_id: None, - dialogue_id: None, - items: vec![] - }, - 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_id: Some("SPR_0".to_string()), - room_id: Some("0".to_string()), - position: Some(Position { x: 8, y: 12 }), - colour_id: None, - items: vec![] - }], + sprites: vec![ + Sprite { + id: "A".to_string(), + 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, + ], + }], + name: None, + room_id: Some("0".to_string()), + position: Option::from(Position { x: 4, y: 4 }), + colour_id: None, + dialogue_id: None, + items: 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_id: Some("SPR_0".to_string()), + room_id: Some("0".to_string()), + position: Some(Position { x: 8, y: 12 }), + colour_id: None, + items: vec![] + }, + ], items: vec![Item { id: "0".to_string(), animation_frames: vec![Image {