gameServer/HWProtoInRoomState.hs
changeset 1879 bb114339eb4e
parent 1866 36aa0ca6e8af
child 1929 7e6cc8da1c58
--- a/gameServer/HWProtoInRoomState.hs	Mon Mar 09 20:23:04 2009 +0000
+++ b/gameServer/HWProtoInRoomState.hs	Mon Mar 09 20:47:17 2009 +0000
@@ -1,5 +1,6 @@
 module HWProtoInRoomState where
 
+import qualified Data.Foldable as Foldable
 import qualified Data.IntMap as IntMap
 import qualified Data.Map as Map
 import Data.Sequence(Seq, (|>), (><), fromList, empty)
@@ -194,5 +195,24 @@
 	where
 		client = clients IntMap.! clID
 
+handleCmd_inRoom clID clients rooms ["KICK", kickNick] =
+	if not $ isMaster client then
+		[]
+	else
+		if noSuchClient then
+			[]
+		else
+			if (kickID == clID) || (roomID client /= roomID kickClient) then
+				[]
+			else
+				[RemoveClientTeams kickID,
+				KickRoomClient kickID]
+	where
+		client = clients IntMap.! clID
+		maybeClient = Foldable.find (\cl -> kickNick == nick cl) clients
+		noSuchClient = isNothing maybeClient
+		kickClient = fromJust maybeClient
+		kickID = clientUID kickClient
+
 
 handleCmd_inRoom clID _ _ _ = [ProtocolError "Incorrect command (state: in room)"]