From 604319850c4b875fb8cdb9c1e7ca34f013993f20 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Thu, 25 Nov 2021 10:14:00 -0500 Subject: feat(gs/xanthous): Creatures drop their items when they die When a creature is killed, it now drops all the contents of its inventory on the ground. Change-Id: Ie95c397308ba2c9861f10e58b99c91c9cc759c56 --- users/grfn/xanthous/src/Xanthous/Util.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'users/grfn/xanthous/src/Xanthous/Util.hs') diff --git a/users/grfn/xanthous/src/Xanthous/Util.hs b/users/grfn/xanthous/src/Xanthous/Util.hs index 6678cffe6a17..f918340f055b 100644 --- a/users/grfn/xanthous/src/Xanthous/Util.hs +++ b/users/grfn/xanthous/src/Xanthous/Util.hs @@ -34,7 +34,7 @@ module Xanthous.Util , times, times_, endoTimes -- * State utilities - , modifyK, modifyKL + , modifyK, modifyKL, useListOf -- * Type-level programming utils , KnownBool(..) @@ -311,6 +311,14 @@ modifyK k = get >>= k >>= put modifyKL :: MonadState s m => LensLike m s s a b -> (a -> m b) -> m () modifyKL l k = get >>= traverseOf l k >>= put +-- | Use a list of all the targets of a 'Fold' in the current state +-- +-- @@ +-- evalState (useListOf folded) === toList +-- @@ +useListOf :: MonadState s m => Getting (Endo [a]) s a -> m [a] +useListOf = gets . toListOf + -------------------------------------------------------------------------------- -- | A newtype wrapper around 'Char' whose 'Enum' and 'Bounded' instances only -- cgit 1.4.1