{-# LANGUAGE ApplicativeDo #-}
-- | Parsing of commandline arguments.
module Game.LambdaHack.Server.Commandline
  ( serverOptionsPI
#ifdef EXPOSE_INTERNAL
    -- * Internal operations
  , serverOptionsP
      -- other internal operations too numerous and changing, so not listed
#endif
  ) where

import Prelude ()

import Game.LambdaHack.Core.Prelude
-- Cabal
import qualified Paths_LambdaHack as Self (version)

import qualified Data.Text as T
import           Data.Version
import           Options.Applicative
import qualified System.Random as R

-- Dependence on ClientOptions is an anomaly. Instead, probably the raw
-- remaining commandline should be passed and parsed by the client to extract
-- client and ui options from and singnal an error if anything was left.

import Game.LambdaHack.Client (ClientOptions (..))
import Game.LambdaHack.Definition.Defs
import Game.LambdaHack.Common.Faction
import Game.LambdaHack.Content.ModeKind
import Game.LambdaHack.Server.ServerOptions

-- | Parser for server options from commandline arguments.
serverOptionsPI :: ParserInfo ServerOptions
serverOptionsPI :: ParserInfo ServerOptions
serverOptionsPI = Parser ServerOptions
-> InfoMod ServerOptions -> ParserInfo ServerOptions
forall a. Parser a -> InfoMod a -> ParserInfo a
info (Parser ServerOptions
serverOptionsP Parser ServerOptions
-> Parser (ServerOptions -> ServerOptions) -> Parser ServerOptions
forall (f :: * -> *) a b. Applicative f => f a -> f (a -> b) -> f b
<**> Parser (ServerOptions -> ServerOptions)
forall a. Parser (a -> a)
helper Parser ServerOptions
-> Parser (ServerOptions -> ServerOptions) -> Parser ServerOptions
forall (f :: * -> *) a b. Applicative f => f a -> f (a -> b) -> f b
<**> Parser (ServerOptions -> ServerOptions)
forall a. Parser (a -> a)
version)
                  (InfoMod ServerOptions -> ParserInfo ServerOptions)
-> InfoMod ServerOptions -> ParserInfo ServerOptions
forall a b. (a -> b) -> a -> b
$ InfoMod ServerOptions
forall a. InfoMod a
fullDesc
                    InfoMod ServerOptions
-> InfoMod ServerOptions -> InfoMod ServerOptions
forall a. Semigroup a => a -> a -> a
<> String -> InfoMod ServerOptions
forall a. String -> InfoMod a
progDesc "Configure debug options here, gameplay options in configuration file."

version :: Parser (a -> a)
version :: Parser (a -> a)
version = String -> Mod OptionFields (a -> a) -> Parser (a -> a)
forall a. String -> Mod OptionFields (a -> a) -> Parser (a -> a)
infoOption (Version -> String
showVersion Version
Self.version)
  (String -> Mod OptionFields (a -> a)
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "version"
   Mod OptionFields (a -> a)
-> Mod OptionFields (a -> a) -> Mod OptionFields (a -> a)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (a -> a)
forall (f :: * -> *) a. String -> Mod f a
help "Print engine version information")

serverOptionsP :: Parser ServerOptions
serverOptionsP :: Parser ServerOptions
serverOptionsP = do
  ~(snewGameSer :: Bool
snewGameSer, scurChalSer :: Challenge
scurChalSer)
                    <- Maybe Int -> (Bool, Challenge)
serToChallenge (Maybe Int -> (Bool, Challenge))
-> Parser (Maybe Int) -> Parser (Bool, Challenge)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (Maybe Int)
newGameP
  Bool
knowMap           <- Parser Bool
knowMapP
  Bool
knowEvents        <- Parser Bool
knowEventsP
  Bool
knowItems         <- Parser Bool
knowItemsP
  Bool
showItemSamples   <- Parser Bool
showItemSamplesP
  Bool
sexposePlaces     <- Parser Bool
exposePlacesP
  Bool
sexposeItems      <- Parser Bool
exposeItemsP
  Bool
sexposeActors     <- Parser Bool
exposeActorsP
  Bool
sniff             <- Parser Bool
sniffP
  Bool
sallClear         <- Parser Bool
allClearP
  Bool
sboostRandomItem  <- Parser Bool
boostRandItemP
  Maybe (GroupName ModeKind)
sgameMode         <- Parser (Maybe (GroupName ModeKind))
gameModeP
  Bool
sautomateAll      <- Parser Bool
automateAllP
  Bool
skeepAutomated    <- Parser Bool
keepAutomatedP
  Maybe Int
sstopAfterSeconds <- Parser (Maybe Int)
stopAfterSecsP
  Maybe Int
sstopAfterFrames  <- Parser (Maybe Int)
stopAfterFramesP
  Bool
sprintEachScreen  <- Parser Bool
printEachScreenP
  Bool
sbenchmark        <- Parser Bool
benchmarkP
  Maybe StdGen
sdungeonRng       <- Parser (Maybe StdGen)
setDungeonRngP
  Maybe StdGen
smainRng          <- Parser (Maybe StdGen)
setMainRngP
  Bool
sdumpInitRngs     <- Parser Bool
dumpInitRngsP
  Bool
sdbgMsgSer        <- Parser Bool
dbgMsgSerP
  Maybe Text
sgtkFontFamily    <- Parser (Maybe Text)
gtkFontFamilyP
  Maybe Text
sdlFontFile       <- Parser (Maybe Text)
sdlFontFileP
  Maybe Int
sdlScalableSizeAdd <- Parser (Maybe Int)
sdlScalableSizeAddP
  Maybe Int
sdlBitmapSizeAdd  <- Parser (Maybe Int)
sdlBitmapSizeAddP
  Maybe Int
sscalableFontSize <- Parser (Maybe Int)
scalableFontSizeP
  Maybe String
sfontDir          <- Parser (Maybe String)
fontDirP
  Maybe Int
slogPriority      <- Parser (Maybe Int)
logPriorityP
  Maybe Int
smaxFps           <- Parser (Maybe Int)
maxFpsP
  Bool
sdisableAutoYes   <- Parser Bool
disableAutoYesP
  Maybe Bool
snoAnim           <- Parser (Maybe Bool)
noAnimP
  String
ssavePrefixSer    <- Parser String
savePrefixP
  Bool
sfrontendTeletype <- Parser Bool
frontendTeletypeP
  Bool
sfrontendNull     <- Parser Bool
frontendNullP
  Bool
sfrontendLazy     <- Parser Bool
frontendLazyP
  Bool
sdbgMsgCli        <- Parser Bool
dbgMsgCliP

  pure $WServerOptions :: Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> Maybe (GroupName ModeKind)
-> Bool
-> Bool
-> Maybe StdGen
-> Maybe StdGen
-> Bool
-> Challenge
-> Bool
-> String
-> Bool
-> Bool
-> ClientOptions
-> ServerOptions
ServerOptions
    {
      sclientOptions :: ClientOptions
sclientOptions = $WClientOptions :: Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Bool
-> Maybe Bool
-> Bool
-> Bool
-> Maybe Text
-> Maybe String
-> String
-> Bool
-> Bool
-> Bool
-> Bool
-> Maybe Int
-> Maybe Int
-> Bool
-> Bool
-> Bool
-> Bool
-> ClientOptions
ClientOptions
        { stitle :: Maybe Text
stitle         = Maybe Text
forall a. Maybe a
Nothing
        , snewGameCli :: Bool
snewGameCli    = Bool
snewGameSer
        , ssavePrefixCli :: String
ssavePrefixCli = String
ssavePrefixSer
        , ..
        }
    , sknowMap :: Bool
sknowMap = Bool
knowMap Bool -> Bool -> Bool
|| Bool
knowEvents Bool -> Bool -> Bool
|| Bool
knowItems
    , sknowEvents :: Bool
sknowEvents = Bool
knowEvents Bool -> Bool -> Bool
|| Bool
knowItems
    , sknowItems :: Bool
sknowItems = Bool
knowItems
    , sshowItemSamples :: Bool
sshowItemSamples = Bool -> Bool
not (Bool
knowEvents Bool -> Bool -> Bool
|| Bool
knowItems) Bool -> Bool -> Bool
&& Bool
showItemSamples
    , ..
    }
 where
   serToChallenge :: Maybe Int -> (Bool, Challenge)
   serToChallenge :: Maybe Int -> (Bool, Challenge)
serToChallenge Nothing      = (Bool
False, Challenge
defaultChallenge)
   serToChallenge (Just cdiff :: Int
cdiff) = (Bool
True, Challenge
defaultChallenge {Int
cdiff :: Int
cdiff :: Int
cdiff})

knowMapP :: Parser Bool
knowMapP :: Parser Bool
knowMapP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "knowMap"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Reveal map for all clients in the next game" )

knowEventsP :: Parser Bool
knowEventsP :: Parser Bool
knowEventsP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "knowEvents"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Show all events in the next game (implies --knowMap)" )

knowItemsP :: Parser Bool
knowItemsP :: Parser Bool
knowItemsP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "knowItems"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Auto-identify all items in the next game (implies --knowEvents)" )

exposePlacesP :: Parser Bool
exposePlacesP :: Parser Bool
exposePlacesP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "exposePlaces"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Expose all possible places in the next game" )

exposeItemsP :: Parser Bool
exposeItemsP :: Parser Bool
exposeItemsP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "exposeItems"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Expose all possible items in the next game" )

exposeActorsP :: Parser Bool
exposeActorsP :: Parser Bool
exposeActorsP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "exposeActors"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Expose all killable actors in the next game" )

showItemSamplesP :: Parser Bool
showItemSamplesP :: Parser Bool
showItemSamplesP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "showItemSamples"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "At game over show samples of all items (--sknowEvents disables this)" )

