From dc25e66031fc0a1fbdb15579ad346bcb3903b3bb Mon Sep 17 00:00:00 2001 From: troido Date: Sat, 16 May 2020 12:03:49 +0200 Subject: encyclopedia can be split over different files --- src/worldloader.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/worldloader.rs') diff --git a/src/worldloader.rs b/src/worldloader.rs index 9389e58..8e0622e 100644 --- a/src/worldloader.rs +++ b/src/worldloader.rs @@ -34,16 +34,22 @@ impl WorldLoader { .as_str() .ok_or(aerr!("world meta default_room is not a string"))? ); - let encyclopedia_name = + let encyclopediae = json - .get("encyclopedia") - .ok_or(aerr!("world meta does not have encyclopedia"))? - .as_str() - .ok_or(aerr!("world meta encyclopedia is not a string"))? - .to_string(); + .get("encyclopediae") + .ok_or(aerr!("world meta does not have encyclopediae"))? + .as_array() + .ok_or(aerr!("world meta encyclopediae is not a list"))? + .iter() + .map(|v| Ok(v + .as_str() + .ok_or(aerr!("world meta encyclopediae item {:?} is not a string", v))? + .to_string() + )) + .collect::>>()?; Ok(WorldMeta{ default_room, - encyclopedia_name + encyclopediae }) } @@ -73,7 +79,7 @@ impl WorldLoader { } pub struct WorldMeta { - pub encyclopedia_name: String, + pub encyclopediae: Vec, pub default_room: RoomId } -- cgit