gameServer/CommandHelp.hs
changeset 13509 9ba5e4594322
child 13692 70c8feb81d35
equal deleted inserted replaced
13508:da59012fbd7a 13509:9ba5e4594322
       
     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 OverloadedStrings #-}
       
    20 module CommandHelp where
       
    21 
       
    22 import qualified Data.ByteString.Char8 as B
       
    23 
       
    24 import CoreTypes
       
    25 import Utils
       
    26 
       
    27 -- List and documentation of chat commands
       
    28 
       
    29 cmdHelpSharedPlayer :: [B.ByteString]
       
    30 cmdHelpSharedPlayer = [
       
    31     loc "/info <player>: Show info about player",
       
    32     loc "/me <message>: Chat action, e.g. '/me eats pizza' becomes '* Player eats pizza'",
       
    33     loc "/rnd: Flip a virtual coin and reply with 'heads' or 'tails'",
       
    34     loc "/rnd [A] [B] [C] [...]: Reply with a random word from the given list",
       
    35     loc "/watch <id>: Watch a demo stored on the server with the given ID",
       
    36     loc "/help: Show chat command help"
       
    37     ]
       
    38 
       
    39 cmdHelpRoomOnlyPlayer :: [B.ByteString]
       
    40 cmdHelpRoomOnlyPlayer = [
       
    41     -- For everyone
       
    42     loc "/callvote [arguments]: Start a vote",
       
    43     loc "/vote <yes/no>: Vote 'yes' or 'no' for active vote",
       
    44     -- For room master only
       
    45     loc "/greeting <message>: Set greeting message to be shown to players who join the room",
       
    46     loc "/delegate <player>: Surrender room control to player",
       
    47     loc "/maxteams <N>: Limit maximum number of teams to N"
       
    48     ]
       
    49 
       
    50 cmdHelpSharedAdmin :: [B.ByteString]
       
    51 cmdHelpSharedAdmin = [
       
    52     loc "/global <message>: Send global chat message which can be seen by everyone on the server",
       
    53     loc "/registered_only: Toggle 'registered only' state. If enabled, only registered players can join server",
       
    54     loc "/super_power: Activate your super power. With it you can enter any room and are protected from kicking. Expires when you leave server",
       
    55     -- TODO: Add help for /save
       
    56     loc "/save <parameter>"
       
    57     -- TODO: Add /restart_server? This command seems broken at the moment
       
    58     ]
       
    59 
       
    60 cmdHelpLobbyOnlyAdmin :: [B.ByteString]
       
    61 cmdHelpLobbyOnlyAdmin = [
       
    62     loc "/stats: Query server stats"
       
    63     ]
       
    64 
       
    65 cmdHelpRoomOnlyAdmin :: [B.ByteString]
       
    66 cmdHelpRoomOnlyAdmin = [
       
    67     loc "/force <yes/no>: Force vote result for active vote",
       
    68     loc "/fix: Force this room to stay open when it is empty",
       
    69     loc "/unfix: Undo the /fix command",
       
    70     loc "/saveroom <file name>: Save room configuration into a file",
       
    71     loc "/loadroom <file name>: Load room configuration from a file",
       
    72     -- TODO: Add help for /delete
       
    73     loc "/delete <parameter>"
       
    74     ]
       
    75 
       
    76 cmdHelpHeaderLobby :: [B.ByteString]
       
    77 cmdHelpHeaderLobby = [ loc "List of lobby chat commands:" ]
       
    78 
       
    79 cmdHelpHeaderRoom :: [B.ByteString]
       
    80 cmdHelpHeaderRoom = [ loc "List of room chat commands:" ]
       
    81 
       
    82 cmdHelpHeaderAdmin :: [B.ByteString]
       
    83 cmdHelpHeaderAdmin = [ loc "Commands for server admins only:" ]
       
    84 
       
    85 -- Put it all together
       
    86 -- Lobby commands
       
    87 cmdHelpLobbyPlayer :: [B.ByteString]
       
    88 cmdHelpLobbyPlayer = cmdHelpHeaderLobby ++ cmdHelpSharedPlayer
       
    89 
       
    90 cmdHelpLobbyAdmin :: [B.ByteString]
       
    91 cmdHelpLobbyAdmin = cmdHelpLobbyPlayer ++ cmdHelpHeaderAdmin ++ cmdHelpLobbyOnlyAdmin ++ cmdHelpSharedAdmin
       
    92 
       
    93 -- Room commands
       
    94 cmdHelpRoomPlayer :: [B.ByteString]
       
    95 cmdHelpRoomPlayer = cmdHelpHeaderRoom ++ cmdHelpRoomOnlyPlayer ++ cmdHelpSharedPlayer
       
    96 
       
    97 cmdHelpRoomAdmin :: [B.ByteString]
       
    98 cmdHelpRoomAdmin = cmdHelpRoomPlayer ++ cmdHelpHeaderAdmin ++ cmdHelpRoomOnlyAdmin ++ cmdHelpSharedAdmin
       
    99 
       
   100 -- Helper functions for chat command handler
       
   101 cmdHelpActionEntry :: [ClientChan] -> B.ByteString -> Action
       
   102 cmdHelpActionEntry chan msg = AnswerClients chan [ "CHAT", "[server]", B.concat [ " ", msg ] ]
       
   103 
       
   104 cmdHelpActionList :: [ClientChan] -> [B.ByteString] -> [Action]
       
   105 cmdHelpActionList chan list = map (cmdHelpActionEntry chan) list