gameServer/HWProtoCore.hs
changeset 13841 b2cc4e4e380c
parent 13831 b07610de9957
child 13845 1a1fb597da8f
equal deleted inserted replaced
13840:219c2e588874 13841:b2cc4e4e380c
    63             else
    63             else
    64             handleCmd_loggedin cmd
    64             handleCmd_loggedin cmd
    65         else
    65         else
    66         handleCmd_NotEntered cmd
    66         handleCmd_NotEntered cmd
    67 
    67 
       
    68 unknownCmdWarningText :: B.ByteString
       
    69 unknownCmdWarningText = loc "Unknown command or invalid parameters. Say '/help' in chat for a list of commands."
       
    70 
       
    71 handleCmd_loggedin ["CMD"] = return [Warning unknownCmdWarningText]
    68 
    72 
    69 handleCmd_loggedin ["CMD", parameters] = uncurry h $ extractParameters parameters
    73 handleCmd_loggedin ["CMD", parameters] = uncurry h $ extractParameters parameters
    70     where
    74     where
    71         h "DELEGATE" n | not $ B.null n = handleCmd ["DELEGATE", n]
    75         h "DELEGATE" n | not $ B.null n = handleCmd ["DELEGATE", n]
    72         h "SAVEROOM" n | not $ B.null n = handleCmd ["SAVEROOM", n]
    76         h "SAVEROOM" n | not $ B.null n = handleCmd ["SAVEROOM", n]
    73         h "LOADROOM" n | not $ B.null n = handleCmd ["LOADROOM", n]
    77         h "LOADROOM" n | not $ B.null n = handleCmd ["LOADROOM", n]
    74         h "SAVE" n | not $ B.null n = let (sn, ln) = B.break (== ' ') n in if B.null ln then return [] else handleCmd ["SAVE", sn, B.tail ln]
    78         h "SAVE" n | not $ B.null n = let (sn, ln) = B.break (== ' ') n in if B.null ln then return [] else handleCmd ["SAVE", sn, B.tail ln]
    75         h "DELETE" n | not $ B.null n = handleCmd ["DELETE", n]
    79         h "DELETE" n | not $ B.null n = handleCmd ["DELETE", n]
    76         h "STATS" _ = handleCmd ["STATS"]
    80         h "STATS" _ = handleCmd ["STATS"]
    77         h "PART" m | not $ B.null m = handleCmd ["PART", m]
       
    78                    | otherwise = handleCmd ["PART"]
       
    79         h "QUIT" m | not $ B.null m = handleCmd ["QUIT", m]
    81         h "QUIT" m | not $ B.null m = handleCmd ["QUIT", m]
    80                    | otherwise = handleCmd ["QUIT"]
    82                    | otherwise = handleCmd ["QUIT"]
    81         h "RND" p = handleCmd ("RND" : B.words p)
    83         h "RND" p = handleCmd ("RND" : B.words p)
    82         h "GLOBAL" p = serverAdminOnly $ do
    84         h "GLOBAL" p = serverAdminOnly $ do
    83             rnc <- liftM snd ask
    85             rnc <- liftM snd ask
    92                                            if B.null p then handleCmd ["CALLVOTE", c] else handleCmd ["CALLVOTE", c, p]
    94                                            if B.null p then handleCmd ["CALLVOTE", c] else handleCmd ["CALLVOTE", c, p]
    93         h "VOTE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg]
    95         h "VOTE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg]
    94                      | otherwise = handleCmd ["VOTE", ""]
    96                      | otherwise = handleCmd ["VOTE", ""]
    95         h "FORCE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg, "FORCE"]
    97         h "FORCE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg, "FORCE"]
    96                       | otherwise = handleCmd ["VOTE", "", "FORCE"]
    98                       | otherwise = handleCmd ["VOTE", "", "FORCE"]
    97         h "VOTE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg]
       
    98         h "FORCE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg, "FORCE"]
       
    99         h "MAXTEAMS" n | not $ B.null n = handleCmd ["MAXTEAMS", n]
    99         h "MAXTEAMS" n | not $ B.null n = handleCmd ["MAXTEAMS", n]
   100         h "INFO" n | not $ B.null n = handleCmd ["INFO", n]
   100         h "INFO" n | not $ B.null n = handleCmd ["INFO", n]
   101         h "HELP" _ = handleCmd ["HELP"]
   101         h "HELP" _ = handleCmd ["HELP"]
   102         h "RESTART_SERVER" "YES" = handleCmd ["RESTART_SERVER"]
   102         h "RESTART_SERVER" "YES" = handleCmd ["RESTART_SERVER"]
   103         h "REGISTERED_ONLY" _ = serverAdminOnly $ do
   103         h "REGISTERED_ONLY" _ = serverAdminOnly $ do
   111             cl <- thisClient
   111             cl <- thisClient
   112             return
   112             return
   113                 [ModifyClient (\c -> c{hasSuperPower = True})
   113                 [ModifyClient (\c -> c{hasSuperPower = True})
   114                 , AnswerClients [sendChan cl] ["CHAT", nickServer, loc "Super power activated."]
   114                 , AnswerClients [sendChan cl] ["CHAT", nickServer, loc "Super power activated."]
   115                 ]
   115                 ]
   116         h _ _ = return [Warning $ loc "Unknown command or invalid parameters. Say '/help' in chat for a list of commands." ]
   116         h _ _ = return [Warning unknownCmdWarningText]
   117 
   117 
   118 
   118 
   119         extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b)
   119         extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b)
   120 
   120 
   121 handleCmd_loggedin ["INFO", asknick] = do
   121 handleCmd_loggedin ["INFO", asknick] = do