-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevents.c
More file actions
207 lines (193 loc) · 5.92 KB
/
events.c
File metadata and controls
207 lines (193 loc) · 5.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/* WarServ - War Card Game Service - NeoStats Addon Module
** Copyright (c) 2004-2005 Justin Hammond, Mark Hetherington, Jeff Lang
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
** USA
**
** WarServ CVS Identification
** $Id: events.c 62 2005-12-11 11:38:21Z DNB $
*/
#include "neostats.h" /* Required for bot support */
#include "warserv.h"
/*
* Nick Change Check
*/
int PlayerNickChange (const CmdParams *cmdparams)
{
if (currentwarplayercount < 1) {
return NS_SUCCESS;
}
for (wpln = 0; wpln < currentwarplayercount; wpln++) {
if (!ircstrcasecmp (wplayernick[wpln], cmdparams->param)) {
strlcpy (wplayernick[wpln], cmdparams->source->name, MAXNICK);
}
}
return NS_SUCCESS;
}
/*
* Start War Game
*/
int StartWarGame (const CmdParams *cmdparams)
{
if (currentwargamestatus == WS_GAME_STOPPED) {
startcountdowntimer(cmdparams->source->name);
} else if (currentwarplayercount < 10) {
irc_privmsg (ws_bot, cmdparams->source, "\0034A game has already started \0037%s\0034, Type '\2\003Join\2\0034' in \2\003%s\2\0034 To Join in.", cmdparams->source->name, warroom);
} else {
irc_privmsg (ws_bot, cmdparams->source, "\0034A game has already started \0037%s\0034 and all spots are taken. Please try the next game.", cmdparams->source->name);
}
return NS_SUCCESS;
}
/*
* Stop War Game
*/
int StopWarGame (const CmdParams *cmdparams)
{
if (currentwargamestatus != WS_GAME_STOPPED) {
if (cmdparams->source->user->ulevel >= NS_ULEVEL_OPER) {
irc_chanprivmsg (ws_bot, warroom, "\0039Stopping Current Game (\0037%s\0039)", cmdparams->source->name);
stopwar();
wpln = currentwarplayercount;
return NS_SUCCESS;
} else {
for (wpln = 0; wpln < currentwarplayercount; wpln++) {
if (!ircstrcasecmp (wplayernick[wpln], cmdparams->source->name)) {
irc_chanprivmsg (ws_bot, warroom, "\0039Stopping Current Game (\0037%s\0039)", cmdparams->source->name);
stopwar();
wpln = currentwarplayercount;
return NS_SUCCESS;
}
}
}
}
return NS_SUCCESS;
}
/*
* Join War Game
*/
int JoinWarGame (const CmdParams *cmdparams)
{
if (currentwargamestatus == WS_GAME_STARTING) {
joinwar(cmdparams->source->name);
SetUserModValue(cmdparams->source,(void *)1);
}
return NS_SUCCESS;
}
/*
* Remove From War Game
*/
int RemoveWarGame (const CmdParams *cmdparams)
{
Client *u;
if (currentwargamestatus != WS_GAME_STOPPED) {
if ( cmdparams->ac > 0 ) {
/* allows removal of a player by anyone
* if player no longer connected to ircd */
u = FindUser(cmdparams->av[0]);
if (!u || cmdparams->source->user->ulevel >= NS_ULEVEL_OPER) {
removewar(u->name);
if (GetUserModValue(u) > 0)
ClearUserModValue(u);
}
} else {
removewar(cmdparams->source->name);
if (GetUserModValue(cmdparams->source) > 0)
ClearUserModValue(cmdparams->source);
}
}
return NS_SUCCESS;
}
/*
* Display Current Players
*/
int ShowPlayersWarGame (const CmdParams *cmdparams)
{
if (currentwargamestatus == WS_GAME_PLAYING) {
irc_chanprivmsg (ws_bot, warroom, "\0039Current Players are\0038 :\0037 %s %s %s %s %s %s %s %s %s %s", wplayernick[0], wplayernick[1], wplayernick[2], wplayernick[3], wplayernick[4], wplayernick[5], wplayernick[6], wplayernick[7], wplayernick[8], wplayernick[9]);
}
return NS_SUCCESS;
}
/*
* Display Current Player Turn
*/
int ShowTurnWarGame (const CmdParams *cmdparams)
{
if (currentwargamestatus == WS_GAME_PLAYING) {
if (warinprogress == 1) {
irc_chanprivmsg (ws_bot, warroom, "\0039The Current Player is \0037%s\0039 holding\00311 %d\0039 cards, and are currently at \0034WAR\0039 which three would you like to play ?", wplayernick[currentplayer], wplayercardstotal[currentplayer]);
} else {
irc_chanprivmsg (ws_bot, warroom, "\0039The Current Player is \0037%s\0039 currently holding\00311 %d\0039 cards, which would you like to play ?", wplayernick[currentplayer], wplayercardstotal[currentplayer]);
}
}
return NS_SUCCESS;
}
/*
* Play Cards
*/
int PlayCardsWarGame (const CmdParams *cmdparams)
{
if (!ircstrcasecmp (cmdparams->source->name,wplayernick[currentplayer]) && currentwargamestatus == WS_GAME_PLAYING) {
if (warinprogress == 1) {
if (cmdparams->ac == 3) {
playwarcards(atoi(cmdparams->av[0]), atoi(cmdparams->av[1]), atoi(cmdparams->av[2]));
}
} else {
if (cmdparams->ac == 1) {
playcard(atoi(cmdparams->av[0]));
}
}
}
return NS_SUCCESS;
}
/*
* User Events
*
* check if user is a War Player
* and if so, remove from game as appropriate
*/
int CheckPlayerPart (const CmdParams *cmdparams)
{
SET_SEGV_LOCATION();
if (GetUserModValue(cmdparams->source) > 0)
RemoveWarGame(cmdparams);
return NS_SUCCESS;
}
int CheckPlayerQuit (const CmdParams *cmdparams)
{
SET_SEGV_LOCATION();
if (GetUserModValue(cmdparams->source) > 0)
RemoveWarGame(cmdparams);
return NS_SUCCESS;
}
int CheckPlayerKick (const CmdParams *cmdparams)
{
SET_SEGV_LOCATION();
if (GetUserModValue(cmdparams->target) > 0 && currentwargamestatus != WS_GAME_STOPPED)
{
removewar(cmdparams->target->name);
ClearUserModValue(cmdparams->target);
}
return NS_SUCCESS;
}
int CheckPlayerKill (const CmdParams *cmdparams)
{
SET_SEGV_LOCATION();
if (GetUserModValue(cmdparams->target) > 0 && currentwargamestatus != WS_GAME_STOPPED)
{
removewar(cmdparams->target->name);
ClearUserModValue(cmdparams->target);
}
return NS_SUCCESS;
}