summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-03-04 19:58:29 +0100
committertroido <troido@protonmail.com>2020-03-04 19:58:29 +0100
commite0dcd48034e2bab9e0ae17a80a5b4d9f0f2a7900 (patch)
tree958a9de5ec4552613379b8077b79b5956f092c7f /src
parent022e439a6677b9865b7a3287dbd197d86266f8ef (diff)
useitem now actually respects rank
Diffstat (limited to 'src')
-rw-r--r--src/controls.rs8
-rw-r--r--src/systems/useitem.rs2
2 files changed, 9 insertions, 1 deletions
diff --git a/src/controls.rs b/src/controls.rs
index 581b522..3254e00 100644
--- a/src/controls.rs
+++ b/src/controls.rs
@@ -62,7 +62,13 @@ impl Control {
},
"take" => Some(Control::Take(val.get(1)?.as_u64().map(|idx| idx as usize))),
"drop" => Some(Control::Drop(val.get(1)?.as_u64().unwrap_or(0) as usize)),
- "use" => Some(Control::Use(val.get(1)?.as_u64().unwrap_or(0) as usize)),
+ "use" => Some({
+ println!("use argument {:?}", val);
+ if val.get(1)?.as_str()? != "inventory" {
+ return None;
+ }
+ Control::Use(val.get(2)?.as_u64().unwrap_or(0) as usize)
+ }),
"attack" => Some(Control::Attack({
let mut directions = Vec::new();
for dir in val.get(1)?.as_array()? {
diff --git a/src/systems/useitem.rs b/src/systems/useitem.rs
index 89a301c..43f38be 100644
--- a/src/systems/useitem.rs
+++ b/src/systems/useitem.rs
@@ -39,7 +39,9 @@ impl <'a> System<'a> for Use {
for (ent, controller, position, inventory) in (&entities, &controllers, &positions, &mut inventories).join(){
match &controller.control {
Control::Use(rank) => {
+ println!("rank {:?}", rank);
if let Some(item) = inventory.items.get(*rank) {
+ println!("rank {:?}", item);
match &item.action {
Build(template) => {
new.create(position.pos, template.clone()).unwrap();