gameServer/Actions.hs
changeset 1841 fba7210b438b
parent 1839 5dd4cb7fd7e5
child 1846 24d0074d4eed
equal deleted inserted replaced
1840:4747f0232b88 1841:fba7210b438b
    21 	| RoomAddThisClient Int -- roomID
    21 	| RoomAddThisClient Int -- roomID
    22 	| RoomRemoveThisClient
    22 	| RoomRemoveThisClient
    23 	| RemoveTeam String
    23 	| RemoveTeam String
    24 	| RemoveRoom
    24 	| RemoveRoom
    25 	| UnreadyRoomClients
    25 	| UnreadyRoomClients
       
    26 	| MoveToLobby
    26 	| ProtocolError String
    27 	| ProtocolError String
    27 	| Warning String
    28 	| Warning String
    28 	| ByeClient String
    29 	| ByeClient String
    29 	| ModifyClient (ClientInfo -> ClientInfo)
    30 	| ModifyClient (ClientInfo -> ClientInfo)
    30 	| ModifyRoom (RoomInfo -> RoomInfo)
    31 	| ModifyRoom (RoomInfo -> RoomInfo)
   248 	writeChan (dbQueries serverInfo) $ CheckAccount clID (nick client)
   249 	writeChan (dbQueries serverInfo) $ CheckAccount clID (nick client)
   249 	return (clID, serverInfo, clients, rooms)
   250 	return (clID, serverInfo, clients, rooms)
   250 	where
   251 	where
   251 		client = clients ! clID
   252 		client = clients ! clID
   252 
   253 
       
   254 
   253 processAction (clID, serverInfo, clients, rooms) (Dump) = do
   255 processAction (clID, serverInfo, clients, rooms) (Dump) = do
   254 	writeChan (sendChan $ clients ! clID) ["DUMP", show serverInfo, showTree clients, showTree rooms]
   256 	writeChan (sendChan $ clients ! clID) ["DUMP", show serverInfo, showTree clients, showTree rooms]
   255 	return (clID, serverInfo, clients, rooms)
   257 	return (clID, serverInfo, clients, rooms)
   256 
   258 
       
   259 
   257 processAction (clID, serverInfo, clients, rooms) (ProcessAccountInfo info) = do
   260 processAction (clID, serverInfo, clients, rooms) (ProcessAccountInfo info) = do
   258 	case info of
   261 	case info of
   259 		HasAccount -> do
   262 		HasAccount passwd -> do
   260 			infoM "Clients" $ show clID ++ " has account"
   263 			infoM "Clients" $ show clID ++ " has account"
   261 			writeChan (sendChan $ clients ! clID) ["ASKPASSWORD"]
   264 			writeChan (sendChan $ clients ! clID) ["ASKPASSWORD"]
   262 		LogonPassed -> do
   265 			return (clID, serverInfo, adjust (\cl -> cl{webPassword = passwd}) clID clients, rooms)
   263 			infoM "Clients" $ show clID ++ " authenticated"
       
   264 		Guest -> do
   266 		Guest -> do
   265 			infoM "Clients" $ show clID ++ " is guest"
   267 			infoM "Clients" $ show clID ++ " is guest"
   266 	return (clID, serverInfo, clients, rooms)
   268 			processAction (clID, serverInfo, adjust (\cl -> cl{logonPassed = True}) clID clients, rooms) MoveToLobby
       
   269 
       
   270 
       
   271 processAction (clID, serverInfo, clients, rooms) (MoveToLobby) = do
       
   272 	foldM processAction (clID, serverInfo, clients, rooms) $
       
   273 		(RoomAddThisClient 0)
       
   274 		: answerLobbyNicks
       
   275 		-- ++ (answerServerMessage client clients)
       
   276 	where
       
   277 		lobbyNicks = Prelude.filter (\n -> (not (Prelude.null n))) $ Prelude.map nick $ elems clients
       
   278 		answerLobbyNicks = if not $ Prelude.null lobbyNicks then
       
   279 					[AnswerThisClient (["LOBBY:JOINED"] ++ lobbyNicks)]
       
   280 				else
       
   281 					[]
       
   282 
       
   283