diff options
author | Griffin Smith <root@gws.fyi> | 2020-01-25T16·18-0500 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2020-01-25T16·38-0500 |
commit | 9256c976edec462af26f33317df6171045e68aa5 (patch) | |
tree | cedf0e97a8a6a40f0f083e164ad88daad57dc3e7 /src/Xanthous/App.hs | |
parent | 2fc4fcfee95ad34a9272414c4fd214b10007539f (diff) |
Factor out an "entitiesAtCharacter" lens
Factor an "entitiesAtCharacter" lens from the one-two step of getting the character position, then getting the entities at that position.
Diffstat (limited to 'src/Xanthous/App.hs')
-rw-r--r-- | src/Xanthous/App.hs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/Xanthous/App.hs b/src/Xanthous/App.hs index 202f38e8685b..1c2fbf86f3b8 100644 --- a/src/Xanthous/App.hs +++ b/src/Xanthous/App.hs @@ -167,8 +167,7 @@ handleCommand Drop = do selectItemFromInventory_ ["drop", "menu"] Cancellable id (say_ ["drop", "nothing"]) $ \(MenuResult item) -> do - charPos <- use characterPosition - entities . EntityMap.atPosition charPos %= (SomeEntity item <|) + entitiesAtCharacter %= (SomeEntity item <|) say ["drop", "dropped"] $ object [ "item" A..= item ] continue @@ -277,9 +276,7 @@ handleCommand Save = do exitSuccess handleCommand GoUp = do - charPos <- use characterPosition - hasStairs <- uses (entities . EntityMap.atPosition charPos) - $ elem (SomeEntity UpStaircase) + hasStairs <- uses entitiesAtCharacter $ elem (SomeEntity UpStaircase) if hasStairs then uses levels prevLevel >>= \case Just levs' -> levels .= levs' @@ -291,9 +288,7 @@ handleCommand GoUp = do continue handleCommand GoDown = do - charPos <- use characterPosition - hasStairs <- uses (entities . EntityMap.atPosition charPos) - $ elem (SomeEntity DownStaircase) + hasStairs <- uses entitiesAtCharacter $ elem (SomeEntity DownStaircase) if hasStairs then do |