module Game.LambdaHack.Server.ServerOptions
( ServerOptions(..), RNGs(..), defServerOptions
) where
import Prelude ()
import Game.LambdaHack.Core.Prelude
import Data.Binary
import qualified System.Random.SplitMix32 as SM
import Game.LambdaHack.Common.ClientOptions
import Game.LambdaHack.Common.Faction
import Game.LambdaHack.Content.ModeKind
import Game.LambdaHack.Definition.Defs
data ServerOptions = ServerOptions
{ ServerOptions -> Bool
sknowMap :: Bool
, ServerOptions -> Bool
sknowEvents :: Bool
, ServerOptions -> Bool
sknowItems :: Bool
, ServerOptions -> Bool
sniff :: Bool
, ServerOptions -> Bool
sallClear :: Bool
, ServerOptions -> Bool
sboostRandomItem :: Bool
, ServerOptions -> Maybe (GroupName ModeKind)
sgameMode :: Maybe (GroupName ModeKind)
, ServerOptions -> Bool
sautomateAll :: Bool
, ServerOptions -> Bool
skeepAutomated :: Bool
, ServerOptions -> Maybe SMGen
sdungeonRng :: Maybe SM.SMGen
, ServerOptions -> Maybe SMGen
smainRng :: Maybe SM.SMGen
, ServerOptions -> Bool
snewGameSer :: Bool
, ServerOptions -> Challenge
scurChalSer :: Challenge
, ServerOptions -> Bool
sdumpInitRngs :: Bool
, ServerOptions -> String
ssavePrefixSer :: String
, ServerOptions -> Bool
sdbgMsgSer :: Bool
, ServerOptions -> Maybe Int
sassertExplored :: Maybe Int
, ServerOptions -> Bool
sshowItemSamples :: Bool
, ServerOptions -> Bool
sstopAfterGameOver :: Bool
, ServerOptions -> ClientOptions
sclientOptions :: ClientOptions
}
deriving Int -> ServerOptions -> ShowS
[ServerOptions] -> ShowS
ServerOptions -> String
(Int -> ServerOptions -> ShowS)
-> (ServerOptions -> String)
-> ([ServerOptions] -> ShowS)
-> Show ServerOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServerOptions] -> ShowS
$cshowList :: [ServerOptions] -> ShowS
show :: ServerOptions -> String
$cshow :: ServerOptions -> String
showsPrec :: Int -> ServerOptions -> ShowS
$cshowsPrec :: Int -> ServerOptions -> ShowS
Show
data RNGs = RNGs
{ RNGs -> Maybe SMGen
dungeonRandomGenerator :: Maybe SM.SMGen
, RNGs -> Maybe SMGen
startingRandomGenerator :: Maybe SM.SMGen
}
instance Show RNGs where
show :: RNGs -> String
show RNGs{..} =
let args :: [String]
args = [ String -> (SMGen -> String) -> Maybe SMGen -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe "" (\gen :: SMGen
gen -> "--setDungeonRng \"" String -> ShowS
forall a. [a] -> [a] -> [a]
++ SMGen -> String
forall a. Show a => a -> String
show SMGen
gen String -> ShowS
forall a. [a] -> [a] -> [a]
++ "\"")
Maybe SMGen
dungeonRandomGenerator
, String -> (SMGen -> String) -> Maybe SMGen -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe "" (\gen :: SMGen
gen -> "--setMainRng \"" String -> ShowS
forall a. [a] -> [a] -> [a]
++ SMGen -> String
forall a. Show a => a -> String
show SMGen
gen String -> ShowS
forall a. [a] -> [a] -> [a]
++ "\"")
Maybe SMGen
startingRandomGenerator ]
in [String] -> String
unwords [String]
args
instance Binary ServerOptions where
put :: ServerOptions -> Put
put ServerOptions{..} = do
Bool -> Put
forall t. Binary t => t -> Put
put Bool
sknowMap
Bool -> Put
forall t. Binary t => t -> Put
put Bool
sknowEvents
Bool -> Put
forall t. Binary t => t -> Put
put Bool
sknowItems
Bool -> Put
forall t. Binary t => t -> Put
put Bool
sniff
Bool -> Put
forall t. Binary t => t -> Put
put Bool
sallClear
Bool -> Put
forall t. Binary t => t -> Put
put Bool
sboostRandomItem
Maybe (GroupName ModeKind) -> Put
forall t. Binary t => t -> Put
put Maybe (GroupName ModeKind)
sgameMode
Bool -> Put
forall t. Binary t => t -> Put
put Bool
sautomateAll
Bool -> Put
forall t. Binary t => t -> Put
put Bool
skeepAutomated
Challenge -> Put
forall t. Binary t => t -> Put
put Challenge
scurChalSer
String -> Put
forall t. Binary t => t -> Put
put String
ssavePrefixSer
Bool -> Put
forall t. Binary t => t -> Put
put Bool
sdbgMsgSer
Maybe Int -> Put
forall t. Binary t => t -> Put
put Maybe Int
sassertExplored
Bool -> Put
forall t. Binary t => t -> Put
put Bool
sshowItemSamples
ClientOptions -> Put
forall t. Binary t => t -> Put
put ClientOptions
sclientOptions
get :: Get ServerOptions
get = do
Bool
sknowMap <- Get Bool
forall t. Binary t => Get t
get
Bool
sknowEvents <- Get Bool
forall t. Binary t => Get t
get
Bool
sknowItems <- Get Bool
forall t. Binary t => Get t
get
Bool
sniff <- Get Bool
forall t. Binary t => Get t
get
Bool
sallClear <- Get Bool
forall t. Binary t => Get t
get
Bool
sboostRandomItem <- Get Bool
forall t. Binary t => Get t
get
Maybe (GroupName ModeKind)
sgameMode <- Get (Maybe (GroupName ModeKind))
forall t. Binary t => Get t
get
Bool
sautomateAll <- Get Bool
forall t. Binary t => Get t
get
Bool
skeepAutomated <- Get Bool
forall t. Binary t => Get t
get
Challenge
scurChalSer <- Get Challenge
forall t. Binary t => Get t
get
String
ssavePrefixSer <- Get String
forall t. Binary t => Get t
get
Bool
sdbgMsgSer <- Get Bool
forall t. Binary t => Get t
get
Maybe Int
sassertExplored <- Get (Maybe Int)
forall t. Binary t => Get t
get
Bool
sshowItemSamples <- Get Bool
forall t. Binary t => Get t
get
ClientOptions
sclientOptions <- Get ClientOptions
forall t. Binary t => Get t
get
let sdungeonRng :: Maybe a
sdungeonRng = Maybe a
forall a. Maybe a
Nothing
smainRng :: Maybe a
smainRng = Maybe a
forall a. Maybe a
Nothing
snewGameSer :: Bool
snewGameSer = Bool
False
sdumpInitRngs :: Bool
sdumpInitRngs = Bool
False
sstopAfterGameOver :: Bool
sstopAfterGameOver = Bool
False
ServerOptions -> Get ServerOptions
forall (m :: * -> *) a. Monad m => a -> m a
return (ServerOptions -> Get ServerOptions)
-> ServerOptions -> Get ServerOptions
forall a b. (a -> b) -> a -> b
$! $WServerOptions :: Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> Maybe (GroupName ModeKind)
-> Bool
-> Bool
-> Maybe SMGen
-> Maybe SMGen
-> Bool
-> Challenge
-> Bool
-> String
-> Bool
-> Maybe Int
-> Bool
-> Bool
-> ClientOptions
-> ServerOptions
ServerOptions{..}
instance Binary RNGs where
put :: RNGs -> Put
put RNGs{..} = do
String -> Put
forall t. Binary t => t -> Put
put (Maybe SMGen -> String
forall a. Show a => a -> String
show Maybe SMGen
dungeonRandomGenerator)
String -> Put
forall t. Binary t => t -> Put
put (Maybe SMGen -> String
forall a. Show a => a -> String
show Maybe SMGen
startingRandomGenerator)
get :: Get RNGs
get = do
String
dg <- Get String
forall t. Binary t => Get t
get
String
sg <- Get String
forall t. Binary t => Get t
get
let dungeonRandomGenerator :: Maybe SMGen
dungeonRandomGenerator = String -> Maybe SMGen
forall a. Read a => String -> a
read String
dg
startingRandomGenerator :: Maybe SMGen
startingRandomGenerator = String -> Maybe SMGen
forall a. Read a => String -> a
read String
sg
RNGs -> Get RNGs
forall (m :: * -> *) a. Monad m => a -> m a
return (RNGs -> Get RNGs) -> RNGs -> Get RNGs
forall a b. (a -> b) -> a -> b
$! $WRNGs :: Maybe SMGen -> Maybe SMGen -> RNGs
RNGs{..}
defServerOptions :: ServerOptions
defServerOptions :: ServerOptions
defServerOptions = $WServerOptions :: Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> Maybe (GroupName ModeKind)
-> Bool
-> Bool
-> Maybe SMGen
-> Maybe SMGen
-> Bool
-> Challenge
-> Bool
-> String
-> Bool
-> Maybe Int
-> Bool
-> Bool
-> ClientOptions
-> ServerOptions
ServerOptions
{ sknowMap :: Bool
sknowMap = Bool
False
, sknowEvents :: Bool
sknowEvents = Bool
False
, sknowItems :: Bool
sknowItems = Bool
False
, sniff :: Bool
sniff = Bool
False
, sallClear :: Bool
sallClear = Bool
False
, sboostRandomItem :: Bool
sboostRandomItem = Bool
False
, sgameMode :: Maybe (GroupName ModeKind)
sgameMode = Maybe (GroupName ModeKind)
forall a. Maybe a
Nothing
, sautomateAll :: Bool
sautomateAll = Bool
False
, skeepAutomated :: Bool
skeepAutomated = Bool
False
, sdungeonRng :: Maybe SMGen
sdungeonRng = Maybe SMGen
forall a. Maybe a
Nothing
, smainRng :: Maybe SMGen
smainRng = Maybe SMGen
forall a. Maybe a
Nothing
, snewGameSer :: Bool
snewGameSer = Bool
False
, scurChalSer :: Challenge
scurChalSer = Challenge
defaultChallenge
, sdumpInitRngs :: Bool
sdumpInitRngs = Bool
False
, ssavePrefixSer :: String
ssavePrefixSer = ""
, sdbgMsgSer :: Bool
sdbgMsgSer = Bool
False
, sassertExplored :: Maybe Int
sassertExplored = Maybe Int
forall a. Maybe a
Nothing
, sshowItemSamples :: Bool
sshowItemSamples = Bool
False
, sstopAfterGameOver :: Bool
sstopAfterGameOver = Bool
False
, sclientOptions :: ClientOptions
sclientOptions = ClientOptions
defClientOptions
}