gameServer/HWProtoInRoomState.hs
changeset 2747 7889a3a9724f
parent 2408 41ebdb5f1e6e
child 2867 9be6693c78cb
equal deleted inserted replaced
2746:55593f8a490b 2747:7889a3a9724f
    40 		AnswerOthersInRoom ("CFG" : paramName : paramStrs)]
    40 		AnswerOthersInRoom ("CFG" : paramName : paramStrs)]
    41 	| otherwise = [ProtocolError "Not room master"]
    41 	| otherwise = [ProtocolError "Not room master"]
    42 	where
    42 	where
    43 		client = clients IntMap.! clID
    43 		client = clients IntMap.! clID
    44 
    44 
    45 handleCmd_inRoom clID clients rooms ("ADD_TEAM" : name : color : grave : fort : voicepack : difStr : hhsInfo)
    45 handleCmd_inRoom clID clients rooms ("ADD_TEAM" : name : color : grave : fort : voicepack : flag : difStr : hhsInfo)
    46 	| length hhsInfo /= 16 = []
    46 	| length hhsInfo /= 16 = []
    47 	| length (teams room) == 6 = [Warning "too many teams"]
    47 	| length (teams room) == 6 = [Warning "too many teams"]
    48 	| canAddNumber <= 0 = [Warning "too many hedgehogs"]
    48 	| canAddNumber <= 0 = [Warning "too many hedgehogs"]
    49 	| isJust findTeam = [Warning "There's already a team with same name in the list"]
    49 	| isJust findTeam = [Warning "There's already a team with same name in the list"]
    50 	| gameinprogress room = [Warning "round in progress"]
    50 	| gameinprogress room = [Warning "round in progress"]
    59 	where
    59 	where
    60 		client = clients IntMap.! clID
    60 		client = clients IntMap.! clID
    61 		room = rooms IntMap.! (roomID client)
    61 		room = rooms IntMap.! (roomID client)
    62 		canAddNumber = 48 - (sum . map hhnum $ teams room)
    62 		canAddNumber = 48 - (sum . map hhnum $ teams room)
    63 		findTeam = find (\t -> name == teamname t) $ teams room
    63 		findTeam = find (\t -> name == teamname t) $ teams room
    64 		newTeam = (TeamInfo clID (nick client) name color grave fort voicepack difficulty newTeamHHNum (hhsList hhsInfo))
    64 		newTeam = (TeamInfo clID (nick client) name color grave fort voicepack flag difficulty newTeamHHNum (hhsList hhsInfo))
    65 		difficulty = fromMaybe 0 (maybeRead difStr :: Maybe Int)
    65 		difficulty = fromMaybe 0 (maybeRead difStr :: Maybe Int)
    66 		hhsList [] = []
    66 		hhsList [] = []
    67 		hhsList (n:h:hhs) = HedgehogInfo n h : hhsList hhs
    67 		hhsList (n:h:hhs) = HedgehogInfo n h : hhsList hhs
    68 		newTeamHHNum = min 4 canAddNumber
    68 		newTeamHHNum = min 4 canAddNumber
    69 
    69