310 processAction FinishGame = do |
310 processAction FinishGame = do |
311 rnc <- gets roomsClients |
311 rnc <- gets roomsClients |
312 ri <- clientRoomA |
312 ri <- clientRoomA |
313 thisRoomChans <- liftM (map sendChan) $ roomClientsS ri |
313 thisRoomChans <- liftM (map sendChan) $ roomClientsS ri |
314 clNick <- client's nick |
314 clNick <- client's nick |
315 answerRemovedTeams <- io $ |
|
316 room'sM rnc (map (\t -> AnswerClients thisRoomChans ["REMOVE_TEAM", t]) . leftTeams . fromJust . gameInfo) ri |
|
317 |
315 |
318 mapM_ processAction $ SaveReplay |
316 mapM_ processAction [ |
319 : ModifyRoom |
317 SaveReplay |
|
318 , ModifyRoom |
320 (\r -> r{ |
319 (\r -> r{ |
321 gameInfo = Nothing, |
320 gameInfo = Nothing, |
322 readyPlayers = 0 |
321 readyPlayers = 0 |
323 } |
322 } |
324 ) |
323 ) |
325 : UnreadyRoomClients |
324 , UnreadyRoomClients |
326 : answerRemovedTeams |
325 ] |
327 |
326 |
328 |
327 |
329 processAction (SendTeamRemovalMessage teamName) = do |
328 processAction (SendTeamRemovalMessage teamName) = do |
330 chans <- othersChans |
329 chans <- othersChans |
331 mapM_ processAction [ |
330 mapM_ processAction [ |
332 AnswerClients chans ["EM", rmTeamMsg], |
331 AnswerClients chans ["EM", rmTeamMsg], |
333 ModifyRoom (\r -> r{ |
332 ModifyRoom (\r -> r{ |
334 gameInfo = liftM (\g -> g{ |
333 gameInfo = liftM (\g -> g{ |
335 teamsInGameNumber = teamsInGameNumber g - 1, |
334 teamsInGameNumber = teamsInGameNumber g - 1 |
336 roundMsgs = roundMsgs g Seq.|> rmTeamMsg |
335 , roundMsgs = roundMsgs g Seq.|> rmTeamMsg |
337 }) $ gameInfo r |
336 }) $ gameInfo r |
338 }) |
337 }) |
339 ] |
338 ] |
340 |
339 |
341 rnc <- gets roomsClients |
340 rnc <- gets roomsClients |
350 processAction (RemoveTeam teamName) = do |
349 processAction (RemoveTeam teamName) = do |
351 rnc <- gets roomsClients |
350 rnc <- gets roomsClients |
352 ri <- clientRoomA |
351 ri <- clientRoomA |
353 inGame <- io $ room'sM rnc (isJust . gameInfo) ri |
352 inGame <- io $ room'sM rnc (isJust . gameInfo) ri |
354 chans <- othersChans |
353 chans <- othersChans |
355 if not $ inGame then |
354 mapM_ processAction $ |
356 mapM_ processAction [ |
355 ModifyRoom (\r -> r{teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r}) |
357 AnswerClients chans ["REMOVE_TEAM", teamName], |
356 : AnswerClients chans ["REMOVE_TEAM", teamName] |
358 ModifyRoom (\r -> r{teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r}) |
357 : [SendTeamRemovalMessage teamName | inGame] |
359 ] |
|
360 else |
|
361 mapM_ processAction [ |
|
362 SendTeamRemovalMessage teamName, |
|
363 ModifyRoom (\r -> r{ |
|
364 teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r, |
|
365 gameInfo = liftM (\g -> g{ |
|
366 leftTeams = teamName : leftTeams g |
|
367 }) $ gameInfo r |
|
368 }) |
|
369 ] |
|
370 |
358 |
371 |
359 |
372 processAction (RemoveClientTeams clId) = do |
360 processAction (RemoveClientTeams clId) = do |
373 rnc <- gets roomsClients |
361 rnc <- gets roomsClients |
374 |
362 |