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