/* --------------------------------------------
 * Automated Auction for ROM24, v1.00 - 2/28/99
 * --------------------------------------------
 * This code provides a full-featured automatic
 * auction system/channel for your mud. Follow
 * the instructions below to install, and
 * please send me an email if you decide to
 * use this code, it means a lot to me! I'd
 * love to hear about any bugs, suggestions,
 * etc. that you may have.
 *
 * Thanks,
 *
 * Brian Babey (aka Varen)
 * [bbabey@iname.com]
 * http://www.erols.com/bribe/
 * ------------------------------------------ */


/* -----------------------------------------------
 * First, copy the included auction.c to your src
 * directory, and add auction.o to the O_FILES
 * section of your Makefile. */


/* -----------------------------------------------
 * Add these lines to your merc.h in the
 * appropriate areas; it doesn't *really* matter
 * where you put them but it's good practice to put 
 * each item with the others like it. */

typedef struct	auction_data		AUCTION_DATA;


struct auction_data
{
	OBJ_DATA *	item;
	CHAR_DATA *	owner;
	CHAR_DATA *	high_bidder;
	sh_int		status;
	long		current_bid;
	long		silver_held;
	long		gold_held;
};


extern          AUCTION_DATA            auction_info;


#define PULSE_AUCTION             (20 * PULSE_PER_SECOND)


#define MINIMUM_BID			100
#define AUCTION_LENGTH			  5


/* -----------------------------------------------
 * In db.c, just before the list of gsn's begins,
 * you'll find a line looking like this:
 *
 * WEATHER_DATA              weather_info;
 *
 * After it, insert this line: */

AUCTION_DATA            auction_info;


/* -----------------------------------------------
 * In db.c, inside boot_db, near the top of the
 * function, just before the section titled
 * "Set time and weather.", add these lines: */

    auction_info.item           = NULL;
    auction_info.owner          = NULL;
    auction_info.high_bidder    = NULL;
    auction_info.current_bid    = 0;
    auction_info.status         = 0;
    auction_info.gold_held	= 0;
    auction_info.silver_held	= 0;


/* -----------------------------------------------
 * Add these lines into merc.h where the function
 * prototypes are listed. */

/* auction.c */
void    auction_update  args( ( void ) );
void    auction_channel args( ( char *msg ) );


/* -----------------------------------------------
 * At the top of update_handler in update.c, add
 * this declaration. */

    static	int	pulse_auction;


/* -----------------------------------------------
 * Inside update_handler in update.c, add these
 * lines in between two of the other pulse update
 * checks ( pulse_area, pulse_music, etc. ) */

    if ( --pulse_auction        <= 0 )
    {
        pulse_auction   = PULSE_AUCTION;
        auction_update( );
    }


/* -----------------------------------------------
 * Find do_quit in act_comm.c and add these lines
 * after the check for POS_STUNNED, before the
 * quit message is sent. */

    if ( auction_info.high_bidder == ch || auction_info.owner == ch )
    {
        send_to_char("You still have a stake in the auction!\n\r",ch);
        return;
    }


/* -----------------------------------------------
 * Go into act_comm.c and remove the do_auction 
 * function completely, or comment it out if you
 * wish to keep it for odd reasons. */


/* -----------------------------------------------
 * Add this help file into your helps with a level
 * of -1 and keyword of 'AUCTION' */

Syntax: auction                   toggle auction channel on/off
        auction info              view info about current item
        auction bid <amount>      place bid for the current item
        auction <item name>       put an item up for auction


/* -----------------------------------------------
 * Lines below will already be in place if you are
 * running stock ROM, but if you have changed your
 * auction code or removed it, you'll need to put
 * them in. */

[merc.h]

#DEFINE COMM_NOAUCTION		(D)	/* or next available letter */


[interp.h]

DECLARE_DO_FUN		(	do_auction	);


[interp.c] /* inside the command table */

{ "auction",        do_auction,     POS_SLEEPING,    0,  LOG_NORMAL, 1 },
