156 ModifyClient (\c -> c{isReady = not $ isReady cl}), |
156 ModifyClient (\c -> c{isReady = not $ isReady cl}), |
157 ModifyRoom (\r -> r{readyPlayers = readyPlayers r + (if isReady cl then -1 else 1)}), |
157 ModifyRoom (\r -> r{readyPlayers = readyPlayers r + (if isReady cl then -1 else 1)}), |
158 AnswerClients chans [if isReady cl then "NOT_READY" else "READY", nick cl] |
158 AnswerClients chans [if isReady cl then "NOT_READY" else "READY", nick cl] |
159 ] |
159 ] |
160 |
160 |
161 {- |
161 handleCmd_inRoom ["START_GAME"] = do |
162 handleCmd_inRoom clID clients rooms ["START_GAME"] = |
162 cl <- thisClient |
163 if isMaster client && (playersIn room == readyPlayers room) && (not . gameinprogress) room then |
163 r <- thisRoom |
164 if enoughClans then |
164 chans <- roomClientsChans |
165 [ModifyRoom |
165 |
|
166 if isMaster cl && (playersIn r == readyPlayers r) && (not $ gameinprogress r) then |
|
167 if enoughClans r then |
|
168 return [ |
|
169 ModifyRoom |
166 (\r -> r{ |
170 (\r -> r{ |
167 gameinprogress = True, |
171 gameinprogress = True, |
168 roundMsgs = empty, |
172 roundMsgs = empty, |
169 leftTeams = [], |
173 leftTeams = [], |
170 teamsAtStart = teams r} |
174 teamsAtStart = teams r} |
171 ), |
175 ), |
172 AnswerThisRoom ["RUN_GAME"]] |
176 AnswerClients chans ["RUN_GAME"] |
173 else |
177 ] |
174 [Warning "Less than two clans!"] |
178 else |
175 else |
179 return [Warning "Less than two clans!"] |
176 [] |
180 else |
177 where |
181 return [] |
178 client = clients IntMap.! clID |
182 where |
179 room = rooms IntMap.! (roomID client) |
183 enoughClans = not . null . drop 1 . group . map teamcolor . teams |
180 enoughClans = not $ null $ drop 1 $ group $ map teamcolor $ teams room |
184 |
181 |
185 |
182 |
186 {- |
183 handleCmd_inRoom clID clients rooms ["EM", msg] = |
187 handleCmd_inRoom clID clients rooms ["EM", msg] = |
184 if (teamsInGame client > 0) && isLegal then |
188 if (teamsInGame client > 0) && isLegal then |
185 (AnswerOthersInRoom ["EM", msg]) : [ModifyRoom (\r -> r{roundMsgs = roundMsgs r |> msg}) | not isKeepAlive] |
189 (AnswerOthersInRoom ["EM", msg]) : [ModifyRoom (\r -> r{roundMsgs = roundMsgs r |> msg}) | not isKeepAlive] |
186 else |
190 else |
187 [] |
191 [] |