gameServer/Actions.hs
branchflibqtfrontend
changeset 8244 0f8893faeb00
parent 8242 6735a8ce1946
child 8330 aaefa587e277
child 8369 31033e521653
equal deleted inserted replaced
8242:6735a8ce1946 8244:0f8893faeb00
    53     | BanClient NominalDiffTime B.ByteString ClientIndex
    53     | BanClient NominalDiffTime B.ByteString ClientIndex
    54     | BanIP B.ByteString NominalDiffTime B.ByteString
    54     | BanIP B.ByteString NominalDiffTime B.ByteString
    55     | BanNick B.ByteString NominalDiffTime B.ByteString
    55     | BanNick B.ByteString NominalDiffTime B.ByteString
    56     | BanList
    56     | BanList
    57     | Unban B.ByteString
    57     | Unban B.ByteString
    58     | ChangeMaster
    58     | ChangeMaster (Maybe ClientIndex)
    59     | RemoveClientTeams ClientIndex
    59     | RemoveClientTeams ClientIndex
    60     | ModifyClient (ClientInfo -> ClientInfo)
    60     | ModifyClient (ClientInfo -> ClientInfo)
    61     | ModifyClient2 ClientIndex (ClientInfo -> ClientInfo)
    61     | ModifyClient2 ClientIndex (ClientInfo -> ClientInfo)
    62     | ModifyRoomClients (ClientInfo -> ClientInfo)
    62     | ModifyRoomClients (ClientInfo -> ClientInfo)
    63     | ModifyRoom (RoomInfo -> RoomInfo)
    63     | ModifyRoom (RoomInfo -> RoomInfo)
   233     clNick <- client's nick
   233     clNick <- client's nick
   234     chans <- othersChans
   234     chans <- othersChans
   235 
   235 
   236     if master then
   236     if master then
   237         if playersNum > 1 then
   237         if playersNum > 1 then
   238             mapM_ processAction [ChangeMaster, NoticeMessage AdminLeft, RemoveClientTeams ci, AnswerClients chans ["LEFT", clNick, msg]]
   238             mapM_ processAction [ChangeMaster Nothing, NoticeMessage AdminLeft, RemoveClientTeams ci, AnswerClients chans ["LEFT", clNick, msg]]
   239             else
   239             else
   240             processAction RemoveRoom
   240             processAction RemoveRoom
   241         else
   241         else
   242         mapM_ processAction [RemoveClientTeams ci, AnswerClients chans ["LEFT", clNick, msg]]
   242         mapM_ processAction [RemoveClientTeams ci, AnswerClients chans ["LEFT", clNick, msg]]
   243 
   243 
   249                 readyPlayers = if ready then readyPlayers r - 1 else readyPlayers r
   249                 readyPlayers = if ready then readyPlayers r - 1 else readyPlayers r
   250                 }) ri
   250                 }) ri
   251         moveClientToLobby rnc ci
   251         moveClientToLobby rnc ci
   252 
   252 
   253 
   253 
   254 processAction ChangeMaster = do
   254 processAction (ChangeMaster delegateId)= do
   255     (Just ci) <- gets clientIndex
   255     (Just ci) <- gets clientIndex
   256     proto <- client's clientProto
   256     proto <- client's clientProto
   257     ri <- clientRoomA
   257     ri <- clientRoomA
   258     rnc <- gets roomsClients
   258     rnc <- gets roomsClients
   259     newMasterId <- liftM (last . filter (/= ci)) . io $ roomClientsIndicesM rnc ri
   259     newMasterId <- liftM (\ids -> fromMaybe (last . filter (/= ci) $ ids) delegateId) . io $ roomClientsIndicesM rnc ri
   260     newMaster <- io $ client'sM rnc id newMasterId
   260     newMaster <- io $ client'sM rnc id newMasterId
   261     oldRoomName <- io $ room'sM rnc name ri
   261     oldRoomName <- io $ room'sM rnc name ri
   262     oldMaster <- client's nick
   262     oldMaster <- client's nick
   263     kicked <- client's isKickedFromServer
   263     kicked <- client's isKickedFromServer
   264     thisRoomChans <- liftM (map sendChan) $ roomClientsS ri
   264     thisRoomChans <- liftM (map sendChan) $ roomClientsS ri