From 052bc8455a99e7f1a90b6c9354e54cff10de02cc Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Mon, 23 Dec 2019 12:19:51 -0500 Subject: Add a drop command Add a drop command, bound to 'd', which prompts the character for an item in their inventory, removes it from the inventory, and places it on the ground. Along the way I had to fix a bug in the `EntityMap.atPosition` lens, which was always appending to the existing entities at the position on set, without removing the entities that were already there - the rabbit hole of quickchecking the lens laws here also lead to replacing the target of this lens with a newtype called `VectorBag`, which ignores order (since the entitymap makes no guarantees about order of entities at a given position). --- src/Xanthous/Command.hs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Xanthous/Command.hs') diff --git a/src/Xanthous/Command.hs b/src/Xanthous/Command.hs index 3547bdf09ab0..d5bb5cd9eee2 100644 --- a/src/Xanthous/Command.hs +++ b/src/Xanthous/Command.hs @@ -14,6 +14,7 @@ data Command | Move Direction | PreviousMessage | PickUp + | Drop | Open | Wait | Eat @@ -32,6 +33,7 @@ commandFromKey (KChar '.') [] = Just Wait commandFromKey (KChar (directionFromChar -> Just dir)) [] = Just $ Move dir commandFromKey (KChar 'p') [MCtrl] = Just PreviousMessage commandFromKey (KChar ',') [] = Just PickUp +commandFromKey (KChar 'd') [] = Just Drop commandFromKey (KChar 'o') [] = Just Open commandFromKey (KChar ';') [] = Just Look commandFromKey (KChar 'e') [] = Just Eat -- cgit 1.4.1