netserver/HWProto.hs
changeset 1338 758c39a3dcfe
parent 1336 4e88eccbe7f6
child 1344 4004e597f1bf
equal deleted inserted replaced
1337:b652c002633b 1338:758c39a3dcfe
    46 		toAnswer team =
    46 		toAnswer team =
    47 			[(clientOnly, teamToNet team),
    47 			[(clientOnly, teamToNet team),
    48 			(clientOnly, ["TEAM_COLOR", teamname team, teamcolor team]),
    48 			(clientOnly, ["TEAM_COLOR", teamname team, teamcolor team]),
    49 			(clientOnly, ["HH_NUM", teamname team, show $ hhnum team])]
    49 			(clientOnly, ["HH_NUM", teamname team, show $ hhnum team])]
    50 answerMap mapName = [(othersInRoom, ["MAP", mapName])]
    50 answerMap mapName = [(othersInRoom, ["MAP", mapName])]
       
    51 answerRunGame = [(sameRoom, ["RUN_GAME"])]
    51 
    52 
    52 -- Main state-independent cmd handler
    53 -- Main state-independent cmd handler
    53 handleCmd :: CmdHandler
    54 handleCmd :: CmdHandler
    54 handleCmd client _ rooms ("QUIT":xs) =
    55 handleCmd client _ rooms ("QUIT":xs) =
    55 	if null (room client) then
    56 	if null (room client) then
   209 		noSuchTeam = isNothing findTeam
   210 		noSuchTeam = isNothing findTeam
   210 		team = fromJust findTeam
   211 		team = fromJust findTeam
   211 		findTeam = find (\t -> teamName == teamname t) $ teams clRoom
   212 		findTeam = find (\t -> teamName == teamname t) $ teams clRoom
   212 		clRoom = roomByName (room client) rooms
   213 		clRoom = roomByName (room client) rooms
   213 
   214 
       
   215 handleCmd_inRoom client _ _ ["READY"] =
       
   216 	if not $ isMaster client then
       
   217 		(noChangeClients, noChangeRooms, answerNotMaster)
       
   218 	else
       
   219 		(noChangeClients, noChangeRooms, answerRunGame)
       
   220 
       
   221 handleCmd_inRoom client _ _ ["GAMEMSG", msg] =
       
   222 	(noChangeClients, noChangeRooms, [(othersInRoom, ["GAMEMSG", msg])])
       
   223 
   214 handleCmd_inRoom _ _ _ _ = (noChangeClients, noChangeRooms, answerBadCmd)
   224 handleCmd_inRoom _ _ _ _ = (noChangeClients, noChangeRooms, answerBadCmd)