# HG changeset patch # User unc0rr # Date 1277746905 -14400 # Node ID 0ef6f5182a7599408b0957eaf0b3603c59d75110 # Parent d85bdd5dc835c51ef061dcb28fd52671c110a223 START_GAME command diff -r d85bdd5dc835 -r 0ef6f5182a75 gameServer/HWProtoInRoomState.hs --- a/gameServer/HWProtoInRoomState.hs Sun Jun 27 21:28:28 2010 +0400 +++ b/gameServer/HWProtoInRoomState.hs Mon Jun 28 21:41:45 2010 +0400 @@ -158,28 +158,32 @@ AnswerClients chans [if isReady cl then "NOT_READY" else "READY", nick cl] ] -{- -handleCmd_inRoom clID clients rooms ["START_GAME"] = - if isMaster client && (playersIn room == readyPlayers room) && (not . gameinprogress) room then - if enoughClans then - [ModifyRoom +handleCmd_inRoom ["START_GAME"] = do + cl <- thisClient + r <- thisRoom + chans <- roomClientsChans + + if isMaster cl && (playersIn r == readyPlayers r) && (not $ gameinprogress r) then + if enoughClans r then + return [ + ModifyRoom (\r -> r{ gameinprogress = True, roundMsgs = empty, leftTeams = [], teamsAtStart = teams r} ), - AnswerThisRoom ["RUN_GAME"]] + AnswerClients chans ["RUN_GAME"] + ] + else + return [Warning "Less than two clans!"] else - [Warning "Less than two clans!"] - else - [] + return [] where - client = clients IntMap.! clID - room = rooms IntMap.! (roomID client) - enoughClans = not $ null $ drop 1 $ group $ map teamcolor $ teams room + enoughClans = not . null . drop 1 . group . map teamcolor . teams +{- handleCmd_inRoom clID clients rooms ["EM", msg] = if (teamsInGame client > 0) && isLegal then (AnswerOthersInRoom ["EM", msg]) : [ModifyRoom (\r -> r{roundMsgs = roundMsgs r |> msg}) | not isKeepAlive]