56 readyPlayers :: Int, |
57 readyPlayers :: Int, |
57 isRestrictedJoins :: Bool, |
58 isRestrictedJoins :: Bool, |
58 isRestrictedTeams :: Bool, |
59 isRestrictedTeams :: Bool, |
59 params :: Map.Map String [String] |
60 params :: Map.Map String [String] |
60 } |
61 } |
61 createRoom = (RoomInfo "" "" 0 [] "+rnd+" False 1 0 False False Map.empty) |
62 createRoom = ( |
|
63 RoomInfo |
|
64 "" |
|
65 "" |
|
66 0 |
|
67 [] |
|
68 "+rnd+" |
|
69 False |
|
70 1 |
|
71 0 |
|
72 False |
|
73 False |
|
74 Map.empty |
|
75 ) |
62 |
76 |
63 data ServerInfo = |
77 data ServerInfo = |
64 ServerInfo |
78 ServerInfo |
65 { |
79 { |
66 message :: String |
80 isDedicated :: Bool, |
|
81 serverMessage :: String, |
|
82 listenPort :: PortNumber |
67 } |
83 } |
|
84 newServerInfo = ( |
|
85 ServerInfo |
|
86 True |
|
87 "<h2><p align=center><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p></h2>" |
|
88 46631 |
|
89 ) |
68 |
90 |
69 type ClientsTransform = [ClientInfo] -> [ClientInfo] |
91 type ClientsTransform = [ClientInfo] -> [ClientInfo] |
70 type RoomsTransform = [RoomInfo] -> [RoomInfo] |
92 type RoomsTransform = [RoomInfo] -> [RoomInfo] |
71 type HandlesSelector = ClientInfo -> [ClientInfo] -> [RoomInfo] -> [Handle] |
93 type HandlesSelector = ClientInfo -> [ClientInfo] -> [RoomInfo] -> [Handle] |
72 type Answer = (HandlesSelector, [String]) |
94 type Answer = ServerInfo -> (HandlesSelector, [String]) |
73 type CmdHandler = ClientInfo -> [ClientInfo] -> [RoomInfo] -> [String] -> (ClientsTransform, RoomsTransform, [Answer]) |
95 type CmdHandler = ClientInfo -> [ClientInfo] -> [RoomInfo] -> [String] -> (ClientsTransform, RoomsTransform, [Answer]) |
74 |
96 |
75 |
97 |
76 roomByName :: String -> [RoomInfo] -> RoomInfo |
98 roomByName :: String -> [RoomInfo] -> RoomInfo |
77 roomByName roomName rooms = fromJust $ find (\room -> roomName == name room) rooms |
99 roomByName roomName rooms = fromJust $ find (\room -> roomName == name room) rooms |