gameServer/HWProtoLobbyState.hs
branchserver_refactor
changeset 4591 c91364bf6a69
parent 4587 adf64662b6a8
child 4595 cd4433b44920
equal deleted inserted replaced
4587:adf64662b6a8 4591:c91364bf6a69
    14 import Actions
    14 import Actions
    15 import Utils
    15 import Utils
    16 import HandlerUtils
    16 import HandlerUtils
    17 import RoomsAndClients
    17 import RoomsAndClients
    18 
    18 
    19 {-answerAllTeams protocol teams = concatMap toAnswer teams
    19 answerAllTeams cl = concatMap toAnswer
    20     where
    20     where
       
    21         clChan = sendChan cl
    21         toAnswer team =
    22         toAnswer team =
    22             [AnswerThisClient $ teamToNet protocol team,
    23             [AnswerClients [clChan] $ teamToNet team,
    23             AnswerThisClient ["TEAM_COLOR", teamname team, teamcolor team],
    24             AnswerClients [clChan] ["TEAM_COLOR", teamname team, teamcolor team],
    24             AnswerThisClient ["HH_NUM", teamname team, show $ hhnum team]]
    25             AnswerClients [clChan] ["HH_NUM", teamname team, B.pack . show $ hhnum team]]
    25 -}
    26 
    26 handleCmd_lobby :: CmdHandler
    27 handleCmd_lobby :: CmdHandler
    27 
    28 
    28 
    29 
    29 handleCmd_lobby ["LIST"] = do
    30 handleCmd_lobby ["LIST"] = do
    30     (ci, irnc) <- ask
    31     (ci, irnc) <- ask
    89                 AnswerClients (map sendChan $ cl : jRoomClients) ["NOT_READY", nick cl],
    90                 AnswerClients (map sendChan $ cl : jRoomClients) ["NOT_READY", nick cl],
    90                 AnswerClients [sendChan cl] $ "JOINED" : map nick jRoomClients
    91                 AnswerClients [sendChan cl] $ "JOINED" : map nick jRoomClients
    91             ]
    92             ]
    92             ++ (map (readynessMessage cl) jRoomClients)
    93             ++ (map (readynessMessage cl) jRoomClients)
    93             ++ (answerFullConfig cl $ params jRoom)
    94             ++ (answerFullConfig cl $ params jRoom)
       
    95             ++ (answerTeams cl jRoom)
    94 
    96 
    95         where
    97         where
    96         readynessMessage cl c = AnswerClients [sendChan cl] [if isReady c then "READY" else "NOT_READY", nick c]
    98         readynessMessage cl c = AnswerClients [sendChan cl] [if isReady c then "READY" else "NOT_READY", nick c]
    97 
    99 
    98         toAnswer cl (paramName, paramStrs) = AnswerClients [sendChan cl] $ "CFG" : paramName : paramStrs
   100         toAnswer cl (paramName, paramStrs) = AnswerClients [sendChan cl] $ "CFG" : paramName : paramStrs
    99 
   101 
   100         answerFullConfig cl params = map (toAnswer cl) (leftConfigPart ++ rightConfigPart)
   102         answerFullConfig cl params = map (toAnswer cl) (leftConfigPart ++ rightConfigPart)
   101             where
   103             where
   102             (leftConfigPart, rightConfigPart) = partition (\(p, _) -> p /= "MAP") $ Map.toList params
   104             (leftConfigPart, rightConfigPart) = partition (\(p, _) -> p /= "MAP") $ Map.toList params
       
   105 
       
   106         answerTeams cl jRoom = let f = if gameinprogress jRoom then teamsAtStart else teams in answerAllTeams cl $ f jRoom
   103 
   107 
   104 
   108 
   105 
   109 
   106 {-
   110 {-
   107 
   111