(e,ps') <- getNextUserMessage h ps
d' <- case e of
Left dm -> do (client_messages, d') <- callDayCallback dcb ps' d dm
- undefined -- send_client_messages client_messages
+ mapM_ (sendClientMessage h) client_messages
return d'
Right nm -> callNightCallback ncb ps' d nm
loop ps' d'
parseIncomingMessage :: String -> IncomingMessage
parseIncomingMessage = undefined
+sendClientMessage :: Handle -> ClientMessage -> IO ()
+sendClientMessage h msg = hPutStrLn h (toString msg)
+ where toString (Goto place) = unwords ["goto", show place]
+ toString (Tell player (PartyAt place)) = unwords ["party", show player, show place]
+ toString (Tell player (NoPartyAt place)) = unwords ["no_party", show player, show place]
+ toString (Tell player (Liar other)) = unwords ["liar", show player, show other]
+ toString (Tell player (NoLiar other)) = unwords ["recommand",show player, show other]
+
+
-- Convenience functions for accessing the state
whoIsHere :: (MonadReader ParttyState m) => m [Player]