38 showB $ gameinprogress r, |
38 showB $ gameinprogress r, |
39 name r, |
39 name r, |
40 showB $ playersIn r, |
40 showB $ playersIn r, |
41 showB $ length $ teams r, |
41 showB $ length $ teams r, |
42 nick $ irnc `client` masterID r, |
42 nick $ irnc `client` masterID r, |
43 head (Map.findWithDefault ["+gen+"] "MAP" (params r)), |
43 head (Map.findWithDefault ["+rnd+"] "MAP" (mapParams r)), |
44 head (Map.findWithDefault ["Default"] "SCHEME" (params r)), |
44 head (Map.findWithDefault ["Default"] "SCHEME" (params r)), |
45 head (Map.findWithDefault ["Default"] "AMMO" (params r)), |
45 head (Map.findWithDefault ["Default"] "AMMO" (params r)) |
46 head (Map.findWithDefault ["Default"] "SCHEME" (params r)), |
|
47 head (Map.findWithDefault ["0"] "MAPGEN" (params r)), |
|
48 head (Map.findWithDefault ["seed"] "SEED" (params r)) |
|
49 ] |
46 ] |
50 |
47 |
51 |
48 |
52 handleCmd_lobby ["CHAT", msg] = do |
49 handleCmd_lobby ["CHAT", msg] = do |
53 n <- clientNick |
50 n <- clientNick |
94 MoveToRoom jRI, |
91 MoveToRoom jRI, |
95 AnswerClients [sendChan cl] $ "JOINED" : nicks, |
92 AnswerClients [sendChan cl] $ "JOINED" : nicks, |
96 AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl] |
93 AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl] |
97 ] |
94 ] |
98 ++ map (readynessMessage cl) jRoomClients |
95 ++ map (readynessMessage cl) jRoomClients |
99 ++ answerFullConfig cl (params jRoom) |
96 ++ answerFullConfig cl (mapParams jRoom) (params jRoom) |
100 ++ answerTeams cl jRoom |
97 ++ answerTeams cl jRoom |
101 ++ watchRound cl jRoom |
98 ++ watchRound cl jRoom |
102 |
99 |
103 where |
100 where |
104 readynessMessage cl c = AnswerClients [sendChan cl] ["CLIENT_FLAGS", if isReady c then "+r" else "-r", nick c] |
101 readynessMessage cl c = AnswerClients [sendChan cl] ["CLIENT_FLAGS", if isReady c then "+r" else "-r", nick c] |
105 |
102 |
106 toAnswer cl (paramName, paramStrs) = AnswerClients [sendChan cl] $ "CFG" : paramName : paramStrs |
103 toAnswer cl (paramName, paramStrs) = AnswerClients [sendChan cl] $ "CFG" : paramName : paramStrs |
107 |
104 |
108 answerFullConfig cl pr = map (toAnswer cl) $ |
105 answerFullConfig cl mpr pr = map (toAnswer cl) $ |
109 ("FULLMAPCONFIG", concatMap ((Map.!) pr) ["MAP", "MAPGEN", "SEED"]) |
106 ("FULLMAPCONFIG", Map.elems mpr) |
110 : ("SCHEME", pr Map.! "SCHEME") |
107 : ("SCHEME", pr Map.! "SCHEME") |
111 : (filter (\(p, _) -> p /= "SCHEME" && p /= "MAP" && p /= "MAPGEN" && p /= "SEED") $ Map.toList pr) |
108 : (filter (\(p, _) -> p /= "SCHEME") $ Map.toList pr) |
112 |
109 |
113 answerTeams cl jRoom = let f = if gameinprogress jRoom then teamsAtStart else teams in answerAllTeams cl $ f jRoom |
110 answerTeams cl jRoom = let f = if gameinprogress jRoom then teamsAtStart else teams in answerAllTeams cl $ f jRoom |
114 |
111 |
115 watchRound cl jRoom = if not $ gameinprogress jRoom then |
112 watchRound cl jRoom = if not $ gameinprogress jRoom then |
116 [] |
113 [] |