equal
deleted
inserted
replaced
179 return [ |
179 return [ |
180 ModifyRoom |
180 ModifyRoom |
181 (\r -> r{ |
181 (\r -> r{ |
182 gameInfo = Just $ newGameInfo (teams rm) (length $ teams rm) allPlayersRegistered (mapParams rm) (params rm) |
182 gameInfo = Just $ newGameInfo (teams rm) (length $ teams rm) allPlayersRegistered (mapParams rm) (params rm) |
183 } |
183 } |
184 ), |
184 ) |
185 AnswerClients chans ["RUN_GAME"] |
185 , AnswerClients chans ["RUN_GAME"] |
|
186 , ModifyRoomClients (\c -> c{isInGame = True}) |
186 ] |
187 ] |
187 else |
188 else |
188 return [Warning "Less than two clans!"] |
189 return [Warning "Less than two clans!"] |
189 else |
190 else |
190 return [] |
191 return [] |
204 where |
205 where |
205 (isLegal, isKeepAlive) = checkNetCmd msg |
206 (isLegal, isKeepAlive) = checkNetCmd msg |
206 |
207 |
207 |
208 |
208 handleCmd_inRoom ["ROUNDFINISHED", correctly] = do |
209 handleCmd_inRoom ["ROUNDFINISHED", correctly] = do |
209 clId <- asks fst |
|
210 cl <- thisClient |
210 cl <- thisClient |
211 rm <- thisRoom |
211 rm <- thisRoom |
212 let clTeams = map teamname . filter (\t -> teamowner t == nick cl) . teams $ rm |
212 let clTeams = map teamname . filter (\t -> teamowner t == nick cl) . teams $ rm |
213 |
213 |
214 if isJust $ gameInfo rm then |
214 if isInGame cl then |
215 if (isMaster cl && isCorrect) then |
215 if isJust $ gameInfo rm then |
216 return [FinishGame] |
216 if (isMaster cl && isCorrect) then |
217 else return $ map SendTeamRemovalMessage clTeams |
217 return [ModifyClient (\c -> c{isInGame = False}), FinishGame] |
218 else |
218 else |
219 return [] |
219 return $ (ModifyClient (\c -> c{isInGame = False})) : map SendTeamRemovalMessage clTeams |
|
220 else |
|
221 return [ModifyClient (\c -> c{isInGame = False})] |
|
222 else |
|
223 return [] -- don't accept this message twice |
220 where |
224 where |
221 isCorrect = correctly == "1" |
225 isCorrect = correctly == "1" |
222 |
226 |
223 -- compatibility with clients with protocol < 38 |
227 -- compatibility with clients with protocol < 38 |
224 handleCmd_inRoom ["ROUNDFINISHED"] = |
228 handleCmd_inRoom ["ROUNDFINISHED"] = |