50 lines
952 B
Haskell
50 lines
952 B
Haskell
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 Network.Socket
|
|
|
|
import Options.Applicative as O
|
|
|
|
-- internal imports
|
|
|
|
import Library.Types
|
|
|
|
newtype Options = Options
|
|
{ optSockLoc :: FilePath
|
|
}
|
|
|
|
options :: O.Parser Options
|
|
options = Options
|
|
<$> argument str
|
|
( metavar "FILEPATH"
|
|
<> help "Location of the server's socket"
|
|
)
|
|
|
|
data ReaderContainer = ReaderContainer
|
|
{ rcSocket :: Socket
|
|
, rcClientUUID :: UUID
|
|
, rcQueue :: STM.TQueue ServerMessage
|
|
}
|
|
|
|
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
|