gameServer/RoomsAndClients.hs
changeset 3436 288fcbdb77b6
parent 3435 4e4f88a7bdf2
child 3458 11cd56019f00
equal deleted inserted replaced
3435:4e4f88a7bdf2 3436:288fcbdb77b6
     6     newRoomsAndClients,
     6     newRoomsAndClients,
     7     addRoom,
     7     addRoom,
     8     addClient,
     8     addClient,
     9     removeRoom,
     9     removeRoom,
    10     removeClient,
    10     removeClient,
       
    11     modifyRoom,
       
    12     modifyClient,
    11     lobbyId,
    13     lobbyId,
    12     moveClientToLobby,
    14     moveClientToLobby,
    13     moveClientToRoom,
    15     moveClientToRoom,
    14     clientRoom,
    16     clientRoom,
       
    17     clientRoomM,
    15     client,
    18     client,
    16     allClients,
    19     allClients,
    17     withRoomsAndClients,
    20     withRoomsAndClients,
    18     showRooms,
    21     showRooms,
    19     roomClients
    22     roomClients
   104     RoomIndex ri <- liftM clientRoom' $ readElem clients ci
   107     RoomIndex ri <- liftM clientRoom' $ readElem clients ci
   105     modifyElem rooms (roomRemoveClient cl) ri
   108     modifyElem rooms (roomRemoveClient cl) ri
   106     removeElem clients ci
   109     removeElem clients ci
   107 
   110 
   108 
   111 
       
   112 modifyRoom :: MRoomsAndClients r c -> (r -> r) -> RoomIndex -> IO ()
       
   113 modifyRoom (MRoomsAndClients (rooms, _)) f (RoomIndex ri) = modifyElem rooms (\r -> r{room' = f $ room' r}) ri
       
   114 
       
   115 modifyClient :: MRoomsAndClients r c -> (c -> c) -> ClientIndex -> IO ()
       
   116 modifyClient (MRoomsAndClients (_, clients)) f (ClientIndex ci) = modifyElem clients (\c -> c{client' = f $ client' c}) ci
       
   117 
   109 moveClientInRooms :: MRoomsAndClients r c -> RoomIndex -> RoomIndex -> ClientIndex -> IO ()
   118 moveClientInRooms :: MRoomsAndClients r c -> RoomIndex -> RoomIndex -> ClientIndex -> IO ()
   110 moveClientInRooms (MRoomsAndClients (rooms, clients)) (RoomIndex riFrom) rt@(RoomIndex riTo) cl@(ClientIndex ci) = do
   119 moveClientInRooms (MRoomsAndClients (rooms, clients)) (RoomIndex riFrom) rt@(RoomIndex riTo) cl@(ClientIndex ci) = do
   111     modifyElem rooms (roomRemoveClient cl) riFrom
   120     modifyElem rooms (roomRemoveClient cl) riFrom
   112     modifyElem rooms (roomAddClient cl) riTo
   121     modifyElem rooms (roomAddClient cl) riTo
   113     modifyElem clients (\c -> c{clientRoom' = rt}) ci
   122     modifyElem clients (\c -> c{clientRoom' = rt}) ci