add high score HTML output
This commit is contained in:
parent
3e0f97e748
commit
ef0985c316
9 changed files with 560 additions and 22 deletions
2
.gitattributes
vendored
2
.gitattributes
vendored
|
@ -11,6 +11,8 @@
|
|||
/configure -text
|
||||
/configure.in -text
|
||||
/highscores.c -text
|
||||
html/ys.tpl -text
|
||||
/htmlscores.c -text
|
||||
/install-sh -text
|
||||
/misc.c -text
|
||||
/modconfig.h.in -text
|
||||
|
|
|
@ -2,6 +2,7 @@ YahtzeeServ Module for NeoStats Changelog.
|
|||
Fish (F), Mark (M), DeadNotBuried (D)
|
||||
==============================================================================
|
||||
3.0.a3-dev
|
||||
- add HTML High Score page generation (D)
|
||||
- allow Yahtzee to substitue for Full House Short/Long Straight when
|
||||
yahtzee already scored 50 , No bonus points given. (D)
|
||||
- add segfault locations (D)
|
||||
|
|
|
@ -8,13 +8,13 @@ INSTALL_DATA = @INSTALL_DATA@
|
|||
DIRECTORY = @DIRINST@/modules/
|
||||
INCLUDES = -I@DIRINST@/include/ -I.
|
||||
|
||||
SRCS= yahtzeeserv.c yahtzeeserv_help.c play.c misc.c highscores.c channel.c
|
||||
SRCS= yahtzeeserv.c yahtzeeserv_help.c play.c misc.c highscores.c channel.c htmlscores.c
|
||||
OBJS= ${SRCS:.c=.o}
|
||||
TARGET= yahtzeeserv.so
|
||||
DOCS=README.YahtzeeServ
|
||||
DATA=
|
||||
DATA=html/ys.tpl
|
||||
SCRIPTS=
|
||||
DISTFILES=$(SRCS) $(DOCS) $(SCRIPTS) *.in configure install-sh ChangeLog *.h LICENSE RELNOTES yahtzeeserv.vcproj modconfigwin32.h
|
||||
DISTFILES=$(SRCS) $(DATA) $(DOCS) $(SCRIPTS) *.in configure install-sh ChangeLog *.h LICENSE RELNOTES yahtzeeserv.vcproj modconfigwin32.h
|
||||
DISTDIR= @PACKAGE@-@VERSION@
|
||||
|
||||
all: module
|
||||
|
@ -41,6 +41,7 @@ distclean:
|
|||
install: module
|
||||
$(INSTALL) -m 644 $(TARGET) $(DIRECTORY)
|
||||
$(INSTALL) -m 644 $(DOCS) $(DIRECTORY)../doc/
|
||||
$(INSTALL) -m 644 $(DATA) $(DIRECTORY)../data/
|
||||
@echo "Installation complete."
|
||||
@echo "See the README file for instructions on loading this module."
|
||||
|
||||
|
|
|
@ -208,6 +208,8 @@ void clearyahtzeescores(int clearscore)
|
|||
}
|
||||
list_sort(highscores, sortlistbytypepos);
|
||||
DBACloseTable("Scores");
|
||||
if( YahtzeeServ.html )
|
||||
ys_HTMLOutput();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -451,6 +453,9 @@ void checkhighscorelists(Channel *c)
|
|||
}
|
||||
ln = list_next(highscores, ln);
|
||||
}
|
||||
} else {
|
||||
if( YahtzeeServ.html )
|
||||
ys_HTMLOutput();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
130
html/ys.tpl
Normal file
130
html/ys.tpl
Normal file
|
@ -0,0 +1,130 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
|
||||
<title>YahtzeeServ High Scores</title>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
|
||||
BODY {background-color:#444444;color:#ECECEC}
|
||||
P {font-family:Verdana, serif;font-size:10pt}
|
||||
|
||||
TH {background-color:#66555F;color:#ECECEC;font-family:Arial, Helvetica, sans-serif;font-size:8pt;font-weight:bold}
|
||||
TH.secondary {background-color:#66555F;color:#ECECEC;font-family:Verdana, serif;font-size:10pt;font-weight:normal;text-align:left}
|
||||
TD.tablebg {background-color:#000000}
|
||||
TD.cat {background-color:#80707F;font-family:Verdana, serif;font-size:12pt}
|
||||
TD.row1 {background-color:#60707D}
|
||||
TD.row2 {background-color:#667A80}
|
||||
|
||||
SPAN.title {font-family:Arial, Helvetica, sans-serif;font-size:26pt}
|
||||
SPAN.cattitle {font-family:Verdana, serif;font-size:12pt;font-weight:bold}
|
||||
SPAN.gen {font-family:Verdana, serif;font-size:10pt}
|
||||
SPAN.gensmall {font-family:Verdana, serif;font-size:8pt}
|
||||
SPAN.courier {font-family:courier;font-size:10pt}
|
||||
|
||||
SELECT {font-family:Verdana;font-size:8pt}
|
||||
INPUT {font-family:Verdana;font-size:8pt}
|
||||
SELECT.small {font-family:"Courier New",courier;font-size:8pt;width:140px}
|
||||
INPUT.text {font-family:"Courier New",courier;font-size:8pt;}
|
||||
|
||||
INPUT.outsidetable {background-color:#60707D}
|
||||
INPUT.mainoptiontable {background-color:#60707D}
|
||||
INPUT.liteoptiontable {background-color:#60707D}
|
||||
|
||||
A.forumlinks {font-weight:bold}
|
||||
A {text-decoration:none}
|
||||
A:hover {color:#EDF2F2;text-decoration:underline}
|
||||
|
||||
HR {height:2px}
|
||||
|
||||
//-->
|
||||
</style>
|
||||
</head>
|
||||
<body bgcolor="#444444" text="#ECECEC" link="#EDF2F2" vlink="#DDEDED">
|
||||
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="98%" cellpadding="0" cellspacing="0" border="0" align="center">
|
||||
<tr>
|
||||
<td class="tablebg" width="100%"><table width="100%" cellspacing="1" cellpadding="4" border="0">
|
||||
<tr>
|
||||
<td class="row2"><table width="100%" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td><a href="http://www.neostats.net/" target=_NEW>
|
||||
<img border="0" src="http://www.neostats.net/neostats.gif" alt="NeoStats"></a>
|
||||
</td>
|
||||
<td align="center" valign="top" bordercolorlight="#000000" bordercolor="#000000"><span class=title>!TITLE!</span></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1"><table width="100%" cellspacing="0" cellpadding="4" border="0">
|
||||
<tr>
|
||||
<td width="90%"><span class="gensmall"><center>
|
||||
<a href="#high">Overall High Scores</a> <font color="#444444">|</font>
|
||||
<a href="#daily">Todays High Scores</a> <font color="#444444">|</font>
|
||||
<a href="#weekly">This Weeks High Scores</a> <font color="#444444">|</font>
|
||||
<a href="#monthly">This Months High Scores</a> <font color="#444444">|</font>
|
||||
</center></span></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="98%" cellspacing="0" cellpadding="4" border="0" align="center">
|
||||
<tr>
|
||||
<td align="left" valign="bottom">
|
||||
<p align="right"><span class="gensmall">Version is: !VERSION!</span></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="98%" cellpadding="0" cellspacing="0" border="0" align="center">
|
||||
<tr>
|
||||
<td class="tablebg"><table width="100%" cellpadding="0"
|
||||
cellspacing="0" border="1">
|
||||
<tr>
|
||||
<td class="cat" height="30"><span class="cattitle">Overall High Scores</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1" align="center">
|
||||
<a name=netstats></a>!HIGHSCORES!
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="cat" height="30"><span class="cattitle">Todays High Scores</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1" align="center">
|
||||
<a name=daily></a>!DAILYSCORES!
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cat" height="30"><span class="cattitle">This Weeks High Scores</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1" align="center">
|
||||
<a name=weekly></a>!WEEKLYSCORES!
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cat" height="30"><span class="cattitle">This Months High Scores</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1" align="center">
|
||||
<a name=monthly></a>!MONTHLYSCORES!
|
||||
</td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
</body>
|
||||
</html>
|
301
htmlscores.c
Normal file
301
htmlscores.c
Normal file
|
@ -0,0 +1,301 @@
|
|||
/* YahtzeeServ - Yahtzee Game Service - NeoStats Addon Module
|
||||
** Copyright (c) 2003-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
|
||||
**
|
||||
** YahtzeeServ CVS Identification
|
||||
** $Id: highscores.c 26 2005-10-15 18:06:38Z DNB $
|
||||
*/
|
||||
|
||||
#include "neostats.h" /* Required for bot support */
|
||||
#include "yahtzeeserv.h"
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif /* HAVE_FCNTL_H */
|
||||
|
||||
/** HTML output handler type */
|
||||
typedef void( *htmlhandler )( void );
|
||||
|
||||
/** HTML handler table struct */
|
||||
typedef struct htmlfunc {
|
||||
char* directive;
|
||||
htmlhandler handler;
|
||||
}htmlfunc;
|
||||
|
||||
#define TABLE_START( opf ) os_fprintf( ( opf ), "<table border = 0>" );
|
||||
#define TABLE_END( opf ) os_fprintf( opf, "</table>" );
|
||||
|
||||
/** HTML handler prototypes */
|
||||
static void html_title( void );
|
||||
static void html_version( void );
|
||||
static void put_copyright( void );
|
||||
static void html_highscores( void );
|
||||
static void html_dailyscores( void );
|
||||
static void html_weeklyscores( void );
|
||||
static void html_monthlyscores( void );
|
||||
|
||||
/** Output file pointer */
|
||||
static FILE *opf;
|
||||
/** Output file template */
|
||||
static const char html_template[]="data/ys.tpl";
|
||||
|
||||
/** HTML handler lookup table */
|
||||
static htmlfunc htmlfuncs[]=
|
||||
{
|
||||
{"!HIGHSCORES!", html_highscores},
|
||||
{"!DAILYSCORES!", html_dailyscores},
|
||||
{"!WEEKLYSCORES!", html_weeklyscores},
|
||||
{"!MONTHLYSCORES!", html_monthlyscores},
|
||||
{"!VERSION!", html_version},
|
||||
{"!TITLE!", html_title},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
||||
/** @brief html_title
|
||||
*
|
||||
* HTML handler for title
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
|
||||
static void html_title( void )
|
||||
{
|
||||
os_fprintf( opf, "YahtzeeServ High Scores for %s", me.netname );
|
||||
}
|
||||
|
||||
/** @brief html_version
|
||||
*
|
||||
* HTML handler for version
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
|
||||
static void html_version( void )
|
||||
{
|
||||
os_fputs( me.version, opf );
|
||||
}
|
||||
|
||||
/** @brief put_copyright
|
||||
*
|
||||
* HTML handler for copyright footer
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
|
||||
static void put_copyright( void )
|
||||
{
|
||||
os_fprintf( opf, "<br><br><center>Scores last changed at %s<br>", sftime( time( NULL ) ) );
|
||||
os_fprintf( opf, "<b>YahtzeeServ Information:</b>\n" );
|
||||
os_fprintf( opf, "<br> %s compiled on %s at %s\n", me.name, version_date, version_time );
|
||||
os_fprintf( opf, "<br> %s compiled on %s at %s\n", module_info.name,
|
||||
module_info.build_date, module_info.build_time );
|
||||
os_fprintf( opf, "<br><a href=\"http://www.neostats.net\">http://www.neostats.net</a>\n" );
|
||||
os_fprintf( opf, "</center>\n" );
|
||||
}
|
||||
|
||||
/** @brief html_highscores
|
||||
*
|
||||
* HTML handler for High Scores
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
|
||||
static void html_highscores( void )
|
||||
{
|
||||
lnode_t *ln;
|
||||
HighScoreData *hs;
|
||||
|
||||
list_sort(highscores, sortlistbytypepos);
|
||||
TABLE_START( opf );
|
||||
os_fprintf( opf, "<tr><th>Nickname<b></b></th><th><b>Score</b></th></tr>\n" );
|
||||
ln = list_first(highscores);
|
||||
while (ln)
|
||||
{
|
||||
hs = lnode_get(ln);
|
||||
if (hs->type == 'O')
|
||||
os_fprintf( opf, "<tr><td>%s</td><td>%d</td>\n", hs->name, hs->score );
|
||||
ln = list_next(highscores, ln);
|
||||
}
|
||||
TABLE_END( opf );
|
||||
}
|
||||
|
||||
/** @brief html_dailyscores
|
||||
*
|
||||
* HTML handler for daily scores
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
|
||||
static void html_dailyscores( void )
|
||||
{
|
||||
lnode_t *ln;
|
||||
HighScoreData *hs;
|
||||
|
||||
list_sort(highscores, sortlistbytypepos);
|
||||
TABLE_START( opf );
|
||||
os_fprintf( opf, "<tr><th>Nickname<b></b></th><th><b>Score</b></th></tr>\n" );
|
||||
ln = list_first(highscores);
|
||||
while (ln)
|
||||
{
|
||||
hs = lnode_get(ln);
|
||||
if (hs->type == 'D')
|
||||
os_fprintf( opf, "<tr><td>%s</td><td>%d</td>\n", hs->name, hs->score );
|
||||
ln = list_next(highscores, ln);
|
||||
}
|
||||
TABLE_END( opf );
|
||||
}
|
||||
|
||||
/** @brief html_weeklycores
|
||||
*
|
||||
* HTML handler for weekly scores
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
|
||||
static void html_weeklyscores( void )
|
||||
{
|
||||
lnode_t *ln;
|
||||
HighScoreData *hs;
|
||||
|
||||
list_sort(highscores, sortlistbytypepos);
|
||||
TABLE_START( opf );
|
||||
os_fprintf( opf, "<tr><th>Nickname<b></b></th><th><b>Score</b></th></tr>\n" );
|
||||
ln = list_first(highscores);
|
||||
while (ln)
|
||||
{
|
||||
hs = lnode_get(ln);
|
||||
if (hs->type == 'W')
|
||||
os_fprintf( opf, "<tr><td>%s</td><td>%d</td>\n", hs->name, hs->score );
|
||||
ln = list_next(highscores, ln);
|
||||
}
|
||||
TABLE_END( opf );
|
||||
}
|
||||
|
||||
/** @brief html_monthlyscores
|
||||
*
|
||||
* HTML handler for monthly scores
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
|
||||
static void html_monthlyscores( void )
|
||||
{
|
||||
lnode_t *ln;
|
||||
HighScoreData *hs;
|
||||
|
||||
list_sort(highscores, sortlistbytypepos);
|
||||
TABLE_START( opf );
|
||||
os_fprintf( opf, "<tr><th>Nickname<b></b></th><th><b>Score</b></th></tr>\n" );
|
||||
ln = list_first(highscores);
|
||||
while (ln)
|
||||
{
|
||||
hs = lnode_get(ln);
|
||||
if (hs->type == 'M')
|
||||
os_fprintf( opf, "<tr><td>%s</td><td>%d</td>\n", hs->name, hs->score );
|
||||
ln = list_next(highscores, ln);
|
||||
}
|
||||
TABLE_END( opf );
|
||||
}
|
||||
|
||||
/** @brief ys_HTMLOutput
|
||||
*
|
||||
* output HTML file
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
|
||||
void ys_HTMLOutput( void )
|
||||
{
|
||||
#define HTMLREADBUFSIZE 512
|
||||
static char buf[HTMLREADBUFSIZE];
|
||||
FILE *tpl;
|
||||
char *buftemp;
|
||||
char *bufptr;
|
||||
htmlfunc* htmlfuncptr;
|
||||
|
||||
tpl = os_fopen( html_template, "rt" );
|
||||
if( !tpl ) {
|
||||
nlog( LOG_WARNING, "Failed to open YahtzeeServ HTML template %s.", html_template );
|
||||
irc_chanalert( ys_bot, "Failed to open YahtzeeServ HTML template %s.", html_template );
|
||||
return;
|
||||
}
|
||||
opf = os_fopen( YahtzeeServ.htmlpath, "wt" );
|
||||
if( !opf ) {
|
||||
nlog( LOG_WARNING, "Failed to open HTML output file %s. Check file permissions.", YahtzeeServ.htmlpath );
|
||||
irc_chanalert( ys_bot, "Failed to open HTML output file %s. Check file permissions.", YahtzeeServ.htmlpath );
|
||||
return;
|
||||
}
|
||||
while( os_fgets( buf, HTMLREADBUFSIZE, tpl ) ) {
|
||||
bufptr = buf;
|
||||
htmlfuncptr = htmlfuncs;
|
||||
while( htmlfuncptr->directive ) {
|
||||
buftemp = strstr( bufptr, htmlfuncptr->directive );
|
||||
if( buftemp ) {
|
||||
os_fwrite( bufptr, ( int )buftemp -( int )bufptr, 1, opf );
|
||||
htmlfuncptr->handler();
|
||||
bufptr = buftemp + strlen( htmlfuncptr->directive );
|
||||
}
|
||||
htmlfuncptr++;
|
||||
}
|
||||
buftemp = strcasestr( bufptr, "</html>" );
|
||||
if( buftemp ) {
|
||||
os_fwrite( bufptr, ( int )buftemp -( int )bufptr, 1, opf );
|
||||
put_copyright();
|
||||
bufptr = buftemp;
|
||||
os_fputs( bufptr, opf );
|
||||
} else {
|
||||
os_fputs( bufptr, opf );
|
||||
}
|
||||
}
|
||||
os_fclose( tpl );
|
||||
os_fclose( opf );
|
||||
/* update the umode so others can read it and owner can overwrite it */
|
||||
chmod(YahtzeeServ.htmlpath, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
|
||||
}
|
||||
|
||||
/** @brief ss_cmd_forcehtml
|
||||
*
|
||||
* FORCEHTML command handler
|
||||
* Reports current statistics to requesting user
|
||||
*
|
||||
* @param cmdparams
|
||||
*
|
||||
* @return NS_SUCCESS if succeeds, else NS_FAILURE
|
||||
*/
|
||||
|
||||
int ys_cmd_forcehtml( const CmdParams *cmdparams )
|
||||
{
|
||||
nlog( LOG_NOTICE, "%s!%s@%s forced an update of the HTML file.",
|
||||
cmdparams->source->name, cmdparams->source->user->username, cmdparams->source->user->hostname );
|
||||
ys_HTMLOutput();
|
||||
return NS_SUCCESS;
|
||||
}
|
102
yahtzeeserv.c
102
yahtzeeserv.c
|
@ -43,30 +43,33 @@ const char *ys_about[] = {
|
|||
*/
|
||||
static bot_cmd ys_commands[]=
|
||||
{
|
||||
{"START", StartYahtzeeGame, 0, 0, ys_help_start},
|
||||
{"STOP", StopYahtzeeGame, 0, 0, ys_help_stop, CMD_FLAG_CHANONLY},
|
||||
{"JOIN", JoinYahtzeeGame, 0, 0, ys_help_join, CMD_FLAG_CHANONLY},
|
||||
{"REMOVE", RemoveYahtzeeGame, 0, 0, ys_help_remove, CMD_FLAG_CHANONLY},
|
||||
{"PLAYERS", ShowPlayersYahtzeeGame, 0, 0, ys_help_players, CMD_FLAG_CHANONLY},
|
||||
{"TURN", ShowTurnYahtzeeGame, 0, 0, ys_help_turn, CMD_FLAG_CHANONLY},
|
||||
{"PASS", PassYahtzeeGame, 1, 0, ys_help_pass, CMD_FLAG_CHANONLY},
|
||||
{"DICE", ShowYahtzeeDice, 0, 0, ys_help_dice, CMD_FLAG_CHANONLY},
|
||||
{"SHEET", ShowYahtzeeSheet, 0, 0, ys_help_sheet, CMD_FLAG_CHANONLY},
|
||||
{"ROLL", RollYahtzeeDice, 0, 0, ys_help_roll, CMD_FLAG_CHANONLY},
|
||||
{"KEEP", KeepYahtzeeDice, 0, 0, ys_help_keep, CMD_FLAG_CHANONLY},
|
||||
{"SCORE", ScoreYahtzeeDice, 1, 0, ys_help_score, CMD_FLAG_CHANONLY},
|
||||
{"TOP10", ShowTop10Lists, 0, 0, ys_help_top10},
|
||||
{"HIGH", ShowHighList, 0, 0, ys_help_high},
|
||||
{"RULES", ShowRulePages, 0, 0, ys_help_rules},
|
||||
{"START", StartYahtzeeGame, 0, 0, ys_help_start},
|
||||
{"STOP", StopYahtzeeGame, 0, 0, ys_help_stop, CMD_FLAG_CHANONLY},
|
||||
{"JOIN", JoinYahtzeeGame, 0, 0, ys_help_join, CMD_FLAG_CHANONLY},
|
||||
{"REMOVE", RemoveYahtzeeGame, 0, 0, ys_help_remove, CMD_FLAG_CHANONLY},
|
||||
{"PLAYERS", ShowPlayersYahtzeeGame, 0, 0, ys_help_players, CMD_FLAG_CHANONLY},
|
||||
{"TURN", ShowTurnYahtzeeGame, 0, 0, ys_help_turn, CMD_FLAG_CHANONLY},
|
||||
{"PASS", PassYahtzeeGame, 1, 0, ys_help_pass, CMD_FLAG_CHANONLY},
|
||||
{"DICE", ShowYahtzeeDice, 0, 0, ys_help_dice, CMD_FLAG_CHANONLY},
|
||||
{"SHEET", ShowYahtzeeSheet, 0, 0, ys_help_sheet, CMD_FLAG_CHANONLY},
|
||||
{"ROLL", RollYahtzeeDice, 0, 0, ys_help_roll, CMD_FLAG_CHANONLY},
|
||||
{"KEEP", KeepYahtzeeDice, 0, 0, ys_help_keep, CMD_FLAG_CHANONLY},
|
||||
{"SCORE", ScoreYahtzeeDice, 1, 0, ys_help_score, CMD_FLAG_CHANONLY},
|
||||
{"TOP10", ShowTop10Lists, 0, 0, ys_help_top10},
|
||||
{"HIGH", ShowHighList, 0, 0, ys_help_high},
|
||||
{"RULES", ShowRulePages, 0, 0, ys_help_rules},
|
||||
{"FORCEHTML", ys_cmd_forcehtml, 0, NS_ULEVEL_ADMIN, ys_help_forcehtml},
|
||||
NS_CMD_END()
|
||||
};
|
||||
|
||||
static bot_setting ys_settings[]=
|
||||
{
|
||||
{"EXCLUSIONS", &YahtzeeServ.exclusions, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, ys_help_set_exclusions, NULL, (void *)0 },
|
||||
{"CHAN", &YahtzeeServ.yahtzeeroom, SET_TYPE_CHANNEL, 0, MAXCHANLEN, NS_ULEVEL_ADMIN, NULL, ys_help_set_chan, ys_cmd_set_chan, (void *)"#Games_Yahtzee" },
|
||||
{"MULTICHAN", &YahtzeeServ.multichan, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, ys_help_set_multichan, NULL, (void *)0 },
|
||||
{"CHANOPONLY", &YahtzeeServ.chanoponly, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, ys_help_set_chanoponly, NULL, (void *)0 },
|
||||
{"EXCLUSIONS", &YahtzeeServ.exclusions, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, ys_help_set_exclusions, NULL, ( void * )0 },
|
||||
{"CHAN", &YahtzeeServ.yahtzeeroom, SET_TYPE_CHANNEL, 0, MAXCHANLEN, NS_ULEVEL_ADMIN, NULL, ys_help_set_chan, ys_cmd_set_chan, ( void * )"#Games_Yahtzee" },
|
||||
{"MULTICHAN", &YahtzeeServ.multichan, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, ys_help_set_multichan, NULL, ( void * )0 },
|
||||
{"CHANOPONLY", &YahtzeeServ.chanoponly, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, ys_help_set_chanoponly, NULL, ( void * )0 },
|
||||
{"HTML", &YahtzeeServ.html, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, ys_help_set_html, ys_cmd_set_html, ( void * )0},
|
||||
{"HTMLPATH", &YahtzeeServ.htmlpath, SET_TYPE_STRING, 0, MAXPATH, NS_ULEVEL_ADMIN, NULL, ys_help_set_htmlpath, ys_cmd_set_htmlpath, ( void * )""},
|
||||
NS_SETTING_END()
|
||||
};
|
||||
|
||||
|
@ -129,6 +132,8 @@ int ModSynch (void)
|
|||
ys_bot = AddBot (&ys_botinfo);
|
||||
if (!ys_bot)
|
||||
return NS_FAILURE;
|
||||
if( YahtzeeServ.html )
|
||||
ys_HTMLOutput();
|
||||
srand((unsigned int)me.now);
|
||||
irc_chanalert (ys_bot, "Game will start in %s", YahtzeeServ.yahtzeeroom);
|
||||
irc_join (ys_bot, YahtzeeServ.yahtzeeroom, "+o");
|
||||
|
@ -178,3 +183,62 @@ int ModFini( void )
|
|||
DelTimer ("yahtzeetimer");
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/** @brief ys_cmd_set_html
|
||||
*
|
||||
* Set callback for SET HTML
|
||||
* Enable or disable html output
|
||||
*
|
||||
* @params cmdparams pointer to commands param struct
|
||||
* @params reason for SET
|
||||
*
|
||||
* @return NS_SUCCESS if suceeds else NS_FAILURE
|
||||
*/
|
||||
|
||||
int ys_cmd_set_html( const CmdParams *cmdparams, SET_REASON reason )
|
||||
{
|
||||
if( reason == SET_CHANGE )
|
||||
{
|
||||
if( YahtzeeServ.html && YahtzeeServ.htmlpath[0] == 0 )
|
||||
{
|
||||
irc_prefmsg ( ys_bot, cmdparams->source,
|
||||
"You need to SET HTMLPATH. HTML output disabled." );
|
||||
YahtzeeServ.html = 0;
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
if( YahtzeeServ.html && YahtzeeServ.htmlpath[0] != 0 )
|
||||
ys_HTMLOutput();
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/** @brief ys_cmd_set_htmlpath
|
||||
*
|
||||
* Set callback for SET HTMLPATH
|
||||
* Change html output path
|
||||
*
|
||||
* @params cmdparams pointer to commands param struct
|
||||
* @params reason for SET
|
||||
*
|
||||
* @return NS_SUCCESS if suceeds else NS_FAILURE
|
||||
*/
|
||||
|
||||
int ys_cmd_set_htmlpath( const CmdParams *cmdparams, SET_REASON reason )
|
||||
{
|
||||
FILE *opf;
|
||||
|
||||
if( reason == SET_CHANGE )
|
||||
{
|
||||
opf = os_fopen( YahtzeeServ.htmlpath, "wt" );
|
||||
if( !opf )
|
||||
{
|
||||
irc_prefmsg( ys_bot, cmdparams->source,
|
||||
"Failed to open HTML output file %s. Check file permissions. HTML output disabled.", YahtzeeServ.htmlpath );
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
os_fclose( opf );
|
||||
if( YahtzeeServ.html )
|
||||
ys_HTMLOutput();
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ extern const char *ys_help_set_exclusions[];
|
|||
extern const char *ys_help_set_chan[];
|
||||
extern const char *ys_help_set_multichan[];
|
||||
extern const char *ys_help_set_chanoponly[];
|
||||
extern const char *ys_help_set_html[];
|
||||
extern const char *ys_help_set_htmlpath[];
|
||||
extern const char *ys_help_start[];
|
||||
extern const char *ys_help_stop[];
|
||||
extern const char *ys_help_join[];
|
||||
|
@ -49,6 +51,7 @@ extern const char *ys_help_rules_page_1[];
|
|||
extern const char *ys_help_rules_page_2[];
|
||||
extern const char *ys_help_rules_page_3[];
|
||||
extern const char *ys_help_rules_page_4[];
|
||||
extern const char *ys_help_forcehtml[];
|
||||
|
||||
/*
|
||||
* Defines
|
||||
|
@ -74,6 +77,8 @@ struct YahtzeeServ {
|
|||
int exclusions;
|
||||
int multichan;
|
||||
int chanoponly;
|
||||
int html;
|
||||
char htmlpath[MAXPATH];
|
||||
} YahtzeeServ;
|
||||
|
||||
typedef struct Players {
|
||||
|
@ -114,6 +119,10 @@ extern char dicetext[5][15];
|
|||
* Procedures
|
||||
*/
|
||||
|
||||
/* yahzteeserv.c */
|
||||
int ys_cmd_set_html( const CmdParams *cmdparams, SET_REASON reason );
|
||||
int ys_cmd_set_htmlpath( const CmdParams *cmdparams, SET_REASON reason );
|
||||
|
||||
/* channel.c */
|
||||
int ys_cmd_set_chan (const CmdParams *cmdparams, SET_REASON reason);
|
||||
void CreateChannelGameData(Channel *c);
|
||||
|
@ -155,3 +164,7 @@ void RollDice(Channel *c);
|
|||
int RollYahtzeeDice (const CmdParams *cmdparams);
|
||||
int KeepYahtzeeDice (const CmdParams *cmdparams);
|
||||
void reroll (const CmdParams *cmdparams, int rolltype);
|
||||
|
||||
/* htmlscores */
|
||||
void ys_HTMLOutput( void );
|
||||
int ys_cmd_forcehtml( const CmdParams *cmdparams );
|
||||
|
|
|
@ -43,6 +43,19 @@ const char *ys_help_set_chanoponly[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
const char *ys_help_set_htmlpath[] = {
|
||||
"\2HTMLPATH <path>\2",
|
||||
"Set the full pathname including filename used to write HTML",
|
||||
"high scores when HTML is enabled",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *ys_help_set_html[] = {
|
||||
"\2HTML <ON|OFF>\2",
|
||||
"Enable or disable HTML High Scores generation.",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *ys_help_start[] = {
|
||||
"Start Game",
|
||||
"Syntax: \2START\2",
|
||||
|
@ -310,3 +323,11 @@ const char *ys_help_rules_page_4[] = {
|
|||
"NOTE: You must receive points when scoring to receive the Bonus.",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *ys_help_forcehtml[] = {
|
||||
"Force output of the HTML High Scores",
|
||||
"Syntax: \2FORCEHTML\2",
|
||||
"",
|
||||
"Forces an immediate update of the HTML High Scores output.",
|
||||
NULL
|
||||
};
|
||||
|
|
Reference in a new issue