From d2d00c135f27bbf68e5eb75a859a87001a1b85b3 Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Tue, 8 Apr 2014 21:41:30 -0500 Subject: [PATCH] clear the screen before printing game state --- src/Test.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Test.hs b/src/Test.hs index e39cd43..22f5002 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -85,9 +85,13 @@ b5 = Building { _buildingCost = 4 , _buildingAccumType = NoAccumulation } +clearScreen :: IO () +clearScreen = putStr "\o033[H\o033[2J" >> hFlush stdout + printWaterdeep :: WaterdeepState -> IO () printWaterdeep w = do let ps = map snd $ w ^. gamePlayers . to IM.toAscList + clearScreen putStrLn ("Players: " ++ intercalate ", " (map (^. playerName) ps)) putStrLn ("First Player: " ++ (w ^. gamePlayers . singular (ix (w ^. gameFirstPlayer)) . playerName)) @@ -125,7 +129,12 @@ menuPrompt prm@(SolicitChoice w p t cs) = do let menuSize = length cs let menuLine n t = putStrLn (show n ++ ") " ++ t) let blankLine = putStrLn "" - let redo why = putStrLn ("ERROR: " ++ why) >> blankLine >> menuPrompt prm + + let redo why = do + printWaterdeep w + putStrLn ("ERROR: " ++ why) + blankLine + menuPrompt prm putStrLn t forM_ (zip [1..] cs) $ \(i, (c, _)) -> menuLine i c