diff options
Diffstat (limited to 'src/Xanthous/Game')
-rw-r--r-- | src/Xanthous/Game/Draw.hs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/Xanthous/Game/Draw.hs b/src/Xanthous/Game/Draw.hs index 79089029ea8d..5a2f773c1b18 100644 --- a/src/Xanthous/Game/Draw.hs +++ b/src/Xanthous/Game/Draw.hs @@ -8,15 +8,25 @@ import Xanthous.Prelude import Brick hiding (loc) import Brick.Widgets.Border import Brick.Widgets.Border.Style +import Data.List.NonEmpty(NonEmpty((:|))) import Xanthous.Data (Position(Position), x, y, loc) import Xanthous.Data.EntityMap import Xanthous.Entities -import Xanthous.Game (GameState(..), entities, characterPosition) +import Xanthous.Game + ( GameState(..) + , entities + , characterPosition + , MessageHistory(..) + , messageHistory + ) import Xanthous.Resource (Name(..)) +import Xanthous.Orphans () -drawMessages :: GameState -> Widget Name -drawMessages _ = str "Welcome to Xanthous! It's dangerous out there, why not stay inside?" +drawMessages :: MessageHistory -> Widget Name +drawMessages NoMessageHistory = emptyWidget +drawMessages (MessageHistory _ False) = emptyWidget +drawMessages (MessageHistory (lastMessage :| _) True) = str $ unpack lastMessage drawEntities :: (Draw a, Show a) => EntityMap a -> Widget Name drawEntities em@(fromNullable . positions -> Just entityPositions) @@ -41,5 +51,5 @@ drawGame :: GameState -> [Widget Name] drawGame game = pure . withBorderStyle unicode - $ drawMessages game + $ drawMessages (game ^. messageHistory) <=> border (drawMap game) |