sniffP :: Parser Bool
sniffP :: Parser Bool
sniffP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "sniff"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Monitor all trafic between server and clients" )

allClearP :: Parser Bool
allClearP :: Parser Bool
allClearP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "allClear"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Let all map tiles be translucent" )

boostRandItemP :: Parser Bool
boostRandItemP :: Parser Bool
boostRandItemP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "boostRandomItem"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Pick a random item and make it very common" )

gameModeP :: Parser (Maybe (GroupName ModeKind))
gameModeP :: Parser (Maybe (GroupName ModeKind))
gameModeP = Parser (GroupName ModeKind) -> Parser (Maybe (GroupName ModeKind))
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser (GroupName ModeKind)
 -> Parser (Maybe (GroupName ModeKind)))
-> Parser (GroupName ModeKind)
-> Parser (Maybe (GroupName ModeKind))
forall a b. (a -> b) -> a -> b
$ String -> GroupName ModeKind
toGameMode (String -> GroupName ModeKind)
-> Parser String -> Parser (GroupName ModeKind)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
  Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
strOption (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "gameMode"
            Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar "MODE"
            Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
help "Start next game in the scenario indicated by MODE" )
 where
  toGameMode :: String -> GroupName ModeKind
  toGameMode :: String -> GroupName ModeKind
