    -- | Server and client game state types and operations.
    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

    -- | Options that affect the behaviour of the server (including game rules).
    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
          -- The client debug inside server debug only holds the client commandline
          -- options and is never updated with config options, etc.
      }
      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
    $cshowsPrec :: Int -> ServerOptions -> ShowS
    showsPrec :: Int -> ServerOptions -> ShowS
    $cshow :: ServerOptions -> String
    show :: ServerOptions -> String
    $cshowList :: [ServerOptions] -> ShowS
    showList :: [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{Maybe SMGen
    dungeonRandomGenerator :: RNGs -> Maybe SMGen
    startingRandomGenerator :: RNGs -> Maybe SMGen
    dungeonRandomGenerator :: Maybe SMGen
    startingRandomGenerator :: Maybe SMGen
    ..} =
        let args :: [String]
    args = [ String -> (SMGen -> String) -> Maybe SMGen -> String
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe String
    "" (\SMGen
    gen -> String
    "--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]
    ++ String
    "\"")
                           Maybe SMGen
    dungeonRandomGenerator
                   , String -> (SMGen -> String) -> Maybe SMGen -> String
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe String
    "" (\SMGen
    gen -> String
    "--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]
    ++ String
    "\"")
                           Maybe SMGen
    startingRandomGenerator ]
        in [String] -> String
    unwords [String]
    args

    instance Binary ServerOptions where
      put :: ServerOptions -> Put
    put ServerOptions{Bool
    String
    Maybe Int
    Maybe SMGen
    Maybe (GroupName ModeKind)
    ClientOptions
    Challenge
    sknowMap :: ServerOptions -> Bool
    sknowEvents :: ServerOptions -> Bool
    sknowItems :: ServerOptions -> Bool
    sniff :: ServerOptions -> Bool
    sallClear :: ServerOptions -> Bool
    sboostRandomItem :: ServerOptions -> Bool
    sgameMode :: ServerOptions -> Maybe (GroupName ModeKind)
    sautomateAll :: ServerOptions -> Bool
    skeepAutomated :: ServerOptions -> Bool
    sdungeonRng :: ServerOptions -> Maybe SMGen
    smainRng :: ServerOptions -> Maybe SMGen
    snewGameSer :: ServerOptions -> Bool
    scurChalSer :: ServerOptions -> Challenge
    sdumpInitRngs :: ServerOptions -> Bool
    ssavePrefixSer :: ServerOptions -> String
    sdbgMsgSer :: ServerOptions -> Bool
    sassertExplored :: ServerOptions -> Maybe Int
    sshowItemSamples :: ServerOptions -> Bool
    sstopAfterGameOver :: ServerOptions -> Bool
    sclientOptions :: ServerOptions -> ClientOptions
    sknowMap :: Bool
    sknowEvents :: Bool
    sknowItems :: Bool
    sniff :: Bool
    sallClear :: Bool
    sboostRandomItem :: Bool
    sgameMode :: Maybe (GroupName ModeKind)
    sautomateAll :: Bool
    skeepAutomated :: Bool
    sdungeonRng :: Maybe SMGen
    smainRng :: Maybe SMGen
    snewGameSer :: Bool
    scurChalSer :: Challenge
    sdumpInitRngs :: Bool
    ssavePrefixSer :: String
    sdbgMsgSer :: Bool
    sassertExplored :: Maybe Int
    sshowItemSamples :: Bool
    sstopAfterGameOver :: Bool
    sclientOptions :: ClientOptions
    ..} = 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
        sknowMap <- Get Bool
    forall t. Binary t => Get t
    get
        sknowEvents <- get
        sknowItems <- get
        sniff <- get
        sallClear <- get
        sboostRandomItem <- get
        sgameMode <- get
        sautomateAll <- get
        skeepAutomated <- get
        scurChalSer <- get
        ssavePrefixSer <- get
        sdbgMsgSer <- get
        sassertExplored <- get
        sshowItemSamples <- get
        sclientOptions <- get
        let sdungeonRng = Maybe a
    forall a. Maybe a
    Nothing
            smainRng = Maybe a
    forall a. Maybe a
    Nothing
            snewGameSer = Bool
    False
            sdumpInitRngs = Bool
    False
            sstopAfterGameOver = Bool
    False
        return $! ServerOptions{..}

    instance Binary RNGs where
      put :: RNGs -> Put
    put RNGs{Maybe SMGen
    dungeonRandomGenerator :: RNGs -> Maybe SMGen
    startingRandomGenerator :: RNGs -> Maybe SMGen
    dungeonRandomGenerator :: Maybe SMGen
    startingRandomGenerator :: Maybe SMGen
    ..} = 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
        dg <- Get String
    forall t. Binary t => Get t
    get
        sg <- get
        let dungeonRandomGenerator = String -> Maybe SMGen
    forall a. Read a => String -> a
    read String
    dg
            startingRandomGenerator = String -> Maybe SMGen
    forall a. Read a => String -> a
    read String
    sg
        return $! RNGs{..}

    -- | Default value of server options.
    defServerOptions :: ServerOptions
    defServerOptions :: ServerOptions
    defServerOptions = 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 = String
    ""
      , 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
      }