author | unc0rr |
Thu, 26 Feb 2009 06:39:20 +0000 | |
changeset 1844 | 81abed9d4c11 |
parent 1841 | fba7210b438b |
child 1862 | 7f303aa066da |
permissions | -rw-r--r-- |
1804 | 1 |
module HWProtoCore where |
2 |
||
3 |
import qualified Data.IntMap as IntMap |
|
4 |
-------------------------------------- |
|
5 |
import CoreTypes |
|
6 |
import Actions |
|
7 |
import Utils |
|
8 |
import HWProtoNEState |
|
9 |
import HWProtoLobbyState |
|
10 |
import HWProtoInRoomState |
|
11 |
||
12 |
handleCmd:: CmdHandler |
|
13 |
||
14 |
handleCmd clID _ _ ["PING"] = [AnswerThisClient ["PONG"]] |
|
15 |
||
1814 | 16 |
handleCmd clID clients rooms ("QUIT" : xs) = |
17 |
(if isMaster client then [RemoveRoom] else removeClientTeams) |
|
1804 | 18 |
++ [ByeClient msg] |
19 |
where |
|
20 |
client = clients IntMap.! clID |
|
21 |
clientNick = nick client |
|
22 |
msg = if not $ null xs then head xs else "" |
|
1814 | 23 |
room = rooms IntMap.! (roomID client) |
24 |
clientTeams = filter (\t -> teamowner t == nick client) $ teams room |
|
25 |
removeClientTeams = map (RemoveTeam . teamname) clientTeams |
|
1804 | 26 |
|
27 |
handleCmd clID clients rooms cmd = |
|
1841
fba7210b438b
Retrieve client password from web database and ask for it
unc0rr
parents:
1814
diff
changeset
|
28 |
if not $ logonPassed client then |
1804 | 29 |
handleCmd_NotEntered clID clients rooms cmd |
30 |
else if roomID client == 0 then |
|
31 |
handleCmd_lobby clID clients rooms cmd |
|
32 |
else |
|
33 |
handleCmd_inRoom clID clients rooms cmd |
|
34 |
where |
|
35 |
client = clients IntMap.! clID |
|
36 |