equal
deleted
inserted
replaced
170 (ci, rnc) <- ask |
170 (ci, rnc) <- ask |
171 cl <- thisClient |
171 cl <- thisClient |
172 rm <- thisRoom |
172 rm <- thisRoom |
173 chans <- roomClientsChans |
173 chans <- roomClientsChans |
174 |
174 |
|
175 let nicks = map (nick . client rnc) . roomClients rnc $ clientRoom rnc ci |
175 let allPlayersRegistered = all ((<) 0 . B.length . webPassword . client rnc . teamownerId) $ teams rm |
176 let allPlayersRegistered = all ((<) 0 . B.length . webPassword . client rnc . teamownerId) $ teams rm |
176 |
177 |
177 if isMaster cl && playersIn rm == readyPlayers rm && not (isJust $ gameInfo rm) then |
178 if isMaster cl && playersIn rm == readyPlayers rm && not (isJust $ gameInfo rm) then |
178 if enoughClans rm then |
179 if enoughClans rm then |
179 return [ |
180 return [ |
181 (\r -> r{ |
182 (\r -> r{ |
182 gameInfo = Just $ newGameInfo (teams rm) (length $ teams rm) allPlayersRegistered (mapParams rm) (params rm) |
183 gameInfo = Just $ newGameInfo (teams rm) (length $ teams rm) allPlayersRegistered (mapParams rm) (params rm) |
183 } |
184 } |
184 ) |
185 ) |
185 , AnswerClients chans ["RUN_GAME"] |
186 , AnswerClients chans ["RUN_GAME"] |
|
187 , AnswerClients chans $ "CLIENT_FLAGS" : "+g" : nicks |
186 , ModifyRoomClients (\c -> c{isInGame = True}) |
188 , ModifyRoomClients (\c -> c{isInGame = True}) |
187 ] |
189 ] |
188 else |
190 else |
189 return [Warning "Less than two clans!"] |
191 return [Warning "Less than two clans!"] |
190 else |
192 else |
207 |
209 |
208 |
210 |
209 handleCmd_inRoom ["ROUNDFINISHED", correctly] = do |
211 handleCmd_inRoom ["ROUNDFINISHED", correctly] = do |
210 cl <- thisClient |
212 cl <- thisClient |
211 rm <- thisRoom |
213 rm <- thisRoom |
|
214 chans <- roomClientsChans |
|
215 |
212 let clTeams = map teamname . filter (\t -> teamowner t == nick cl) . teams $ rm |
216 let clTeams = map teamname . filter (\t -> teamowner t == nick cl) . teams $ rm |
|
217 let unsetInGameState = [AnswerClients chans ["CLIENT_FLAGS", "-g", nick cl], ModifyClient (\c -> c{isInGame = False})] |
213 |
218 |
214 if isInGame cl then |
219 if isInGame cl then |
215 if isJust $ gameInfo rm then |
220 if isJust $ gameInfo rm then |
216 if (isMaster cl && isCorrect) then |
221 if (isMaster cl && isCorrect) then |
217 return [ModifyClient (\c -> c{isInGame = False}), FinishGame] |
222 return $ FinishGame : unsetInGameState |
218 else |
223 else |
219 return $ (ModifyClient (\c -> c{isInGame = False})) : map SendTeamRemovalMessage clTeams |
224 return $ unsetInGameState ++ map SendTeamRemovalMessage clTeams |
220 else |
225 else |
221 return [ModifyClient (\c -> c{isInGame = False})] |
226 return unsetInGameState |
222 else |
227 else |
223 return [] -- don't accept this message twice |
228 return [] -- don't accept this message twice |
224 where |
229 where |
225 isCorrect = correctly == "1" |
230 isCorrect = correctly == "1" |
226 |
231 |