Skip to content

Instantly share code, notes, and snippets.

@mauriciofierrom
Last active July 16, 2017 01:44
Show Gist options
  • Save mauriciofierrom/1718f592d74fd0223577d78b57da9b0e to your computer and use it in GitHub Desktop.
Save mauriciofierrom/1718f592d74fd0223577d78b57da9b0e to your computer and use it in GitHub Desktop.
Jenga Throw 'N Go Dice
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