summaryrefslogtreecommitdiff
path: root/src/componentwrapper.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-09-21 02:33:19 +0200
committertroido <troido@protonmail.com>2020-09-21 02:33:19 +0200
commit5ce9b012a7987f4085057f4f0b0af35e76810a7a (patch)
treea99418b5aec06d6be28e22150bce85d3c40b8ee7 /src/componentwrapper.rs
parentb6a4c7b2d383755402e5e2c6f60d9a75a899b809 (diff)
parent455867294cc849bff2c0829a7464e71e79a0dcae (diff)
Merge branch 'interact' into master
Diffstat (limited to 'src/componentwrapper.rs')
-rw-r--r--src/componentwrapper.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/componentwrapper.rs b/src/componentwrapper.rs
index 2619d9c..08d95ee 100644
--- a/src/componentwrapper.rs
+++ b/src/componentwrapper.rs
@@ -14,8 +14,7 @@ use crate::{
AttackType,
Clan,
Flag,
- Trigger,
- interactable::Interactable
+ Trigger
},
parameter::{Parameter},
fromtoparameter::FromToParameter,
@@ -50,12 +49,13 @@ macro_rules! components {
ComponentType::$comp => Ok(Self::$comp({
use crate::components::$comp;
$(
- let $paramname = <$paramtype>::from_parameter(
- parameters
+ let $paramname = {
+ let param = parameters
.remove(stringify!($paramname))
- .ok_or(aerr!("required parameter '{}'not found", stringify!($paramname)))?
- )
- .ok_or(aerr!("parameter {} is invalid type", stringify!($paramname)))?;
+ .ok_or(aerr!("required parameter '{}'not found", stringify!($paramname)))?;
+ <$paramtype>::from_parameter(param.clone())
+ .ok_or(aerr!("parameter {} is invalid type: {:?} is not of type {}", stringify!($paramname), param, stringify!($paramtype)))?
+ };
)*
$creation
@@ -183,7 +183,9 @@ components!(all:
Clan (name: String);
Home (home: Pos);
Faction (faction: String) {Faction::from_str(faction.as_str()).ok_or(aerr!("invalid faction name"))?};
- Interactable (action: Interactable) {action};
+ Interactable (typ: String, arg: Parameter) {
+ Interactable::parse_from_parameter(&typ, &arg).ok_or(aerr!("invalid interaction {:?} {:?}", typ, arg))?
+ };
Loot (loot: Vec<(Template, f64)>);
Timer (
trigger: String, (panic!("can't turn trigger to string")),