--- a/netserver/HWProto.hs Thu Oct 09 13:48:06 2008 +0000
+++ b/netserver/HWProto.hs Thu Oct 09 13:53:03 2008 +0000
@@ -38,6 +38,7 @@
answerHHNum teamName hhNumber = [(othersInRoom, ["HH_NUM", teamName, show hhNumber])]
answerRemoveTeam teamName = [(othersInRoom, ["REMOVE_TEAM", teamName])]
answerNotOwner = [(clientOnly, ["ERROR", "You do not own this team"])]
+answerTeamColor teamName newColor = [(othersInRoom, ["TEAM_COLOR", teamName, newColor])]
-- Main state-independent cmd handler
handleCmd :: CmdHandler
@@ -164,6 +165,17 @@
clRoom = roomByName (room client) rooms
canAddNumber = 18 - (sum . map hhnum $ teams clRoom)
+handleCmd_inRoom client _ rooms ["TEAM_COLOR", teamName, newColor] =
+ if not $ isMaster client then
+ (noChangeClients, noChangeRooms, answerNotMaster)
+ else
+ (noChangeClients, modifyRoom $ modifyTeam clRoom team{teamcolor = newColor}, answerTeamColor teamName newColor)
+ where
+ noSuchTeam = isNothing findTeam
+ team = fromJust findTeam
+ findTeam = find (\t -> teamName == teamname t) $ teams clRoom
+ clRoom = roomByName (room client) rooms
+
handleCmd_inRoom client _ rooms ["REMOVE_TEAM", teamName] =
if noSuchTeam then
(noChangeClients, noChangeRooms, answerBadParam)