gameServer/HWProtoInRoomState.hs
changeset 13703 2df519242d41
parent 13700 feda0d1da62c
child 13704 54eb4c774ef5
equal deleted inserted replaced
13702:dc06ef77a73a 13703:2df519242d41
   348         else if (kickId == thisClientId) then
   348         else if (kickId == thisClientId) then
   349             [Warning $ loc "You can't kick yourself!"]
   349             [Warning $ loc "You can't kick yourself!"]
   350         else if (not ((isNothing $ gameInfo rm) || notOnly2Players || teamsInGame kickCl == 0)) then
   350         else if (not ((isNothing $ gameInfo rm) || notOnly2Players || teamsInGame kickCl == 0)) then
   351             [Warning $ loc "You can't kick the only other player!"]
   351             [Warning $ loc "You can't kick the only other player!"]
   352         else if (not sameRoom) then
   352         else if (not sameRoom) then
   353             [Warning $ loc "The player you tried to kick is not in your room."]
   353             [Warning $ loc "The player is not in your room."]
   354         else if (hasSuperPower kickCl) then
   354         else if (hasSuperPower kickCl) then
   355             [Warning $ loc "This player is protected from being kicked."]
   355             [Warning $ loc "This player is protected from being kicked."]
   356         else
   356         else
   357             -- Kick!
   357             -- Kick!
   358             [KickRoomClient kickId]
   358             [KickRoomClient kickId]
   363     master <- liftM isMaster thisClient
   363     master <- liftM isMaster thisClient
   364     serverAdmin <- liftM isAdministrator thisClient
   364     serverAdmin <- liftM isAdministrator thisClient
   365     thisRoomMasterId <- liftM masterID thisRoom
   365     thisRoomMasterId <- liftM masterID thisRoom
   366     let newAdminId = fromJust maybeClientId
   366     let newAdminId = fromJust maybeClientId
   367     let sameRoom = clientRoom rnc thisClientId == clientRoom rnc newAdminId
   367     let sameRoom = clientRoom rnc thisClientId == clientRoom rnc newAdminId
   368     return
   368     return $
   369         [ChangeMaster (Just newAdminId) |
   369         if (not (master || serverAdmin)) then
   370             (master || serverAdmin)
   370             [Warning $ loc "You not the room master or a server admin!"]
   371                 && isJust maybeClientId
   371         else if (isNothing maybeClientId) then
   372                 && (Just newAdminId /= thisRoomMasterId)
   372             [Warning $ loc "Player is not online."]
   373                 && sameRoom]
   373         else if (Just newAdminId == thisRoomMasterId) then
   374 
   374             [Warning $ loc "You're already the room master."]
       
   375         else if (not sameRoom) then
       
   376             [Warning $ loc "The player is not in your room."]
       
   377         else
       
   378             [ChangeMaster (Just newAdminId)]
   375 
   379 
   376 handleCmd_inRoom ["TEAMCHAT", msg] = do
   380 handleCmd_inRoom ["TEAMCHAT", msg] = do
   377     cl <- thisClient
   381     cl <- thisClient
   378     chans <- roomSameClanChans
   382     chans <- roomSameClanChans
   379     return [AnswerClients chans ["EM", engineMsg cl]]
   383     return [AnswerClients chans ["EM", engineMsg cl]]
   410         return [ModifyRoom (\r -> r{teamsNumberLimit = m})]
   414         return [ModifyRoom (\r -> r{teamsNumberLimit = m})]
   411 
   415 
   412 handleCmd_inRoom ["FIX"] = serverAdminOnly $
   416 handleCmd_inRoom ["FIX"] = serverAdminOnly $
   413     return [ModifyRoom (\r -> r{isSpecial = True})]
   417     return [ModifyRoom (\r -> r{isSpecial = True})]
   414 
   418 
   415 handleCmd_inRoom ["UNFIX"] = serverAdminOnly $
   419 handleCmd_inRoom ["UNFIX"] = serverAdminOnly $ do
   416     return [ModifyRoom (\r -> r{isSpecial = False})]
   420     cl <- thisClient
       
   421     return $ if not $ isMaster cl then
       
   422                  [Warning $ loc "You're not the room master!"]
       
   423              else
       
   424                  [ModifyRoom (\r -> r{isSpecial = False})]
   417 
   425 
   418 handleCmd_inRoom ["HELP"] = do
   426 handleCmd_inRoom ["HELP"] = do
   419     cl <- thisClient
   427     cl <- thisClient
   420     if isAdministrator cl then
   428     if isAdministrator cl then
   421         return (cmdHelpActionList [sendChan cl] cmdHelpRoomAdmin)
   429         return (cmdHelpActionList [sendChan cl] cmdHelpRoomAdmin)