clear the screen before printing game state
This commit is contained in:
parent
f7b7a6dc00
commit
d2d00c135f
11
src/Test.hs
11
src/Test.hs
|
|
@ -85,9 +85,13 @@ b5 = Building { _buildingCost = 4
|
||||||
, _buildingAccumType = NoAccumulation
|
, _buildingAccumType = NoAccumulation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearScreen :: IO ()
|
||||||
|
clearScreen = putStr "\o033[H\o033[2J" >> hFlush stdout
|
||||||
|
|
||||||
printWaterdeep :: WaterdeepState -> IO ()
|
printWaterdeep :: WaterdeepState -> IO ()
|
||||||
printWaterdeep w = do
|
printWaterdeep w = do
|
||||||
let ps = map snd $ w ^. gamePlayers . to IM.toAscList
|
let ps = map snd $ w ^. gamePlayers . to IM.toAscList
|
||||||
|
clearScreen
|
||||||
putStrLn ("Players: " ++ intercalate ", " (map (^. playerName) ps))
|
putStrLn ("Players: " ++ intercalate ", " (map (^. playerName) ps))
|
||||||
putStrLn ("First Player: " ++
|
putStrLn ("First Player: " ++
|
||||||
(w ^. gamePlayers . singular (ix (w ^. gameFirstPlayer)) . playerName))
|
(w ^. gamePlayers . singular (ix (w ^. gameFirstPlayer)) . playerName))
|
||||||
|
|
@ -125,7 +129,12 @@ menuPrompt prm@(SolicitChoice w p t cs) = do
|
||||||
let menuSize = length cs
|
let menuSize = length cs
|
||||||
let menuLine n t = putStrLn (show n ++ ") " ++ t)
|
let menuLine n t = putStrLn (show n ++ ") " ++ t)
|
||||||
let blankLine = putStrLn ""
|
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
|
putStrLn t
|
||||||
forM_ (zip [1..] cs) $ \(i, (c, _)) -> menuLine i c
|
forM_ (zip [1..] cs) $ \(i, (c, _)) -> menuLine i c
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue