netserver/HWProto.hs
changeset 1470 ebaca3b66d92
parent 1469 5218aa76939e
child 1473 60e1fad78d58
equal deleted inserted replaced
1469:5218aa76939e 1470:ebaca3b66d92
    40 answerConfigParam paramName paramStrs = [(othersInRoom, "CONFIG_PARAM" : paramName : paramStrs)]
    40 answerConfigParam paramName paramStrs = [(othersInRoom, "CONFIG_PARAM" : paramName : paramStrs)]
    41 answerFullConfig room = map toAnswer (Map.toList $ params room) ++ [(clientOnly, ["MAP", gamemap room])]
    41 answerFullConfig room = map toAnswer (Map.toList $ params room) ++ [(clientOnly, ["MAP", gamemap room])]
    42 	where
    42 	where
    43 		toAnswer (paramName, paramStrs) =
    43 		toAnswer (paramName, paramStrs) =
    44 			(clientOnly, "CONFIG_PARAM" : paramName : paramStrs)
    44 			(clientOnly, "CONFIG_PARAM" : paramName : paramStrs)
    45 answerCantAdd = [(clientOnly, ["WARNING", "Too many teams or hedgehogs, or same name team, or round in progress"])]
    45 answerCantAdd reason = [(clientOnly, ["WARNING", "Cannot add team: " ++ reason])]
    46 answerTeamAccepted team = [(clientOnly, ["TEAM_ACCEPTED", teamname team])]
    46 answerTeamAccepted team = [(clientOnly, ["TEAM_ACCEPTED", teamname team])]
    47 answerAddTeam team = [(othersInRoom, teamToNet team)]
    47 answerAddTeam team = [(othersInRoom, teamToNet team)]
    48 answerHHNum teamName hhNumber = [(othersInRoom, ["HH_NUM", teamName, show hhNumber])]
    48 answerHHNum teamName hhNumber = [(othersInRoom, ["HH_NUM", teamName, show hhNumber])]
    49 answerRemoveTeam teamName = [(othersInRoom, ["REMOVE_TEAM", teamName])]
    49 answerRemoveTeam teamName = [(othersInRoom, ["REMOVE_TEAM", teamName])]
    50 answerNotOwner = [(clientOnly, ["ERROR", "You do not own this team"])]
    50 answerNotOwner = [(clientOnly, ["ERROR", "You do not own this team"])]
   193 	where
   193 	where
   194 		clRoom = roomByName (room client) rooms
   194 		clRoom = roomByName (room client) rooms
   195 
   195 
   196 handleCmd_inRoom client _ rooms ("ADD_TEAM" : name : color : grave : fort : difStr : hhsInfo)
   196 handleCmd_inRoom client _ rooms ("ADD_TEAM" : name : color : grave : fort : difStr : hhsInfo)
   197 	| length hhsInfo == 16 =
   197 	| length hhsInfo == 16 =
   198 	if length (teams clRoom) == 6
   198 	if length (teams clRoom) == 6 then
   199 		|| canAddNumber <= 0
   199 		(noChangeClients, noChangeRooms, answerCantAdd "too many teams")
   200 		|| isJust findTeam
   200 	else if canAddNumber <= 0 then
   201 		|| gameinprogress clRoom
   201 		(noChangeClients, noChangeRooms, answerCantAdd "too many hedgehogs")
   202 		|| isRestrictedTeams clRoom then
   202 	else if isJust findTeam then
   203 		(noChangeClients, noChangeRooms, answerCantAdd)
   203 		(noChangeClients, noChangeRooms, answerCantAdd "already has a team with same name")
       
   204 	else if gameinprogress clRoom then
       
   205 		(noChangeClients, noChangeRooms, answerCantAdd "round in progress")
       
   206 	else if isRestrictedTeams clRoom then
       
   207 		(noChangeClients, noChangeRooms, answerCantAdd "restricted")
   204 	else
   208 	else
   205 		(noChangeClients, modifyRoom clRoom{teams = teams clRoom ++ [newTeam]}, answerTeamAccepted newTeam ++ answerAddTeam newTeam ++ answerTeamColor name color)
   209 		(noChangeClients, modifyRoom clRoom{teams = teams clRoom ++ [newTeam]}, answerTeamAccepted newTeam ++ answerAddTeam newTeam ++ answerTeamColor name color)
   206 	where
   210 	where
   207 		clRoom = roomByName (room client) rooms
   211 		clRoom = roomByName (room client) rooms
   208 		newTeam = (TeamInfo (nick client) name color grave fort difficulty newTeamHHNum (hhsList hhsInfo))
   212 		newTeam = (TeamInfo (nick client) name color grave fort difficulty newTeamHHNum (hhsList hhsInfo))