gameServer/HWProtoInRoomState.hs
changeset 2245 c011aecc95e5
parent 2207 aeea95909aba
child 2304 a6e733ad0366
equal deleted inserted replaced
2244:853a1db1cff6 2245:c011aecc95e5
    56 		[Warning "round in progress"]
    56 		[Warning "round in progress"]
    57 	else if isRestrictedTeams room then
    57 	else if isRestrictedTeams room then
    58 		[Warning "restricted"]
    58 		[Warning "restricted"]
    59 	else
    59 	else
    60 		[ModifyRoom (\r -> r{teams = teams r ++ [newTeam]}),
    60 		[ModifyRoom (\r -> r{teams = teams r ++ [newTeam]}),
       
    61 		ModifyClient (\c -> c{teamsInGame = teamsInGame c + 1}),
    61 		AnswerThisClient ["TEAM_ACCEPTED", name],
    62 		AnswerThisClient ["TEAM_ACCEPTED", name],
    62 		AnswerOthersInRoom $ teamToNet newTeam,
    63 		AnswerOthersInRoom $ teamToNet newTeam,
    63 		AnswerOthersInRoom ["TEAM_COLOR", name, color]
    64 		AnswerOthersInRoom ["TEAM_COLOR", name, color]
    64 		]
    65 		]
    65 	where
    66 	where
    79 		[Warning "REMOVE_TEAM: no such team"]
    80 		[Warning "REMOVE_TEAM: no such team"]
    80 	else
    81 	else
    81 		if not $ nick client == teamowner team then
    82 		if not $ nick client == teamowner team then
    82 			[ProtocolError "Not team owner!"]
    83 			[ProtocolError "Not team owner!"]
    83 		else
    84 		else
    84 			[RemoveTeam teamName]
    85 			[RemoveTeam teamName,
       
    86 			ModifyClient (\c -> c{teamsInGame = teamsInGame c - 1})	
       
    87 			]
    85 	where
    88 	where
    86 		client = clients IntMap.! clID
    89 		client = clients IntMap.! clID
    87 		room = rooms IntMap.! (roomID client)
    90 		room = rooms IntMap.! (roomID client)
    88 		noSuchTeam = isNothing findTeam
    91 		noSuchTeam = isNothing findTeam
    89 		team = fromJust findTeam
    92 		team = fromJust findTeam
   153 		client = clients IntMap.! clID
   156 		client = clients IntMap.! clID
   154 		room = rooms IntMap.! (roomID client)
   157 		room = rooms IntMap.! (roomID client)
   155 		enoughClans = not $ null $ drop 1 $ group $ map teamcolor $ teams room
   158 		enoughClans = not $ null $ drop 1 $ group $ map teamcolor $ teams room
   156 
   159 
   157 
   160 
   158 handleCmd_inRoom _ _ rooms ["EM", msg] =
   161 handleCmd_inRoom clID clients rooms ["EM", msg] =
   159 	[ModifyRoom (\r -> r{roundMsgs = roundMsgs r |> msg}),
   162 	if teamsInGame client > 0 then
   160 	AnswerOthersInRoom ["EM", msg]]
   163 		[ModifyRoom (\r -> r{roundMsgs = roundMsgs r |> msg}),
   161 
   164 		AnswerOthersInRoom ["EM", msg]]
       
   165 	else
       
   166 		[]
       
   167 	where
       
   168 		client = clients IntMap.! clID
   162 
   169 
   163 handleCmd_inRoom clID clients rooms ["ROUNDFINISHED"] =
   170 handleCmd_inRoom clID clients rooms ["ROUNDFINISHED"] =
   164 	if isMaster client then
   171 	if isMaster client then
   165 		[ModifyRoom
   172 		[ModifyRoom
   166 				(\r -> r{
   173 				(\r -> r{