Disallow kicking the opponent in duel
authorunc0rr
Mon, 18 Feb 2013 22:21:31 +0400
changeset 8513 cd85ab23f38b
parent 8512 d2bca8e68688
child 8514 896b283f41a2
Disallow kicking the opponent in duel
gameServer/HWProtoInRoomState.hs
--- a/gameServer/HWProtoInRoomState.hs	Mon Feb 18 00:22:16 2013 +0100
+++ b/gameServer/HWProtoInRoomState.hs	Mon Feb 18 22:21:31 2013 +0400
@@ -181,6 +181,7 @@
                     ["CLIENT_FLAGS", if isReady cl then "-r" else "+r", nick cl]
             ]
 
+
 handleCmd_inRoom ["START_GAME"] = do
     (ci, rnc) <- ask
     cl <- thisClient
@@ -297,10 +298,19 @@
     (thisClientId, rnc) <- ask
     maybeClientId <- clientByNick kickNick
     master <- liftM isMaster thisClient
+    rm <- thisRoom
     let kickId = fromJust maybeClientId
+    let kickCl = rnc `client` kickId
     let sameRoom = clientRoom rnc thisClientId == clientRoom rnc kickId
+    let notOnly2Clans = (length . group . sort . map teamcolor . teams $ rm) > 2
     return
-        [KickRoomClient kickId | master && isJust maybeClientId && (kickId /= thisClientId) && sameRoom]
+        [KickRoomClient kickId |
+            master
+            && isJust maybeClientId
+            && (kickId /= thisClientId)
+            && sameRoom
+            && ((isNothing $ gameInfo rm) || notOnly2Clans || teamsInGame kickCl = 0)
+        ]
 
 
 handleCmd_inRoom ["DELEGATE", newAdmin] = do