clear the screen before printing game state

This commit is contained in:
Jesse D. McDonald 2014-04-08 21:41:30 -05:00
parent f7b7a6dc00
commit d2d00c135f
1 changed files with 10 additions and 1 deletions

View File

@ -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