gameServer/CommandHelp.hs
branchui-scaling
changeset 15288 c4fd2813b127
parent 13852 1738ae8c8e75
child 15413 d9a12aba5c05
equal deleted inserted replaced
13395:0135e64c6c66 15288:c4fd2813b127
       
     1 {-
       
     2  * Hedgewars, a free turn based strategy game
       
     3  * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License as published by
       
     7  * the Free Software Foundation; version 2 of the License
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12  * GNU General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License
       
    15  * along with this program; if not, write to the Free Software
       
    16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
       
    17  \-}
       
    18 
       
    19 {-# LANGUAGE CPP, OverloadedStrings #-}
       
    20 module CommandHelp where
       
    21 
       
    22 import qualified Data.ByteString.Char8 as B
       
    23 
       
    24 import CoreTypes
       
    25 import Utils
       
    26 import Consts
       
    27 
       
    28 -- List and documentation of chat commands
       
    29 
       
    30 cmdHelpSharedPlayer :: [B.ByteString]
       
    31 cmdHelpSharedPlayer = [
       
    32     loc "/info <player>: Show info about player",
       
    33     loc "/me <message>: Chat action, e.g. '/me eats pizza' becomes '* Player eats pizza'",
       
    34     loc "/rnd: Flip a virtual coin and reply with 'heads' or 'tails'",
       
    35     loc "/rnd [A] [B] [C] [...]: Reply with a random word from the given list",
       
    36 #if defined(OFFICIAL_SERVER)
       
    37     loc "/watch <id>: Watch a demo stored on the server with the given ID",
       
    38 #endif
       
    39     loc "/quit: Quit the server",
       
    40     loc "/help: Show chat command help"
       
    41     ]
       
    42 
       
    43 cmdHelpRoomOnlyPlayer :: [B.ByteString]
       
    44 cmdHelpRoomOnlyPlayer = [
       
    45     -- For everyone
       
    46     loc "/callvote [arguments]: Start a vote",
       
    47     loc "/vote <yes/no>: Vote 'yes' or 'no' for active vote",
       
    48     -- For room master only
       
    49     loc "/greeting [message]: Set or clear greeting message to be shown to players who join the room",
       
    50     loc "/delegate <player>: Surrender room control to player",
       
    51     loc "/maxteams <N>: Limit maximum number of teams to N"
       
    52     ]
       
    53 
       
    54 cmdHelpSharedAdmin :: [B.ByteString]
       
    55 cmdHelpSharedAdmin = [
       
    56     loc "/global <message>: Send global chat message which can be seen by everyone on the server",
       
    57     loc "/registered_only: Toggle 'registered only' state. If enabled, only registered players can join server",
       
    58     loc "/super_power: Activate your super power. With it you can enter any room and are protected from kicking. Expires when you leave server"
       
    59     -- TODO: Add /restart_server? This command seems broken at the moment
       
    60     ]
       
    61 
       
    62 cmdHelpLobbyOnlyAdmin :: [B.ByteString]
       
    63 cmdHelpLobbyOnlyAdmin = [
       
    64     loc "/stats: Query server stats"
       
    65     ]
       
    66 
       
    67 cmdHelpRoomOnlyAdmin :: [B.ByteString]
       
    68 cmdHelpRoomOnlyAdmin = [
       
    69     loc "/force <yes/no>: Force vote result for active vote",
       
    70     loc "/fix: Force this room to stay open when it is empty",
       
    71     loc "/unfix: Undo the /fix command",
       
    72     loc "/save <config ID> <config name>: Add current room configuration as votable choice for /callvote map",
       
    73     loc "/delete <config ID>: Delete a votable room configuration",
       
    74     loc "/saveroom <file name>: Save all votable room configurations (and the greeting) of this room into a file",
       
    75     loc "/loadroom <file name>: Load votable room configurations (and greeting) from a file"
       
    76     ]
       
    77 
       
    78 cmdHelpHeaderLobby :: [B.ByteString]
       
    79 cmdHelpHeaderLobby = [ loc "List of lobby chat commands:" ]
       
    80 
       
    81 cmdHelpHeaderRoom :: [B.ByteString]
       
    82 cmdHelpHeaderRoom = [ loc "List of room chat commands:" ]
       
    83 
       
    84 cmdHelpHeaderAdmin :: [B.ByteString]
       
    85 cmdHelpHeaderAdmin = [ loc "Commands for server admins only:" ]
       
    86 
       
    87 -- Put it all together
       
    88 -- Lobby commands
       
    89 cmdHelpLobbyPlayer :: [B.ByteString]
       
    90 cmdHelpLobbyPlayer = cmdHelpHeaderLobby ++ cmdHelpSharedPlayer
       
    91 
       
    92 cmdHelpLobbyAdmin :: [B.ByteString]
       
    93 cmdHelpLobbyAdmin = cmdHelpLobbyPlayer ++ cmdHelpHeaderAdmin ++ cmdHelpLobbyOnlyAdmin ++ cmdHelpSharedAdmin
       
    94 
       
    95 -- Room commands
       
    96 cmdHelpRoomPlayer :: [B.ByteString]
       
    97 cmdHelpRoomPlayer = cmdHelpHeaderRoom ++ cmdHelpRoomOnlyPlayer ++ cmdHelpSharedPlayer
       
    98 
       
    99 cmdHelpRoomAdmin :: [B.ByteString]
       
   100 cmdHelpRoomAdmin = cmdHelpRoomPlayer ++ cmdHelpHeaderAdmin ++ cmdHelpRoomOnlyAdmin ++ cmdHelpSharedAdmin
       
   101 
       
   102 -- Helper functions for chat command handler
       
   103 cmdHelpActionEntry :: [ClientChan] -> B.ByteString -> Action
       
   104 cmdHelpActionEntry chan msg = AnswerClients chan [ "CHAT", nickServer, msg ]
       
   105 
       
   106 cmdHelpActionList :: [ClientChan] -> [B.ByteString] -> [Action]
       
   107 cmdHelpActionList chan list = map (cmdHelpActionEntry chan) list