10 |
10 |
11 teamToNet team = ["ADD_TEAM", teamname team, teamgrave team, teamfort team, show $ difficulty team] ++ hhsInfo |
11 teamToNet team = ["ADD_TEAM", teamname team, teamgrave team, teamfort team, show $ difficulty team] ++ hhsInfo |
12 where |
12 where |
13 hhsInfo = concatMap (\(HedgehogInfo name hat) -> [name, hat]) $ hedgehogs team |
13 hhsInfo = concatMap (\(HedgehogInfo name hat) -> [name, hat]) $ hedgehogs team |
14 |
14 |
15 answerServerMessage = [(clientOnly, "SERVER_MESSAGE" : [body])] |
15 answerServerMessage clients = [(clientOnly, "SERVER_MESSAGE" : [mainbody ++ clientsIn])] |
16 where |
16 where |
17 body = serverMessage globalOptions ++ if isDedicated globalOptions then "<p align=center>Dedicated server</p>" else "<p align=center>Private server</p>" |
17 mainbody = serverMessage globalOptions ++ if isDedicated globalOptions then "<p align=center>Dedicated server</p>" else "<p align=center>Private server</p>" |
|
18 clientsIn = "<p align=left>" ++ (show $ length nicks) ++ " clients in: " ++ clientslist ++ "</p>" |
|
19 clientslist = if not $ null nicks then foldr1 (\a b -> a ++ ", " ++ b) nicks else "" |
|
20 nicks = filter (not . null) $ map nick clients |
|
21 |
18 answerBadCmd = [(clientOnly, ["ERROR", "Bad command, state or incorrect parameter"])] |
22 answerBadCmd = [(clientOnly, ["ERROR", "Bad command, state or incorrect parameter"])] |
19 answerNotMaster = [(clientOnly, ["ERROR", "You cannot configure room parameters"])] |
23 answerNotMaster = [(clientOnly, ["ERROR", "You cannot configure room parameters"])] |
20 answerBadParam = [(clientOnly, ["ERROR", "Bad parameter"])] |
24 answerBadParam = [(clientOnly, ["ERROR", "Bad parameter"])] |
21 answerQuit = [(clientOnly, ["BYE"])] |
25 answerQuit = [(clientOnly, ["BYE"])] |
22 answerAbandoned = [(othersInRoom, ["BYE"])] |
26 answerAbandoned = [(othersInRoom, ["BYE"])] |
110 handleCmd_noInfo _ _ _ _ = (noChangeClients, noChangeRooms, answerBadCmd) |
114 handleCmd_noInfo _ _ _ _ = (noChangeClients, noChangeRooms, answerBadCmd) |
111 |
115 |
112 |
116 |
113 -- 'noRoom' clients state command handlers |
117 -- 'noRoom' clients state command handlers |
114 handleCmd_noRoom :: CmdHandler |
118 handleCmd_noRoom :: CmdHandler |
115 handleCmd_noRoom client _ rooms ["LIST"] = |
119 handleCmd_noRoom client clients rooms ["LIST"] = |
116 (noChangeClients, noChangeRooms, answerServerMessage ++ (answerRoomsList $ concatMap roomInfo $ sameProtoRooms)) |
120 (noChangeClients, noChangeRooms, answerServerMessage clients ++ (answerRoomsList $ concatMap roomInfo $ sameProtoRooms)) |
117 where |
121 where |
118 roomInfo room = [ |
122 roomInfo room = [ |
119 name room, |
123 name room, |
120 (show $ playersIn room) ++ "(" ++ (show $ length $ teams room) ++ ")", |
124 (show $ playersIn room) ++ "(" ++ (show $ length $ teams room) ++ ")", |
121 show $ gameinprogress room |
125 show $ gameinprogress room |