From 4331512a3e66d00343ae91e01928bb5b37237a1f Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Sat, 26 Jul 2014 17:00:53 -0500 Subject: [PATCH] store all the messages from the game and print them at the end. --- src/ConsoleUI.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ConsoleUI.hs b/src/ConsoleUI.hs index 62e703b..a9ba962 100755 --- a/src/ConsoleUI.hs +++ b/src/ConsoleUI.hs @@ -95,7 +95,7 @@ drawState :: IORef DisplayState -> IO () drawState ref = do ds <- readIORef ref printWaterdeep (ds ^. gameState) - forM_ (ds ^. gameMessages) putStrLn + mapM_ putStrLn $ take 4 $ ds ^. gameMessages unless (null (ds ^. gameMessages)) $ putStrLn "" menuPrompt :: IORef DisplayState -> IO () -> WaterdeepPrompt a -> IO a @@ -103,7 +103,7 @@ menuPrompt ref redraw (NotifyState w) = do modifyIORef ref (gameState .~ w) redraw menuPrompt ref redraw (Broadcast s) = do - modifyIORef ref (gameMessages %~ ((s:) . take 4)) + modifyIORef ref (gameMessages %~ (s:)) redraw menuPrompt ref redraw prm@(SolicitChoice p t cs) = do let menuSize = length cs @@ -149,4 +149,6 @@ main = do let w0 = newGame players defaultQuestDeck defaultIntrigueDeck defaultBuildingDeck rndgen ref <- newIORef (DisplayState { _gameState = w0, _gameMessages = [] }) runWaterdeepM (menuPrompt ref (drawState ref)) waterdeepGame w0 + putStrLn "--- GAME LOG ---" + mapM_ putStrLn . reverse . view gameMessages =<< readIORef ref return ()