From 1bbfaceeb47c6a1e0e8c07b0859fe35479d0ec5a Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Sun, 18 Oct 2020 17:03:09 +0100 Subject: [PATCH] give warning on missing avatar --- src/game.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/game.rs b/src/game.rs index 0353f72..d6a69d2 100644 --- a/src/game.rs +++ b/src/game.rs @@ -5,6 +5,7 @@ use loe::TransformMode; use std::collections::HashMap; use std::borrow::BorrowMut; use std::fmt; +use crate::error::NotFound; /// in very early versions of Bitsy, room tiles were defined as single alphanumeric characters - /// so there was a maximum of 36 unique tiles. later versions are comma-separated. @@ -170,7 +171,7 @@ impl Game { let mut tiles: Vec = Vec::new(); let mut sprites: Vec = Vec::new(); let mut items: Vec = Vec::new(); - // let mut avatar_exists = false; + let mut avatar_exists = false; for segment in segments { if segment.starts_with("# BITSY VERSION") { @@ -216,7 +217,7 @@ impl Game { let result = Sprite::from_str(&segment); if let Ok(sprite) = result { - // avatar_exists |= sprite.id == "A"; + avatar_exists |= sprite.id == "A"; sprites.push(sprite); } else { @@ -240,6 +241,7 @@ impl Game { } } else if segment.starts_with("END ") { let result = Ending::from_str(&segment); + if let Ok(ending) = result { endings.push(ending); } else { @@ -252,9 +254,9 @@ impl Game { } } - // if ! avatar_exists { - // return Err(crate::Error::NotFound::Avatar); - // } + if ! avatar_exists { + warnings.push(crate::Error::Game { missing: NotFound::Avatar}); + } Ok( (