gameServer/Utils.hs
branchwebgl
changeset 9950 2759212a27de
parent 9837 fa94ee96f006
child 10017 de822cd3df3a
equal deleted inserted replaced
9521:8054d9d775fd 9950:2759212a27de
    90             , (42, "0.9.18-dev")
    90             , (42, "0.9.18-dev")
    91             , (43, "0.9.18")
    91             , (43, "0.9.18")
    92             , (44, "0.9.19-dev")
    92             , (44, "0.9.19-dev")
    93             , (45, "0.9.19")
    93             , (45, "0.9.19")
    94             , (46, "0.9.20-dev")
    94             , (46, "0.9.20-dev")
       
    95             , (47, "0.9.20")
       
    96             , (48, "0.9.21-dev")
    95             ]
    97             ]
    96 
    98 
    97 askFromConsole :: B.ByteString -> IO B.ByteString
    99 askFromConsole :: B.ByteString -> IO B.ByteString
    98 askFromConsole msg = do
   100 askFromConsole msg = do
    99     B.putStr msg
   101     B.putStr msg
   123 caseInsensitiveCompare a b = upperCase a == upperCase b
   125 caseInsensitiveCompare a b = upperCase a == upperCase b
   124 
   126 
   125 upperCase :: B.ByteString -> B.ByteString
   127 upperCase :: B.ByteString -> B.ByteString
   126 upperCase = UTF8.fromString . map Char.toUpper . UTF8.toString
   128 upperCase = UTF8.fromString . map Char.toUpper . UTF8.toString
   127 
   129 
   128 roomInfo :: B.ByteString -> RoomInfo -> [B.ByteString]
   130 roomInfo :: Word16 -> B.ByteString -> RoomInfo -> [B.ByteString]
   129 roomInfo n r = [
   131 roomInfo p n r 
       
   132     | p < 46 = [
   130         showB $ isJust $ gameInfo r,
   133         showB $ isJust $ gameInfo r,
   131         name r,
   134         name r,
   132         showB $ playersIn r,
   135         showB $ playersIn r,
   133         showB $ length $ teams r,
   136         showB $ length $ teams r,
   134         n,
   137         n,
   135         Map.findWithDefault "+rnd+" "MAP" (mapParams r),
   138         Map.findWithDefault "+rnd+" "MAP" (mapParams r),
   136         head (Map.findWithDefault ["Default"] "SCHEME" (params r)),
   139         head (Map.findWithDefault ["Default"] "SCHEME" (params r)),
   137         head (Map.findWithDefault ["Default"] "AMMO" (params r))
   140         head (Map.findWithDefault ["Default"] "AMMO" (params r))
   138         ]
   141         ]
   139 
   142     | otherwise = [
       
   143         showB $ isJust $ gameInfo r,
       
   144         name r,
       
   145         showB $ playersIn r,
       
   146         showB $ length $ teams r,
       
   147         n,
       
   148         Map.findWithDefault "+rnd+" "MAP" (mapParams r),
       
   149         head (Map.findWithDefault ["Normal"] "SCRIPT" (params r)),
       
   150         head (Map.findWithDefault ["Default"] "SCHEME" (params r)),
       
   151         head (Map.findWithDefault ["Default"] "AMMO" (params r))
       
   152         ]
   140 
   153 
   141 answerFullConfigParams ::
   154 answerFullConfigParams ::
   142             ClientInfo
   155             ClientInfo
   143             -> Map.Map B.ByteString B.ByteString
   156             -> Map.Map B.ByteString B.ByteString
   144             -> Map.Map B.ByteString [B.ByteString]
   157             -> Map.Map B.ByteString [B.ByteString]
   167             AnswerClients [clChan] ["HH_NUM", teamname team, showB $ hhnum team]]
   180             AnswerClients [clChan] ["HH_NUM", teamname team, showB $ hhnum team]]
   168 
   181 
   169 
   182 
   170 loc :: B.ByteString -> B.ByteString
   183 loc :: B.ByteString -> B.ByteString
   171 loc = id
   184 loc = id
       
   185 
       
   186 maybeNick :: Maybe ClientInfo -> B.ByteString
       
   187 maybeNick = fromMaybe "[empty]" . liftM nick