gameServer/Actions.hs
changeset 7367 ad3f5f2e6ea9
parent 7351 34efdd1f230f
child 7465 c2dcf97ca664
equal deleted inserted replaced
7365:26df99967963 7367:ad3f5f2e6ea9
   208 processAction (MoveToLobby msg) = do
   208 processAction (MoveToLobby msg) = do
   209     (Just ci) <- gets clientIndex
   209     (Just ci) <- gets clientIndex
   210     ri <- clientRoomA
   210     ri <- clientRoomA
   211     rnc <- gets roomsClients
   211     rnc <- gets roomsClients
   212     (gameProgress, playersNum) <- io $ room'sM rnc ((isJust . gameInfo) &&& playersIn) ri
   212     (gameProgress, playersNum) <- io $ room'sM rnc ((isJust . gameInfo) &&& playersIn) ri
   213     ready <- client's isReady
       
   214     master <- client's isMaster
   213     master <- client's isMaster
   215 --    client <- client's id
   214 --    client <- client's id
   216     clNick <- client's nick
   215     clNick <- client's nick
   217     chans <- othersChans
   216     chans <- othersChans
   218 
   217 
   219     if master then
   218     if master then
   220         if gameProgress && playersNum > 1 then
   219         if gameProgress && playersNum > 1 then
   221             mapM_ processAction [ChangeMaster, AnswerClients chans ["LEFT", clNick, msg], NoticeMessage AdminLeft, RemoveClientTeams ci]
   220             mapM_ processAction [ChangeMaster, NoticeMessage AdminLeft, RemoveClientTeams ci, AnswerClients chans ["LEFT", clNick, msg]]
   222             else
   221             else
   223             processAction RemoveRoom
   222             processAction RemoveRoom
   224         else
   223         else
   225         mapM_ processAction [AnswerClients chans ["LEFT", clNick, msg], RemoveClientTeams ci]
   224         mapM_ processAction [RemoveClientTeams ci, AnswerClients chans ["LEFT", clNick, msg]]
   226 
   225 
   227     -- when not removing room
   226     -- when not removing room
       
   227     ready <- client's isReady
   228     when (not master || (gameProgress && playersNum > 1)) . io $ do
   228     when (not master || (gameProgress && playersNum > 1)) . io $ do
   229         modifyRoom rnc (\r -> r{
   229         modifyRoom rnc (\r -> r{
   230                 playersIn = playersIn r - 1,
   230                 playersIn = playersIn r - 1,
   231                 readyPlayers = if ready then readyPlayers r - 1 else readyPlayers r
   231                 readyPlayers = if ready then readyPlayers r - 1 else readyPlayers r
   232                 }) ri
   232                 }) ri