gameServer/Actions.hs
changeset 1811 1b9e33623b7e
parent 1804 4e78ad846fb6
child 1813 cfe1481e0247
--- a/gameServer/Actions.hs	Thu Feb 19 14:52:32 2009 +0000
+++ b/gameServer/Actions.hs	Fri Feb 20 11:58:58 2009 +0000
@@ -18,6 +18,7 @@
 	| RoomAddThisClient Int -- roomID
 	| RoomRemoveThisClient
 	| RemoveRoom
+	| UnreadyRoomClients
 	| ProtocolError String
 	| Warning String
 	| ByeClient String
@@ -179,18 +180,32 @@
 
 
 processAction (clID, serverInfo, clients, rooms) (RemoveRoom) = do
-	processAction (clID, serverInfo, clients, rooms) $ AnswerLobby ["ROOM", "DEL", name clRoom]
-	processAction (clID, serverInfo, clients, rooms) $ AnswerOthersInRoom ["ROOMABANDONED", name clRoom]
+	processAction (clID, serverInfo, clients, rooms) $ AnswerLobby ["ROOM", "DEL", name room]
+	processAction (clID, serverInfo, clients, rooms) $ AnswerOthersInRoom ["ROOMABANDONED", name room]
 	return (clID,
 		serverInfo,
 		Data.IntMap.map (\cl -> if roomID cl == rID then cl{roomID = 0, isMaster = False} else cl) clients,
-		delete rID $ adjust (\r -> r{playersIDs = IntSet.union (playersIDs clRoom) (playersIDs r)}) 0 rooms
+		delete rID $ adjust (\r -> r{playersIDs = IntSet.union (playersIDs room) (playersIDs r)}) 0 rooms
 		)
 	where
-		clRoom = rooms ! rID
+		room = rooms ! rID
 		rID = roomID client
 		client = clients ! clID
 
+processAction (clID, serverInfo, clients, rooms) (UnreadyRoomClients) = do
+	processAction (clID, serverInfo, clients, rooms) $ AnswerThisRoom ("NOT_READY" : roomPlayers)
+	return (clID,
+		serverInfo,
+		Data.IntMap.map (\cl -> if roomID cl == rID then cl{isReady = False} else cl) clients,
+		rooms)
+	where
+		room = rooms ! rID
+		rID = roomID client
+		client = clients ! clID
+		roomPlayers = Prelude.map (nick . (clients !)) roomPlayersIDs
+		roomPlayersIDs = IntSet.elems $ playersIDs room
+
+
 processAction (clID, serverInfo, clients, rooms) (Dump) = do
 	writeChan (sendChan $ clients ! clID) ["DUMP", show serverInfo, showTree clients, showTree rooms]
 	return (clID, serverInfo, clients, rooms)