wizard-wipeout/src-server/Main.hs

53 lines
1.4 KiB
Haskell
Raw Normal View History

2023-12-08 04:19:32 +00:00
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
2023-12-04 16:20:06 +00:00
module Main where
2023-12-08 04:19:32 +00:00
import Control.Monad.RWS.Strict
import qualified Data.ByteString.Char8 as B8
import Data.String (fromString)
import Data.Time
import Data.Yaml
import Options.Applicative
-- internal imports
import Library.Types
import Server.Game
2023-12-08 04:19:32 +00:00
import Server.Map (generateArena)
import Server.Types
2023-12-08 04:19:32 +00:00
2023-12-04 16:20:06 +00:00
main :: IO ()
2023-12-08 04:19:32 +00:00
main = do
putStrLn "Hello, Wizards!"
(Options optSettingLoc) <- execParser opts
raw <- B8.readFile optSettingLoc
case decodeEither' raw of
Left msg ->
error (optSettingLoc <> ":" <>
" error: " <>
fromString (prettyPrintParseException msg)
)
Right (Settings {..}) -> do
arena <- generateArena setMapRows setMapColumns setSpawnerProbability
putStrLn "generated arena:"
print (arenaMap arena)
putStrLn "-----------------------------------------------------------------------------------"
putStrLn "starting game…"
now <- getCurrentTime
let initRead = ReaderContainer (arenaMap arena) setFPS
initState = StateContainer (arenaSpawners arena) [] (ServerState False False) now
(finalState, finalWrite) <- execRWST runGame initRead initState
print finalWrite
where
opts = info (options <**> helper)
( fullDesc
<> progDesc "Run the \"wizard-wipeout\" Server."
<> header "wizard-wipeout - Last Mage standing"
)