#include <sys/types.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "emlen.h" int e_bidders=0; int g_bidders=0; CHAR_DATA *e_auction_lastbidder=NULL; CHAR_DATA *auction_lastbidder=NULL; void do_e_bid (CHAR_DATA * ch, char *argy) { int obid; char general_use[STD_LENGTH*5]; if (e_auction_item[0] == '\0') { send_to_char ("Nothing is currently up for auction.\n\r", ch); return; } if (!ch->pcdata->listen_auction) { ch->pcdata->listen_auction = TRUE; send_to_char ("You have now tuned into bidding for this item.\n\r", ch); } if (argy[0] == '\0') { sprintf (general_use, "Up for bid: %s\x1B[37;0m by %s\n\r", e_auction_item, NAME (e_auction_char)); send_to_char (general_use, ch); sprintf (general_use, "Current bid: %d coins. Minimum bid was: %d coins.\n\r", e_auction_bid, e_auction_minbid); send_to_char (general_use, ch); send_to_char ("Type bid <amount> to bid for the item.\n\r", ch); return; } if (ch == e_auction_char) { send_to_char ("You can't bid on your own item!\n\r", ch); return; } if (ch == e_auction_tochar) { send_to_char("You already have the highest bid on the item.\n\r", ch); return; } if (!is_number (argy)) { send_to_char ("Bids are a number of copper coins. EX: bid 1500\n\r", ch); return; } obid = atoi (argy); if (obid < e_auction_minbid) { sprintf (general_use, "You must at least match the minimum bid of %d coins!\n\r", e_auction_minbid); send_to_char (general_use, ch); return; } if (obid <= e_auction_bid) { sprintf (general_use, "You must beat the current bid of %d coins!\n\r", e_auction_bid); return; } if (!e_auto_xfer) { if ((tally_coins (ch) + ch->pcdata->bank) < obid) { send_to_char ("You do not have that many coins in the bank and on you!\n\r", ch); return; } } else { if (ch->pcdata->bank < obid) { send_to_char ("You do not have that many coins in the bank for the autotransfer auction.\n\r", ch); return; } } if (e_auction_bid + 20 > obid) { send_to_char ("The minimum bid increase is 20 coins.\n\r", ch); return; } if (e_auction_tochar!=e_auction_lastbidder) { e_bidders++; } e_auction_lastbidder = e_auction_tochar; e_auction_tochar = ch; e_auction_bid = obid; sprintf (general_use, "I'll pay %d coins for \x1B[37;1m%s\x1B[34;1m!", obid, e_auction_item); do_auction (ch, general_use, FALSE); e_auction_going = 0; return; } void do_bid (CHAR_DATA * ch, char *argy) /*By Owen Emlen */ { char general_use[STD_LENGTH*5]; int obid; DEFINE_COMMAND ("bid", do_bid, POSITION_SLEEPING, 0, LOG_NORMAL, "This command allows you to bid on an auction.") if (IS_MOB (ch)) return; if (!pow.auto_auction) { send_to_char ("Huh?\n\r", ch); return; } if (IS_PLAYER (ch) && LEVEL (ch) > 99 && LEVEL (ch) < 110) { send_to_char ("You can't bid! You're an immortal.\n\r", ch); return; } if (IS_SET (ch->pcdata->raceflag, RC_EVILRACE)) { do_e_bid (ch, argy); return; } if (auction_item[0] == '\0') { send_to_char ("Nothing is currently up for auction.\n\r", ch); return; } if (!ch->pcdata->listen_auction) { ch->pcdata->listen_auction = TRUE; send_to_char ("You have now tuned into bidding for this item.\n\r", ch); } if (argy[0] == '\0') { sprintf (general_use, "Up for bid: %s\x1B[37;0m by %s\n\r", auction_item, NAME (auction_char)); send_to_char (general_use, ch); sprintf (general_use, "Current bid: %d coins. Minimum bid was: %d coins.\n\r", auction_bid, auction_minbid); send_to_char (general_use, ch); send_to_char ("Type bid <amount> to bid for the item.\n\r", ch); return; } if (ch == auction_char) { send_to_char ("You can't bid on your own item!\n\r", ch); return; } if (ch == auction_tochar) { send_to_char("You already have the highest bid on the item.\n\r", ch); return; } if (!is_number (argy)) { send_to_char ("Bids are a number of copper coins. EX: bid 1500\n\r", ch); return; } obid = atoi (argy); if (obid < auction_minbid) { sprintf (general_use, "You must at least match the minimum bid of %d coins!\n\r", auction_minbid); send_to_char (general_use, ch); return; } if (obid <= auction_bid) { sprintf (general_use, "You must beat the current bid of %d coins!\n\r", auction_bid); return; } if (!auto_xfer) { if ((tally_coins (ch) + ch->pcdata->bank) < obid) { send_to_char ("You do not have that many coins in the bank and on you!\n\r", ch); return; } } else { if (ch->pcdata->bank < obid) { send_to_char ("You do not have that many coins in the bank for the autotransfer auction.\n\r", ch); return; } } if (auction_bid + 20 > obid) { send_to_char ("The minimum bid increase is 20 coins.\n\r", ch); return; } if (auction_tochar!=auction_lastbidder) { g_bidders++; } auction_lastbidder=auction_tochar; auction_tochar = ch; auction_bid = obid; sprintf (general_use, "I'll pay %d coins for \x1B[37;1m%s\x1B[34;1m!", obid, auction_item); do_auction (ch, general_use, FALSE); auction_going = 0; return; } void do_e_tauction (CHAR_DATA * ch, char *argy) /*By Owen Emlen */ { SINGLE_OBJECT *tobj; char arg1[SML_LENGTH]; char arg2[SML_LENGTH]; char arg3[SML_LENGTH]; char buff[1024]; int ocost; arg3[0] = '\0'; if (IS_MOB (ch)) return; if (pow.auction_lag && ch->pcdata->no_quit_pk) { send_to_char("You must wait for your PKill no-quit timer to run out before you auction.\n\r",ch); return; } if (argy[0] == '\0') { send_to_char ("Syntax: Auction <item> <min-bid> <y/n>\n\r", ch); send_to_char ("Or : Auction halt\n\r", ch); send_to_char ("Note : Min-bid is in # of COPPER coins\n\r", ch); send_to_char (" : <y/n> is autotransfer (exclude y/n to see cost)\n\r", ch); return; } argy = one_argy (argy, arg1); argy = one_argy (argy, arg2); argy = one_argy (argy, arg3); if (!str_cmp (arg1, "halt")) { if (e_auction_item[0] != '\0' && e_auction_bid >= e_auction_minbid && e_auction_going > 1 && e_auction_char == ch) { send_to_char ("You can't withdraw this late into the auction!\n\r", ch); return; } if (e_auction_item[0] != '\0' && e_auction_char == ch) { send_to_char ("Item withdrawn from auction block.\n\r", ch); sprintf (buff, "%s has withdrawn \x1B[37;1m%s\x1B[34;1m from the auction block.", NAME (ch), e_auction_item); if (e_auto_xfer) { obj_to (e_auction_item_e, e_auction_char); ch->pcdata->bank += e_auction_item_e->cost / 7; } e_auction_item[0] = '\0'; e_auction_going = 0; e_auction_char = NULL; e_auction_tochar = NULL; do_auction (ch, buff, TRUE); return; } if (e_auction_item[0] != '\0' && e_auction_char != ch) { send_to_char ("You didn't put the item up for bid!!\n\r", ch); return; } return; } if (e_auction_item[0] != '\0') { send_to_char ("Sorry! There is already another auction going on!\n\r", ch); return; } if ((tobj = get_obj_inv (ch, arg1)) == NULL) { send_to_char ("You do not have that item!\n\r", ch); return; } if (tobj->wear_loc != -1 || tobj->in_obj != NULL) { send_to_char ("The object must be in your inventory!\n\r", ch); return; } if (!is_number (arg2)) { send_to_char ("Syntax: Auction <item> <min bid # of coins> <y/n>\n\r", ch); send_to_char ("Or : Auction halt\n\r", ch); send_to_char ("Note : Min-bid is in # of COPPER coins\n\r", ch); send_to_char (" : <y/n> is autotransfer (exclude y/n to see cost)\n\r", ch); return; } ocost = atoi (arg2); if (ocost > 32000) { send_to_char ("The maximum auction price is 30000 coins.\n\r", ch); return; } if (ocost < 100 || tobj->cost < 20) { send_to_char ("Why bother selling something that cheap anyways!\n\r", ch); return; } if (arg3[0] != 'Y' && arg3[0] != 'y' && arg3[0] != 'N' && arg3[0] != 'n') { int i; i = tobj->cost / 7; sprintf (buff, "It would cost you %d coins to have this item autotransfer. Half of\n\r", i); send_to_char (buff, ch); send_to_char ("this cost will be added to the minimum bid, essentially making the buyer\n\r", ch); send_to_char ("pay half of the transfer fee.\n\r", ch); return; } if (UPPER (arg3[0]) == 'Y') { int i; i = tobj->cost / 7; if (ch->pcdata->bank < i) { send_to_char ("You don't have enough money in the bank to autotransfer.\n\r", ch); return; } ch->pcdata->bank -= i; obj_from (tobj); e_auto_xfer = TRUE; e_auction_lastbidder=NULL; e_bidders = 0; } else e_auto_xfer = FALSE; e_auction_going = 0; strcpy (e_auction_item, OOSTR (tobj, short_descr)); e_auction_item_e = tobj; if (e_auto_xfer) e_auction_minbid = ocost + tobj->cost / 14; else e_auction_minbid = ocost; e_auction_bid = 0; e_auction_tochar = NULL; e_auction_char = ch; sprintf (buff, "<\x1B[37;1m%s\x1B[34;1m> MinBid: %d. AutoXfer: %s.", e_auction_item, e_auction_minbid, e_auto_xfer ? "Yes" : "No"); do_auction (ch, buff, TRUE); if (tobj->pIndexData->item_type == ITEM_WEAPON || tobj->pIndexData->item_type == ITEM_ARMOR) { get_condition (tobj); sprintf (buff, "Condition [%s]. Type BID to listen to the auction.", condition_var); do_auction (ch, buff, TRUE); } ch->pcdata->listen_auction = TRUE; return; } void do_tauction (CHAR_DATA * ch, char *argy) /*By Owen Emlen */ { SINGLE_OBJECT *tobj; char buff[1024]; char arg1[SML_LENGTH]; char arg2[SML_LENGTH]; char arg3[SML_LENGTH]; int ocost; DEFINE_COMMAND ("auction", do_tauction, POSITION_SLEEPING, 0, LOG_NORMAL, "This command allows you to auction a piece of equipment.") if (IS_SET (ch->pcdata->deaf, CHANNEL_AUCTION)) { send_to_char ("But you aren't even listening to the auction channel!\n\r", ch); return; } arg3[0] = '\0'; if (IS_MOB (ch)) return; if (pow.auction_lag && ch->pcdata->no_quit_pk) { send_to_char("You must wait for your PKill no-quit timer to run out before you auction.\n\r",ch); return; } if (FIGHTING (ch)) { send_to_char ("You cannot auction while fighting.\n\r", ch); return; } if (!pow.auto_auction) { send_to_char ("Huh?\n\r", ch); return; } if (LEVEL (ch) > 99 && !IS_REAL_GOD (ch)) { send_to_char ("You cannot auction items as an immortal!\n\r", ch); return; } if (IS_SET (ch->pcdata->raceflag, RC_EVILRACE)) { do_e_tauction (ch, argy); return; } if (argy[0] == '\0') { send_to_char ("Syntax: Auction <item> <min-bid> <y/n>\n\r", ch); send_to_char ("Or : Auction halt\n\r", ch); send_to_char ("Note : Min-bid is in # of COPPER coins\n\r", ch); send_to_char (" : <y/n> is autotransfer (exclude y/n to see cost)\n\r", ch); return; } argy = one_argy (argy, arg1); argy = one_argy (argy, arg2); argy = one_argy (argy, arg3); if (!str_cmp (arg1, "halt")) { if (auction_item[0] != '\0' && auction_bid >= auction_minbid && auction_going > 1 && auction_char == ch) { send_to_char ("You can't withdraw this late into the auction!\n\r", ch); return; } if (auction_item[0] != '\0' && auction_char == ch) { send_to_char ("Item withdrawn from auction block.\n\r", ch); sprintf (buff, "%s has withdrawn \x1B[37;1m%s\x1B[34;1m from the auction block.", NAME (ch), auction_item); if (auto_xfer) { obj_to (auction_item_g, auction_char); ch->pcdata->bank += auction_item_g->cost / 7; } auction_item[0] = '\0'; auction_going = 0; auction_char = NULL; auction_tochar = NULL; do_auction (ch, buff, TRUE); return; } if (auction_item[0] != '\0' && auction_char != ch) { send_to_char ("You didn't put the item up for bid!!\n\r", ch); return; } return; } if (auction_item[0] != '\0') { send_to_char ("Sorry! There is already another auction going on!\n\r", ch); return; } if ((tobj = get_obj_inv (ch, arg1)) == NULL) { send_to_char ("You do not have that item!\n\r", ch); return; } if (tobj->wear_loc != -1 || tobj->in_obj != NULL) { send_to_char ("The object must be in your inventory!\n\r", ch); return; } if (!is_number (arg2)) { send_to_char ("Syntax: Auction <item> <min bid # of coins> <y/n>\n\r", ch); send_to_char ("Or : Auction halt\n\r", ch); send_to_char ("Note : Min-bid is in # of COPPER coins\n\r", ch); send_to_char (" : <y/n> is autotransfer (exclude y/n to see cost)\n\r", ch); return; } ocost = atoi (arg2); if (ocost > 32000) { send_to_char ("The maximum auction price is 30000 coins.\n\r", ch); return; } if (ocost < 100 || tobj->cost < 20) { send_to_char ("Why bother selling something that cheap anyways!\n\r", ch); return; } if (arg3[0] != 'Y' && arg3[0] != 'y' && arg3[0] != 'N' && arg3[0] != 'n') { int i; i = tobj->cost / 7; sprintf (buff, "It would cost you %d coins to have this item autotransfer. Half of\n\r", i); send_to_char (buff, ch); send_to_char ("this cost will be added to the minimum bid, essentially making the buyer\n\r", ch); send_to_char ("pay half of the transfer fee.\n\r", ch); return; } if (UPPER (arg3[0]) == 'Y') { int i; i = tobj->cost / 7; if (ch->pcdata->bank < i) { send_to_char ("You don't have enough money in the bank to autotransfer.\n\r", ch); return; } ch->pcdata->bank -= i; obj_from (tobj); auto_xfer = TRUE; g_bidders = 0; auction_lastbidder=NULL; } else auto_xfer = FALSE; auction_going = 0; strcpy (auction_item, OOSTR (tobj, short_descr)); auction_item_g = tobj; if (auto_xfer) auction_minbid = ocost + (tobj->cost / 14); else auction_minbid = ocost; auction_bid = 0; auction_tochar = NULL; auction_char = ch; sprintf (buff, "<\x1B[37;1m%s\x1B[34;1m> MinBid: %d. AutoXfer: %s.", auction_item, auction_minbid, auto_xfer ? "Yes" : "No"); do_auction (ch, buff, TRUE); if (tobj->pIndexData->item_type == ITEM_WEAPON || tobj->pIndexData->item_type == ITEM_ARMOR) { get_condition (tobj); sprintf (buff, "Condition [%s]. Type BID to listen to the auction.", condition_var); do_auction (ch, buff, TRUE); } ch->pcdata->listen_auction = TRUE; return; } void do_auction (CHAR_DATA * ch, char *argy, bool to_all) { char temp[512]; DESCRIPTOR_DATA *dd; bool evil; sprintf (temp, "\x1B[32;1m<A> \x1B[34m[\x1B[37;1m%s\x1B[34;1m] %s\x1B[37;0m\n\r", NAME (ch), argy); evil = IS_EVIL (ch); for (dd = descriptor_list; dd != NULL; dd = dd->next) { if (!dd->character || dd->connected != CON_PLAYING) continue; if (IS_EVIL (dd->character) != evil) continue; if (IS_SET (dd->character->pcdata->deaf, CHANNEL_AUCTION)) continue; if (!to_all && !dd->character->pcdata->listen_auction) continue; send_to_char (temp, dd->character); } return; } void clear_evil_auction_listeners (void) { DESCRIPTOR_DATA *dd; for (dd = descriptor_list; dd != NULL; dd = dd->next) { if (!dd->character) continue; if (IS_EVIL (dd->character) && dd->character->pcdata->listen_auction) dd->character->pcdata->listen_auction = FALSE; } return; } void clear_gn_auction_listeners (void) { DESCRIPTOR_DATA *dd; for (dd = descriptor_list; dd != NULL; dd = dd->next) { if (!dd->character) continue; if (!IS_EVIL (dd->character) && dd->character->pcdata->listen_auction) dd->character->pcdata->listen_auction = FALSE; } return; } void e_auction_update (void) { char general_use[2000]; if (e_auction_item[0] == '\0') return; if (e_auction_bid == 0) { ++e_auction_going; if (e_auction_going > 2) { sprintf (general_use, "Due to lack of interest, \x1B[37;1m%s\x1B[34;1m is no longer for sale.", e_auction_item); do_auction (e_auction_char, general_use, FALSE); if (e_auto_xfer) { obj_to (e_auction_item_e, e_auction_char); e_auction_char->pcdata->bank += e_auction_item_e->cost / 7; } e_auction_item[0] = '\0'; e_auction_minbid = 0; e_auction_bid = 0; e_auction_char = NULL; e_auction_tochar = NULL; e_auction_going = 0; clear_evil_auction_listeners (); return; } sprintf (general_use, "Anyone? \x1B[37;1m%s\x1B[35;1m for %d coins?", capitalize (e_auction_item), e_auction_minbid); do_auction (e_auction_char, general_use, FALSE); return; } if (e_auction_going < 3) { ++e_auction_going; if (e_auction_going == 1) { sprintf (general_use, "\x1B[37;1m%s\x1B[34;1m is going once to %s for %d coins.", capitalize (e_auction_item), NAME (e_auction_tochar), e_auction_bid); do_auction (e_auction_char, general_use, FALSE); } if (e_auction_going == 2) { sprintf (general_use, "\x1B[37;1m%s\x1B[34;1m is going TWICE to %s for %d coins.", capitalize (e_auction_item), NAME (e_auction_tochar), e_auction_bid); do_auction (e_auction_char, general_use, FALSE); } return; } if (e_auction_going == 3) { if (e_bidders < 3) { sprintf (general_use, "Due to very few bidders, \x1B[37;1m%s\x1B[34;1m is no longer for sale.", e_auction_item); do_auction (e_auction_char, general_use, TRUE); if (e_auto_xfer) { obj_to (e_auction_item_e, e_auction_char); e_auction_char->pcdata->bank += e_auction_item_e->cost / 7; } e_auction_item[0] = '\0'; e_auction_minbid = 0; e_auction_bid = 0; e_auction_char = NULL; e_auction_tochar = NULL; e_auction_going = 0; clear_evil_auction_listeners (); return; } sprintf (general_use, "\x1B[37;1m%s\x1B[34;1m has been SOLD to %s for %d coins.", capitalize (e_auction_item), NAME (e_auction_tochar), e_auction_bid); do_auction (e_auction_char, general_use, TRUE); if (!e_auto_xfer) { sprintf (general_use, "You won the auction!\n\rITEM: <%s> with your bid of %d coins.\n\r", e_auction_item, e_auction_bid); send_to_char (general_use, e_auction_tochar); sprintf (general_use, "Please contact %s to arrange a meeting place and/or time!\n\r", NAME (e_auction_char)); send_to_char (general_use, e_auction_tochar); sprintf (general_use, "%s just won your e_auction of <%s> for %d coins.\n\r", NAME (e_auction_tochar), e_auction_item, e_auction_bid); send_to_char (general_use, e_auction_char); sprintf (general_use, "Contact %s to arrange a meeting place/time for the transaction.\n\r", NAME (e_auction_tochar)); send_to_char (general_use, e_auction_char); } if (e_auto_xfer) { sprintf (general_use, "You won the auction!\n\rITEM: <%s> with your bid of %d coins.\n\r", e_auction_item, e_auction_bid); send_to_char (general_use, e_auction_tochar); send_to_char ("Item and money have been auto transferred.\n\r", e_auction_char); e_auction_char->pcdata->bank += e_auction_bid; e_auction_tochar->pcdata->bank -= e_auction_bid; /*obj_from(e_auction_item_e); */ obj_to (e_auction_item_e, e_auction_tochar); } e_auction_item[0] = '\0'; e_auction_char = NULL; e_auction_tochar = NULL; e_auction_bid = 0; e_auction_minbid = 0; e_auction_going = 0; e_auto_xfer = FALSE; clear_evil_auction_listeners (); return; } return; } void auction_update (void) { char general_use[2500]; e_auction_update (); if (auction_item[0] == '\0') return; if (auction_bid == 0) { ++auction_going; if (auction_going > 2) { sprintf (general_use, "Due to lack of interest, \x1B[37;1m%s\x1B[34;1m is no longer for sale.", auction_item); do_auction (auction_char, general_use, TRUE); if (auto_xfer) { obj_to (auction_item_g, auction_char); auction_char->pcdata->bank += auction_item_g->cost / 7; } auction_item[0] = '\0'; auction_minbid = 0; auction_bid = 0; auction_char = NULL; auction_tochar = NULL; auction_going = 0; clear_gn_auction_listeners (); return; } sprintf (general_use, "Anyone? \x1B[37;1m%s\x1B[34;1m for %d coins?", capitalize (auction_item), auction_minbid); do_auction (auction_char, general_use, FALSE); return; } if (auction_going < 3) { ++auction_going; if (auction_going == 1) { sprintf (general_use, "\x1B[37;1m%s\x1B[34;1m is going once to %s for %d coins.", capitalize (auction_item), NAME (auction_tochar), auction_bid); do_auction (auction_char, general_use, FALSE); } if (auction_going == 2) { sprintf (general_use, "\x1B[37;1m%s\x1B[34;1m is going TWICE to %s for %d coins.", capitalize (auction_item), NAME (auction_tochar), auction_bid); do_auction (auction_char, general_use, FALSE); } return; } if (auction_going == 3) { if (g_bidders < 3) { sprintf (general_use, "Due to very few bidders, \x1B[37;1m%s\x1B[34;1m is no longer for sale.", auction_item); do_auction (auction_char, general_use, TRUE); if (auto_xfer) { auction_char->pcdata->bank += auction_item_g->cost / 7; obj_to (auction_item_g, auction_char); } auction_item[0] = '\0'; auction_minbid = 0; auction_bid = 0; auction_char = NULL; auction_tochar = NULL; auction_going = 0; clear_gn_auction_listeners (); return; } sprintf (general_use, "\x1B[37;1m%s\x1B[34;1m has been SOLD to %s for %d coins.", auction_item, NAME (auction_tochar), auction_bid); do_auction (auction_char, general_use, TRUE); if (!auto_xfer) { sprintf (general_use, "You won the auction!\n\rITEM: <%s> with your bid of %d coins.\n\r", auction_item, auction_bid); send_to_char (general_use, auction_tochar); sprintf (general_use, "Please contact %s to arrange a meeting place and/or time!\n\r", NAME (auction_char)); send_to_char (general_use, auction_tochar); sprintf (general_use, "%s just won your auction of <%s> for %d coins.\n\r", NAME (auction_tochar), auction_item, auction_bid); send_to_char (general_use, auction_char); sprintf (general_use, "Contact %s to arrange a meeting place/time for the transaction.\n\r", NAME (auction_tochar)); send_to_char (general_use, auction_char); } if (auto_xfer) { sprintf (general_use, "You won the auction!\n\rITEM: <%s> with your bid of %d coins.\n\r", auction_item, auction_bid); send_to_char (general_use, auction_tochar); send_to_char ("Item and money have been auto transferred.\n\r", auction_char); auction_char->pcdata->bank += auction_bid; auction_tochar->pcdata->bank -= auction_bid; /*obj_from(auction_item_g); */ obj_to (auction_item_g, auction_tochar); } auction_item[0] = '\0'; auction_char = NULL; auction_tochar = NULL; auction_bid = 0; auction_minbid = 0; auction_going = 0; auto_xfer = FALSE; clear_gn_auction_listeners (); return; } return; }