netserver/Miscutils.hs
changeset 1317 13cf8c5a7428
parent 1304 05cebf68ebd8
child 1321 d7dc4e86201e
--- a/netserver/Miscutils.hs	Wed Oct 08 13:58:27 2008 +0000
+++ b/netserver/Miscutils.hs	Wed Oct 08 15:42:09 2008 +0000
@@ -6,7 +6,7 @@
 import Data.Char
 import Data.List
 import Maybe (fromJust)
-
+import qualified Data.Map as Map
 
 data ClientInfo =
  ClientInfo
@@ -22,10 +22,14 @@
 instance Eq ClientInfo where
 	a1 == a2 = handle a1 == handle a2
 
+data HedgehogInfo =
+	HedgehogInfo String String
+
 data TeamInfo =
 	TeamInfo
 	{
-		teamname :: String
+		teamname :: String,
+		hedgehogs :: [HedgehogInfo]
 	}
 
 data RoomInfo =
@@ -33,7 +37,9 @@
 	{
 		name :: String,
 		password :: String,
-		teams :: [TeamInfo]
+		roomProto :: Word16,
+		teams :: [TeamInfo],
+		params :: Map.Map String [String]
 	}
 
 type ClientsTransform = [ClientInfo] -> [ClientInfo]
@@ -90,3 +96,11 @@
 
 removeRoom :: String -> RoomsTransform
 removeRoom roomname rooms = filter (\rm -> roomname /= name rm) rooms
+
+changeRoomConfig :: String -> String -> [String] -> RoomsTransform
+changeRoomConfig _ _ _ [] = error "changeRoomConfig: no such room"
+changeRoomConfig roomName paramName paramStrs (room:rooms) =
+	if roomName == name room then
+		room{params = Map.insert paramName paramStrs (params room)} : rooms
+	else
+		room : changeRoomConfig roomName paramName paramStrs rooms