gameServer/HWProtoInRoomState.hs
changeset 1879 bb114339eb4e
parent 1866 36aa0ca6e8af
child 1929 7e6cc8da1c58
equal deleted inserted replaced
1878:b3b277d2b891 1879:bb114339eb4e
     1 module HWProtoInRoomState where
     1 module HWProtoInRoomState where
     2 
     2 
       
     3 import qualified Data.Foldable as Foldable
     3 import qualified Data.IntMap as IntMap
     4 import qualified Data.IntMap as IntMap
     4 import qualified Data.Map as Map
     5 import qualified Data.Map as Map
     5 import Data.Sequence(Seq, (|>), (><), fromList, empty)
     6 import Data.Sequence(Seq, (|>), (><), fromList, empty)
     6 import Data.List
     7 import Data.List
     7 import Maybe
     8 import Maybe
   192 	else
   193 	else
   193 		[ProtocolError "Not room master"]
   194 		[ProtocolError "Not room master"]
   194 	where
   195 	where
   195 		client = clients IntMap.! clID
   196 		client = clients IntMap.! clID
   196 
   197 
       
   198 handleCmd_inRoom clID clients rooms ["KICK", kickNick] =
       
   199 	if not $ isMaster client then
       
   200 		[]
       
   201 	else
       
   202 		if noSuchClient then
       
   203 			[]
       
   204 		else
       
   205 			if (kickID == clID) || (roomID client /= roomID kickClient) then
       
   206 				[]
       
   207 			else
       
   208 				[RemoveClientTeams kickID,
       
   209 				KickRoomClient kickID]
       
   210 	where
       
   211 		client = clients IntMap.! clID
       
   212 		maybeClient = Foldable.find (\cl -> kickNick == nick cl) clients
       
   213 		noSuchClient = isNothing maybeClient
       
   214 		kickClient = fromJust maybeClient
       
   215 		kickID = clientUID kickClient
       
   216 
   197 
   217 
   198 handleCmd_inRoom clID _ _ _ = [ProtocolError "Incorrect command (state: in room)"]
   218 handleCmd_inRoom clID _ _ _ = [ProtocolError "Incorrect command (state: in room)"]