toGameMode = Text -> GroupName ModeKind
forall a. Text -> GroupName a
toGroupName (Text -> GroupName ModeKind)
-> (String -> Text) -> String -> GroupName ModeKind
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack

automateAllP :: Parser Bool
automateAllP :: Parser Bool
automateAllP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "automateAll"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Give control of all UI teams to computer" )

keepAutomatedP :: Parser Bool
keepAutomatedP :: Parser Bool
keepAutomatedP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "keepAutomated"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Keep factions automated after game over" )

newGameP :: Parser (Maybe Int)
newGameP :: Parser (Maybe Int)
newGameP = Parser Int -> Parser (Maybe Int)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser Int -> Parser (Maybe Int))
-> Parser Int -> Parser (Maybe Int)
forall a b. (a -> b) -> a -> b
$
  ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM Int
forall a. Read a => ReadM a
auto (  String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "newGame"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
help "Start a new game, overwriting the save file, with difficulty for all UI players set to N"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar "N" )

stopAfterSecsP :: Parser (Maybe Int)
stopAfterSecsP :: Parser (Maybe Int)
stopAfterSecsP = Parser Int -> Parser (Maybe Int)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser Int -> Parser (Maybe Int))
-> Parser Int -> Parser (Maybe Int)
forall a b. (a -> b) -> a -> b
$
  ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM Int
forall a. Read a => ReadM a
auto (  String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "stopAfterSeconds"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
help "Exit game session after around N seconds"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar "N" )

stopAfterFramesP :: Parser (Maybe Int)
stopAfterFramesP :: Parser (Maybe Int)
stopAfterFramesP = Parser Int -> Parser (Maybe Int)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser Int -> Parser (Maybe Int))
-> Parser Int -> Parser (Maybe Int)
forall a b. (a -> b) -> a -> b
$
  ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM Int
forall a. Read a => ReadM a
auto (  String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "stopAfterFrames"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
help "Exit game session after around N frames"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar "N" )

printEachScreenP :: Parser Bool
printEachScreenP :: Parser Bool
printEachScreenP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "printEachScreen"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Take a screenshot of each rendered distinct frame (SDL only)" )

