2005-03-27 14:59:59 +00:00
/* GamesServ - Small Games Service - NeoStats Addon Module
2006-01-26 15:33:00 +00:00
* * Copyright ( c ) 2006 Justin Hammond , Mark Hetherington , DeadNotBuried
2005-03-27 14:59:59 +00:00
* *
* * 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
* *
* * GamesServ CVS Identification
* * $ Id $
*/
# include "neostats.h" /* Required for bot support */
# include "gamesserv.h"
2005-10-18 22:13:38 +00:00
static void stophilo ( char * nic , int hlg ) ;
2005-03-27 14:59:59 +00:00
static int num_low ;
static int num_high ;
static int num ;
2005-10-18 22:13:38 +00:00
/*
* HiLO Timer Finished
*/
int timerupstophilo ( void * userptr ) {
stophilo ( " " , 0 ) ;
return NS_SUCCESS ;
}
2005-03-27 14:59:59 +00:00
/*
* Start HiLo Game
*/
2005-10-13 22:39:49 +00:00
int starthilo ( const CmdParams * cmdparams ) {
2005-10-18 22:25:50 +00:00
if ( CheckGameStart ( cmdparams - > source , cmdparams - > av [ 0 ] , GS_GAME_CHANNEL_HILO , 120 , NS_FALSE , NS_TRUE ) ! = NS_SUCCESS ) {
2005-03-31 02:33:10 +00:00
return NS_SUCCESS ;
2005-03-27 14:59:59 +00:00
}
2005-03-31 02:33:10 +00:00
num_low = ( rand ( ) % 999000 ) ;
num = ( num_low + ( rand ( ) % 999 ) + 1 ) ;
num_high = ( num_low + 1000 ) ;
2005-05-26 02:29:33 +00:00
irc_chanprivmsg ( gs_bot , gameroom [ GS_GAME_CHANNEL_HILO ] , " \003 7A game of HiLo has been started by %s. Can you guess the number between %d and %d. " , cmdparams - > source - > name , num_low , num_high ) ;
2005-08-09 12:17:31 +00:00
AddTimer ( TIMER_TYPE_COUNTDOWN , timerupstophilo , " hilocountdown " , countdowntime [ GS_GAME_CHANNEL_HILO ] , NULL ) ;
2005-03-27 14:59:59 +00:00
return NS_SUCCESS ;
}
/*
* Guess Number
*/
2005-10-13 22:39:49 +00:00
int guesshilo ( const CmdParams * cmdparams ) {
2005-03-27 14:59:59 +00:00
int hlg ;
2005-05-26 02:29:33 +00:00
if ( gamestatus [ GS_GAME_CHANNEL_HILO ] = = GS_GAME_CHANNEL_PLAYING ) {
2005-03-27 14:59:59 +00:00
hlg = atoi ( cmdparams - > av [ 0 ] ) ;
if ( hlg = = num ) {
stophilo ( cmdparams - > source - > name , hlg ) ;
return NS_SUCCESS ;
}
if ( hlg > num_low & & hlg < num_high ) {
if ( hlg < num ) {
num_low = hlg ;
} else {
num_high = hlg ;
}
2005-05-26 02:29:33 +00:00
irc_chanprivmsg ( gs_bot , gameroom [ GS_GAME_CHANNEL_HILO ] , " \003 7%s You are a bit closer with %d , number is between %d and %d. " , cmdparams - > source - > name , hlg , num_low , num_high ) ;
2005-03-27 14:59:59 +00:00
return NS_SUCCESS ;
}
}
return NS_SUCCESS ;
}
/*
* Stop HiLo Game
*/
2005-10-18 22:13:38 +00:00
static void stophilo ( char * nic , int hlg ) {
2005-03-27 14:59:59 +00:00
if ( ! hlg ) {
2005-05-26 02:29:33 +00:00
irc_chanprivmsg ( gs_bot , gameroom [ GS_GAME_CHANNEL_HILO ] , " \003 7Times Up, it looks like your all Losers :) " ) ;
2005-03-27 14:59:59 +00:00
} else {
2005-05-26 02:29:33 +00:00
irc_chanprivmsg ( gs_bot , gameroom [ GS_GAME_CHANNEL_HILO ] , " \003 7%s is correct with %d and wins, the rest of you are just Losers :) " , nic , hlg ) ;
2005-03-27 14:59:59 +00:00
DelTimer ( " hilocountdown " ) ;
}
2005-05-26 02:29:33 +00:00
CheckPartGameChannel ( GS_GAME_CHANNEL_HILO ) ;
2005-03-27 14:59:59 +00:00
}