use std::collections::HashMap; use serde_json::Value; use crate::Pos; use crate::template::Template; struct RoomTemplate { size: (i64, i64), spawn: Pos, field: Vec> } impl RoomTemplate { pub fn from_json(jsonroom: &Value) -> Result{ let size = ( jsonroom.get("width").ok_or("no with")?.as_i64().ok_or("with not a number")?, jsonroom.get("height").ok_or("no height")?.as_i64().ok_or("height not a number")? ); let spawn = Pos::from_json(jsonroom.get("spawn").ok_or("no spawn")?).ok_or("spawn not a pos")?; let mut mapping = HashMap::new(); for (key, value) in jsonroom.get("mapping").ok_or("no mapping")?.as_object().ok_or("mapping not a json object")?.iter() { let mut templates: Vec