diff options
| author | troido <troido@protonmail.com> | 2020-03-04 19:58:29 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-03-04 19:58:29 +0100 |
| commit | e0dcd48034e2bab9e0ae17a80a5b4d9f0f2a7900 (patch) | |
| tree | 958a9de5ec4552613379b8077b79b5956f092c7f | |
| parent | 022e439a6677b9865b7a3287dbd197d86266f8ef (diff) | |
useitem now actually respects rank
| -rw-r--r-- | src/controls.rs | 8 | ||||
| -rw-r--r-- | src/systems/useitem.rs | 2 | ||||
| -rw-r--r-- | todo.md | 4 |
3 files changed, 10 insertions, 4 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(); @@ -1,13 +1,11 @@ # TODO -- interactions -- growing/timers - save variable arguments (health etc) +- timer resource - safely write files - log failure in room loading - log world events to player -- loot - room unloading - relative room locations - equipment |