benchmarkP :: Parser Bool
benchmarkP :: Parser Bool
benchmarkP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "benchmark"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Restrict file IO, print timing stats" )

setDungeonRngP :: Parser (Maybe R.StdGen)
setDungeonRngP :: Parser (Maybe StdGen)
setDungeonRngP = Parser StdGen -> Parser (Maybe StdGen)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser StdGen -> Parser (Maybe StdGen))
-> Parser StdGen -> Parser (Maybe StdGen)
forall a b. (a -> b) -> a -> b
$
  ReadM StdGen -> Mod OptionFields StdGen -> Parser StdGen
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM StdGen
forall a. Read a => ReadM a
auto (  String -> Mod OptionFields StdGen
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "setDungeonRng"
              Mod OptionFields StdGen
-> Mod OptionFields StdGen -> Mod OptionFields StdGen
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields StdGen
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar "RNG_SEED"
              Mod OptionFields StdGen
-> Mod OptionFields StdGen -> Mod OptionFields StdGen
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields StdGen
forall (f :: * -> *) a. String -> Mod f a
help "Set dungeon generation RNG seed to string RNG_SEED" )

setMainRngP :: Parser (Maybe R.StdGen)
setMainRngP :: Parser (Maybe StdGen)
setMainRngP = Parser StdGen -> Parser (Maybe StdGen)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser StdGen -> Parser (Maybe StdGen))
-> Parser StdGen -> Parser (Maybe StdGen)
forall a b. (a -> b) -> a -> b
$
  ReadM StdGen -> Mod OptionFields StdGen -> Parser StdGen
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM StdGen
forall a. Read a => ReadM a
auto (  String -> Mod OptionFields StdGen
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "setMainRng"
              Mod OptionFields StdGen
-> Mod OptionFields StdGen -> Mod OptionFields StdGen
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields StdGen
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar "RNG_SEED"
              Mod OptionFields StdGen
-> Mod OptionFields StdGen -> Mod OptionFields StdGen
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields StdGen
forall (f :: * -> *) a. String -> Mod f a
help "Set the main game RNG seed to string RNG_SEED" )

dumpInitRngsP :: Parser Bool
dumpInitRngsP :: Parser Bool
dumpInitRngsP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "dumpInitRngs"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Dump the RNG seeds used to initialize the game" )

dbgMsgSerP :: Parser Bool
dbgMsgSerP :: Parser Bool
dbgMsgSerP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "dbgMsgSer"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Emit extra internal server debug messages" )

gtkFontFamilyP :: Parser (Maybe Text)
gtkFontFamilyP :: Parser (Maybe Text)
gtkFontFamilyP = Parser Text -> Parser (Maybe Text)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser Text -> Parser (Maybe Text))
-> Parser Text -> Parser (Maybe Text)
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack (String -> Text) -> Parser String -> Parser Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
  Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
strOption (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "gtkFontFamily"
            Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar "FONT_FAMILY"
            Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
help "Use FONT_FAMILY for the main game window in GTK frontend" )

sdlFontFileP :: Parser (Maybe Text)
sdlFontFileP :: Parser (Maybe Text)
sdlFontFileP = Parser Text -> Parser (Maybe Text)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser Text -> Parser (Maybe Text))
-> Parser Text -> Parser (Maybe Text)
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack (String -> Text) -> Parser String -> Parser Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
  Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
strOption (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "sdlFontFile"
            Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar "FONT_FILE"
            Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
help "Use FONT_FILE for the main game window in SDL2 frontend" )

sdlScalableSizeAddP :: Parser (Maybe Int)
sdlScalableSizeAddP :: Parser (Maybe Int)
sdlScalableSizeAddP = Parser Int -> Parser (Maybe Int)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser Int -> Parser (Maybe Int))
-> Parser Int -> Parser (Maybe Int)
forall a b. (a -> b) -> a -> b
$
  ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM Int
forall a. Read a => ReadM a
auto (  String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "sdlScalableSizeAdd"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar "N"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
help "Enlarge map cells by N over scalable font max height in SDL2 frontend (N may be negative)" )

sdlBitmapSizeAddP :: Parser (Maybe Int)
sdlBitmapSizeAddP :: Parser (Maybe Int)
sdlBitmapSizeAddP = Parser Int -> Parser (Maybe Int)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser Int -> Parser (Maybe Int))
-> Parser Int -> Parser (Maybe Int)
forall a b. (a -> b) -> a -> b
$
  ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM Int
forall a. Read a => ReadM a
auto (  String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "sdlBitmapSizeAdd"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar "N"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
help "Enlarge map cells by N on top of bitmap font max height in SDL2 frontend (N may be negative)" )

scalableFontSizeP :: Parser (Maybe Int)
scalableFontSizeP :: Parser (Maybe Int)
scalableFontSizeP = Parser Int -> Parser (Maybe Int)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser Int -> Parser (Maybe Int))
-> Parser Int -> Parser (Maybe Int)
forall a b. (a -> b) -> a -> b
$
  ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM Int
forall a. Read a => ReadM a
auto (  String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "scalableFontSize"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar "N"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
help "Use font size of N pixels for the main game window (interpreted differently by different graphical frontends; ignored for bitmap fonts)" )

fontDirP :: Parser (Maybe FilePath)
fontDirP :: Parser (Maybe String)
fontDirP = Parser String -> Parser (Maybe String)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser String -> Parser (Maybe String))
-> Parser String -> Parser (Maybe String)
forall a b. (a -> b) -> a -> b
$
  ReadM String -> Mod OptionFields String -> Parser String
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM String
forall a. Read a => ReadM a
auto (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "fontDir"
              Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar "FILEPATH"
              Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
help "Take font files for the SDL2 frontend from FILEPATH" )

maxFpsP :: Parser (Maybe Int)
maxFpsP :: Parser (Maybe Int)
maxFpsP = Parser Int -> Parser (Maybe Int)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser Int -> Parser (Maybe Int))
-> Parser Int -> Parser (Maybe Int)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Int
forall a. Ord a => a -> a -> a
max 1 (Int -> Int) -> Parser Int -> Parser Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
  ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM Int
forall a. Read a => ReadM a
auto (  String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "maxFps"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar "N"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
help "Display at most N frames per second" )

logPriorityP :: Parser (Maybe Int)
logPriorityP :: Parser (Maybe Int)
logPriorityP = Parser Int -> Parser (Maybe Int)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser Int -> Parser (Maybe Int))
-> Parser Int -> Parser (Maybe Int)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Int
forall a. Ord a => a -> a -> a
max 0 (Int -> Int) -> Parser Int -> Parser Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
  ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM Int
forall a. Read a => ReadM a
auto (  String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "logPriority"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar "N"
              Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
help "Log only messages of priority at least N, where 1 (all) is the lowest and 5 (errors only) is the default." )

disableAutoYesP :: Parser Bool
disableAutoYesP :: Parser Bool
disableAutoYesP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "disableAutoYes"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Never auto-answer prompts, not even when UI faction is automated" )

noAnimP :: Parser (Maybe Bool)
noAnimP :: Parser (Maybe Bool)
noAnimP =
  Maybe Bool
-> Maybe Bool -> Mod FlagFields (Maybe Bool) -> Parser (Maybe Bool)
forall a. a -> a -> Mod FlagFields a -> Parser a
flag Maybe Bool
forall a. Maybe a
Nothing (Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
True)
       (  String -> Mod FlagFields (Maybe Bool)
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "noAnim"
       Mod FlagFields (Maybe Bool)
-> Mod FlagFields (Maybe Bool) -> Mod FlagFields (Maybe Bool)
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields (Maybe Bool)
forall (f :: * -> *) a. String -> Mod f a
help "Don't show any animations" )

savePrefixP :: Parser String
savePrefixP :: Parser String
savePrefixP =
  Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
strOption (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "savePrefix"
            Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar "PREFIX"
            Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasValue f => a -> Mod f a
value ""
            Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
help "Prepend PREFIX to all savefile names" )

frontendTeletypeP :: Parser Bool
frontendTeletypeP :: Parser Bool
frontendTeletypeP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "frontendTeletype"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Use the line terminal frontend (for tests)" )

frontendNullP :: Parser Bool
frontendNullP :: Parser Bool
frontendNullP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "frontendNull"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Use frontend with no display (for benchmarks)" )

frontendLazyP :: Parser Bool
frontendLazyP :: Parser Bool
frontendLazyP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "frontendLazy"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Use frontend that not even computes frames (for benchmarks)" )

dbgMsgCliP :: Parser Bool
dbgMsgCliP :: Parser Bool
dbgMsgCliP =
  Mod FlagFields Bool -> Parser Bool
switch (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long "dbgMsgCli"
         Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help "Emit extra internal client debug messages" )