summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-02-06 13:17:58 +0100
committertroido <troido@protonmail.com>2020-02-06 13:17:58 +0100
commitc4aefd46b437b0138a53333febdee486d197b960 (patch)
tree681c011434ec4736b76bd450ad33103e2f1ddd6a /src/main.rs
parent283c5287b2dd7b4b83e51756bd7c41d5a3c35ef9 (diff)
better template creation
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs
index 524d70f..cff91a9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -5,6 +5,7 @@ use std::time::Duration;
use std::path::Path;
use std::collections::HashMap;
+use serde_json::json;
mod server;
mod gameserver;
@@ -63,16 +64,16 @@ fn main() {
fn gen_room<'a, 'b>(width: i32, height: i32) -> Room<'a, 'b> {
let mut room = Room::new((width, height));
- let wall = Template{
- arguments: Vec::new(),
- components: vec![
- (ComponentType::from_str("Blocking").unwrap(), HashMap::new()),
- (ComponentType::from_str("Visible").unwrap(), hashmap!(
- "sprite".to_string() => CompParam::Constant(Parameter::String("wall".to_string())),
- "height".to_string() => CompParam::Constant(Parameter::Float(1.0))
- ))
+ let wall = Template::from_json(json!({
+ "arguments": [],
+ "components": [
+ ["Blocking", {}],
+ ["Visible", {
+ "sprite": ["const", "wall"],
+ "height": ["const", 1.0]
+ }]
]
- }.instantiate(Vec::new(), HashMap::new()).unwrap();
+ })).unwrap().instantiate(Vec::new(), HashMap::new()).unwrap();
for x in 0..width {
room.add_complist(&wall, (x, 0));
room.add_complist(&wall, (x, height - 1));
@@ -89,3 +90,7 @@ fn gen_room<'a, 'b>(width: i32, height: i32) -> Room<'a, 'b> {
room
}
+// fn default_assemblages() -> Hashmap<&str, Template> {
+// hashmap!(
+//
+