gameServer/RoomsAndClients.hs
changeset 3654 18189fbc7530
parent 3645 c0b3f1bb9316
child 3656 c74a4a407146
equal deleted inserted replaced
3653:c0d94fedbd86 3654:18189fbc7530
    17     clientRoomM,
    17     clientRoomM,
    18     client,
    18     client,
    19     room,
    19     room,
    20     client'sM,
    20     client'sM,
    21     room'sM,
    21     room'sM,
       
    22     allClientsM,
    22     clientsM,
    23     clientsM,
    23     roomClientsM,
    24     roomClientsM,
    24     withRoomsAndClients,
    25     withRoomsAndClients,
    25     allRooms,
    26     allRooms,
    26     allClients,
    27     allClients,
   144 client'sM (MRoomsAndClients (_, clients)) f (ClientIndex ci) = liftM (f . client') (clients `readElem` ci)
   145 client'sM (MRoomsAndClients (_, clients)) f (ClientIndex ci) = liftM (f . client') (clients `readElem` ci)
   145 
   146 
   146 room'sM :: MRoomsAndClients r c -> (r -> a) -> RoomIndex -> IO a
   147 room'sM :: MRoomsAndClients r c -> (r -> a) -> RoomIndex -> IO a
   147 room'sM (MRoomsAndClients (rooms, _)) f (RoomIndex ri) = liftM (f . room') (rooms `readElem` ri)
   148 room'sM (MRoomsAndClients (rooms, _)) f (RoomIndex ri) = liftM (f . room') (rooms `readElem` ri)
   148 
   149 
       
   150 allClientsM :: MRoomsAndClients r c -> IO [ClientIndex]
       
   151 allClientsM (MRoomsAndClients (_, clients)) = liftM (map ClientIndex) $ indicesM clients
       
   152 
   149 clientsM :: MRoomsAndClients r c -> IO [c]
   153 clientsM :: MRoomsAndClients r c -> IO [c]
   150 clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (\ci -> liftM client' $ readElem clients ci)
   154 clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (\ci -> liftM client' $ readElem clients ci)
   151 
   155 
   152 roomClientsM :: MRoomsAndClients r c -> RoomIndex -> IO [c]
   156 roomClientsM :: MRoomsAndClients r c -> RoomIndex -> IO [c]
   153 roomClientsM (MRoomsAndClients (rooms, clients)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri) >>= mapM (\(ClientIndex ci) -> liftM client' $ readElem clients ci)
   157 roomClientsM (MRoomsAndClients (rooms, clients)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri) >>= mapM (\(ClientIndex ci) -> liftM client' $ readElem clients ci)