gameServer/Actions.hs
changeset 4942 1c85a8e6e11c
parent 4932 f11d80bac7ed
child 4955 84543ecae8c3
equal deleted inserted replaced
4941:90572c338e60 4942:1c85a8e6e11c
   259 processAction (UnreadyRoomClients) = do
   259 processAction (UnreadyRoomClients) = do
   260     rnc <- gets roomsClients
   260     rnc <- gets roomsClients
   261     ri <- clientRoomA
   261     ri <- clientRoomA
   262     roomPlayers <- roomClientsS ri
   262     roomPlayers <- roomClientsS ri
   263     roomClIDs <- io $ roomClientsIndicesM rnc ri
   263     roomClIDs <- io $ roomClientsIndicesM rnc ri
   264     processAction $ AnswerClients (map sendChan roomPlayers) ("CLIENT_FLAGS" : "-r" : map nick roomPlayers)
   264     pr <- client's clientProto
       
   265     processAction $ AnswerClients (map sendChan roomPlayers) $ notReadyMessage pr (map nick roomPlayers)
   265     io $ mapM_ (modifyClient rnc (\cl -> cl{isReady = False})) roomClIDs
   266     io $ mapM_ (modifyClient rnc (\cl -> cl{isReady = False})) roomClIDs
   266     processAction $ ModifyRoom (\r -> r{readyPlayers = 0})
   267     processAction $ ModifyRoom (\r -> r{readyPlayers = 0})
       
   268     where
       
   269         notReadyMessage p nicks = if p < 38 then "NOT_READY" : nicks else "CLIENT_FLAGS" : "-r" : nicks
   267 
   270 
   268 
   271 
   269 processAction (RemoveTeam teamName) = do
   272 processAction (RemoveTeam teamName) = do
   270     rnc <- gets roomsClients
   273     rnc <- gets roomsClients
   271     ri <- clientRoomA
   274     ri <- clientRoomA
   338     mapM_ processAction $
   341     mapM_ processAction $
   339         AnswerClients clientsChans ["LOBBY:JOINED", clientNick]
   342         AnswerClients clientsChans ["LOBBY:JOINED", clientNick]
   340         : AnswerClients [chan] ("LOBBY:JOINED" : clientNick : lobbyNicks)
   343         : AnswerClients [chan] ("LOBBY:JOINED" : clientNick : lobbyNicks)
   341         : [ModifyClient (\cl -> cl{logonPassed = True}), SendServerMessage]
   344         : [ModifyClient (\cl -> cl{logonPassed = True}), SendServerMessage]
   342 
   345 
   343 {-
   346 
   344 processAction (clID, serverInfo, rnc) (RoomAddThisClient rID) =
       
   345     processAction (
       
   346         clID,
       
   347         serverInfo,
       
   348         adjust (\cl -> cl{roomID = rID, teamsInGame = if rID == 0 then teamsInGame cl else 0}) clID clients,
       
   349         adjust (\r -> r{playersIDs = IntSet.insert clID (playersIDs r), playersIn = (playersIn r) + 1}) rID $
       
   350             adjust (\r -> r{playersIDs = IntSet.delete clID (playersIDs r)}) 0 rooms
       
   351         ) joinMsg
       
   352     where
       
   353         client = clients ! clID
       
   354         joinMsg = if rID == 0 then
       
   355                 AnswerAllOthers ["LOBBY:JOINED", nick client]
       
   356             else
       
   357                 AnswerThisRoom ["JOINED", nick client]
       
   358                 -}
       
   359 processAction (KickClient kickId) = do
   347 processAction (KickClient kickId) = do
   360     modify (\s -> s{clientIndex = Just kickId})
   348     modify (\s -> s{clientIndex = Just kickId})
   361     processAction $ ByeClient "Kicked"
   349     processAction $ ByeClient "Kicked"
   362 
   350 
   363 
   351