equal
deleted
inserted
replaced
32 name room, |
32 name room, |
33 (show $ playersIn room) ++ "(" ++ (show $ length $ teams room) ++ ")", |
33 (show $ playersIn room) ++ "(" ++ (show $ length $ teams room) ++ ")", |
34 show $ gameinprogress room |
34 show $ gameinprogress room |
35 ] |
35 ] |
36 |
36 |
|
37 |
37 handleCmd_lobby clID clients _ ["CHAT", msg] = |
38 handleCmd_lobby clID clients _ ["CHAT", msg] = |
38 [AnswerOthersInRoom ["CHAT", clientNick, msg]] |
39 [AnswerOthersInRoom ["CHAT", clientNick, msg]] |
39 where |
40 where |
40 clientNick = nick $ clients IntMap.! clID |
41 clientNick = nick $ clients IntMap.! clID |
|
42 |
41 |
43 |
42 handleCmd_lobby clID clients rooms ["CREATE", newRoom, roomPassword] = |
44 handleCmd_lobby clID clients rooms ["CREATE", newRoom, roomPassword] = |
43 if haveSameRoom then |
45 if haveSameRoom then |
44 [Warning "Room exists"] |
46 [Warning "Room exists"] |
45 else |
47 else |
49 ] |
51 ] |
50 where |
52 where |
51 clientNick = nick $ clients IntMap.! clID |
53 clientNick = nick $ clients IntMap.! clID |
52 haveSameRoom = isJust $ find (\room -> newRoom == name room) $ IntMap.elems rooms |
54 haveSameRoom = isJust $ find (\room -> newRoom == name room) $ IntMap.elems rooms |
53 |
55 |
|
56 |
54 handleCmd_lobby clID clients rooms ["CREATE", newRoom] = |
57 handleCmd_lobby clID clients rooms ["CREATE", newRoom] = |
55 handleCmd_lobby clID clients rooms ["CREATE", newRoom, ""] |
58 handleCmd_lobby clID clients rooms ["CREATE", newRoom, ""] |
|
59 |
56 |
60 |
57 handleCmd_lobby clID clients rooms ["JOIN", roomName, roomPassword] = |
61 handleCmd_lobby clID clients rooms ["JOIN", roomName, roomPassword] = |
58 if noSuchRoom then |
62 if noSuchRoom then |
59 [Warning "No such room"] |
63 [Warning "No such room"] |
60 else if isRestrictedJoins jRoom then |
64 else if isRestrictedJoins jRoom then |
98 answerAllTeams (teamsAtStart jRoom) |
102 answerAllTeams (teamsAtStart jRoom) |
99 else |
103 else |
100 answerAllTeams (teams jRoom) |
104 answerAllTeams (teams jRoom) |
101 |
105 |
102 |
106 |
103 handleCmd_lobby client clients rooms ["JOIN", roomName] = |
107 handleCmd_lobby clID clients rooms ["JOIN", roomName] = |
104 handleCmd_lobby client clients rooms ["JOIN", roomName, ""] |
108 handleCmd_lobby clID clients rooms ["JOIN", roomName, ""] |
|
109 |
|
110 |
|
111 handleCmd_lobby clID clients rooms ["KICK", kickNick] = |
|
112 if not $ isAdministrator client then |
|
113 [] |
|
114 else |
|
115 if noSuchClient then |
|
116 [] |
|
117 else |
|
118 if kickID == clID then |
|
119 [] |
|
120 else |
|
121 [KickClient kickID] |
|
122 where |
|
123 client = clients IntMap.! clID |
|
124 maybeClient = Foldable.find (\cl -> kickNick == nick cl) clients |
|
125 noSuchClient = isNothing maybeClient |
|
126 kickID = clientUID $ fromJust maybeClient |
|
127 -- room = rooms IntMap.! roomID client |
|
128 -- roomInfo = if roomID client /= 0 then "room " ++ (name room) else "lobby" |
|
129 |
105 |
130 |
106 handleCmd_lobby clID _ _ _ = [ProtocolError "Incorrect command (state: in lobby)"] |
131 handleCmd_lobby clID _ _ _ = [ProtocolError "Incorrect command (state: in lobby)"] |