wizard-wipeout/src-client/Main.hs

58 lines
1.5 KiB
Haskell
Raw Normal View History

2023-12-10 16:00:50 +00:00
{-# LANGUAGE LambdaCase #-}
2023-12-04 16:20:06 +00:00
module Main where
import Control.Concurrent (threadDelay)
import Options.Applicative
-- internal imports
import Client.Communication
import Client.Types
2023-12-10 16:00:50 +00:00
import Library.Types
2023-12-04 16:20:06 +00:00
main :: IO ()
main = do
putStrLn "Hello, Arena!"
(Options socketLocation) <- execParser opts
putStrLn $ "connecting to Socket " <> socketLocation
2023-12-10 19:12:53 +00:00
sock <- connectSocket socketLocation
putStrLn "connected"
sendMessage (IdRequest) sock
2023-12-10 16:00:50 +00:00
threadDelay $ 5 * 10 ^ 6
clientIdMsg <- receiveMessage sock
let clientId = acClientUUID clientIdMsg
putStrLn $ "received client UUID: " <> show clientId
2023-12-11 09:48:25 +00:00
threadDelay $ 5 * 10 ^ 6
putStrLn welcomeText
threadDelay $ 15 * 10 ^ 6
sendMessage (ClientMessage clientId ClientRequestWizard) sock
playerWizard <- receiveMessage sock
let initRead = ReaderContainer sock clientId
initState = StateContainer (initWizard playerWizard)
2023-12-11 09:48:25 +00:00
putStrLn "sending quit message"
sendMessage (ClientMessage clientId ClientQuit) sock
where
opts = info (options <**> helper)
( fullDesc
<> progDesc "Run the \"wizard-wipeout\" Server."
<> header "wizard-wipeout - Last Mage standing"
)
welcomeText :: String
welcomeText = mconcat $ map (<> "\n")
[ "Welcome to the arena, wizards."
, ""
, "Let the toughest and bravest of you survive"
, ""
, "Some last hints before you enter the fighting grounds:"
, ""
, "press [SpACE] to fire your wand"
, "press [1] through [9] to change wands, if you have collected more wands"
, "press [ESC] to leave"
, ""
, "Good Luck!"
]