gameServer/HWProtoLobbyState.hs
changeset 3435 4e4f88a7bdf2
parent 3425 ead2ed20dfd4
child 3500 af8390d807d6
equal deleted inserted replaced
3434:6af73e7f2438 3435:4e4f88a7bdf2
     9 import Data.Word
     9 import Data.Word
    10 --------------------------------------
    10 --------------------------------------
    11 import CoreTypes
    11 import CoreTypes
    12 import Actions
    12 import Actions
    13 import Utils
    13 import Utils
       
    14 import HandlerUtils
    14 
    15 
    15 answerAllTeams protocol teams = concatMap toAnswer teams
    16 {-answerAllTeams protocol teams = concatMap toAnswer teams
    16     where
    17     where
    17         toAnswer team =
    18         toAnswer team =
    18             [AnswerThisClient $ teamToNet protocol team,
    19             [AnswerThisClient $ teamToNet protocol team,
    19             AnswerThisClient ["TEAM_COLOR", teamname team, teamcolor team],
    20             AnswerThisClient ["TEAM_COLOR", teamname team, teamcolor team],
    20             AnswerThisClient ["HH_NUM", teamname team, show $ hhnum team]]
    21             AnswerThisClient ["HH_NUM", teamname team, show $ hhnum team]]
    21 
    22 -}
    22 handleCmd_lobby :: CmdHandler
    23 handleCmd_lobby :: CmdHandler
    23 
    24 
       
    25 {-
    24 handleCmd_lobby clID clients rooms ["LIST"] =
    26 handleCmd_lobby clID clients rooms ["LIST"] =
    25     [AnswerThisClient ("ROOMS" : roomsInfoList)]
    27     [AnswerThisClient ("ROOMS" : roomsInfoList)]
    26     where
    28     where
    27         roomsInfoList = concatMap roomInfo sameProtoRooms
    29         roomsInfoList = concatMap roomInfo sameProtoRooms
    28         sameProtoRooms = filter (\r -> (roomProto r == protocol) && not (isRestrictedJoins r)) roomsList
    30         sameProtoRooms = filter (\r -> (roomProto r == protocol) && not (isRestrictedJoins r)) roomsList
    43                 nick $ clients IntMap.! (masterID room),
    45                 nick $ clients IntMap.! (masterID room),
    44                 head (Map.findWithDefault ["+gen+"] "MAP" (params room)),
    46                 head (Map.findWithDefault ["+gen+"] "MAP" (params room)),
    45                 head (Map.findWithDefault ["Default"] "SCHEME" (params room)),
    47                 head (Map.findWithDefault ["Default"] "SCHEME" (params room)),
    46                 head (Map.findWithDefault ["Default"] "AMMO" (params room))
    48                 head (Map.findWithDefault ["Default"] "AMMO" (params room))
    47                 ]
    49                 ]
       
    50 -}
    48 
    51 
    49 handleCmd_lobby clID clients _ ["CHAT", msg] =
    52 handleCmd_lobby ["CHAT", msg] = do
    50     [AnswerOthersInRoom ["CHAT", clientNick, msg]]
    53     n <- clientNick
    51     where
    54     s <- roomOthersChans
    52         clientNick = nick $ clients IntMap.! clID
    55     return [AnswerClients s ["CHAT", n, msg]]
    53 
    56 
    54 
    57 {-
    55 handleCmd_lobby clID clients rooms ["CREATE_ROOM", newRoom, roomPassword]
    58 handleCmd_lobby clID clients rooms ["CREATE_ROOM", newRoom, roomPassword]
    56     | haveSameRoom = [Warning "Room exists"]
    59     | haveSameRoom = [Warning "Room exists"]
    57     | illegalName newRoom = [Warning "Illegal room name"]
    60     | illegalName newRoom = [Warning "Illegal room name"]
    58     | otherwise =
    61     | otherwise =
    59         [RoomRemoveThisClient "", -- leave lobby
    62         [RoomRemoveThisClient "", -- leave lobby
   181     where
   184     where
   182         client = clients IntMap.! clID
   185         client = clients IntMap.! clID
   183 
   186 
   184 
   187 
   185 handleCmd_lobby clID _ _ _ = [ProtocolError "Incorrect command (state: in lobby)"]
   188 handleCmd_lobby clID _ _ _ = [ProtocolError "Incorrect command (state: in lobby)"]
       
   189 -}