53 lines
1.1 KiB
Haskell
53 lines
1.1 KiB
Haskell
{-# LANGUAGE DeriveGeneric #-}
|
|
module Server.Types where
|
|
|
|
import Control.Monad.RWS.Strict
|
|
|
|
import qualified Data.Aeson as Aeson
|
|
|
|
import Data.Time.Clock
|
|
|
|
import GHC.Generics
|
|
|
|
import Options.Applicative as O
|
|
|
|
import Library.Types
|
|
|
|
data Settings = Settings
|
|
{ setSocketPath :: FilePath
|
|
, setMapRows :: Int
|
|
, setMapColumns :: Int
|
|
, setSpawnerProbability :: Float
|
|
, setFPS :: Int
|
|
}
|
|
deriving (Show, Generic)
|
|
|
|
instance Aeson.FromJSON Settings
|
|
|
|
newtype Options = Options
|
|
{ optConfLoc :: FilePath
|
|
}
|
|
|
|
options :: O.Parser Options
|
|
options = Options
|
|
<$> strOption
|
|
( long "configuration"
|
|
<> short 'c'
|
|
<> metavar "FILEPATH"
|
|
<> help "Location of the configuration YAML-file"
|
|
)
|
|
|
|
data ReaderContainer = ReaderContainer
|
|
{ rcMap :: ServerMap
|
|
, rcFPS :: Int
|
|
}
|
|
deriving (Eq, Show)
|
|
|
|
data StateContainer = StateContainer
|
|
{ scSpawners :: [ Spawner ]
|
|
, scPlayers :: [ Wizard ]
|
|
, scServerState :: ServerState
|
|
, scServerLastTick :: UTCTime
|
|
}
|
|
|
|
type Game = RWST ReaderContainer String StateContainer IO ()
|