Last active
July 16, 2017 01:44
-
-
Save mauriciofierrom/1718f592d74fd0223577d78b57da9b0e to your computer and use it in GitHub Desktop.
Jenga Throw 'N Go Dice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.Random | |
import Rainbow | |
import Data.Maybe (fromMaybe) | |
import qualified Data.Map.Lazy as Map | |
main :: IO () | |
main = do | |
roll <- getStdRandom (randomR (0,5)) | |
mapM_ putColorText (replicate 4 roll) | |
input <- getLine | |
case input of | |
"1" -> putStrLn "Goodbye!" | |
_ -> main | |
where | |
putColorText :: Int -> IO () | |
putColorText roll = putChunkLn $ chunk (replicate 8 ' ') & back (fromMaybe white (Map.lookup roll colors)) | |
colors :: Map.Map Int Radiant | |
colors = | |
Map.fromList [ (0, yellow) | |
, (1, brightYellow) | |
, (2, blue) | |
, (3, red) | |
, (4, green) | |
, (5, magenta) ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment