{-# LANGUAGE StrictData #-} module Client.Types where import qualified Control.Concurrent.STM as STM import Control.Exception (Exception) import Control.Monad.RWS import Data.IORef (IORef) import Data.UUID import Graphics.Vty import Network.Socket import Options.Applicative as O -- internal imports import Library.Types data Options = Options { optLogLevel :: LogLevel , optSockLoc :: FilePath } options :: O.Parser Options options = Options <$> option auto ( metavar "LEVEL" <> help "Log level (Error, Warning, Info or Verbose)" <> long "log" <> short 'l' <> value Warning ) <*> argument str ( metavar "FILEPATH" <> help "Location of the server's socket" ) data LogLevel = Error | Warning | Info | Verbose deriving (Eq, Ord, Show, Read) data ReaderContainer = ReaderContainer { rcSocket :: Socket , rcClientUUID :: UUID , rcMessageQueue :: STM.TQueue ServerMessage , rcEventQueue :: STM.TQueue Event , rcLogLevel :: LogLevel } data StateContainer = StateContainer { scWizard :: Wizard , scClientState :: STM.TMVar ClientState , scMapSlice :: MapSlice , scStopper :: IORef Bool } type Game = RWST ReaderContainer String StateContainer IO data ClientTerminate = ClientTerminate deriving (Show) instance Exception ClientTerminate