gameServer/RoomsAndClients.hs
changeset 3436 288fcbdb77b6
parent 3435 4e4f88a7bdf2
child 3458 11cd56019f00
--- a/gameServer/RoomsAndClients.hs	Thu May 06 17:39:08 2010 +0000
+++ b/gameServer/RoomsAndClients.hs	Thu May 06 17:53:37 2010 +0000
@@ -8,10 +8,13 @@
     addClient,
     removeRoom,
     removeClient,
+    modifyRoom,
+    modifyClient,
     lobbyId,
     moveClientToLobby,
     moveClientToRoom,
     clientRoom,
+    clientRoomM,
     client,
     allClients,
     withRoomsAndClients,
@@ -106,6 +109,12 @@
     removeElem clients ci
 
 
+modifyRoom :: MRoomsAndClients r c -> (r -> r) -> RoomIndex -> IO ()
+modifyRoom (MRoomsAndClients (rooms, _)) f (RoomIndex ri) = modifyElem rooms (\r -> r{room' = f $ room' r}) ri
+
+modifyClient :: MRoomsAndClients r c -> (c -> c) -> ClientIndex -> IO ()
+modifyClient (MRoomsAndClients (_, clients)) f (ClientIndex ci) = modifyElem clients (\c -> c{client' = f $ client' c}) ci
+
 moveClientInRooms :: MRoomsAndClients r c -> RoomIndex -> RoomIndex -> ClientIndex -> IO ()
 moveClientInRooms (MRoomsAndClients (rooms, clients)) (RoomIndex riFrom) rt@(RoomIndex riTo) cl@(ClientIndex ci) = do
     modifyElem rooms (roomRemoveClient cl) riFrom