summaryrefslogtreecommitdiff
path: root/src/componentwrapper.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/componentwrapper.rs')
-rw-r--r--src/componentwrapper.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/componentwrapper.rs b/src/componentwrapper.rs
index 0fb46d0..038b526 100644
--- a/src/componentwrapper.rs
+++ b/src/componentwrapper.rs
@@ -15,6 +15,7 @@ use crate::{
},
parameter::{Parameter, ParameterType},
Timestamp,
+ Template,
Result,
aerr
};
@@ -182,7 +183,25 @@ components!(
Home (home: Pos);
Faction (faction: String) {Faction::from_str(faction.as_str()).ok_or(aerr!("invalid faction name"))?};
Interactable (action: Interaction) {action};
- Loot (loot: LootList);
+ Loot (loot: List) {
+ Loot { loot:
+ loot
+ .iter()
+ .map(|param| {match param {
+ Parameter::Template(template) => Some((template.clone(), 1.0)),
+ Parameter::List(l) => {
+ if l.len() == 2 {
+ if let (Parameter::Template(template), Parameter::Float(chance)) = (l[0].clone(), l[1].clone()) {
+ return Some((template.clone(), chance))
+ }
+ }
+ None?
+ },
+ _ => None?
+ }})
+ .collect::<Option<Vec<(Template, f64)>>>().ok_or(aerr!("invalid loot definition"))?
+ }
+ };
Grow (
into: Template (Grow.into.clone()),
delay: Int (Grow.delay),