add world list

This commit is contained in:
Eric Mertens 2022-12-02 20:56:58 -08:00
parent f9d9e332eb
commit 86a360bfaf

View File

@ -159,11 +159,15 @@ world0 = World {
main :: IO ()
main =
do args <- getArgs
let name = case args of x:_ -> x; [] -> ""
bracket (mkVty =<< userConfig) shutdown \vty ->
do
loop vty (pure (pickWorld name))
pure ()
case args of
x:_ | Just w <- Map.lookup x worldList ->
bracket (mkVty =<< userConfig) shutdown \vty ->
loop vty (pure w)
_ ->
do putStrLn "Usage: parabox <worldname>"
putStrLn ""
putStrLn "Available worlds:"
mapM_ putStrLn (Map.keys worldList)
loop :: Vty -> NonEmpty World -> IO ()
loop vty (world :| history) =
@ -184,13 +188,16 @@ loop vty (world :| history) =
_ -> loop vty (world :| history)
_ -> loop vty (world :| history)
pickWorld :: String -> World
pickWorld "world0" = world0
pickWorld "small" = smallWorld
pickWorld "center8" = center8
pickWorld "center13" = center13
pickWorld "clone11" = clone11
pickWorld _ = transfer14
worldList :: Map.Map String World
worldList = Map.fromList
[ ("world0", world0)
, ("small", smallWorld)
, ("center8", center8)
, ("center13", center13)
, ("clone11", clone11)
, ("transfer14", transfer14)
]
smallWorld :: World
smallWorld =