*** VERSION 5.5.0 ***
[NeonServV5.git] / src / modules / NeonFun.mod / cmd_neonfun.c
1 /* cmd_neonfun.c - NeonServ v5.5
2  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
3  * 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
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, see <http://www.gnu.org/licenses/>. 
16  */
17 #include "../module.h"
18
19 #include "cmd_neonfun.h"
20 #include "../../modcmd.h"
21 #include "../../lang.h"
22 #include "../../ConfigParser.h"
23
24 static const struct default_language_entry msgtab[] = {
25     {"NF_UNO_ALREADY_RUNNING", "There is already a UNO game running in %s."}, /* {ARGS: "#channel"} */
26     {"NF_UNO_ALREADY_JOINED", "You have already joined this UNO game."},
27     {"NF_UNO_USER_JOINED", "$b%s$b has joined the game."}, /* {ARGS: "TestUser"} */
28     {"NF_UNO_CREATED", "$b%s$b started an UNO game. Type $b+uno$b to join the game."}, /* {ARGS: "TestUser"} */
29     {"NF_UNO_ERROR", "UNO program error. Please contact a bot administrator. (ErrCode: %d)"}, /* {ARGS: 0} */
30     {"NF_UNO_START", "GAME START"},
31     {"NF_UNO_USER_HURRY_UP", "$b%s$b, it's your turn!"}, /* {ARGS: "TestUser"} */
32     {"NF_UNO_USER_TOOK_CARD", "$b%s$b took another card."}, /* {ARGS: "TestUser"} */
33     {"NF_UNO_USER_TOOK_CARDS", "$b%s$b took $b%d$b cards."}, /* {ARGS: "TestUser", 4} */
34     {"NF_UNO_YOUR_CARDS", "Your cards: %s"}, /* {ARGS: "[+2] [+4] [R5] ..."} */
35     {"NF_UNO_TOP_CARD", "upper card: %s"}, /* {ARGS: "[+4]"} */
36     {"NF_UNO_NOT_YOUR_TURN", "Wait your turn!"},
37     {"NF_UNO_UNKNOWN_CARD", "Unknown card [%s]."}, /* {ARGS: "xy"} */
38     {"NF_UNO_CARD_NOT_IN_DECK", "You don't have this card."},
39     {"NF_UNO_CARD_YELLOW", "yellow"},
40     {"NF_UNO_CARD_BLUE", "blue"},
41     {"NF_UNO_CARD_RED", "red"},
42     {"NF_UNO_CARD_GREEN", "green"},
43     {"NF_UNO_DEFINE_COLOR", "Please define the color you want to set as a parameter to the command (eg. $b+unoplay +4 RED$b)"},
44     {"NF_UNO_CARD_NOT_POSSIBLE", "You can't play this card."},
45     {"NF_UNO_ONE_CARD", "$b%s$b has only one card! $k4U$k$k9N$k$k12O$k"}, /* {ARGS: "TestUser"} */
46     {"NF_UNO_USER_WIN", "$b%s$b has 0 cards! $k4U$k$k9N$k$k12O$k $k4U$k$k9N$k$k12O$k!!!"}, /* {ARGS: "TestUser"} */
47     {"NF_UNO_TIMEOUT", "game stopped (no more active players)."},
48     {"NF_UNO_USER_SKIP", "skipped $b%s$b."}, /* {ARGS: "TestUser"} */
49     {"NF_UNO_GAME_FINISHED", "The UNO Game has been finished!"},
50     {"NF_UNO_ADD_CARD", "$b%s$b has to take up %d cards. There is still the possibility that he/she has another card of this type...?"},
51     {"NF_UNO_RANK", "Rank"},
52     {"NF_UNO_NAME", "Name"},
53     {"NF_UNO_WON_GAMES", "Won Games"},
54     {"NF_UNO_TOTAL_WON_GAMES", "Total won Games"},
55     {"NF_UNO_LESS_PLAYERS", "There are not enough players to start the game."},
56     
57     {"NF_4WINS_NOT_YOUR_TURN", "Wait your turn!"},
58     {"NF_4WINS_INVALID_COLUMN", "invalid column!"},
59     {"NF_4WINS_COLUMN_FULL", "This column is full!"},
60     {"NF_4WINS_USER_HURRY_UP", "$b%s$b, it's your turn! To put a stone into a column use: 4stone <colomn>"}, /* {ARGS: "TestUser"} */
61     {"NF_4WINS_USER_WON", "$b%s$b won the game!"}, /* {ARGS: "TestUser"} */
62     {"NF_4WINS_ENTER_OPPONENT", "Please enter the nick of the opponent you want to play against as a parameter of 4wins (eg. $b4wins TestUser$b)"},
63     {"NF_4WINS_OPPONENT_NOT_IN_CHAN", "$b%s$b needs to be in this channel to start a game against him/her."}, /* {ARGS: "TestUser"} */
64     {"NF_4WINS_DRAW", "Noone has won this game."},
65     {"NF_4WINS_REQUEST", "$b%s$b wants to play a game against you. use $b4wins$b to start the game."}, /* {ARGS: "TestUser"} */
66     {"NF_4WINS_REQUESTED", "waiting for $b%s$b accepting the game..."}, /* {ARGS: "TestUser"} */
67     {"NF_4WINS_START", "%s accepted the challenge! game starts:"}, /* {ARGS: "TestUser"} */
68     {"NF_4WINS_APPEND_PLAYER", "Please append the nick of a player playing the game you want to view. (eg. $b4view TestUser$b)"},
69     {"NF_4WINS_NO_GAME_FOUND", "Couldn't find a game with this user in this channel."},
70     {"NF_4WINS_VIEWING_ANOTHER_GAME", "You are already viewing another game."},
71     {"NF_4WINS_VIEWING_GAME", "You are now viewing the game."},
72     {"NF_4WINS_GAME_CLOSED", "Game aborted."},
73     {"NF_4WINS_TIMEOUT", "Game aborted (timeout)."},
74     {"NF_4WINS_SELF", "You may not play against yourself."},
75     {NULL, NULL}
76 };
77
78 void register_commands() {
79     //NeonFun Commands
80     register_default_language_table(msgtab);
81     register_command_alias(5, "NeonFun");
82     
83     #define USER_COMMAND(NAME,FUNCTION,PARAMCOUNT,PRIVS,FLAGS) register_command(5, NAME, module_id, FUNCTION, PARAMCOUNT, PRIVS, 0, FLAGS)
84     //           NAME            FUNCTION              PARAMS  PRIVS     FLAGS
85     USER_COMMAND("uno",          neonfun_cmd_uno,      0,      NULL,     CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN);
86     USER_COMMAND("unotake",      neonfun_cmd_unotake,  0,      NULL,     CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN);
87     USER_COMMAND("unoplay",      neonfun_cmd_unoplay,  1,      NULL,     CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN);
88     
89     USER_COMMAND("4wins",        neonfun_cmd_4wins,    0,      NULL,     CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN);
90     USER_COMMAND("4stone",       neonfun_cmd_4stone,   1,      NULL,     CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN);
91     USER_COMMAND("4view",        neonfun_cmd_4view,    0,      NULL,     CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN);
92     
93     #undef USER_COMMAND
94     
95 }
96
97