# HG changeset patch # User unc0rr # Date 1277317273 -14400 # Node ID d84a93b985c15328d499971af3fb7821e7b352c7 # Parent f216b24aeb7f21c2ae0a4bd66dd69386a31ad2b6 Reimplement TOGGLE_READY command diff -r f216b24aeb7f -r d84a93b985c1 gameServer/HWProtoInRoomState.hs --- a/gameServer/HWProtoInRoomState.hs Wed Jun 23 22:17:27 2010 +0400 +++ b/gameServer/HWProtoInRoomState.hs Wed Jun 23 22:21:13 2010 +0400 @@ -108,16 +108,18 @@ findTeam = find (\t -> teamName == teamname t) $ teams room client = clients IntMap.! clID room = rooms IntMap.! (roomID client) - +-} -handleCmd_inRoom clID clients rooms ["TOGGLE_READY"] = - [ModifyClient (\c -> c{isReady = not $ isReady client}), - ModifyRoom (\r -> r{readyPlayers = readyPlayers r + (if isReady client then -1 else 1)}), - AnswerThisRoom [if isReady client then "NOT_READY" else "READY", nick client]] - where - client = clients IntMap.! clID +handleCmd_inRoom ["TOGGLE_READY"] = do + cl <- thisClient + chans <- roomClientsChans + return [ + ModifyClient (\c -> c{isReady = not $ isReady cl}), + ModifyRoom (\r -> r{readyPlayers = readyPlayers r + (if isReady cl then -1 else 1)}), + 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 diff -r f216b24aeb7f -r d84a93b985c1 gameServer/HandlerUtils.hs --- a/gameServer/HandlerUtils.hs Wed Jun 23 22:17:27 2010 +0400 +++ b/gameServer/HandlerUtils.hs Wed Jun 23 22:21:13 2010 +0400 @@ -21,6 +21,12 @@ let ri = clientRoom rnc ci return $ map (sendChan . client rnc) $ filter (/= ci) (roomClients rnc ri) +roomClientsChans :: Reader (ClientIndex, IRnC) [ClientChan] +roomClientsChans = do + (ci, rnc) <- ask + let ri = clientRoom rnc ci + return $ map (sendChan . client rnc) (roomClients rnc ri) + thisClientChans :: Reader (ClientIndex, IRnC) [ClientChan] thisClientChans = do (ci, rnc) <- ask