wizard-wipeout/src-client/Client/Game.hs
2024-04-19 20:18:49 +02:00

43 lines
814 B
Haskell

module Client.Game where
import Control.Monad.Loops
import Control.Monad.RWS
import Data.IORef (readIORef)
import Graphics.Vty
-- internal imports
import Client.Communication
import Client.Graphics
import Client.Types
import Library.Types
runGame
:: Game ()
runGame = do
sock <- asks rcSocket
queue <- asks rcQueue
clientId <- asks rcClientUUID
st <- get
-- recvThread <- liftIO $ forkIO $ forever $ receiveMessage sock queue st
liftIO $ sendMessage (ClientMessage clientId ClientReady) sock
whileM_
(liftIO (not <$> readIORef (scStopper st)))
(do
liftIO $ receiveMessage sock queue st
handleMessages
-- draw
)
-- liftIO $ killThread recvThread
handleEvent
:: Maybe Event
-> Game ()
handleEvent Nothing =
pure ()
handleEvent (Just event) =
pure ()