gameServer/RoomsAndClients.hs
changeset 3502 ad38c653b7d9
parent 3501 a3159a410e5c
child 3555 4c5ca656d1bb
equal deleted inserted replaced
3501:a3159a410e5c 3502:ad38c653b7d9
    17     clientRoomM,
    17     clientRoomM,
    18     client,
    18     client,
    19     room,
    19     room,
    20     client'sM,
    20     client'sM,
    21     clientsM,
    21     clientsM,
       
    22     roomClientsM,
    22     withRoomsAndClients,
    23     withRoomsAndClients,
    23     allRooms,
    24     allRooms,
    24     allClients,
    25     allClients,
    25     showRooms,
    26     showRooms,
    26     roomClients
    27     roomClients
   141 client'sM (MRoomsAndClients (_, clients)) f (ClientIndex ci) = liftM (f . client') (clients `readElem` ci)
   142 client'sM (MRoomsAndClients (_, clients)) f (ClientIndex ci) = liftM (f . client') (clients `readElem` ci)
   142 
   143 
   143 clientsM :: MRoomsAndClients r c -> IO [c]
   144 clientsM :: MRoomsAndClients r c -> IO [c]
   144 clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (\ci -> liftM client' $ readElem clients ci)
   145 clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (\ci -> liftM client' $ readElem clients ci)
   145 
   146 
       
   147 roomClientsM :: MRoomsAndClients r c -> RoomIndex -> IO [c]
       
   148 roomClientsM (MRoomsAndClients (rooms, clients)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri) >>= mapM (\(ClientIndex ci) -> liftM client' $ readElem clients ci)
       
   149 
   146 withRoomsAndClients :: MRoomsAndClients r c -> (IRoomsAndClients r c -> a) -> IO a
   150 withRoomsAndClients :: MRoomsAndClients r c -> (IRoomsAndClients r c -> a) -> IO a
   147 withRoomsAndClients (MRoomsAndClients (rooms, clients)) f =
   151 withRoomsAndClients (MRoomsAndClients (rooms, clients)) f =
   148     withIStore2 rooms clients (\r c -> f $ IRoomsAndClients (r, c))
   152     withIStore2 rooms clients (\r c -> f $ IRoomsAndClients (r, c))
   149 
   153 
   150 ----------------------------------------
   154 ----------------------------------------