Improve some replies for chat commands on server
authorWuzzy <Wuzzy2@mail.ru>
Wed, 18 Jul 2018 17:02:40 +0200
changeset 13510 60bcc20e6ab0
parent 13509 9ba5e4594322
child 13511 b62b14aa88d4
Improve some replies for chat commands on server
gameServer/HWProtoCore.hs
gameServer/HWProtoInRoomState.hs
--- a/gameServer/HWProtoCore.hs	Wed Jul 18 15:35:54 2018 +0200
+++ b/gameServer/HWProtoCore.hs	Wed Jul 18 17:02:40 2018 +0200
@@ -87,6 +87,10 @@
                          | otherwise = let (c, p) = extractParameters msg in
                                            if B.null p then handleCmd ["CALLVOTE", c] else handleCmd ["CALLVOTE", c, p]
         h "VOTE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg]
+                     | otherwise = handleCmd ["VOTE", ""]
+        h "FORCE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg, "FORCE"]
+                      | otherwise = handleCmd ["VOTE", "", "FORCE"]
+        h "VOTE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg]
         h "FORCE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg, "FORCE"]
         h "MAXTEAMS" n | not $ B.null n = handleCmd ["MAXTEAMS", n]
         h "INFO" n | not $ B.null n = handleCmd ["INFO", n]
@@ -99,7 +103,8 @@
                 , AnswerClients [sendChan cl] ["CHAT", "[server]", "'Registered only' state toggled"]
                 ]
         h "SUPER_POWER" _ = serverAdminOnly $ return [ModifyClient (\c -> c{hasSuperPower = True})]
-        h c p = return [Warning $ B.concat ["Unknown cmd: /", c, " ", p]]
+        h c p = return [Warning $ B.concat [ loc "Unknown command:", " /", c, " ", p, "<br/>", loc "Say '/help' in chat for a list of commands" ]]
+
 
         extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b)
 
@@ -114,14 +119,14 @@
     let clRoom = room rnc roomId
     let roomMasterSign = if isMaster cl then "+" else ""
     let adminSign = if isAdministrator cl then "@" else ""
-    let rInfo = if roomId /= lobbyId then B.concat [adminSign, roomMasterSign, "room ", name clRoom] else adminSign `B.append` "lobby"
+    let rInfo = if roomId /= lobbyId then B.concat [adminSign, roomMasterSign, loc "room", " ", name clRoom] else adminSign `B.append` (loc "lobby")
     let roomStatus = if isJust $ gameInfo clRoom then
-            if teamsInGame cl > 0 then "(playing)" else "(spectating)"
+            if teamsInGame cl > 0 then (loc "(playing)") else (loc "(spectating)")
             else
             ""
     let hostStr = if isAdminAsking then host cl else B.empty
     if noSuchClient then
-        return []
+        answerClient [ "CHAT", "[server]", loc "Player is not online." ]
         else
         answerClient [
             "INFO",
--- a/gameServer/HWProtoInRoomState.hs	Wed Jul 18 15:35:54 2018 +0200
+++ b/gameServer/HWProtoInRoomState.hs	Wed Jul 18 17:02:40 2018 +0200
@@ -496,8 +496,13 @@
     let b = if m == "YES" then Just True else if m == "NO" then Just False else Nothing
     if isJust b then
         voted (p == ["FORCE"]) (fromJust b)
-        else
-        return [AnswerClients [sendChan cl] ["CHAT", "[server]", "/vote: Please use 'yes' or 'no'."]]
+    else
+        return [AnswerClients [sendChan cl] ["CHAT", "[server]",
+            if (p == ["FORCE"]) then
+                loc "/force: Please use 'yes' or 'no'."
+            else
+                loc "/vote: Please use 'yes' or 'no'."
+        ]]
 
 
 handleCmd_inRoom ["SAVE", stateName, location] = serverAdminOnly $ do