gameServer/Actions.hs
changeset 3436 288fcbdb77b6
parent 3435 4e4f88a7bdf2
child 3451 62089ccec75c
equal deleted inserted replaced
3435:4e4f88a7bdf2 3436:288fcbdb77b6
    93 
    93 
    94 processAction (ci, serverInfo, rnc) (ByeClient msg) = do
    94 processAction (ci, serverInfo, rnc) (ByeClient msg) = do
    95     infoM "Clients" (show ci ++ " quits: " ++ msg)
    95     infoM "Clients" (show ci ++ " quits: " ++ msg)
    96 
    96 
    97     ri <- clientRoomM rnc ci
    97     ri <- clientRoomM rnc ci
    98     when (ri /= lobbyId)
    98     when (ri /= lobbyId) $ do
    99         processAction (ci, serverInfo, rnc) $ RoomRemoveThisClient ("quit: " ++ msg)
    99         processAction (ci, serverInfo, rnc) $ RoomRemoveThisClient ("quit: " ++ msg)
   100 
   100         return ()
   101     mapM_ (processAction (ci, serverInfo, rnc)) $ answerOthersQuit ++ answerInformRoom
   101 
   102     writeChan (sendChan $ clients ! clID) ["BYE", msg]
   102     --mapM_ (processAction (ci, serverInfo, rnc)) $ answerOthersQuit ++ answerInformRoom
   103     return (
   103     --writeChan (sendChan $ clients ! clID) ["BYE", msg]
   104             0,
   104     modifyRoom rnc (\r -> r{
   105             serverInfo,
   105                     --playersIDs = IntSet.delete ci (playersIDs r)
   106             delete clID newClients,
   106                     playersIn = (playersIn r) - 1
   107             adjust (\r -> r{
   107                     --readyPlayers = if isReady client then readyPlayers r - 1 else readyPlayers r
   108                     playersIDs = IntSet.delete clID (playersIDs r),
   108                     }) ri
   109                     playersIn = (playersIn r) - 1,
   109     removeClient rnc ci
   110                     readyPlayers = if isReady client then readyPlayers r - 1 else readyPlayers r
   110     
   111                     }) (roomID $ newClients ! clID) newRooms
   111     return (ci, serverInfo)
   112             )
   112     
       
   113 {-
   113     where
   114     where
   114         client = clients ! clID
   115         client = clients ! clID
   115         clientNick = nick client
   116         clientNick = nick client
   116         answerInformRoom =
   117         answerInformRoom =
   117             if roomID client /= 0 then
   118             if roomID client /= 0 then
   126                 if not $ Prelude.null msg then
   127                 if not $ Prelude.null msg then
   127                     [AnswerAll ["LOBBY:LEFT", clientNick, msg]]
   128                     [AnswerAll ["LOBBY:LEFT", clientNick, msg]]
   128                 else
   129                 else
   129                     [AnswerAll ["LOBBY:LEFT", clientNick]]
   130                     [AnswerAll ["LOBBY:LEFT", clientNick]]
   130             else
   131             else
   131                 []
   132             [] 
       
   133 -}
   132 {-
   134 {-
   133 
   135 
   134 processAction (clID, serverInfo, rnc) (ModifyClient func) =
   136 processAction (clID, serverInfo, rnc) (ModifyClient func) =
   135     return (clID, serverInfo, adjust func clID rnc)
   137     return (clID, serverInfo, adjust func clID rnc)
   136 
   138