wizard-wipeout/src-client/Client/Types.hs

72 lines
1.3 KiB
Haskell
Raw Normal View History

2024-11-05 00:24:07 +00:00
{-# LANGUAGE StrictData #-}
module Client.Types where
2023-12-12 10:21:25 +00:00
import qualified Control.Concurrent.STM as STM
2024-04-17 17:44:47 +00:00
import Control.Exception (Exception)
2023-12-10 14:18:40 +00:00
import Control.Monad.RWS
2024-04-19 18:18:49 +00:00
import Data.IORef (IORef)
2023-12-10 14:18:40 +00:00
import Data.UUID
import Graphics.Vty
2023-12-10 19:12:53 +00:00
import Network.Socket
2023-12-10 19:12:53 +00:00
import Options.Applicative as O
2023-12-10 14:18:40 +00:00
-- internal imports
import Library.Types
2024-11-07 16:47:11 +00:00
data Options = Options
{ optLogLevel :: LogLevel
, optSockLoc :: FilePath
}
options :: O.Parser Options
options = Options
2024-11-07 16:47:11 +00:00
<$> 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"
)
2023-12-10 14:18:40 +00:00
2024-11-07 16:47:11 +00:00
data LogLevel
= Error
| Warning
| Info
| Verbose
deriving (Eq, Ord, Show, Read)
2023-12-10 14:18:40 +00:00
data ReaderContainer = ReaderContainer
{ rcSocket :: Socket
, rcClientUUID :: UUID
, rcMessageQueue :: STM.TQueue ServerMessage
, rcEventQueue :: STM.TQueue Event
2024-11-07 16:47:11 +00:00
, rcLogLevel :: LogLevel
2023-12-10 14:18:40 +00:00
}
2023-12-12 10:21:25 +00:00
data StateContainer = StateContainer
2023-12-12 08:47:50 +00:00
{ scWizard :: Wizard
2023-12-12 10:21:25 +00:00
, scClientState :: STM.TMVar ClientState
2023-12-20 07:12:22 +00:00
, scMapSlice :: MapSlice
2024-04-19 18:18:49 +00:00
, scStopper :: IORef Bool
2023-12-10 14:18:40 +00:00
}
type Game = RWST ReaderContainer String StateContainer IO
2024-04-17 17:44:47 +00:00
data ClientTerminate = ClientTerminate
deriving (Show)
instance Exception ClientTerminate