Index: src/store.c =================================================================== --- src/store.c (revision 1826) +++ src/store.c (working copy) @@ -1848,6 +1848,11 @@ else text_out("' sells"); text_out(" an item from your inventory. "); + if (current_store() != STORE_HOME) + { + text_out_c(TERM_L_GREEN, "K"); + text_out(" restocks the store."); + } text_out_c(TERM_L_GREEN, "ESC"); text_out(" exits the building."); @@ -1867,6 +1872,8 @@ if (store_flags & STORE_SHOW_HELP) store_display_help(); + else if (current_store() != STORE_HOME) + prt("'?' for help, 'K' restocks store", scr_places_y[LOC_HELP_PROMPT], 1); else prt("Press '?' for help.", scr_places_y[LOC_HELP_PROMPT], 1); @@ -2788,6 +2795,121 @@ /* + * Buy out the store so it will restock + */ +static bool store_purchase_all(void) +{ + int i; + + store_type *st_ptr = &store[current_store()]; + + object_type *o_ptr; + + s32b price; + + /* Clear all current messages */ + msg_flag = FALSE; + prt("", 0, 0); + + if (current_store() == STORE_HOME) + { + /* this routine should not have been called from home */ + prt("Deleting all items stored at home currently not implemented.", 1, 0); + return FALSE; + } + + price = 0; + for (i = 0; i < st_ptr->stock_num; i++) + { + /* Get the existing object */ + o_ptr = &st_ptr->stock[i]; + price += price_item(o_ptr, FALSE, o_ptr->number); + } + + /* Check if the player can afford it */ + if ((u32b)p_ptr->au < (u32b)price) + { + /* Tell the user */ + msg_print("You do not have enough gold to buy out this store."); + store_flags |= STORE_KEEP_PROMPT; + + /* Abort now */ + return FALSE; + } + + screen_save(); + + /* Show price */ + prt(format("Total cost: %d", price), 1, 0); + + /* Confirm purchase */ + if (store_get_check("Restock the store? [ESC, any other key to accept]")) + screen_load(); + else + { + screen_load(); + return FALSE; + } + + /* Spend the money */ + p_ptr->au -= price; + + /* Update the display */ + store_flags |= STORE_GOLD_CHANGE; + + /* Message */ + if (one_in_(3)) message(MSG_STORE5, 0, ONE_OF(comment_accept)); + msg_format("You restocked the store for %ld gold.", (long)price); + + store_flags |= STORE_KEEP_PROMPT; + + /* Handle stuff */ + handle_stuff(); + + /* Buying an object makes you aware of it */ + for (i = 0; i < st_ptr->stock_num; i++) + { + /* Get the existing object */ + o_ptr = &st_ptr->stock[i]; + object_flavor_aware(o_ptr); + } + /* in case by buying you the store became aware of flavor in pack */ + p_ptr->notice |= (PN_COMBINE | PN_REORDER); + + /* Empty the store */ + st_ptr->stock_num =0; + + /* Shuffle */ + if (one_in_(STORE_SHUFFLE)) + { + /* Message */ + msg_print("The shopkeeper retires."); + + /* Shuffle the store */ + store_shuffle(current_store()); + store_flags |= STORE_INIT_CHANGE; + } + + /* Maintain */ + else + { + /* Message */ + msg_print("The shopkeeper brings out some new stock."); + } + + /* New inventory */ + for (i = 0; i < 10; ++i) + { + /* Maintain the store */ + store_maint(current_store()); + } + + /* Not kicked out */ + return TRUE; +} + + +/* * Process a command in a store * * Note that we must allow the use of a few "special" commands in the stores @@ -2803,6 +2925,14 @@ /* Parse the command */ switch (cmd) { + /* new command to buy out a store */ + case 'K': + { + if (store_purchase_all()) + return TRUE; + break; + } + /* Leave */ case ESCAPE: { @@ -3112,7 +3242,7 @@ if (OPT(rogue_like_commands)) { /* These two can't intersect! */ - menu.cmd_keys = "\n\x04\x10\r?={}~CEIPTdegilpswx\x8B\x8C"; /* \x10 = ^p , \x04 = ^D */ + menu.cmd_keys = "K\n\x04\x10\r?={}~CEIPTdegilpswx\x8B\x8C"; /* \x10 = ^p , \x04 = ^D */ menu.selections = "abcfmnoqrtuvyz13456790ABDFGH"; } @@ -3120,7 +3250,7 @@ else { /* These two can't intersect! */ - menu.cmd_keys = "\n\x010\r?={}~CEIbdegiklpstw\x8B\x8C"; /* \x10 = ^p */ + menu.cmd_keys = "K\n\x010\r?={}~CEIbdegiklpstw\x8B\x8C"; /* \x10 = ^p */ menu.selections = "acfhmnoqruvxyz13456790ABDFGH"; }