diff options
| author | troido <troido@protonmail.com> | 2020-04-01 16:48:24 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-04-01 16:48:24 +0200 |
| commit | 633cb7d5b2048324a13bedb43468a7f04a81a519 (patch) | |
| tree | 5541a261e9e65fa8b26f0bc521cb1bd16c7e6a0c | |
| parent | a911b7fabbaac429efd1747c3b1e925f679752f9 (diff) | |
removed Sometime parameter
| -rw-r--r-- | content/encyclopediae/default_encyclopedia.json | 9 | ||||
| -rw-r--r-- | src/assemblage.rs | 7 | ||||
| -rw-r--r-- | src/componentwrapper.rs | 17 | ||||
| -rw-r--r-- | src/parameter.rs | 10 |
4 files changed, 29 insertions, 14 deletions
diff --git a/content/encyclopediae/default_encyclopedia.json b/content/encyclopediae/default_encyclopedia.json index e682fe2..19d57d0 100644 --- a/content/encyclopediae/default_encyclopedia.json +++ b/content/encyclopediae/default_encyclopedia.json @@ -196,7 +196,7 @@ "item": ["build", "plantedradishseed"] }, "plantedradishseed": { - "arguments": [["target_time", "sometime", null]], + "arguments": [["target_time", "int", 0]], "sprite": "seed", "height": 0.05, "name": "seed", @@ -206,10 +206,13 @@ "target_time": ["arg", "target_time"], "into": ["template", "radishseedling"] }] - ] + ], + "extract": { + "target_time": ["Grow", "target_time"] + } }, "radishseedling": { - "arguments": [["target_time", "sometime", null]], + "arguments": [["target_time", "int", 0]], "sprite": "seedling", "height": 0.05, "name": "seedling", diff --git a/src/assemblage.rs b/src/assemblage.rs index df60b45..1aa775f 100644 --- a/src/assemblage.rs +++ b/src/assemblage.rs @@ -166,7 +166,12 @@ impl Assemblage { }; let param = value.ok_or(aerr!(&format!("argument <{:?}> has no value", (idx, (name, typ, def)))))?; if param.paramtype() != *typ { - return Err(aerr!("argument has incorrect type")); + return Err(aerr!(&format!( + "argument has incorrect type: {:?}, {:?}, {:?}", + (idx, (name, typ, def)), + param.paramtype(), + param + ))); } arguments.insert(name, param); } diff --git a/src/componentwrapper.rs b/src/componentwrapper.rs index 40faa2d..589da15 100644 --- a/src/componentwrapper.rs +++ b/src/componentwrapper.rs @@ -181,7 +181,22 @@ components!( Faction (faction: String) {Faction::from_str(faction.as_str())?}; Interactable (action: String) {Interactable::from_str(action.as_str())?}; Loot (loot: LootList); - Grow (into: Template, delay: Int, target_time: SomeTime); + Grow ( + into: Template (Grow.into.clone()), + delay: Int (Grow.delay), + target_time: Int ({ + if let Some(time) = Grow.target_time { + time.0 + } else { + 0 + } + }) + ) + Grow { + into, + delay, + target_time: if target_time == 0 { None } else { Some(Timestamp(target_time)) } + }; Equipment () {panic!("equipment from parameters not implemented")}; CreationTime (time: Int) {CreationTime{time: Timestamp(time)}}; ); diff --git a/src/parameter.rs b/src/parameter.rs index a56dd23..829c5cf 100644 --- a/src/parameter.rs +++ b/src/parameter.rs @@ -3,8 +3,7 @@ use serde_json::{Value, json}; use crate::{ Template, components::item::ItemAction, - Pos, - Timestamp + Pos }; @@ -76,13 +75,6 @@ parameters!( Some((Template::from_json(item.get(0)?).ok()?, item.get(1)?.as_f64()?)) ).collect::<Option<Vec<(Template, f64)>>>()?) ({json!(v.iter().map(|(t, c)| (t.to_json(), *c)).collect::<Vec<(Value, f64)>>())}); - SomeTime (Option<Timestamp>) sometime, v - ( - serde_json::from_value::<Option<i64>>(v.clone()) - .ok()? - .map(|time| Timestamp(time)) - ) - (json!(v.map(|timestamp| timestamp.0))); ); |
