diff options
| author | troido <troido@protonmail.com> | 2020-02-23 23:44:50 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-02-23 23:44:50 +0100 |
| commit | 86cdc6c567d0ca429d69bebbb2fb02f1d3754c8d (patch) | |
| tree | d70eb9d9f014c9cdbf301772c339f22ee5e3ab82 /src/controls.rs | |
| parent | f422238d7aaae0ff1b2d560a71a99b0a881ad338 (diff) | |
players can now attack other objects
Diffstat (limited to 'src/controls.rs')
| -rw-r--r-- | src/controls.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/controls.rs b/src/controls.rs index 29d45a0..d7471e5 100644 --- a/src/controls.rs +++ b/src/controls.rs @@ -44,7 +44,8 @@ pub enum Control { Move(Direction), Take(Option<usize>), Drop(usize), - Use(usize) + Use(usize), + Attack(Vec<Direction>) } @@ -59,6 +60,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)), + "attack" => Some(Control::Attack({ + let mut directions = Vec::new(); + for dir in val.get(1)?.as_array()? { + directions.push(Direction::from_json(dir)?); + } + directions + })), _ => None } } else {None} |
