gameServer/RoomsAndClients.hs
author nemo
Thu, 08 Dec 2011 23:30:03 -0500
changeset 6521 16d9ac07f504
parent 4932 f11d80bac7ed
child 6805 097289be7200
permissions -rw-r--r--
missing nil
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4905
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
     1
module RoomsAndClients(
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
     2
    RoomIndex(),
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
     3
    ClientIndex(),
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
     4
    MRoomsAndClients(),
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
     5
    IRoomsAndClients(),
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
     6
    newRoomsAndClients,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
     7
    addRoom,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
     8
    addClient,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
     9
    removeRoom,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    10
    removeClient,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    11
    modifyRoom,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    12
    modifyClient,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    13
    lobbyId,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    14
    moveClientToLobby,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    15
    moveClientToRoom,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    16
    clientRoomM,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    17
    clientExists,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    18
    client,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    19
    room,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    20
    client'sM,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    21
    room'sM,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    22
    allClientsM,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    23
    clientsM,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    24
    roomClientsM,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    25
    roomClientsIndicesM,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    26
    withRoomsAndClients,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    27
    allRooms,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    28
    allClients,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    29
    clientRoom,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    30
    showRooms,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    31
    roomClients
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    32
    ) where
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    33
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    34
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    35
import Store
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    36
import Control.Monad
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    37
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    38
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    39
data Room r = Room {
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    40
    roomClients' :: [ClientIndex],
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    41
    room' :: r
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    42
    }
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    43
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    44
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    45
data Client c = Client {
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    46
    clientRoom' :: RoomIndex,
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    47
    client' :: c
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    48
    }
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    49
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    50
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    51
newtype RoomIndex = RoomIndex ElemIndex
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    52
    deriving (Eq)
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    53
newtype ClientIndex = ClientIndex ElemIndex
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    54
    deriving (Eq, Show, Read, Ord)
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    55
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    56
instance Show RoomIndex where
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    57
    show (RoomIndex i) = 'r' : show i
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    58
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    59
unRoomIndex :: RoomIndex -> ElemIndex
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    60
unRoomIndex (RoomIndex r) = r
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    61
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    62
unClientIndex :: ClientIndex -> ElemIndex
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    63
unClientIndex (ClientIndex c) = c
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    64
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    65
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    66
newtype MRoomsAndClients r c = MRoomsAndClients (MStore (Room r), MStore (Client c))
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    67
newtype IRoomsAndClients r c = IRoomsAndClients (IStore (Room r), IStore (Client c))
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    68
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    69
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    70
lobbyId :: RoomIndex
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    71
lobbyId = RoomIndex firstIndex
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    72
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    73
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    74
newRoomsAndClients :: r -> IO (MRoomsAndClients r c)
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    75
newRoomsAndClients r = do
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    76
    rooms <- newStore
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    77
    clients <- newStore
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    78
    let rnc = MRoomsAndClients (rooms, clients)
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    79
    ri <- addRoom rnc r
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    80
    when (ri /= lobbyId) $ error "Empty struct inserts not at firstIndex index"
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    81
    return rnc
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    82
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    83
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    84
roomAddClient :: ClientIndex -> Room r -> Room r
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
    85
roomAddClient cl rm = let cls = cl : roomClients' rm; nr = rm{roomClients' = cls} in cls `seq` nr
4905
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    86
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    87
roomRemoveClient :: ClientIndex -> Room r -> Room r
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
    88
roomRemoveClient cl rm = let cls = filter (/= cl) $ roomClients' rm; nr = rm{roomClients' = cls} in cls `seq` nr
4905
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    89
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    90
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    91
addRoom :: MRoomsAndClients r c -> r -> IO RoomIndex
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
    92
addRoom (MRoomsAndClients (rooms, _)) rm = do
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
    93
    i <- addElem rooms (Room  [] rm)
4905
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    94
    return $ RoomIndex i
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    95
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    96
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
    97
addClient :: MRoomsAndClients r c -> c -> IO ClientIndex
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
    98
addClient (MRoomsAndClients (rooms, clients)) cl = do
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
    99
    i <- addElem clients (Client lobbyId cl)
4905
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   100
    modifyElem rooms (roomAddClient (ClientIndex i)) (unRoomIndex lobbyId)
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   101
    return $ ClientIndex i
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   102
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   103
removeRoom :: MRoomsAndClients r c -> RoomIndex -> IO ()
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
   104
removeRoom rnc@(MRoomsAndClients (rooms, _)) rm@(RoomIndex ri)
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
   105
    | rm == lobbyId = error "Cannot delete lobby"
