fixed players being asked to play a war hand when they are not in the war
fixed error in calculating correct winner of a war
This commit is contained in:
parent
20b528f951
commit
ef18326974
2 changed files with 59 additions and 53 deletions
|
@ -1,6 +1,8 @@
|
||||||
WarServ ChangeLog
|
WarServ ChangeLog
|
||||||
=============================================================================
|
=============================================================================
|
||||||
1.2 - DeadNotBuried
|
1.2 - DeadNotBuried
|
||||||
|
- fixed players being asked to play a war hand when they are not in the war
|
||||||
|
- fixed error in calculating correct winner of a war
|
||||||
- added Installation Instructions to Readme file
|
- added Installation Instructions to Readme file
|
||||||
- fixed version number displayed in !rules
|
- fixed version number displayed in !rules
|
||||||
- added explanation of games to !rules
|
- added explanation of games to !rules
|
||||||
|
|
70
warserv.c
70
warserv.c
|
@ -46,9 +46,8 @@ char csuit[10];
|
||||||
char csuitcolour[10];
|
char csuitcolour[10];
|
||||||
char csuitcard[10];
|
char csuitcard[10];
|
||||||
|
|
||||||
/** Module Info definition
|
/*
|
||||||
* version information about our module
|
* Module Info definition
|
||||||
* This structure is required for your module to load and run on NeoStats
|
|
||||||
*/
|
*/
|
||||||
ModuleInfo __module_info = {
|
ModuleInfo __module_info = {
|
||||||
"WarServ",
|
"WarServ",
|
||||||
|
@ -58,9 +57,8 @@ ModuleInfo __module_info = {
|
||||||
__TIME__
|
__TIME__
|
||||||
};
|
};
|
||||||
|
|
||||||
/** printf version information
|
/*
|
||||||
* respond to the /VERSION command on IRC with this text
|
* respond to the /VERSION command
|
||||||
* This is recommended for your module to load and run on NeoStats
|
|
||||||
*/
|
*/
|
||||||
int new_m_version(char *origin, char **av, int ac)
|
int new_m_version(char *origin, char **av, int ac)
|
||||||
{
|
{
|
||||||
|
@ -70,11 +68,8 @@ int new_m_version(char *origin, char **av, int ac)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Module function list
|
/*
|
||||||
* A list of IRCd (server) commands that we will respond to
|
* Module function list
|
||||||
* e.g. VERSION
|
|
||||||
* This table is required for your module to load and run on NeoStats
|
|
||||||
* but you do not have to have any functions in it
|
|
||||||
*/
|
*/
|
||||||
Functions __module_functions[] = {
|
Functions __module_functions[] = {
|
||||||
{MSG_VERSION, new_m_version, 1},
|
{MSG_VERSION, new_m_version, 1},
|
||||||
|
@ -84,9 +79,8 @@ Functions __module_functions[] = {
|
||||||
{NULL, NULL, 0}
|
{NULL, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Channel message processing
|
/*
|
||||||
* What do we do with messages in channels
|
* Channel message processing
|
||||||
* This is required if you want your module to respond to channel messages
|
|
||||||
*/
|
*/
|
||||||
int __ChanMessage(char *origin, char **argv, int argc)
|
int __ChanMessage(char *origin, char **argv, int argc)
|
||||||
{
|
{
|
||||||
|
@ -203,9 +197,8 @@ int __ChanMessage(char *origin, char **argv, int argc)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Bot message processing
|
/*
|
||||||
* What do we do with messages sent to our bot with /mag
|
* private message processing
|
||||||
* This is required if you want your module to respond to /msg
|
|
||||||
*/
|
*/
|
||||||
int __BotMessage(char *origin, char **argv, int argc)
|
int __BotMessage(char *origin, char **argv, int argc)
|
||||||
{
|
{
|
||||||
|
@ -249,8 +242,8 @@ int __BotMessage(char *origin, char **argv, int argc)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Online event processing
|
/*
|
||||||
* What we do when we first come online
|
* Online event processing
|
||||||
*/
|
*/
|
||||||
int Online(char **av, int ac)
|
int Online(char **av, int ac)
|
||||||
{
|
{
|
||||||
|
@ -288,10 +281,8 @@ int PlayerNickChange(char **av, int ac) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Module event list
|
/*
|
||||||
* What events we will act on
|
* Module event list
|
||||||
* This is required if you want your module to respond to events on IRC
|
|
||||||
* see modules.txt for a list of all events available
|
|
||||||
*/
|
*/
|
||||||
EventFnList __module_events[] = {
|
EventFnList __module_events[] = {
|
||||||
{EVENT_ONLINE, Online},
|
{EVENT_ONLINE, Online},
|
||||||
|
@ -299,9 +290,8 @@ EventFnList __module_events[] = {
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Init module
|
/*
|
||||||
* This is required if you need to do initialisation of your module when
|
* Init module
|
||||||
* first loaded
|
|
||||||
*/
|
*/
|
||||||
int __ModInit(int modnum, int apiver)
|
int __ModInit(int modnum, int apiver)
|
||||||
{
|
{
|
||||||
|
@ -310,8 +300,8 @@ int __ModInit(int modnum, int apiver)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Exit module
|
/*
|
||||||
* This is required if you need to do cleanup of your module when it ends
|
* Exit module
|
||||||
*/
|
*/
|
||||||
void __ModFini()
|
void __ModFini()
|
||||||
{
|
{
|
||||||
|
@ -474,7 +464,7 @@ int removewarother(char *nic, char *ntr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove PLayer
|
* Remove Player
|
||||||
* removes player from game and adds any cards they have to the stack
|
* removes player from game and adds any cards they have to the stack
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -490,6 +480,7 @@ int removewar(char *nic) {
|
||||||
}
|
}
|
||||||
for (wpln = 0; wpln < currentwarplayercount; wpln++) {
|
for (wpln = 0; wpln < currentwarplayercount; wpln++) {
|
||||||
if (!strcasecmp(wplayernick[wpln], nic)) {
|
if (!strcasecmp(wplayernick[wpln], nic)) {
|
||||||
|
privmsg(warroom, s_module_bot_name, "\0037%s \0038Removed from the current game of \0034War", nic);
|
||||||
if (wpln == currentplayer) {
|
if (wpln == currentplayer) {
|
||||||
tfrpacp= 1;
|
tfrpacp= 1;
|
||||||
} else if (wpln < currentplayer) {
|
} else if (wpln < currentplayer) {
|
||||||
|
@ -517,7 +508,6 @@ int removewar(char *nic) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentwarplayercount--;
|
currentwarplayercount--;
|
||||||
privmsg(warroom, s_module_bot_name, "\0037%s \0038Removed from the current game of \0034War", nic);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentwarplayercount < 2) {
|
if (currentwarplayercount < 2) {
|
||||||
|
@ -565,6 +555,7 @@ int askplaycard() {
|
||||||
wpln= currentwarplayercount;
|
wpln= currentwarplayercount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
currentplayer = nwp;
|
||||||
}
|
}
|
||||||
if (nwp > currentwarplayercount) {
|
if (nwp > currentwarplayercount) {
|
||||||
checkwarwinner();
|
checkwarwinner();
|
||||||
|
@ -608,6 +599,7 @@ int askplaycard() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int playwarcards(char *cnps1, char *cnps2, char *cnps3) {
|
int playwarcards(char *cnps1, char *cnps2, char *cnps3) {
|
||||||
|
int ncob;
|
||||||
int cnp[3];
|
int cnp[3];
|
||||||
char *tempint;
|
char *tempint;
|
||||||
cnp[0] = atoi(cnps1);
|
cnp[0] = atoi(cnps1);
|
||||||
|
@ -654,6 +646,14 @@ int playwarcards(char *cnps1, char *cnps2, char *cnps3) {
|
||||||
wstackcards[wstackcardscurrent]= wplayercardsinhand[currentplayer][cnp[wpln]];
|
wstackcards[wstackcardscurrent]= wplayercardsinhand[currentplayer][cnp[wpln]];
|
||||||
wstackcardscurrent++;
|
wstackcardscurrent++;
|
||||||
wplayerwarcardsplayed[currentplayer][wpln]= wplayercardsinhand[currentplayer][cnp[wpln]];
|
wplayerwarcardsplayed[currentplayer][wpln]= wplayercardsinhand[currentplayer][cnp[wpln]];
|
||||||
|
}
|
||||||
|
if (cnp[2] > cnp[0])
|
||||||
|
cnp[2]--;
|
||||||
|
if (cnp[2] > cnp[1])
|
||||||
|
cnp[2]--;
|
||||||
|
if (cnp[1] > cnp[0])
|
||||||
|
cnp[1]--;
|
||||||
|
for (wpln = 0; wpln < 3; wpln++) {
|
||||||
wplayercardstotal[currentplayer]--;
|
wplayercardstotal[currentplayer]--;
|
||||||
for (wplnh = cnp[wpln]; wplnh < wplayercardstotal[currentplayer]; wplnh++) {
|
for (wplnh = cnp[wpln]; wplnh < wplayercardstotal[currentplayer]; wplnh++) {
|
||||||
wplayercardsinhand[currentplayer][wplnh]= wplayercardsinhand[currentplayer][(wplnh +1)];
|
wplayercardsinhand[currentplayer][wplnh]= wplayercardsinhand[currentplayer][(wplnh +1)];
|
||||||
|
@ -767,7 +767,10 @@ int checkhandwinner() {
|
||||||
} else {
|
} else {
|
||||||
privmsg(warroom, s_module_bot_name, "\0034WAR DECLARED");
|
privmsg(warroom, s_module_bot_name, "\0034WAR DECLARED");
|
||||||
for (wpln = 0; wpln < currentwarplayercount; wpln++) {
|
for (wpln = 0; wpln < currentwarplayercount; wpln++) {
|
||||||
|
if (warinprogress == wplayeratwar[wpln]) {
|
||||||
|
wplayeratwar[wpln] = 0;
|
||||||
if ((wplayercardplayed[wpln] % 13) == hcnp) {
|
if ((wplayercardplayed[wpln] % 13) == hcnp) {
|
||||||
|
wplayeratwar[wpln]= 1;
|
||||||
if (wplayercardstotal[wpln] < 3) {
|
if (wplayercardstotal[wpln] < 3) {
|
||||||
privmsg(warroom, s_module_bot_name, "\0037%s\0038 Surrenders\0039 (Insufficient Cards)", wplayernick[wpln]);
|
privmsg(warroom, s_module_bot_name, "\0037%s\0038 Surrenders\0039 (Insufficient Cards)", wplayernick[wpln]);
|
||||||
hcnpt--;
|
hcnpt--;
|
||||||
|
@ -776,8 +779,7 @@ int checkhandwinner() {
|
||||||
wpln= currentwarplayercount;
|
wpln= currentwarplayercount;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
wplayeratwar[wpln]= 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -796,11 +798,13 @@ int checkwarwinner() {
|
||||||
for (wpln = 0; wpln < currentwarplayercount; wpln++) {
|
for (wpln = 0; wpln < currentwarplayercount; wpln++) {
|
||||||
if (wplayeratwar[wpln] == 1) {
|
if (wplayeratwar[wpln] == 1) {
|
||||||
wplayercardplayed[wpln]= wplayerwarcardsplayed[wpln][2];
|
wplayercardplayed[wpln]= wplayerwarcardsplayed[wpln][2];
|
||||||
|
} else {
|
||||||
|
wplayercardplayed[wpln]= 0;
|
||||||
|
}
|
||||||
for (wplnh = 0; wplnh < 3; wplnh++) {
|
for (wplnh = 0; wplnh < 3; wplnh++) {
|
||||||
wplayerwarcardsplayed[wpln][wplnh]= 0;
|
wplayerwarcardsplayed[wpln][wplnh]= 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
checkhandwinner();
|
checkhandwinner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue