gameServer/Actions.hs
changeset 7126 8daa5c8e84c0
parent 7124 cfee05712896
child 7321 57bd4f201401
equal deleted inserted replaced
7124:cfee05712896 7126:8daa5c8e84c0
   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     
   315     answerRemovedTeams <- io $ 
   316     mapM_ processAction [
   316          room'sM rnc (map (\t -> AnswerClients thisRoomChans ["REMOVE_TEAM", t]) . leftTeams . fromJust . gameInfo) ri
       
   317          
       
   318     mapM_ processAction $ 
   317         SaveReplay
   319         SaveReplay
   318         , ModifyRoom
   320         : ModifyRoom
   319             (\r -> r{
   321             (\r -> r{
   320                 gameInfo = Nothing,
   322                 gameInfo = Nothing,
   321                 readyPlayers = 0
   323                 readyPlayers = 0
   322                 }
   324                 }
   323             )
   325             )
   324         , UnreadyRoomClients
   326         : UnreadyRoomClients
   325         ]
   327         : answerRemovedTeams
   326 
   328 
   327         
   329         
   328 processAction (SendTeamRemovalMessage teamName) = do
   330 processAction (SendTeamRemovalMessage teamName) = do
   329     chans <- othersChans
   331     chans <- othersChans
   330     mapM_ processAction [
   332     mapM_ processAction [
   350     rnc <- gets roomsClients
   352     rnc <- gets roomsClients
   351     ri <- clientRoomA
   353     ri <- clientRoomA
   352     inGame <- io $ room'sM rnc (isJust . gameInfo) ri
   354     inGame <- io $ room'sM rnc (isJust . gameInfo) ri
   353     chans <- othersChans
   355     chans <- othersChans
   354     mapM_ processAction $ 
   356     mapM_ processAction $ 
   355         ModifyRoom (\r -> r{teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r})
   357         ModifyRoom (\r -> r{
       
   358             teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r
       
   359             , gameInfo = liftM (\g -> g{leftTeams = teamName : leftTeams g}) $ gameInfo r
       
   360             })
   356         : AnswerClients chans ["REMOVE_TEAM", teamName]
   361         : AnswerClients chans ["REMOVE_TEAM", teamName]
   357         : [SendTeamRemovalMessage teamName | inGame]
   362         : [SendTeamRemovalMessage teamName | inGame]
   358 
   363 
   359 
   364 
   360 processAction (RemoveClientTeams clId) = do
   365 processAction (RemoveClientTeams clId) = do