4905
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   106
    | otherwise = do
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   107
        clIds <- liftM roomClients' $ readElem rooms ri
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   108
        forM_ clIds (moveClientToLobby rnc)
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   109
        removeElem rooms ri
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   110
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   111
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   112
removeClient :: MRoomsAndClients r c -> ClientIndex -> IO ()
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   113
removeClient (MRoomsAndClients (rooms, clients)) cl@(ClientIndex ci) = do
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   114
    RoomIndex ri <- liftM clientRoom' $ readElem clients ci
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   115
    modifyElem rooms (roomRemoveClient cl) ri
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   116
    removeElem clients ci
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   117
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   118
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   119
modifyRoom :: MRoomsAndClients r c -> (r -> r) -> RoomIndex -> IO ()
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   120
modifyRoom (MRoomsAndClients (rooms, _)) f (RoomIndex ri) = modifyElem rooms (\r -> r{room' = f $ room' r}) ri
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   121
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   122
modifyClient :: MRoomsAndClients r c -> (c -> c) -> ClientIndex -> IO ()
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   123
modifyClient (MRoomsAndClients (_, clients)) f (ClientIndex ci) = modifyElem clients (\c -> c{client' = f $ client' c}) ci
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   124
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   125
moveClientInRooms :: MRoomsAndClients r c -> RoomIndex -> RoomIndex -> ClientIndex -> IO ()
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   126
moveClientInRooms (MRoomsAndClients (rooms, clients)) (RoomIndex riFrom) rt@(RoomIndex riTo) cl@(ClientIndex ci) = do
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   127
    modifyElem rooms (roomRemoveClient cl) riFrom
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   128
    modifyElem rooms (roomAddClient cl) riTo
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   129
    modifyElem clients (\c -> c{clientRoom' = rt}) ci
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   130
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   131
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   132
moveClientToLobby :: MRoomsAndClients r c -> ClientIndex -> IO ()
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   133
moveClientToLobby rnc ci = do
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
   134
    rm <- clientRoomM rnc ci
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
   135
    moveClientInRooms rnc rm lobbyId ci
4905
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   136
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   137
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   138
moveClientToRoom :: MRoomsAndClients r c -> RoomIndex -> ClientIndex -> IO ()
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
   139
moveClientToRoom rnc = moveClientInRooms rnc lobbyId
4905
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   140
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   141
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   142
clientExists :: MRoomsAndClients r c -> ClientIndex -> IO Bool
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   143
clientExists (MRoomsAndClients (_, clients)) (ClientIndex ci) = elemExists clients ci
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   144
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   145
clientRoomM :: MRoomsAndClients r c -> ClientIndex -> IO RoomIndex
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   146
clientRoomM (MRoomsAndClients (_, clients)) (ClientIndex ci) = liftM clientRoom' (clients `readElem` ci)
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   147
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   148
client'sM :: MRoomsAndClients r c -> (c -> a) -> ClientIndex -> IO a
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   149
client'sM (MRoomsAndClients (_, clients)) f (ClientIndex ci) = liftM (f . client') (clients `readElem` ci)
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   150
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   151
room'sM :: MRoomsAndClients r c -> (r -> a) -> RoomIndex -> IO a
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   152
room'sM (MRoomsAndClients (rooms, _)) f (RoomIndex ri) = liftM (f . room') (rooms `readElem` ri)
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   153
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   154
allClientsM :: MRoomsAndClients r c -> IO [ClientIndex]
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   155
allClientsM (MRoomsAndClients (_, clients)) = liftM (map ClientIndex) $ indicesM clients
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   156
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   157
clientsM :: MRoomsAndClients r c -> IO [c]
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
   158
clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (liftM client' . readElem clients)
4905
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   159
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   160
roomClientsIndicesM :: MRoomsAndClients r c -> RoomIndex -> IO [ClientIndex]
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
   161
roomClientsIndicesM (MRoomsAndClients (rooms, _)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri)
4905
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   162
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   163
roomClientsM :: MRoomsAndClients r c -> RoomIndex -> IO [c]
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   164
roomClientsM (MRoomsAndClients (rooms, clients)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri) >>= mapM (\(ClientIndex ci) -> liftM client' $ readElem clients ci)
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   165
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   166
withRoomsAndClients :: MRoomsAndClients r c -> (IRoomsAndClients r c -> a) -> IO a
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   167
withRoomsAndClients (MRoomsAndClients (rooms, clients)) f =
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   168
    withIStore2 rooms clients (\r c -> f $ IRoomsAndClients (r, c))
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   169
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   170
----------------------------------------
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   171
----------- IRoomsAndClients -----------
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   172
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   173
showRooms :: (Show r, Show c) => IRoomsAndClients r c -> String
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   174
showRooms rnc@(IRoomsAndClients (rooms, clients)) = concatMap showRoom (allRooms rnc)
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   175
    where
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
   176
    showRoom r = unlines $ (show r ++ ": " ++ (show . room' $ rooms ! unRoomIndex r)) : map showClient (roomClients' $ rooms ! unRoomIndex r)
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
   177
    showClient c = "    " ++ show c ++ ": " ++ (show . client' $ clients ! unClientIndex c)
4905
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   178
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   179
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   180
allRooms :: IRoomsAndClients r c -> [RoomIndex]
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   181
allRooms (IRoomsAndClients (rooms, _)) = map RoomIndex $ indices rooms
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   182
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   183
allClients :: IRoomsAndClients r c -> [ClientIndex]
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   184
allClients (IRoomsAndClients (_, clients)) = map ClientIndex $ indices clients
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   185
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   186
clientRoom :: IRoomsAndClients r c -> ClientIndex -> RoomIndex
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   187
clientRoom (IRoomsAndClients (_, clients)) (ClientIndex ci) = clientRoom' (clients ! ci)
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   188
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   189
client :: IRoomsAndClients r c -> ClientIndex -> c
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   190
client (IRoomsAndClients (_, clients)) (ClientIndex ci) = client' (clients ! ci)
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   191
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   192
room :: IRoomsAndClients r c -> RoomIndex -> r
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   193
room (IRoomsAndClients (rooms, _)) (RoomIndex ri) = room' (rooms ! ri)
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   194
7842d085acf4 Fix merge :D
unc0rr
parents:
diff changeset
   195
roomClients :: IRoomsAndClients r c -> RoomIndex -> [ClientIndex]
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4905
diff changeset
   196
roomClients (IRoomsAndClients (rooms, _)) (RoomIndex ri) = roomClients' (rooms ! ri)