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