gameServer/HWProtoInRoomState.hs
changeset 13697 7f174e7285e5
parent 13696 d732ca5dcab9
child 13700 feda0d1da62c
equal deleted inserted replaced
13696:d732ca5dcab9 13697:7f174e7285e5
   333         roomUpdate r = r{name = newName}
   333         roomUpdate r = r{name = newName}
   334 
   334 
   335 
   335 
   336 handleCmd_inRoom ["KICK", kickNick] = roomAdminOnly $ do
   336 handleCmd_inRoom ["KICK", kickNick] = roomAdminOnly $ do
   337     (thisClientId, rnc) <- ask
   337     (thisClientId, rnc) <- ask
   338     maybeClientId <- clientByNick kickNick
   338     maybeKickId <- clientByNick kickNick
   339     rm <- thisRoom
   339     rm <- thisRoom
   340     let kickId = fromJust maybeClientId
   340     let kickId = fromJust maybeKickId
   341     let kickCl = rnc `client` kickId
   341     let kickCl = rnc `client` kickId
   342     let sameRoom = clientRoom rnc thisClientId == clientRoom rnc kickId
   342     let sameRoom = clientRoom rnc thisClientId == clientRoom rnc kickId
   343     let notOnly2Players = (length . group . sort . map teamowner . teams $ rm) > 2
   343     let notOnly2Players = (length . group . sort . map teamowner . teams $ rm) > 2
   344     return
   344     return $
   345         [KickRoomClient kickId |
   345         -- Catch some error conditions
   346             isJust maybeClientId
   346         if (isNothing maybeKickId) then
   347             && (kickId /= thisClientId)
   347             [Warning $ loc "Player is not online."]
   348             && sameRoom
   348         else if (kickId == thisClientId) then
   349             && (not $ hasSuperPower kickCl)
   349             [Warning $ loc "You can't kick yourself!"]
   350             && ((isNothing $ gameInfo rm) || notOnly2Players || teamsInGame kickCl == 0)
   350         else if (not ((isNothing $ gameInfo rm) || notOnly2Players || teamsInGame kickCl == 0)) then
   351         ]
   351             [Warning $ loc "You can't kick the only other player!"]
   352 
   352         else if (not sameRoom) then
       
   353             [Warning $ loc "The player you tried to kick is not in your room."]
       
   354         else if (hasSuperPower kickCl) then
       
   355             [Warning $ loc "This player is protected from being kicked."]
       
   356         else
       
   357             -- Kick!
       
   358             [KickRoomClient kickId]
   353 
   359 
   354 handleCmd_inRoom ["DELEGATE", newAdmin] = do
   360 handleCmd_inRoom ["DELEGATE", newAdmin] = do
   355     (thisClientId, rnc) <- ask
   361     (thisClientId, rnc) <- ask
   356     maybeClientId <- clientByNick newAdmin
   362     maybeClientId <- clientByNick newAdmin
   357     master <- liftM isMaster thisClient
   363     master <- liftM isMaster thisClient
   439     maybeClientId <- clientByNick nickname
   445     maybeClientId <- clientByNick nickname
   440     let kickId = fromJust maybeClientId
   446     let kickId = fromJust maybeClientId
   441     let sameRoom = clientRoom rnc thisClientId == clientRoom rnc kickId
   447     let sameRoom = clientRoom rnc thisClientId == clientRoom rnc kickId
   442 
   448 
   443     if isJust $ masterID rm then
   449     if isJust $ masterID rm then
   444         return []
   450         return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/callvote kick: This is only allowed in rooms without a room master."]]
   445         else
   451         else
   446         if isJust maybeClientId && sameRoom then
   452         if isJust maybeClientId && sameRoom then
   447             startVote $ VoteKick nickname
   453             startVote $ VoteKick nickname
   448             else
   454             else
   449             return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/callvote kick: No such user!"]]
   455             return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/callvote kick: No such user!"]]