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). --- test/Xanthous/Data/EntityMapSpec.hs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/Xanthous/Data/EntityMapSpec.hs') diff --git a/test/Xanthous/Data/EntityMapSpec.hs b/test/Xanthous/Data/EntityMapSpec.hs index 88e0d0d7712c..8317f5f51f8b 100644 --- a/test/Xanthous/Data/EntityMapSpec.hs +++ b/test/Xanthous/Data/EntityMapSpec.hs @@ -3,6 +3,7 @@ module Xanthous.Data.EntityMapSpec where -------------------------------------------------------------------------------- import Test.Prelude +import Control.Lens.Properties -------------------------------------------------------------------------------- import qualified Data.Aeson as JSON -------------------------------------------------------------------------------- @@ -45,4 +46,8 @@ test = localOption (QuickCheckTests 20) let Just em' = JSON.decode $ JSON.encode em in toEIDsAndPositioned em' === toEIDsAndPositioned em ] + + , testGroup "atPosition" + [ testProperty "lens laws" $ \pos -> isLens $ atPosition @Int pos + ] ] -- cgit 1.4.1