about summary refs log tree commit diff
path: root/src/Xanthous/Game/Draw.hs
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2019-09-28T19·01-0400
committerGriffin Smith <root@gws.fyi>2019-09-28T19·03-0400
commitabea2dcfac0e094bf4ce0d378763af7816b04501 (patch)
treefbe772353869571b85c4d73227e642c47acd0f28 /src/Xanthous/Game/Draw.hs
parent1a0f618a829ec356e29176c77ea90a8a5a0157b4 (diff)
Add debug command to reveal the game
Add a (debug) command to reveal all tiles on the game regardless of the
character's vision, which'll make it easier to debug creature's behavior
while they're not visible.
Diffstat (limited to 'src/Xanthous/Game/Draw.hs')
-rw-r--r--src/Xanthous/Game/Draw.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/Xanthous/Game/Draw.hs b/src/Xanthous/Game/Draw.hs
index ff9240a5e1..b3e27f86a6 100644
--- a/src/Xanthous/Game/Draw.hs
+++ b/src/Xanthous/Game/Draw.hs
@@ -23,6 +23,7 @@ import           Xanthous.Game
                  , messageHistory
                  , GamePromptState(..)
                  , promptState
+                 , debugState, allRevealed
                  )
 import           Xanthous.Game.Prompt
 import           Xanthous.Resource (Name)
@@ -46,14 +47,11 @@ drawPromptState (WaitingPrompt msg (Prompt _ pt ps _)) =
     _ -> undefined
 
 drawEntities
-  :: Set Position
-    -- ^ Positions the character has seen
-    -- FIXME: this will break down as soon as creatures can walk around on their
-    -- own, since we don't want to render things walking around when the
-    -- character can't see them
+  :: (Position -> Bool)
+    -- ^ Can we render a given position?
   -> EntityMap SomeEntity -- ^ all entities
   -> Widget Name
-drawEntities visiblePositions allEnts
+drawEntities canRenderPos allEnts
   = vBox rows
   where
     entityPositions = EntityMap.positions allEnts
@@ -62,7 +60,7 @@ drawEntities visiblePositions allEnts
     rows = mkRow <$> [0..maxY]
     mkRow rowY = hBox $ renderEntityAt . flip Position rowY <$> [0..maxX]
     renderEntityAt pos
-      | pos `member` visiblePositions
+      | canRenderPos pos
       = let neighbors = EntityMap.neighbors pos allEnts
         in maybe (str " ") (drawWithNeighbors neighbors)
            $ allEnts ^? atPosition pos . folded
@@ -73,7 +71,12 @@ drawMap game
   = viewport Resource.MapViewport Both
   . showCursor Resource.Character (game ^. characterPosition . loc)
   $ drawEntities
-    (game ^. revealedPositions)
+    (\pos ->
+         (game ^. debugState . allRevealed)
+       || (pos `member` (game ^. revealedPositions)))
+    -- FIXME: this will break down as soon as creatures can walk around on their
+    -- own, since we don't want to render things walking around when the
+    -- character can't see them
     (game ^. entities)
 
 drawGame :: GameState -> [Widget Name]