--- a/gameServer/Actions.hs Mon Jul 19 23:10:33 2010 +0400
+++ b/gameServer/Actions.hs Mon Jul 19 23:30:08 2010 +0400
@@ -277,21 +277,16 @@
rID = roomID client
client = clients ! clID
+-}
+processAction (UnreadyRoomClients) = do
+ rnc <- gets roomsClients
+ ri <- clientRoomA
+ roomPlayers <- roomClientsS ri
+ roomClIDs <- liftIO $ roomClientsIndicesM rnc ri
+ processAction $ AnswerClients (map sendChan roomPlayers) ("NOT_READY" : map nick roomPlayers)
+ liftIO $ mapM_ (modifyClient rnc (\cl -> cl{isReady = False})) roomClIDs
+ processAction $ ModifyRoom (\r -> r{readyPlayers = 0})
-processAction (clID, serverInfo, rnc) (UnreadyRoomClients) = do
- processAction (clID, serverInfo, rnc) $ AnswerThisRoom ("NOT_READY" : roomPlayers)
- return (clID,
- serverInfo,
- Data.IntMap.map (\cl -> if roomID cl == rID then cl{isReady = False} else cl) clients,
- adjust (\r -> r{readyPlayers = 0}) rID rooms)
- where
- room = rooms ! rID
- rID = roomID client
- client = clients ! clID
- roomPlayers = Prelude.map (nick . (clients !)) roomPlayersIDs
- roomPlayersIDs = IntSet.elems $ playersIDs room
-
--}
processAction (RemoveTeam teamName) = do
rnc <- gets roomsClients
--- a/gameServer/RoomsAndClients.hs Mon Jul 19 23:10:33 2010 +0400
+++ b/gameServer/RoomsAndClients.hs Mon Jul 19 23:30:08 2010 +0400
@@ -22,6 +22,7 @@
allClientsM,
clientsM,
roomClientsM,
+ roomClientsIndicesM,
withRoomsAndClients,
allRooms,
allClients,
@@ -153,6 +154,9 @@
clientsM :: MRoomsAndClients r c -> IO [c]
clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (\ci -> liftM client' $ readElem clients ci)
+roomClientsIndicesM :: MRoomsAndClients r c -> RoomIndex -> IO [ClientIndex]
+roomClientsIndicesM (MRoomsAndClients (rooms, clients)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri)
+
roomClientsM :: MRoomsAndClients r c -> RoomIndex -> IO [c]
roomClientsM (MRoomsAndClients (rooms, clients)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri) >>= mapM (\(ClientIndex ci) -> liftM client' $ readElem clients ci)