gameServer/HWProtoInRoomState.hs
changeset 6012 6bac93097da3
parent 5996 2c72fe81dd37
child 6068 e18713ecf1e0
equal deleted inserted replaced
6011:519f8a58c021 6012:6bac93097da3
   164                 else
   164                 else
   165                 ["CLIENT_FLAGS", if isReady cl then "-r" else "+r", nick cl]
   165                 ["CLIENT_FLAGS", if isReady cl then "-r" else "+r", nick cl]
   166         ]
   166         ]
   167 
   167 
   168 handleCmd_inRoom ["START_GAME"] = do
   168 handleCmd_inRoom ["START_GAME"] = do
       
   169     (ci, rnc) <- ask
   169     cl <- thisClient
   170     cl <- thisClient
   170     rm <- thisRoom
   171     rm <- thisRoom
   171     chans <- roomClientsChans
   172     chans <- roomClientsChans
       
   173     
       
   174     let allPlayersRegistered = all ((<) 0 . B.length . webPassword . client rnc . teamownerId) $ teams rm
   172 
   175 
   173     if isMaster cl && playersIn rm == readyPlayers rm && not (isJust $ gameInfo rm) then
   176     if isMaster cl && playersIn rm == readyPlayers rm && not (isJust $ gameInfo rm) then
   174         if enoughClans rm then
   177         if enoughClans rm then
   175             return [
   178             return [
   176                 ModifyRoom
   179                 ModifyRoom
   177                     (\r -> r{
   180                     (\r -> r{
   178                         gameInfo = Just $ newGameInfo False
   181                         gameInfo = Just $ newGameInfo allPlayersRegistered
   179                         }
   182                         }
   180                     ),
   183                     ),
   181                 AnswerClients chans ["RUN_GAME"]
   184                 AnswerClients chans ["RUN_GAME"]
   182                 ]
   185                 ]
   183             else
   186             else
   205     cl <- thisClient
   208     cl <- thisClient
   206     rm <- thisRoom
   209     rm <- thisRoom
   207     chans <- roomClientsChans
   210     chans <- roomClientsChans
   208 
   211 
   209     if isMaster cl && (isJust $ gameInfo rm) then
   212     if isMaster cl && (isJust $ gameInfo rm) then
   210         return $ 
   213         return $
   211             ModifyRoom
   214             SaveReplay
       
   215             : ModifyRoom
   212                 (\r -> r{
   216                 (\r -> r{
   213                     gameInfo = Nothing,
   217                     gameInfo = Nothing,
   214                     readyPlayers = 0
   218                     readyPlayers = 0
   215                     }
   219                     }
   216                 )
   220                 )