diff options
| author | troido <troido@protonmail.com> | 2020-05-16 12:03:49 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-05-16 12:03:49 +0200 |
| commit | dc25e66031fc0a1fbdb15579ad346bcb3903b3bb (patch) | |
| tree | 5d1bb73ce84afec2683367e29a73968603fe1898 /src/worldloader.rs | |
| parent | 9c4e59b670d22fbfa23def1d66a10ea3af4c214d (diff) | |
encyclopedia can be split over different files
Diffstat (limited to 'src/worldloader.rs')
| -rw-r--r-- | src/worldloader.rs | 22 |
1 files changed, 14 insertions, 8 deletions
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::<Result<Vec<String>>>()?; Ok(WorldMeta{ default_room, - encyclopedia_name + encyclopediae }) } @@ -73,7 +79,7 @@ impl WorldLoader { } pub struct WorldMeta { - pub encyclopedia_name: String, + pub encyclopediae: Vec<String>, pub default_room: RoomId } |
