diff options
author | Griffin Smith <grfn@gws.fyi> | 2021-11-25T15·14-0500 |
---|---|---|
committer | grfn <grfn@gws.fyi> | 2021-11-25T17·31+0000 |
commit | 604319850c4b875fb8cdb9c1e7ca34f013993f20 (patch) | |
tree | a8db077291eaf3cf0b6f7511e2c32012f278c477 /users/grfn/xanthous/src/Xanthous/Util.hs | |
parent | a3d220b631d264f4950f17057e60d8908f0783a2 (diff) |
feat(gs/xanthous): Creatures drop their items when they die r/3099
When a creature is killed, it now drops all the contents of its inventory on the ground. Change-Id: Ie95c397308ba2c9861f10e58b99c91c9cc759c56
Diffstat (limited to 'users/grfn/xanthous/src/Xanthous/Util.hs')
-rw-r--r-- | users/grfn/xanthous/src/Xanthous/Util.hs | 10 |
1 files changed, 9 insertions, 1 deletions
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 |