207 |
207 |
208 handleCmd_inRoom ["ROUNDFINISHED", correctly] = do |
208 handleCmd_inRoom ["ROUNDFINISHED", correctly] = do |
209 clId <- asks fst |
209 clId <- asks fst |
210 cl <- thisClient |
210 cl <- thisClient |
211 rm <- thisRoom |
211 rm <- thisRoom |
212 chans <- roomClientsChans |
|
213 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 |
214 let isLastPlayer = (teamsInGameNumber . fromJust . gameInfo $ rm) == length clTeams |
|
215 |
213 |
216 if isJust $ gameInfo rm then |
214 if isJust $ gameInfo rm then |
217 if (isMaster cl && isCorrect) || isLastPlayer then |
215 if (isMaster cl && isCorrect) then |
218 return $ |
216 return [FinishGame] |
219 SaveReplay |
|
220 : ModifyRoom |
|
221 (\r -> r{ |
|
222 gameInfo = Nothing, |
|
223 readyPlayers = 0 |
|
224 } |
|
225 ) |
|
226 : UnreadyRoomClients |
|
227 : answerRemovedTeams chans rm |
|
228 else if not isCorrect then |
217 else if not isCorrect then |
229 return $ map SendTeamRemovalMessage clTeams |
218 return $ map SendTeamRemovalMessage clTeams |
230 else |
219 else |
231 return [] |
220 return [] |
232 else |
221 else |
233 return [] |
222 return [] |
234 where |
223 where |
235 answerRemovedTeams chans = map (\t -> AnswerClients chans ["REMOVE_TEAM", t]) . leftTeams . fromJust . gameInfo |
|
236 isCorrect = correctly == "1" |
224 isCorrect = correctly == "1" |
237 |
225 |
238 -- compatibility with clients with protocol < 38 |
226 -- compatibility with clients with protocol < 38 |
239 handleCmd_inRoom ["ROUNDFINISHED"] = |
227 handleCmd_inRoom ["ROUNDFINISHED"] = |
240 handleCmd_inRoom ["ROUNDFINISHED", "1"] |
228 handleCmd_inRoom ["ROUNDFINISHED", "1"] |