X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fstore.c;h=d3608dcedc1086004a2b77f73ea6d957b38288be;hb=refs%2Fheads%2Fmaster;hp=a0cf9c999adf9c3fcb70ad517bbad2d403a1065a;hpb=a1f4e0ec56f88584a88382f9b29f21b2a89660df;p=hengband%2Fhengband.git diff --git a/src/store.c b/src/store.c deleted file mode 100644 index a0cf9c999..000000000 --- a/src/store.c +++ /dev/null @@ -1,3511 +0,0 @@ -/*! - * @file store.c - * @brief åºã®å¦ç / Store commands - * @date 2014/02/02 - * @author - * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n - * This software may be copied and distributed for educational, research, and\n - * not for profit purposes provided that this copyright and statement are\n - * included in all such copies.\n - * 2014 Deskull rearranged comment for Doxygen. - */ - -#include "angband.h" -#include "market/store-owners.h" -#include "market/store-owner-comments.h" -#include "core.h" -#include "util.h" -#include "term.h" - -#include "floor.h" -#include "io/write-diary.h" -#include "cmd/cmd-basic.h" -#include "cmd/cmd-diary.h" -#include "cmd/cmd-draw.h" -#include "cmd/cmd-dump.h" -#include "cmd/cmd-help.h" -#include "cmd/cmd-item.h" -#include "cmd/cmd-macro.h" -#include "cmd/cmd-smith.h" -#include "cmd/cmd-visuals.h" -#include "cmd/cmd-zapwand.h" -#include "cmd/cmd-magiceat.h" -#include "spells.h" -#include "store.h" -#include "avatar.h" -#include "cmd-spell.h" -#include "rumor.h" -#include "player-status.h" -#include "player-class.h" -#include "player-inventory.h" -#include "object-flavor.h" -#include "object-hook.h" -#include "floor-events.h" -#include "snipe.h" -#include "files.h" -#include "player-effects.h" -#include "player-race.h" -#include "mind.h" -#include "world.h" -#include "objectkind.h" -#include "autopick.h" -#include "floor-town.h" -#include "japanese.h" -#include "view-mainwindow.h" -#include "wild.h" - -#define MIN_STOCK 12 - -static int cur_store_num = 0; -static int store_top = 0; -static int store_bottom = 0; -static int xtra_stock = 0; -static store_type *st_ptr = NULL; -static const owner_type *ot_ptr = NULL; -static s16b old_town_num = 0; -static s16b inner_town_num = 0; -#define RUMOR_CHANCE 8 - -/*** Initialize others ***/ - -/*! - * @brief åå¼æåæã®åºä¸»ã®ã¡ãã»ã¼ã¸å¦ç / - * ãã©ãã¯ãã¼ã±ããã®ã¨ãã¯å¥ã®ã¡ãã»ã¼ã¸ãåºã - * Successful haggle. - * @param player_ptr ãã¬ã¼ã¤ã¼ã¸ã®åç §ãã¤ã³ã¿ - * @return ãªã - */ -static void say_comment_1(player_type *player_ptr) -{ -#ifdef JP - if (cur_store_num == STORE_BLACK) - { - msg_print(comment_1_B[randint0(MAX_COMMENT_1)]); - } - else - { - msg_print(comment_1[randint0(MAX_COMMENT_1)]); - } -#else - msg_print(comment_1[randint0(MAX_COMMENT_1)]); -#endif - - if (one_in_(RUMOR_CHANCE)) - { - msg_print(_("åºä¸»ã¯è³ãã¡ãã:", "The shopkeeper whispers something into your ear:")); - display_rumor(player_ptr, TRUE); - } -} - - -/*! - * @brief ãã¬ã¤ã¤ã¼ãã¢ã¤ãã ãè²·ãæã®ä¾¡æ ¼ä»£æ¡ã¡ãã»ã¼ã¸å¦ç / - * Continue haggling (player is buying) - * @param value åºä¸»ã®æç¤ºä¾¡æ ¼ - * @param annoyed åºä¸»ã®ããã¤ã度 - * @return ãªã - */ -static void say_comment_2(PRICE value, int annoyed) -{ - char tmp_val[80]; - sprintf(tmp_val, "%ld", (long)value); - - if (annoyed > 0) - { - msg_format(comment_2a[randint0(MAX_COMMENT_2A)], tmp_val); - return; - } - -#ifdef JP - if (cur_store_num == STORE_BLACK) - { - msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val); - } - else - { - msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val); - } -#else - msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val); -#endif -} - - -/*! - * @brief ãã¬ã¤ã¤ã¼ãã¢ã¤ãã ã売ãæã®ä¾¡æ ¼ä»£æ¡ã¡ãã»ã¼ã¸å¦ç / - * ãã©ãã¯ãã¼ã±ããã®ã¨ãã¯å¥ã®ã¡ãã»ã¼ã¸ãåºã - * Continue haggling (player is selling) - * @param value åºä¸»ã®æç¤ºä¾¡æ ¼ - * @param annoyed åºä¸»ã®ããã¤ã度 - * @return ãªã - */ -static void say_comment_3(PRICE value, int annoyed) -{ - char tmp_val[80]; - sprintf(tmp_val, "%ld", (long)value); - if (annoyed > 0) - { - msg_format(comment_3a[randint0(MAX_COMMENT_3A)], tmp_val); - } - else - { -#ifdef JP - if (cur_store_num == STORE_BLACK) - { - msg_format(comment_3b_B[randint0(MAX_COMMENT_3B)], tmp_val); - } - else - { - msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val); - } -#else - msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val); -#endif - } -} - - -/*! - * @brief åºä¸»ããã¬ã¤ã¤ã¼ã追ãåºãæã®ã¡ãã»ã¼ã¸å¦ç / - * ãã©ãã¯ãã¼ã±ããã®æã¯å¥ã®ã¡ãã»ã¼ã¸ãåºã - * Kick 'da bum out. -RAK- - * @return ãªã - */ -static void say_comment_4(void) -{ -#ifdef JP - if (cur_store_num == STORE_BLACK) - { - msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]); - msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]); - } - else - { - msg_print(comment_4a[randint0(MAX_COMMENT_4A)]); - msg_print(comment_4b[randint0(MAX_COMMENT_4B)]); - } -#else - msg_print(comment_4a[randint0(MAX_COMMENT_4A)]); - msg_print(comment_4b[randint0(MAX_COMMENT_4B)]); -#endif - -} - - -/*! - * @brief åºä¸»ããã¬ã¤ã¤ã¼ã«åãåããªãæã®ã¡ãã»ã¼ã¸å¦ç / - * ãã©ãã¯ãã¼ã±ããã®æã¯å¥ã®ã¡ãã»ã¼ã¸ãåºã - * You are insulting me - * @return ãªã - */ -static void say_comment_5(void) -{ -#ifdef JP - if (cur_store_num == STORE_BLACK) - { - msg_print(comment_5_B[randint0(MAX_COMMENT_5)]); - } - else - { - msg_print(comment_5[randint0(MAX_COMMENT_5)]); - } -#else - msg_print(comment_5[randint0(MAX_COMMENT_5)]); -#endif - -} - - -/*! - * @brief åºä¸»ããã¬ã¤ã¤ã¼ã®æ示ãç解ã§ããªãã£ãæã®ã¡ãã»ã¼ã¸å¦ç / - * That makes no sense. - * @return ãªã - */ -static void say_comment_6(void) -{ - msg_print(comment_6[randint0(MAX_COMMENT_6)]); -} - -/*! - * @brief åºä¸»ã交æ¸ãçµããéã®åå¿ãè¿ãå¦ç / - * Let a shop-keeper React to a purchase - * @param price ã¢ã¤ãã ã®åå¼é¡ - * @param value ã¢ã¤ãã ã®å®éä¾¡å¤ - * @param guess åºä¸»ãå½åäºæ³ãã¦ããä¾¡å¤ - * @return ãªã - * @details - * We paid "price", it was worth "value", and we thought it was worth "guess" - */ -static void purchase_analyze(player_type *player_ptr, PRICE price, PRICE value, PRICE guess) -{ - /* Item was worthless, but we bought it */ - if ((value <= 0) && (price > value)) - { - msg_print(comment_7a[randint0(MAX_COMMENT_7A)]); - chg_virtue(player_ptr, V_HONOUR, -1); - chg_virtue(player_ptr, V_JUSTICE, -1); - sound(SOUND_STORE1); - return; - } - - /* Item was cheaper than we thought, and we paid more than necessary */ - if ((value < guess) && (price > value)) - { - msg_print(comment_7b[randint0(MAX_COMMENT_7B)]); - chg_virtue(player_ptr, V_JUSTICE, -1); - if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, -1); - sound(SOUND_STORE2); - return; - } - - /* Item was a good bargain, and we got away with it */ - if ((value > guess) && (value < (4 * guess)) && (price < value)) - { - msg_print(comment_7c[randint0(MAX_COMMENT_7C)]); - if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, -1); - else if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, 1); - sound(SOUND_STORE3); - return; - } - - /* Item was a great bargain, and we got away with it */ - if ((value > guess) && (price < value)) - { - msg_print(comment_7d[randint0(MAX_COMMENT_7D)]); - if (one_in_(2)) chg_virtue(player_ptr, V_HONOUR, -1); - if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, 1); - if (10 * price < value) chg_virtue(player_ptr, V_SACRIFICE, 1); - sound(SOUND_STORE4); - return; - } -} - -/* - * We store the current "store feat" here so everyone can access it - */ -static int cur_store_feat; - -/* - * Buying and selling adjustments for race combinations. - * Entry[owner][player] gives the basic "cost inflation". - */ -static byte rgold_adj[MAX_RACES][MAX_RACES] = -{ - /*Hum, HfE, Elf, Hal, Gno, Dwa, HfO, HfT, Dun, HiE, Barbarian, - HfOg, HGn, HTn, Cyc, Yek, Klc, Kbd, Nbl, DkE, Drc, Mind Flayer, - Imp, Glm, Skl, Zombie, Vampire, Spectre, Fairy, Beastman, Ent, - Angel, Demon, Kutar, Android, Merfolk */ - - /* Human */ - { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100, - 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120, - 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140, - 100, 120, 110, 105, 110 }, - - /* Half-Elf */ - { 110, 100, 100, 105, 110, 120, 125, 130, 110, 100, 110, - 120, 115, 108, 115, 110, 110, 120, 120, 115, 115, 110, - 120, 110, 110, 110, 120, 110, 100, 125, 100, 95, 140, - 110, 115, 110, 110, 110 }, - - /* Elf */ - { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110, - 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108, - 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140, - 110, 110, 105, 110, 110 }, - - /* Halfling */ - { 115, 110, 105, 95, 105, 110, 115, 130, 115, 105, 115, - 125, 120, 120, 125, 115, 110, 120, 120, 120, 115, 115, - 120, 110, 120, 120, 130, 110, 110, 130, 110, 95, 140, - 115, 120, 105, 115, 105 }, - - /* Gnome */ - { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115, - 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110, - 120, 101, 110, 110, 120, 120, 115, 130, 115, 95, 140, - 115, 110, 110, 115, 110 }, - - /* Dwarf */ - { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115, - 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120, - 120, 105, 115, 115, 115, 115, 120, 130, 120, 95, 140, - 115, 110, 115, 115, 120 }, - - /* Half-Orc */ - { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115, - 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110, - 115, 125, 120, 120, 115, 120, 125, 115, 125, 95, 140, - 115, 110, 115, 115, 125 }, - - /* Half-Troll */ - { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110, - 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110, - 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140, - 110, 110, 115, 110, 130 }, - - /* Amberite */ - { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100, - 120, 120, 105, 120, 115, 105, 115, 120, 110, 105, 105, - 120, 105, 120, 120, 125, 120, 105, 135, 105, 95, 140, - 100, 110, 110, 100, 110 }, - - /* High_Elf */ - { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110, - 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110, - 125, 115, 120, 120, 125, 120, 100, 125, 100, 95, 140, - 110, 110, 105, 110, 110 }, - - /* Human / Barbarian (copied from human) */ - { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100, - 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120, - 115, 105, 125, 125, 130, 125, 115, 120, 115, 95, 140, - 100, 120, 110, 100, 110 }, - - /* Half-Ogre: theoretical, copied from half-troll */ - { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110, - 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110, - 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140, - 110, 110, 115, 110, 120 }, - - /* Half-Giant: theoretical, copied from half-troll */ - { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110, - 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110, - 110, 115, 112, 112, 115, 112, 130, 120, 130, 95, 140, - 110, 110, 115, 110, 115 }, - - /* Half-Titan: theoretical, copied from High_Elf */ - { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110, - 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110, - 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140, - 110, 110, 115, 110, 108 }, - - /* Cyclops: theoretical, copied from half-troll */ - { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110, - 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110, - 110, 115, 112, 112, 115, 112, 130, 130, 130, 95, 140, - 110, 110, 115, 110, 115 }, - - /* Yeek: theoretical, copied from Half-Orc */ - { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115, - 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110, - 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140, - 115, 110, 115, 115, 110 }, - - /* Klackon: theoretical, copied from Gnome */ - { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115, - 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110, - 120, 101, 110, 110, 120, 120, 130, 130, 130, 95, 140, - 115, 110, 115, 115, 110 }, - - /* Kobold: theoretical, copied from Half-Orc */ - { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115, - 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110, - 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140, - 115, 110, 115, 115, 120 }, - - /* Nibelung: theoretical, copied from Dwarf */ - { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115, - 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120, - 120, 105, 115, 115, 120, 120, 130, 130, 130, 95, 140, - 115, 135, 115, 115, 120 }, - - /* Dark Elf */ - { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115, - 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110, - 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120, - 110, 101, 115, 110, 115 }, - - /* Draconian: theoretical, copied from High_Elf */ - { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110, - 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110, - 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140, - 110, 110, 115, 110, 115 }, - - /* Mind Flayer: theoretical, copied from High_Elf */ - { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110, - 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110, - 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140, - 110, 110, 115, 110, 110 }, - - /* Imp: theoretical, copied from High_Elf */ - { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110, - 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110, - 125, 115, 120, 120, 120, 120, 130, 130, 130, 120, 120, - 110, 110, 115, 110, 120 }, - - /* Golem: theoretical, copied from High_Elf */ - { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110, - 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110, - 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140, - 110, 110, 115, 110, 110 }, - - /* Skeleton: theoretical, copied from half-orc */ - { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115, - 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110, - 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120, - 115, 110, 125, 115, 110 }, - - /* Zombie: Theoretical, copied from half-orc */ - { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115, - 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110, - 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120, - 115, 110, 125, 115, 110 }, - - /* Vampire: Theoretical, copied from half-orc */ - { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115, - 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110, - 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120, - 115, 110, 125, 115, 120 }, - - /* Spectre: Theoretical, copied from half-orc */ - { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115, - 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110, - 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120, - 115, 110, 125, 115, 110 }, - - /* Sprite: Theoretical, copied from half-orc */ - { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115, - 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110, - 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140, - 115, 110, 105, 115, 110 }, - - /* Beastman: Theoretical, copied from half-orc */ - { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115, - 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110, - 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140, - 115, 110, 115, 115, 125 }, - - /* Ent */ - { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110, - 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108, - 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140, - 110, 110, 105, 110, 110 }, - - /* Angel */ - { 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 160, - 95, 95, 95, 95, 95 }, - - /* Demon */ - { 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 140, 140, 160, 120, - 140, 140, 140, 140, 140 }, - - /* Dunadan */ - { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100, - 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120, - 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140, - 100, 120, 110, 100, 110 }, - - /* Shadow Fairy */ - { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115, - 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110, - 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120, - 110, 101, 115, 110, 115 }, - - /* Kutar */ - { 110, 110, 105, 105, 110, 115, 115, 115, 110, 105, 110, - 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, - 115, 115, 125, 125, 125, 125, 105, 115, 105, 95, 140, - 110, 115, 100, 110, 110 }, - - /* Android */ - { 105, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100, - 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120, - 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140, - 100, 120, 110, 100, 110 }, - - /* Merfolk */ - { 110, 110, 110, 105, 110, 120, 125, 130, 110, 110, 110, - 120, 115, 108, 115, 110, 110, 120, 120, 115, 115, 110, - 120, 110, 110, 110, 120, 110, 110, 125, 110, 95, 140, - 110, 115, 110, 110, 100 }, -}; - - -/*! - * @brief åºèä¾¡æ ¼ã決å®ãã. ç¡æã«ã¯ãªããªã / - * Determine the price of an item (qty one) in a store. - * @param o_ptr åºèã«ä¸¦ã¹ããªãã¸ã§ã¯ãæ§é ä½ã®åç §ãã¤ã³ã¿ - * @param greed åºä¸»ã®å¼·æ¬²åº¦ - * @param flip TRUEãªãã°åºä¸»ã«ã¨ã£ã¦ã®è²·åä¾¡æ ¼ãFALSEãªã売åºä¾¡æ ¼ãè¨ç® - * @return ã¢ã¤ãã ã®åºèä¾¡æ ¼ - * @details - *
- * This function takes into account the player's charisma, and the - * shop-keepers friendliness, and the shop-keeper's base greed, but - * never lets a shop-keeper lose money in a transaction. - * The "greed" value should exceed 100 when the player is "buying" the - * item, and should be less than 100 when the player is "selling" it. - * Hack -- the black market always charges twice as much as it should. - * Charisma adjustment runs from 80 to 130 - * Racial adjustment runs from 95 to 130 - * Since greed/charisma/racial adjustments are centered at 100, we need - * to adjust (by 200) to extract a usable multiplier. Note that the - * "greed" value is always something (?). - *- */ -static PRICE price_item(player_type *player_ptr, object_type *o_ptr, int greed, bool flip) -{ - PRICE price = object_value(o_ptr); - if (price <= 0) return (0L); - - int factor = rgold_adj[ot_ptr->owner_race][player_ptr->prace]; - factor += adj_chr_gold[player_ptr->stat_ind[A_CHR]]; - int adjust; - if (flip) - { - adjust = 100 + (300 - (greed + factor)); - if (adjust > 100) adjust = 100; - if (cur_store_num == STORE_BLACK) - price = price / 2; - - price = (price * adjust + 50L) / 100L; - } - else - { - adjust = 100 + ((greed + factor) - 300); - if (adjust < 100) adjust = 100; - if (cur_store_num == STORE_BLACK) - price = price * 2; - - price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL); - } - - if (price <= 0L) return (1L); - return (price); -} - - -/*! - * @brief å®ä¾¡ãªæ¶èåã®è²©å£²æ°ãå¢ãããä½ç¢ºçã§å²å¼ã«ãã / - * Certain "cheap" objects should be created in "piles" - * @param o_ptr åºèã«ä¸¦ã¹ããªãã¸ã§ã¯ãæ§é ä½ã®åç §ãã¤ã³ã¿ - * @return ãªã - * @details - *
- * Some objects can be sold at a "discount" (in small piles) - *- */ -static void mass_produce(object_type *o_ptr) -{ - int size = 1; - PRICE cost = object_value(o_ptr); - switch (o_ptr->tval) - { - case TV_FOOD: - case TV_FLASK: - case TV_LITE: - { - if (cost <= 5L) size += damroll(3, 5); - if (cost <= 20L) size += damroll(3, 5); - if (cost <= 50L) size += damroll(2, 2); - break; - } - case TV_POTION: - case TV_SCROLL: - { - if (cost <= 60L) size += damroll(3, 5); - if (cost <= 240L) size += damroll(1, 5); - if (o_ptr->sval == SV_SCROLL_STAR_IDENTIFY) size += damroll(3, 5); - if (o_ptr->sval == SV_SCROLL_STAR_REMOVE_CURSE) size += damroll(1, 4); - break; - } - case TV_LIFE_BOOK: - case TV_SORCERY_BOOK: - case TV_NATURE_BOOK: - case TV_CHAOS_BOOK: - case TV_DEATH_BOOK: - case TV_TRUMP_BOOK: - case TV_ARCANE_BOOK: - case TV_CRAFT_BOOK: - case TV_DAEMON_BOOK: - case TV_CRUSADE_BOOK: - case TV_MUSIC_BOOK: - case TV_HISSATSU_BOOK: - case TV_HEX_BOOK: - { - if (cost <= 50L) size += damroll(2, 3); - if (cost <= 500L) size += damroll(1, 3); - break; - } - case TV_SOFT_ARMOR: - case TV_HARD_ARMOR: - case TV_SHIELD: - case TV_GLOVES: - case TV_BOOTS: - case TV_CLOAK: - case TV_HELM: - case TV_CROWN: - case TV_SWORD: - case TV_POLEARM: - case TV_HAFTED: - case TV_DIGGING: - case TV_BOW: - { - if (object_is_artifact(o_ptr)) break; - if (object_is_ego(o_ptr)) break; - if (cost <= 10L) size += damroll(3, 5); - if (cost <= 100L) size += damroll(3, 5); - break; - } - case TV_SPIKE: - case TV_SHOT: - case TV_ARROW: - case TV_BOLT: - { - if (cost <= 5L) size += damroll(5, 5); - if (cost <= 50L) size += damroll(5, 5); - if (cost <= 500L) size += damroll(5, 5); - break; - } - case TV_FIGURINE: - { - if (cost <= 100L) size += damroll(2, 2); - if (cost <= 1000L) size += damroll(2, 2); - break; - } - case TV_CAPTURE: - case TV_STATUE: - case TV_CARD: - { - size = 1; - break; - } - - /* - * Because many rods (and a few wands and staffs) are useful mainly - * in quantity, the Black Market will occasionally have a bunch of - * one kind. -LM- - */ - case TV_ROD: - case TV_WAND: - case TV_STAFF: - { - if ((cur_store_num == STORE_BLACK) && one_in_(3)) - { - if (cost < 1601L) size += damroll(1, 5); - else if (cost < 3201L) size += damroll(1, 3); - } - break; - } - } - - DISCOUNT_RATE discount = 0; - if (cost < 5) - { - discount = 0; - } - else if (one_in_(25)) - { - discount = 25; - } - else if (one_in_(150)) - { - discount = 50; - } - else if (one_in_(300)) - { - discount = 75; - } - else if (one_in_(500)) - { - discount = 90; - } - - if (o_ptr->art_name) - { - discount = 0; - } - - o_ptr->discount = discount; - o_ptr->number = size - (size * discount / 100); - if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND)) - { - o_ptr->pval *= (PARAMETER_VALUE)o_ptr->number; - } -} - - -/*! - * @brief åºèã«ä¸¦ã¹ãåãåä¸åã§ãããã©ããå¤å®ãã / - * Determine if a store item can "absorb" another item - * @param o_ptr å¤å®ãããªãã¸ã§ã¯ãæ§é ä½ã®åç §ãã¤ã³ã¿1 - * @param j_ptr å¤å®ãããªãã¸ã§ã¯ãæ§é ä½ã®åç §ãã¤ã³ã¿2 - * @return åä¸æ±ãã§ãããªãTRUEãè¿ã - * @details - *
- * See "object_similar()" for the same function for the "player" - *- */ -static bool store_object_similar(object_type *o_ptr, object_type *j_ptr) -{ - if (o_ptr == j_ptr) return 0; - if (o_ptr->k_idx != j_ptr->k_idx) return 0; - if ((o_ptr->pval != j_ptr->pval) && (o_ptr->tval != TV_WAND) && (o_ptr->tval != TV_ROD)) return 0; - if (o_ptr->to_h != j_ptr->to_h) return 0; - if (o_ptr->to_d != j_ptr->to_d) return 0; - if (o_ptr->to_a != j_ptr->to_a) return 0; - if (o_ptr->name2 != j_ptr->name2) return 0; - if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return 0; - for (int i = 0; i < TR_FLAG_SIZE; i++) - if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return 0; - if (o_ptr->xtra1 || j_ptr->xtra1) return 0; - if (o_ptr->timeout || j_ptr->timeout) return 0; - if (o_ptr->ac != j_ptr->ac) return 0; - if (o_ptr->dd != j_ptr->dd) return 0; - if (o_ptr->ds != j_ptr->ds) return 0; - if (o_ptr->tval == TV_CHEST) return 0; - if (o_ptr->tval == TV_STATUE) return 0; - if (o_ptr->tval == TV_CAPTURE) return 0; - if (o_ptr->discount != j_ptr->discount) return 0; - return TRUE; -} - - -/*! - * @brief åºèã«ä¸¦ã¹ãåãéãåããã§ãããã©ããå¤å®ãã / - * Allow a store item to absorb another item - * @param o_ptr å¤å®ãããªãã¸ã§ã¯ãæ§é ä½ã®åç §ãã¤ã³ã¿1 - * @param j_ptr å¤å®ãããªãã¸ã§ã¯ãæ§é ä½ã®åç §ãã¤ã³ã¿2 - * @return éãåããã§ãããªãTRUEãè¿ã - * @details - *
- * See "object_similar()" for the same function for the "player" - *- */ -static void store_object_absorb(object_type *o_ptr, object_type *j_ptr) -{ - int max_num = (o_ptr->tval == TV_ROD) ? - MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99; - int total = o_ptr->number + j_ptr->number; - int diff = (total > max_num) ? total - max_num : 0; - o_ptr->number = (total > max_num) ? max_num : total; - if (o_ptr->tval == TV_ROD) - { - o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number; - } - - if (o_ptr->tval == TV_WAND) - { - o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number; - } -} - - -/*! - * @brief åºèã«åãç½®ãã¹ãã¼ã¹ããããã©ããã®å¤å®ãè¿ã / - * Check to see if the shop will be carrying too many objects -RAK- - * @param o_ptr åºèã«ç½®ããããªãã¸ã§ã¯ãæ§é ä½ã®åç §ãã¤ã³ã¿ - * @return ç½®ãå ´ããªããªã0ãéãåããã§ããã¢ã¤ãã ããããªã-1ãã¹ãã¼ã¹ããããªã1ãè¿ãã - * @details - *
- * Note that the shop, just like a player, will not accept things - * it cannot hold. Before, one could "nuke" potions this way. - * Return value is now int: - * 0 : No space - * -1 : Can be combined to existing slot. - * 1 : Cannot be combined but there are empty spaces. - *- */ -static int store_check_num(object_type *o_ptr) -{ - object_type *j_ptr; - if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) - { - bool old_stack_force_notes = stack_force_notes; - bool old_stack_force_costs = stack_force_costs; - - if (cur_store_num != STORE_HOME) - { - stack_force_notes = FALSE; - stack_force_costs = FALSE; - } - - for (int i = 0; i < st_ptr->stock_num; i++) - { - j_ptr = &st_ptr->stock[i]; - if (object_similar(j_ptr, o_ptr)) - { - if (cur_store_num != STORE_HOME) - { - stack_force_notes = old_stack_force_notes; - stack_force_costs = old_stack_force_costs; - } - - return -1; - } - } - - if (cur_store_num != STORE_HOME) - { - stack_force_notes = old_stack_force_notes; - stack_force_costs = old_stack_force_costs; - } - } - else - { - for (int i = 0; i < st_ptr->stock_num; i++) - { - j_ptr = &st_ptr->stock[i]; - if (store_object_similar(j_ptr, o_ptr)) return -1; - } - } - - /* Free space is always usable */ - /* - * ãªãã·ã§ã³ powerup_home ãè¨å®ããã¦ãã㨠- * æã家ã 20 ãã¼ã¸ã¾ã§ä½¿ãã - */ - if ((cur_store_num == STORE_HOME) && (powerup_home == FALSE)) - { - if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) - { - return 1; - } - } - else - { - if (st_ptr->stock_num < st_ptr->stock_size) - { - return 1; - } - } - - return 0; -} - - -/*! - * @brief ãªãã¸ã§ã¯ããç¥ç¦ããã¦ãããã®å¤å®ãè¿ã / - * @param o_ptr å¤å®ããããªãã¸ã§ã¯ãæ§é ä½ã®åç §ãã¤ã³ã¿ - * @return ã¢ã¤ãã ãç¥ç¦ãããã¢ã¤ãã ãªãã°TRUEãè¿ã - */ -static bool is_blessed_item(object_type *o_ptr) -{ - BIT_FLAGS flgs[TR_FLAG_SIZE]; - object_flags(o_ptr, flgs); - if (have_flag(flgs, TR_BLESSED)) return TRUE; - else return FALSE; -} - - -/*! - * @brief ãªãã¸ã§ã¯ããæå®ã®åºèã§å¼ãåãããã©ãããè¿ã / - * Determine if the current store will purchase the given item - * @param o_ptr å¤å®ããããªãã¸ã§ã¯ãæ§é ä½ã®åç §ãã¤ã³ã¿ - * @return ã¢ã¤ãã ãè²·ãåãããªãã°TRUEãè¿ã - * @note - * Note that a shop-keeper must refuse to buy "worthless" items - */ -static bool store_will_buy(object_type *o_ptr) -{ - if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) return TRUE; - switch (cur_store_num) - { - case STORE_GENERAL: - { - switch (o_ptr->tval) - { - case TV_POTION: - if (o_ptr->sval != SV_POTION_WATER) return FALSE; - - case TV_WHISTLE: - case TV_FOOD: - case TV_LITE: - case TV_FLASK: - case TV_SPIKE: - case TV_SHOT: - case TV_ARROW: - case TV_BOLT: - case TV_DIGGING: - case TV_CLOAK: - case TV_BOTTLE: - case TV_FIGURINE: - case TV_STATUE: - case TV_CAPTURE: - case TV_CARD: - break; - default: - return FALSE; - } - - break; - } - case STORE_ARMOURY: - { - switch (o_ptr->tval) - { - case TV_BOOTS: - case TV_GLOVES: - case TV_CROWN: - case TV_HELM: - case TV_SHIELD: - case TV_CLOAK: - case TV_SOFT_ARMOR: - case TV_HARD_ARMOR: - case TV_DRAG_ARMOR: - break; - default: - return FALSE; - } - - break; - } - case STORE_WEAPON: - { - switch (o_ptr->tval) - { - case TV_SHOT: - case TV_BOLT: - case TV_ARROW: - case TV_BOW: - case TV_DIGGING: - case TV_POLEARM: - case TV_SWORD: - case TV_HISSATSU_BOOK: - break; - case TV_HAFTED: - { - if (o_ptr->sval == SV_WIZSTAFF) return FALSE; - } - break; - default: - return FALSE; - } - - break; - } - case STORE_TEMPLE: - { - switch (o_ptr->tval) - { - case TV_LIFE_BOOK: - case TV_CRUSADE_BOOK: - case TV_SCROLL: - case TV_POTION: - case TV_HAFTED: - { - break; - } - case TV_FIGURINE: - case TV_STATUE: - { - monster_race *r_ptr = &r_info[o_ptr->pval]; - if (!(r_ptr->flags3 & RF3_EVIL)) - { - if (r_ptr->flags3 & RF3_GOOD) break; - if (r_ptr->flags3 & RF3_ANIMAL) break; - if (my_strchr("?!", r_ptr->d_char)) break; - } - } - case TV_POLEARM: - case TV_SWORD: - { - if (is_blessed_item(o_ptr)) break; - } - default: - return FALSE; - } - - break; - } - case STORE_ALCHEMIST: - { - switch (o_ptr->tval) - { - case TV_SCROLL: - case TV_POTION: - break; - default: - return FALSE; - } - - break; - } - case STORE_MAGIC: - { - switch (o_ptr->tval) - { - case TV_SORCERY_BOOK: - case TV_NATURE_BOOK: - case TV_CHAOS_BOOK: - case TV_DEATH_BOOK: - case TV_TRUMP_BOOK: - case TV_ARCANE_BOOK: - case TV_CRAFT_BOOK: - case TV_DAEMON_BOOK: - case TV_MUSIC_BOOK: - case TV_HEX_BOOK: - case TV_AMULET: - case TV_RING: - case TV_STAFF: - case TV_WAND: - case TV_ROD: - case TV_SCROLL: - case TV_POTION: - case TV_FIGURINE: - break; - case TV_HAFTED: - { - if (o_ptr->sval == SV_WIZSTAFF) break; - else return FALSE; - } - default: - return FALSE; - } - - break; - } - case STORE_BOOK: - { - switch (o_ptr->tval) - { - case TV_SORCERY_BOOK: - case TV_NATURE_BOOK: - case TV_CHAOS_BOOK: - case TV_DEATH_BOOK: - case TV_LIFE_BOOK: - case TV_TRUMP_BOOK: - case TV_ARCANE_BOOK: - case TV_CRAFT_BOOK: - case TV_DAEMON_BOOK: - case TV_CRUSADE_BOOK: - case TV_MUSIC_BOOK: - case TV_HEX_BOOK: - break; - default: - return FALSE; - } - - break; - } - } - - if (object_value(o_ptr) <= 0) return FALSE; - return TRUE; -} - - -/*! - * @brief ç¾å¨ã®çºã®æå®ãããåºèã®ã¢ã¤ãã ãæ´çãã / - * Combine and reorder items in store. - * @param store_num åºèID - * @return å®éã«æ´çãè¡ããããªãã°TRUEãè¿ãã - */ -bool combine_and_reorder_home(int store_num) -{ - store_type *old_st_ptr = st_ptr; - st_ptr = &town_info[1].store[store_num]; - bool flag = FALSE; - if (store_num != STORE_HOME) - { - stack_force_notes = FALSE; - stack_force_costs = FALSE; - } - - bool combined = TRUE; - while (combined) - { - combined = FALSE; - for (int i = st_ptr->stock_num - 1; i > 0; i--) - { - object_type *o_ptr; - o_ptr = &st_ptr->stock[i]; - if (!o_ptr->k_idx) continue; - for (int j = 0; j < i; j++) - { - object_type *j_ptr; - j_ptr = &st_ptr->stock[j]; - if (!j_ptr->k_idx) continue; - - /* - * Get maximum number of the stack if these - * are similar, get zero otherwise. - */ - int max_num = object_similar_part(j_ptr, o_ptr); - if (max_num == 0 || j_ptr->number >= max_num) continue; - - if (o_ptr->number + j_ptr->number <= max_num) - { - object_absorb(j_ptr, o_ptr); - st_ptr->stock_num--; - int k; - for (k = i; k < st_ptr->stock_num; k++) - { - st_ptr->stock[k] = st_ptr->stock[k + 1]; - } - - object_wipe(&st_ptr->stock[k]); - combined = TRUE; - break; - } - - ITEM_NUMBER old_num = o_ptr->number; - ITEM_NUMBER remain = j_ptr->number + o_ptr->number - max_num; - object_absorb(j_ptr, o_ptr); - o_ptr->number = remain; - if (o_ptr->tval == TV_ROD) - { - o_ptr->pval = o_ptr->pval * remain / old_num; - o_ptr->timeout = o_ptr->timeout * remain / old_num; - } - else if (o_ptr->tval == TV_WAND) - { - o_ptr->pval = o_ptr->pval * remain / old_num; - } - - combined = TRUE; - break; - } - } - - flag |= combined; - } - - for (int i = 0; i < st_ptr->stock_num; i++) - { - object_type *o_ptr; - o_ptr = &st_ptr->stock[i]; - if (!o_ptr->k_idx) continue; - - s32b o_value = object_value(o_ptr); - int j; - for (j = 0; j < st_ptr->stock_num; j++) - { - if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break; - } - - if (j >= i) continue; - - flag = TRUE; - object_type *j_ptr; - object_type forge; - j_ptr = &forge; - object_copy(j_ptr, &st_ptr->stock[i]); - for (int k = i; k > j; k--) - { - object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]); - } - - object_copy(&st_ptr->stock[j], j_ptr); - } - - st_ptr = old_st_ptr; - bool old_stack_force_notes = stack_force_notes; - bool old_stack_force_costs = stack_force_costs; - if (store_num != STORE_HOME) - { - stack_force_notes = old_stack_force_notes; - stack_force_costs = old_stack_force_costs; - } - - return flag; -} - - -/*! - * @brief æã家ã«ãªãã¸ã§ã¯ããå ãã / - * Add the item "o_ptr" to the inventory of the "Home" - * @param o_ptr å ããããªãã¸ã§ã¯ãã®æ§é ä½åç §ãã¤ã³ã¿ - * @return åããå ã®ID - * @details - *
- * In all cases, return the slot (or -1) where the object was placed - * Note that this is a hacked up version of "inven_carry()". - * Also note that it may not correctly "adapt" to "knowledge" bacoming - * known, the player may have to pick stuff up and drop it again. - *- */ -static int home_carry(player_type *player_ptr, object_type *o_ptr) -{ - if (cur_store_num != STORE_HOME) - { - stack_force_notes = FALSE; - stack_force_costs = FALSE; - } - - bool old_stack_force_notes = stack_force_notes; - bool old_stack_force_costs = stack_force_costs; - for (int slot = 0; slot < st_ptr->stock_num; slot++) - { - object_type *j_ptr; - j_ptr = &st_ptr->stock[slot]; - if (object_similar(j_ptr, o_ptr)) - { - object_absorb(j_ptr, o_ptr); - if (cur_store_num != STORE_HOME) - { - stack_force_notes = old_stack_force_notes; - stack_force_costs = old_stack_force_costs; - } - - return (slot); - } - } - - if (cur_store_num != STORE_HOME) - { - stack_force_notes = old_stack_force_notes; - stack_force_costs = old_stack_force_costs; - } - - /* No space? */ - /* - * é ãæ©è½: ãªãã·ã§ã³ powerup_home ãè¨å®ããã¦ãã㨠- * æã家ã 20 ãã¼ã¸ã¾ã§ä½¿ãã - */ - if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE)) - { - if (st_ptr->stock_num >= st_ptr->stock_size) - { - return -1; - } - } - else - { - if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10)) - { - return -1; - } - } - - PRICE value = object_value(o_ptr); - int slot; - for (slot = 0; slot < st_ptr->stock_num; slot++) - { - if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break; - } - - for (int i = st_ptr->stock_num; i > slot; i--) - { - st_ptr->stock[i] = st_ptr->stock[i - 1]; - } - - st_ptr->stock_num++; - st_ptr->stock[slot] = *o_ptr; - chg_virtue(player_ptr, V_SACRIFICE, -1); - (void)combine_and_reorder_home(cur_store_num); - return slot; -} - - -/*! - * @brief åºèã«ãªãã¸ã§ã¯ããå ãã / - * Add the item "o_ptr" to a real stores inventory. - * @param o_ptr å ããããªãã¸ã§ã¯ãã®æ§é ä½åç §ãã¤ã³ã¿ - * @return åããå ã®ID - * @details - *
- * In all cases, return the slot (or -1) where the object was placed - * Note that this is a hacked up version of "inven_carry()". - * Also note that it may not correctly "adapt" to "knowledge" bacoming - * known, the player may have to pick stuff up and drop it again. - *- */ -static int store_carry(object_type *o_ptr) -{ - PRICE value = object_value(o_ptr); - if (value <= 0) return -1; - o_ptr->ident |= IDENT_FULL_KNOWN; - o_ptr->inscription = 0; - o_ptr->feeling = FEEL_NONE; - int slot; - for (slot = 0; slot < st_ptr->stock_num; slot++) - { - object_type *j_ptr; - j_ptr = &st_ptr->stock[slot]; - if (store_object_similar(j_ptr, o_ptr)) - { - store_object_absorb(j_ptr, o_ptr); - return slot; - } - } - - if (st_ptr->stock_num >= st_ptr->stock_size) return -1; - - for (slot = 0; slot < st_ptr->stock_num; slot++) - { - object_type *j_ptr; - j_ptr = &st_ptr->stock[slot]; - if (o_ptr->tval > j_ptr->tval) break; - if (o_ptr->tval < j_ptr->tval) continue; - if (o_ptr->sval < j_ptr->sval) break; - if (o_ptr->sval > j_ptr->sval) continue; - if (o_ptr->tval == TV_ROD) - { - if (o_ptr->pval < j_ptr->pval) break; - if (o_ptr->pval > j_ptr->pval) continue; - } - - PRICE j_value = object_value(j_ptr); - if (value > j_value) break; - if (value < j_value) continue; - } - - for (int i = st_ptr->stock_num; i > slot; i--) - { - st_ptr->stock[i] = st_ptr->stock[i - 1]; - } - - st_ptr->stock_num++; - st_ptr->stock[slot] = *o_ptr; - return slot; -} - - -/*! - * @brief åºèã®ãªãã¸ã§ã¯ãæ°ãå¢ãã / - * Add the item "o_ptr" to a real stores inventory. - * @param item å¢ããããã¢ã¤ãã ã®ID - * @param num å¢ããããæ° - * @return ãªã - * @details - *
- * Increase, by a given amount, the number of a certain item - * in a certain store. This can result in zero items. - *- * @todo numã¯æ¬æ¥ITEM_NUMBERåã«ãããã - */ -static void store_item_increase(INVENTORY_IDX item, int num) -{ - object_type *o_ptr; - o_ptr = &st_ptr->stock[item]; - int cnt = o_ptr->number + num; - if (cnt > 255) cnt = 255; - else if (cnt < 0) cnt = 0; - - num = cnt - o_ptr->number; - o_ptr->number += (ITEM_NUMBER)num; -} - - -/*! - * @brief åºèã®ãªãã¸ã§ã¯ãæ°ãåé¤ãã / - * Remove a slot if it is empty - * @param item åé¤ãããã¢ã¤ãã ã®ID - * @return ãªã - */ -static void store_item_optimize(INVENTORY_IDX item) -{ - object_type *o_ptr; - o_ptr = &st_ptr->stock[item]; - if (!o_ptr->k_idx) return; - if (o_ptr->number) return; - - st_ptr->stock_num--; - for (int j = item; j < st_ptr->stock_num; j++) - { - st_ptr->stock[j] = st_ptr->stock[j + 1]; - } - - object_wipe(&st_ptr->stock[st_ptr->stock_num]); -} - - -/*! - * @brief ãã©ãã¯ãã¼ã±ããç¨ã®ç¡ä¾¡å¤åã®æé¤å¤å® / - * This function will keep 'crap' out of the black market. - * @param player_ptr ãã¬ã¼ã¤ã¼ã¸ã®åç §ãã¤ã³ã¿ - * @param o_ptr å¤å®ããããªãã¸ã§ã¯ãã®æ§é ä½åç §ãã¤ã³ã¿ - * @return ãã©ãã¯ãã¼ã±ããã«ã¨ã£ã¦ç¡ä¾¡å¤ãªåãªãã°TRUEãè¿ã - * @details - *
- * Crap is defined as any item that is "available" elsewhere - * Based on a suggestion by "Lee Vogt"- */ -static bool black_market_crap(player_type *player_ptr, object_type *o_ptr) -{ - if (object_is_ego(o_ptr)) return FALSE; - - if (o_ptr->to_a > 0) return FALSE; - if (o_ptr->to_h > 0) return FALSE; - if (o_ptr->to_d > 0) return FALSE; - - for (int i = 0; i < MAX_STORES; i++) - { - if (i == STORE_HOME) continue; - if (i == STORE_MUSEUM) continue; - - for (int j = 0; j < town_info[player_ptr->town_num].store[i].stock_num; j++) - { - object_type *j_ptr = &town_info[player_ptr->town_num].store[i].stock[j]; - if (o_ptr->k_idx == j_ptr->k_idx) return TRUE; - } - } - - return FALSE; -} - - -/*! - * @brief åºèã®åæãå¤åã®ããã«ã¢ã¤ãã ãåé¤ãã / - * Attempt to delete (some of) a random item from the store - * @return ãªã - * @details - *- *
- * Hack -- we attempt to "maintain" piles of items when possible. - *- */ -static void store_delete(void) -{ - INVENTORY_IDX what = (INVENTORY_IDX)randint0(st_ptr->stock_num); - int num = st_ptr->stock[what].number; - if (randint0(100) < 50) num = (num + 1) / 2; - if (randint0(100) < 50) num = 1; - if ((st_ptr->stock[what].tval == TV_ROD) || (st_ptr->stock[what].tval == TV_WAND)) - { - st_ptr->stock[what].pval -= num * st_ptr->stock[what].pval / st_ptr->stock[what].number; - } - - store_item_increase(what, -num); - store_item_optimize(what); -} - - -/*! - * @brief åºèã®åæãå¤åã®ããã«ã¢ã¤ãã ã追å ãã / - * Creates a random item and gives it to a store - * @param player_ptr ãã¬ã¼ã¤ã¼ã¸ã®åç §ãã¤ã³ã¿ - * @return ãªã - * @details - *
- * This algorithm needs to be rethought. A lot. - * Currently, "normal" stores use a pre-built array. - * Note -- the "level" given to "obj_get_num()" is a "favored" - * level, that is, there is a much higher chance of getting - * items with a level approaching that of the given level... - * Should we check for "permission" to have the given item? - *- */ -static void store_create(player_type *player_ptr) -{ - if (st_ptr->stock_num >= st_ptr->stock_size) return; - - for (int tries = 0; tries < 4; tries++) - { - OBJECT_IDX i; - DEPTH level; - if (cur_store_num == STORE_BLACK) - { - /* Pick a level for object/magic */ - level = 25 + randint0(25); - - /* Random item (usually of given level) */ - i = get_obj_num(player_ptr, level, 0x00000000); - - /* Handle failure */ - if (i == 0) continue; - } - else - { - i = st_ptr->table[randint0(st_ptr->table_num)]; - level = rand_range(1, STORE_OBJ_LEVEL); - } - - object_type forge; - object_type *q_ptr; - q_ptr = &forge; - object_prep(q_ptr, i); - apply_magic(player_ptr, q_ptr, level, AM_NO_FIXED_ART); - if (!store_will_buy(q_ptr)) continue; - - if (q_ptr->tval == TV_LITE) - { - if (q_ptr->sval == SV_LITE_TORCH) q_ptr->xtra4 = FUEL_TORCH / 2; - if (q_ptr->sval == SV_LITE_LANTERN) q_ptr->xtra4 = FUEL_LAMP / 2; - } - - object_known(q_ptr); - q_ptr->ident |= IDENT_STORE; - if (q_ptr->tval == TV_CHEST) continue; - - if (cur_store_num == STORE_BLACK) - { - if (black_market_crap(player_ptr, q_ptr)) continue; - if (object_value(q_ptr) < 10) continue; - } - else - { - if (object_value(q_ptr) <= 0) continue; - } - - mass_produce(q_ptr); - (void)store_carry(q_ptr); - break; - } -} - - -/*! - * @brief åºèã®å²å¼å¯¾è±¡å¤ã«ãããã©ãããå¤å® / - * Eliminate need to bargain if player has haggled well in the past - * @param minprice ã¢ã¤ãã ã®æä½è²©å£²ä¾¡æ ¼ - * @return å²å¼ãç¦æ¢ãããªãTRUEãè¿ãã - */ -static bool noneedtobargain(PRICE minprice) -{ - PRICE good = st_ptr->good_buy; - PRICE bad = st_ptr->bad_buy; - if (minprice < 10L) return TRUE; - if (good == MAX_SHORT) return TRUE; - if (good > ((3 * bad) + (5 + (minprice / 50)))) return TRUE; - - return FALSE; -} - - -/*! - * @brief åºä¸»ã®æã¤ãã¬ã¤ã¤ã¼ã«å¯¾ãã売買ã®è¯ãæªãçµé¨ãè¨æ¶ãã / - * Update the bargain info - * @param price å®éã®åå¼ä¾¡æ ¼ - * @param minprice åºä¸»ã®æ示ããä¾¡æ ¼ - * @param num å£²è²·æ° - * @return ãªã - */ -static void updatebargain(PRICE price, PRICE minprice, int num) -{ - if (!manual_haggle) return; - if ((minprice / num) < 10L) return; - if (price == minprice) - { - if (st_ptr->good_buy < MAX_SHORT) - { - st_ptr->good_buy++; - } - } - else - { - if (st_ptr->bad_buy < MAX_SHORT) - { - st_ptr->bad_buy++; - } - } -} - - -/*! - * @brief åºã®ååãªã¹ããå表示ãã / - * Re-displays a single store entry - * @param player_ptr ãã¬ã¼ã¤ã¼ã¸ã®åç §ãã¤ã³ã¿ - * @param pos è¡¨ç¤ºè¡ - * @return ãªã - */ -static void display_entry(player_type *player_ptr, int pos) -{ - object_type *o_ptr; - o_ptr = &st_ptr->stock[pos]; - int i = (pos % store_bottom); - - /* Label it, clear the line --(-- */ - char out_val[160]; - (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i))); - prt(out_val, i + 6, 0); - - int cur_col = 3; - if (show_item_graph) - { - TERM_COLOR a = object_attr(o_ptr); - SYMBOL_CODE c = object_char(o_ptr); - - Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0); - if (use_bigtile) cur_col++; - - cur_col += 2; - } - - /* Describe an item in the home */ - int maxwid = 75; - if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) - { - maxwid = 75; - if (show_weights) maxwid -= 10; - - GAME_TEXT o_name[MAX_NLEN]; - object_desc(player_ptr, o_name, o_ptr, 0); - o_name[maxwid] = '\0'; - c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col); - if (show_weights) - { - WEIGHT wgt = o_ptr->weight; -#ifdef JP - sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt)); - put_str(out_val, i + 6, 67); -#else - (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10); - put_str(out_val, i + 6, 68); -#endif - - } - - return; - } - - maxwid = 65; - if (show_weights) maxwid -= 7; - - GAME_TEXT o_name[MAX_NLEN]; - object_desc(player_ptr, o_name, o_ptr, 0); - o_name[maxwid] = '\0'; - c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col); - - if (show_weights) - { - int wgt = o_ptr->weight; -#ifdef JP - sprintf(out_val, "%3d.%1d", lbtokg1(wgt), lbtokg2(wgt)); - put_str(out_val, i + 6, 60); -#else - (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10); - put_str(out_val, i + 6, 61); -#endif - - } - - s32b x; - if (o_ptr->ident & (IDENT_FIXED)) - { - x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE); -#ifdef JP - (void)sprintf(out_val, "%9ldåº", (long)x); -#else - (void)sprintf(out_val, "%9ld F", (long)x); -#endif - put_str(out_val, i + 6, 68); - return; - } - - if (!manual_haggle) - { - x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE); - if (!noneedtobargain(x)) x += x / 10; - - (void)sprintf(out_val, "%9ld ", (long)x); - put_str(out_val, i + 6, 68); - return; - } - - x = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE); - (void)sprintf(out_val, "%9ld ", (long)x); - put_str(out_val, i + 6, 68); -} - - -/*! - * @brief åºã®ååãªã¹ãã表示ãã / - * Displays a store's inventory -RAK- - * @param player_ptr ãã¬ã¼ã¤ã¼ã¸ã®åç §ãã¤ã³ã¿ - * @return ãªã - * @details - * All prices are listed as "per individual object". -BEN- - */ -static void display_store_inventory(player_type *player_ptr) -{ - int k; - for (k = 0; k < store_bottom; k++) - { - if (store_top + k >= st_ptr->stock_num) break; - - display_entry(player_ptr, store_top + k); - } - - for (int i = k; i < store_bottom + 1; i++) - prt("", i + 6, 0); - -#ifdef JP - put_str(" ", 5, 20); -#else - put_str(" ", 5, 22); -#endif - - if (st_ptr->stock_num > store_bottom) - { - prt(_("-ç¶ã-", "-more-"), k + 6, 3); - put_str(format(_("(%dãã¼ã¸) ", "(Page %d) "), store_top / store_bottom + 1), 5, _(20, 22)); - } - - if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM) - { - k = st_ptr->stock_size; - if (cur_store_num == STORE_HOME && !powerup_home) k /= 10; -#ifdef JP - put_str(format("ã¢ã¤ãã æ°: %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 27); -#else - put_str(format("Objects: %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 30); -#endif - } -} - - -/*! - * @brief ãã¬ã¤ã¤ã¼ã®ææéã表示ãã / - * Displays players gold -RAK- - * @param player_ptr ãã¬ã¼ã¤ã¼ã¸ã®åç §ãã¤ã³ã¿ - * @return ãªã - * @details - */ -static void store_prt_gold(player_type *player_ptr) -{ - prt(_("ææã¡ã®ãé: ", "Gold Remaining: "), 19 + xtra_stock, 53); - char out_val[64]; - sprintf(out_val, "%9ld", (long)player_ptr->au); - prt(out_val, 19 + xtra_stock, 68); -} - - -/*! - * @brief åºèæ å ±å ¨ä½ã表示ããã¡ã¤ã³ã«ã¼ãã³ / - * Displays store (after clearing screen) -RAK- - * @param player_ptr ãã¬ã¼ã¤ã¼ã¸ã®åç §ãã¤ã³ã¿ - * @return ãªã - * @details - */ -static void display_store(player_type *player_ptr) -{ - Term_clear(); - if (cur_store_num == STORE_HOME) - { - put_str(_("æã家", "Your Home"), 3, 31); - put_str(_("ã¢ã¤ãã ã®ä¸è¦§", "Item Description"), 5, 4); - if (show_weights) - { - put_str(_(" éã", "Weight"), 5, 70); - } - - store_prt_gold(player_ptr); - display_store_inventory(player_ptr); - return; - } - - if (cur_store_num == STORE_MUSEUM) - { - put_str(_("åç©é¤¨", "Museum"), 3, 31); - put_str(_("ã¢ã¤ãã ã®ä¸è¦§", "Item Description"), 5, 4); - if (show_weights) - { - put_str(_(" éã", "Weight"), 5, 70); - } - - store_prt_gold(player_ptr); - display_store_inventory(player_ptr); - return; - } - - concptr store_name = (f_name + f_info[cur_store_feat].name); - concptr owner_name = (ot_ptr->owner_name); - concptr race_name = race_info[ot_ptr->owner_race].title; - char buf[80]; - sprintf(buf, "%s (%s)", owner_name, race_name); - put_str(buf, 3, 10); - - sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost)); - prt(buf, 3, 50); - - put_str(_("ååã®ä¸è¦§", "Item Description"), 5, 5); - if (show_weights) - { - put_str(_(" éã", "Weight"), 5, 60); - } - - put_str(_(" ä¾¡æ ¼", "Price"), 5, 72); - store_prt_gold(player_ptr); - display_store_inventory(player_ptr); -} - - -/*! - * @brief åºèããã¢ã¤ãã ãé¸æãã / - * Get the ID of a store item and return its value -RAK- - * @param com_val é¸æIDãè¿ãåç §ãã¤ã³ã¿ - * @param pmt ã¡ãã»ã¼ã¸ãã£ãã·ã§ã³ - * @param i é¸æç¯å²ã®æå°å¤ - * @param j é¸æç¯å²ã®æå¤§å¤ - * @return å®éã«é¸æãããTRUEããã£ã³ã»ã«ãããFALSE - */ -static int get_stock(COMMAND_CODE *com_val, concptr pmt, int i, int j) -{ - if (repeat_pull(com_val) && (*com_val >= i) && (*com_val <= j)) - { - return TRUE; - } - - msg_print(NULL); - *com_val = (-1); - char lo = I2A(i); - char hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j); - char out_val[160]; -#ifdef JP - (void)sprintf(out_val, "(%s:%c-%c, ESCã§ä¸æ) %s", - (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "ã¢ã¤ãã " : "åå"), - lo, hi, pmt); -#else - (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s", - lo, hi, pmt); -#endif - - char command; - while (TRUE) - { - if (!get_com(out_val, &command, FALSE)) break; - - COMMAND_CODE k; - if (islower(command)) - k = A2I(command); - else if (isupper(command)) - k = A2I(tolower(command)) + 26; - else - k = -1; - - if ((k >= i) && (k <= j)) - { - *com_val = k; - break; - } - - bell(); - } - - prt("", 0, 0); - if (command == ESCAPE) return FALSE; - - repeat_push(*com_val); - return TRUE; -} - - -/*! - * @brief åºä¸»ã®ä¸æºåº¦ãå¢ããããã¬ã¤ã¤ã¼ãç· ãåºãå¤å®ã¨å¦çãè¡ã / - * Increase the insult counter and get angry if too many -RAK- - * @return ãã¬ã¤ã¤ã¼ãç· ãåºãå ´åTRUEãè¿ã - */ -static int increase_insults(void) -{ - st_ptr->insult_cur++; - if (st_ptr->insult_cur <= ot_ptr->insult_max) return FALSE; - - say_comment_4(); - - st_ptr->insult_cur = 0; - st_ptr->good_buy = 0; - st_ptr->bad_buy = 0; - st_ptr->store_open = current_world_ptr->game_turn + TURNS_PER_TICK * TOWN_DAWN / 8 + randint1(TURNS_PER_TICK*TOWN_DAWN / 8); - - return TRUE; -} - - -/*! - * @brief åºä¸»ã®ä¸æºåº¦ãæ¸ãã / - * Decrease insults -RAK- - * @return ãã¬ã¤ã¤ã¼ãç· ãåºãå ´åTRUEãè¿ã - */ -static void decrease_insults(void) -{ - if (st_ptr->insult_cur) st_ptr->insult_cur--; -} - - -/*! - * @brief åºä¸»ã®ä¸æºåº¦ãå¢ããå ´åã®ã¿ã®ã¡ãã»ã¼ã¸ã表示ãã / - * Have insulted while haggling -RAK- - * @return ãã¬ã¤ã¤ã¼ãç· ãåºãå ´åTRUEãè¿ã - */ -static int haggle_insults(void) -{ - if (increase_insults()) return TRUE; - - say_comment_5(); - return FALSE; -} - -/* - * Mega-Hack -- Enable "increments" - */ -static bool allow_inc = FALSE; - -/* - * Mega-Hack -- Last "increment" during haggling - */ -static s32b last_inc = 0L; - -/*! - * @brief 交æ¸ä¾¡æ ¼ã確èªã¨èªè¨¼ã®æ¯éãè¡ã / - * Get a haggle - * @param pmt ã¡ãã»ã¼ã¸ - * @param poffer å¥éä¾¡æ ¼æ示ãããå ´åã®å¤ãè¿ãåç §ãã¤ã³ã¿ - * @param price ç¾å¨ã®äº¤æ¸ä¾¡æ ¼ - * @param final æçµç¢ºå®ä¾¡æ ¼ãªãã°TRUE - * @return ãã¬ã¤ã¤ã¼ãç· ãåºãå ´åTRUEãè¿ã - */ -static int get_haggle(concptr pmt, s32b *poffer, PRICE price, int final) -{ - GAME_TEXT buf[128]; - if (!allow_inc) last_inc = 0L; - - if (final) - { - sprintf(buf, _("%s [æ¿è«¾] ", "%s [accept] "), pmt); - } - else if (last_inc < 0) - { - sprintf(buf, _("%s [-$%ld] ", "%s [-%ld] "), pmt, (long)(ABS(last_inc))); - } - else if (last_inc > 0) - { - sprintf(buf, _("%s [+$%ld] ", "%s [+%ld] "), pmt, (long)(ABS(last_inc))); - } - else - { - sprintf(buf, "%s ", pmt); - } - - msg_print(NULL); - GAME_TEXT out_val[160]; - while (TRUE) - { - bool res; - prt(buf, 0, 0); - strcpy(out_val, ""); - - /* - * Ask the user for a response. - * Don't allow to use numpad as cursor key. - */ - res = askfor_aux(out_val, 32, FALSE); - prt("", 0, 0); - if (!res) return FALSE; - - concptr p; - for (p = out_val; *p == ' '; p++) /* loop */; - - if (*p == '\0') - { - if (final) - { - *poffer = price; - last_inc = 0L; - break; - } - - if (allow_inc && last_inc) - { - *poffer += last_inc; - break; - } - - msg_print(_("å¤ãããããã§ãã", "Invalid response.")); - msg_print(NULL); - } - - s32b i = atol(p); - if ((*p == '+' || *p == '-')) - { - if (allow_inc) - { - *poffer += i; - last_inc = i; - break; - } - } - else - { - *poffer = i; - last_inc = 0L; - break; - } - } - - return TRUE; -} - - -/*! - * @brief åºä¸»ããã¬ã¤ã¤ã¼ããã®äº¤æ¸ä¾¡æ ¼ãå¤æãã / - * Receive an offer (from the player) - * @param pmt ã¡ãã»ã¼ã¸ - * @param poffer åºä¸»ããã®äº¤æ¸ä¾¡æ ¼ãè¿ãåç §ãã¤ã³ã¿ - * @param last_offer ç¾å¨ã®äº¤æ¸ä¾¡æ ¼ - * @param factor åºä¸»ã®ä¾¡æ ¼åºæºåç - * @param price ã¢ã¤ãã ã®å®ä¾¡å¤ - * @param final æçµä¾¡æ ¼ç¢ºå®ãªãã°TRUE - * @return ãã¬ã¤ã¤ã¼ã®ä¾¡æ ¼ã«å¯¾ãã¦ä¸æãªãã°TRUEãè¿ã / - * Return TRUE if offer is NOT okay - */ -static bool receive_offer(concptr pmt, s32b *poffer, s32b last_offer, int factor, PRICE price, int final) -{ - while (TRUE) - { - if (!get_haggle(pmt, poffer, price, final)) return TRUE; - if (((*poffer) * factor) >= (last_offer * factor)) break; - if (haggle_insults()) return TRUE; - - (*poffer) = last_offer; - } - - return FALSE; -} - - -/*! - * @brief ãã¬ã¤ã¤ã¼ãè³¼å ¥ããæã®å¤åãå¦çã¡ã¤ã³ã«ã¼ãã³ / - * Haggling routine -RAK- - * @param player_ptr ãã¬ã¼ã¤ã¼ã¸ã®åç §ãã¤ã³ã¿ - * @param o_ptr ãªãã¸ã§ã¯ãã®æ§é ä½åç §ãã¤ã³ã¿ - * @param price æçµä¾¡æ ¼ãè¿ãåç §ãã¤ã³ã¿ - * @return ãã¬ã¤ã¤ã¼ã®ä¾¡æ ¼ã«å¯¾ãã¦åºä¸»ãä¸æãªãã°TRUEãè¿ã / - * Return TRUE if purchase is NOT successful - */ -static bool purchase_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price) -{ - s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE); - s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE); - int noneed = noneedtobargain(final_ask); - bool final = FALSE; - concptr pmt = _("æç¤ºä¾¡æ ¼", "Asking"); - if (noneed || !manual_haggle) - { - if (noneed) - { - msg_print(_("çµå±ãã®éé¡ã«ã¾ã¨ã¾ã£ãã", "You eventually agree upon the price.")); - msg_print(NULL); - } - else - { - msg_print(_("ãããªãã¨ãã®éé¡ã«ã¾ã¨ã¾ã£ãã", "You quickly agree upon the price.")); - msg_print(NULL); - final_ask += final_ask / 10; - } - - cur_ask = final_ask; - pmt = _("æçµæç¤ºä¾¡æ ¼", "Final Offer"); - final = TRUE; - } - - cur_ask *= o_ptr->number; - final_ask *= o_ptr->number; - s32b min_per = ot_ptr->haggle_per; - s32b max_per = min_per * 3; - s32b last_offer = object_value(o_ptr) * o_ptr->number; - last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L; - if (last_offer <= 0) last_offer = 1; - - s32b offer = 0; - allow_inc = FALSE; - bool flag = FALSE; - int annoyed = 0; - bool cancel = FALSE; - *price = 0; - while (!flag) - { - bool loop_flag = TRUE; - - while (!flag && loop_flag) - { - char out_val[160]; - (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask); - put_str(out_val, 1, 0); - cancel = receive_offer(_("æ示ããéé¡? ", "What do you offer? "), &offer, last_offer, 1, cur_ask, final); - if (cancel) - { - flag = TRUE; - } - else if (offer > cur_ask) - { - say_comment_6(); - offer = last_offer; - } - else if (offer == cur_ask) - { - flag = TRUE; - *price = offer; - } - else - { - loop_flag = FALSE; - } - } - - if (flag) continue; - - s32b x1 = 100 * (offer - last_offer) / (cur_ask - last_offer); - if (x1 < min_per) - { - if (haggle_insults()) - { - flag = TRUE; - cancel = TRUE; - } - } - else if (x1 > max_per) - { - x1 = x1 * 3 / 4; - if (x1 < max_per) x1 = max_per; - } - - s32b x2 = rand_range(x1 - 2, x1 + 2); - s32b x3 = ((cur_ask - offer) * x2 / 100L) + 1; - if (x3 < 0) x3 = 0; - cur_ask -= x3; - - if (cur_ask < final_ask) - { - final = TRUE; - cur_ask = final_ask; - pmt = _("æçµæç¤ºä¾¡æ ¼", "What do you offer? "); - annoyed++; - if (annoyed > 3) - { - (void)(increase_insults()); - cancel = TRUE; - flag = TRUE; - } - } - else if (offer >= cur_ask) - { - flag = TRUE; - *price = offer; - } - - last_offer = offer; - allow_inc = TRUE; - prt("", 1, 0); - char out_val[160]; - (void)sprintf(out_val, _("ååã®æ示éé¡: $%ld", "Your last offer: %ld"), (long)last_offer); - put_str(out_val, 1, 39); - say_comment_2(cur_ask, annoyed); - } - - if (cancel) return TRUE; - - updatebargain(*price, final_ask, o_ptr->number); - return FALSE; -} - - -/*! - * @brief ãã¬ã¤ã¤ã¼ã売å´ããæã®å¤åãå¦çã¡ã¤ã³ã«ã¼ãã³ / - * Haggling routine -RAK- - * @param player_ptr ãã¬ã¼ã¤ã¼ã¸ã®åç §ãã¤ã³ã¿ - * @param o_ptr ãªãã¸ã§ã¯ãã®æ§é ä½åç §ãã¤ã³ã¿ - * @param price æçµä¾¡æ ¼ãè¿ãåç §ãã¤ã³ã¿ - * @return ãã¬ã¤ã¤ã¼ã®ä¾¡æ ¼ã«å¯¾ãã¦åºä¸»ãä¸æãªãã°TRUEãè¿ã / - * Return TRUE if purchase is NOT successful - */ -static bool sell_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price) -{ - s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, TRUE); - s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, TRUE); - int noneed = noneedtobargain(final_ask); - s32b purse = (s32b)(ot_ptr->max_cost); - bool final = FALSE; - concptr pmt = _("æ示éé¡", "Offer"); - if (noneed || !manual_haggle || (final_ask >= purse)) - { - if (!manual_haggle && !noneed) - { - final_ask -= final_ask / 10; - } - - if (final_ask >= purse) - { - msg_print(_("å³åº§ã«ãã®éé¡ã«ã¾ã¨ã¾ã£ãã", "You instantly agree upon the price.")); - msg_print(NULL); - final_ask = purse; - } - else if (noneed) - { - msg_print(_("çµå±ãã®éé¡ã«ã¾ã¨ã¾ã£ãã", "You eventually agree upon the price.")); - msg_print(NULL); - } - else - { - msg_print(_("ãããªãã¨ãã®éé¡ã«ã¾ã¨ã¾ã£ãã", "You quickly agree upon the price.")); - msg_print(NULL); - } - - cur_ask = final_ask; - final = TRUE; - pmt = _("æçµæ示éé¡", "Final Offer"); - } - - cur_ask *= o_ptr->number; - final_ask *= o_ptr->number; - - s32b min_per = ot_ptr->haggle_per; - s32b max_per = min_per * 3; - s32b last_offer = object_value(o_ptr) * o_ptr->number; - last_offer = last_offer * ot_ptr->max_inflate / 100L; - s32b offer = 0; - allow_inc = FALSE; - bool flag = FALSE; - bool loop_flag; - int annoyed = 0; - bool cancel = FALSE; - *price = 0; - while (!flag) - { - while (TRUE) - { - loop_flag = TRUE; - - char out_val[160]; - (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask); - put_str(out_val, 1, 0); - cancel = receive_offer(_("æ示ããä¾¡æ ¼? ", "What price do you ask? "), - &offer, last_offer, -1, cur_ask, final); - - if (cancel) - { - flag = TRUE; - } - else if (offer < cur_ask) - { - say_comment_6(); - offer = last_offer; - } - else if (offer == cur_ask) - { - flag = TRUE; - *price = offer; - } - else - { - loop_flag = FALSE; - } - - if (flag || !loop_flag) break; - } - - if (flag) continue; - - s32b x1 = 100 * (last_offer - offer) / (last_offer - cur_ask); - if (x1 < min_per) - { - if (haggle_insults()) - { - flag = TRUE; - cancel = TRUE; - } - } - else if (x1 > max_per) - { - x1 = x1 * 3 / 4; - if (x1 < max_per) x1 = max_per; - } - - s32b x2 = rand_range(x1 - 2, x1 + 2); - s32b x3 = ((offer - cur_ask) * x2 / 100L) + 1; - if (x3 < 0) x3 = 0; - cur_ask += x3; - - if (cur_ask > final_ask) - { - cur_ask = final_ask; - final = TRUE; - pmt = _("æçµæ示éé¡", "Final Offer"); - - annoyed++; - if (annoyed > 3) - { - flag = TRUE; -#ifdef JP - /* 追å $0 ã§è²·ãåããã¦ãã¾ãã®ãé²æ¢ By FIRST*/ - cancel = TRUE; -#endif - (void)(increase_insults()); - } - } - else if (offer <= cur_ask) - { - flag = TRUE; - *price = offer; - } - - last_offer = offer; - allow_inc = TRUE; - prt("", 1, 0); - char out_val[160]; - (void)sprintf(out_val, _("ååã®æç¤ºä¾¡æ ¼ $%ld", "Your last bid %ld"), (long)last_offer); - put_str(out_val, 1, 39); - say_comment_3(cur_ask, annoyed); - } - - if (cancel) return TRUE; - - updatebargain(*price, final_ask, o_ptr->number); - return FALSE; -} - - -/*! - * @brief åºããã®è³¼å ¥å¦çã®ã¡ã¤ã³ã«ã¼ãã³ / - * Buy an item from a store -RAK- - * @param player_ptr ãã¬ã¼ã¤ã¼ã¸ã®åç §ãã¤ã³ã¿ - * @return ãªã - */ -static void store_purchase(player_type *player_ptr) -{ - if (cur_store_num == STORE_MUSEUM) - { - msg_print(_("åç©é¤¨ããåãåºããã¨ã¯ã§ãã¾ããã", "Museum.")); - return; - } - - if (st_ptr->stock_num <= 0) - { - if (cur_store_num == STORE_HOME) - msg_print(_("æã家ã«ã¯ä½ãç½®ãã¦ããã¾ããã", "Your home is empty.")); - else - msg_print(_("ç¾å¨ååã®å¨åº«ãåããã¦ãã¾ãã", "I am currently out of stock.")); - return; - } - - int i = (st_ptr->stock_num - store_top); - if (i > store_bottom) i = store_bottom; - - char out_val[160]; -#ifdef JP - /* ãã©ãã¯ãã¼ã±ããã®æã¯å¥ã®ã¡ãã»ã¼ã¸ */ - switch (cur_store_num) { - case 7: - sprintf(out_val, "ã©ã®ã¢ã¤ãã ãåãã¾ãã? "); - break; - case 6: - sprintf(out_val, "ã©ã? "); - break; - default: - sprintf(out_val, "ã©ã®åç©ã欲ãããã ã? "); - break; - } -#else - if (cur_store_num == STORE_HOME) - { - sprintf(out_val, "Which item do you want to take? "); - } - else - { - sprintf(out_val, "Which item are you interested in? "); - } -#endif - - COMMAND_CODE item; - if (!get_stock(&item, out_val, 0, i - 1)) return; - - item = item + store_top; - object_type *o_ptr; - o_ptr = &st_ptr->stock[item]; - ITEM_NUMBER amt = 1; - object_type forge; - object_type *j_ptr; - j_ptr = &forge; - object_copy(j_ptr, o_ptr); - - /* - * If a rod or wand, allocate total maximum timeouts or charges - * between those purchased and left on the shelf. - */ - reduce_charges(j_ptr, o_ptr->number - amt); - j_ptr->number = amt; - if (!inven_carry_okay(j_ptr)) - { - msg_print(_("ãããªã«ã¢ã¤ãã ãæã¦ãªãã", "You cannot carry that many different items.")); - return; - } - - PRICE best = price_item(player_ptr, j_ptr, ot_ptr->min_inflate, FALSE); - if (o_ptr->number > 1) - { - if ((cur_store_num != STORE_HOME) && - (o_ptr->ident & IDENT_FIXED)) - { - msg_format(_("ä¸ã¤ã«ã¤ã $%ldã§ãã", "That costs %ld gold per item."), (long)(best)); - } - - amt = get_quantity(NULL, o_ptr->number); - if (amt <= 0) return; - } - - j_ptr = &forge; - object_copy(j_ptr, o_ptr); - - /* - * If a rod or wand, allocate total maximum timeouts or charges - * between those purchased and left on the shelf. - */ - reduce_charges(j_ptr, o_ptr->number - amt); - j_ptr->number = amt; - if (!inven_carry_okay(j_ptr)) - { - msg_print(_("ã¶ãã¯ã«ãã®ã¢ã¤ãã ãå ¥ããééããªãã", "You cannot carry that many items.")); - return; - } - - int choice; - COMMAND_CODE item_new; - PRICE price; - if (cur_store_num == STORE_HOME) - { - bool combined_or_reordered; - distribute_charges(o_ptr, j_ptr, amt); - item_new = inven_carry(player_ptr, j_ptr); - GAME_TEXT o_name[MAX_NLEN]; - object_desc(player_ptr, o_name, &player_ptr->inventory_list[item_new], 0); - - msg_format(_("%s(%c)ãåã£ãã", "You have %s (%c)."), o_name, index_to_label(item_new)); - handle_stuff(player_ptr); - - i = st_ptr->stock_num; - store_item_increase(item, -amt); - store_item_optimize(item); - combined_or_reordered = combine_and_reorder_home(STORE_HOME); - if (i == st_ptr->stock_num) - { - if (combined_or_reordered) display_store_inventory(player_ptr); - else display_entry(player_ptr, item); - } - else - { - if (st_ptr->stock_num == 0) store_top = 0; - else if (store_top >= st_ptr->stock_num) store_top -= store_bottom; - display_store_inventory(player_ptr); - - chg_virtue(player_ptr, V_SACRIFICE, 1); - } - - return; - } - - if (o_ptr->ident & (IDENT_FIXED)) - { - choice = 0; - price = (best * j_ptr->number); - } - else - { - GAME_TEXT o_name[MAX_NLEN]; - object_desc(player_ptr, o_name, j_ptr, 0); - msg_format(_("%s(%c)ãè³¼å ¥ããã", "Buying %s (%c)."), o_name, I2A(item)); - msg_print(NULL); - choice = purchase_haggle(player_ptr, j_ptr, &price); - if (st_ptr->store_open >= current_world_ptr->game_turn) return; - } - - if (choice != 0) return; - if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED); - if (player_ptr->au < price) - { - msg_print(_("ãéã足ãã¾ããã", "You do not have enough gold.")); - return; - } - - say_comment_1(player_ptr); - if (cur_store_num == STORE_BLACK) - chg_virtue(player_ptr, V_JUSTICE, -1); - if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME)) - chg_virtue(player_ptr, V_NATURE, -1); - - sound(SOUND_BUY); - decrease_insults(); - player_ptr->au -= price; - store_prt_gold(player_ptr); - object_aware(player_ptr, j_ptr); - j_ptr->ident &= ~(IDENT_FIXED); - GAME_TEXT o_name[MAX_NLEN]; - object_desc(player_ptr, o_name, j_ptr, 0); - - msg_format(_("%sã $%ldã§è³¼å ¥ãã¾ããã", "You bought %s for %ld gold."), o_name, (long)price); - - strcpy(record_o_name, o_name); - record_turn = current_world_ptr->game_turn; - - if (record_buy) exe_write_diary(player_ptr, DIARY_BUY, 0, o_name); - object_desc(player_ptr, o_name, o_ptr, OD_NAME_ONLY); - if (record_rand_art && o_ptr->art_name) - exe_write_diary(player_ptr, DIARY_ART, 0, o_name); - - j_ptr->inscription = 0; - j_ptr->feeling = FEEL_NONE; - j_ptr->ident &= ~(IDENT_STORE); - item_new = inven_carry(player_ptr, j_ptr); - - object_desc(player_ptr, o_name, &player_ptr->inventory_list[item_new], 0); - msg_format(_("%s(%c)ãæã«å ¥ããã", "You have %s (%c)."), o_name, index_to_label(item_new)); - autopick_alter_item(player_ptr, item_new, FALSE); - if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND)) - { - o_ptr->pval -= j_ptr->pval; - } - - handle_stuff(player_ptr); - i = st_ptr->stock_num; - store_item_increase(item, -amt); - store_item_optimize(item); - if (st_ptr->stock_num == 0) - { - if (one_in_(STORE_SHUFFLE)) - { - char buf[80]; - msg_print(_("åºä¸»ã¯å¼éããã", "The shopkeeper retires.")); - store_shuffle(player_ptr, cur_store_num); - - prt("", 3, 0); - sprintf(buf, "%s (%s)", - ot_ptr->owner_name, race_info[ot_ptr->owner_race].title); - put_str(buf, 3, 10); - sprintf(buf, "%s (%ld)", - (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost)); - prt(buf, 3, 50); - } - else - { - msg_print(_("åºä¸»ã¯æ°ããªå¨åº«ãåãåºããã", "The shopkeeper brings out some new stock.")); - } - - for (i = 0; i < 10; i++) - { - store_maint(player_ptr, player_ptr->town_num, cur_store_num); - } - - store_top = 0; - display_store_inventory(player_ptr); - } - else if (st_ptr->stock_num != i) - { - if (store_top >= st_ptr->stock_num) store_top -= store_bottom; - display_store_inventory(player_ptr); - } - else - { - display_entry(player_ptr, item); - } -} - - -/*! - * @brief åºããã®å£²å´å¦çã®ã¡ã¤ã³ã«ã¼ãã³ / - * Sell an item to the store (or home) - * @param owner_ptr ãã¬ã¼ã¤ã¼ã¸ã®åç §ãã¤ã³ã¿ - * @return ãªã - */ -static void store_sell(player_type *owner_ptr) -{ - concptr q; - if (cur_store_num == STORE_HOME) - q = _("ã©ã®ã¢ã¤ãã ãç½®ãã¾ãã? ", "Drop which item? "); - else if (cur_store_num == STORE_MUSEUM) - q = _("ã©ã®ã¢ã¤ãã ãå¯è´ãã¾ãã? ", "Give which item? "); - else - q = _("ã©ã®ã¢ã¤ãã ã売ãã¾ãã? ", "Sell which item? "); - - item_tester_hook = store_will_buy; - - /* æã家ã§ããããªã¡ãã»ã¼ã¸ãåºããªãªã¸ãã«ã®ãã°ãä¿®æ£ */ - concptr s; - if (cur_store_num == STORE_HOME) - { - s = _("ç½®ããã¢ã¤ãã ãæã£ã¦ãã¾ããã", "You don't have any item to drop."); - } - else if (cur_store_num == STORE_MUSEUM) - { - s = _("å¯è´ã§ããã¢ã¤ãã ãæã£ã¦ãã¾ããã", "You don't have any item to give."); - } - else - { - s = _("欲ããç©ããªãã§ãããã", "You have nothing that I want."); - } - - OBJECT_IDX item; - object_type *o_ptr; - o_ptr = choose_object(owner_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0); - if (!o_ptr) return; - - if ((item >= INVEN_RARM) && object_is_cursed(o_ptr)) - { - msg_print(_("ãµã¼ããã©ãããããã¯åªããã¦ããããã ãã", "Hmmm, it seems to be cursed.")); - return; - } - - int amt = 1; - if (o_ptr->number > 1) - { - amt = get_quantity(NULL, o_ptr->number); - if (amt <= 0) return; - } - - object_type forge; - object_type *q_ptr; - q_ptr = &forge; - object_copy(q_ptr, o_ptr); - q_ptr->number = amt; - - /* - * Hack -- If a rod or wand, allocate total maximum - * timeouts or charges to those being sold. -LM- - */ - if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND)) - { - q_ptr->pval = o_ptr->pval * amt / o_ptr->number; - } - - GAME_TEXT o_name[MAX_NLEN]; - object_desc(owner_ptr, o_name, q_ptr, 0); - - /* Remove any inscription, feeling for stores */ - if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM)) - { - q_ptr->inscription = 0; - q_ptr->feeling = FEEL_NONE; - } - - /* Is there room in the store (or the home?) */ - if (!store_check_num(q_ptr)) - { - if (cur_store_num == STORE_HOME) - msg_print(_("æã家ã«ã¯ããç½®ãå ´æããªãã", "Your home is full.")); - - else if (cur_store_num == STORE_MUSEUM) - msg_print(_("åç©é¤¨ã¯ããæºæ¯ã ã", "Museum is full.")); - - else - msg_print(_("ããã¾ããããåºã«ã¯ããç½®ãå ´æãããã¾ããã", "I have not the room in my store to keep it.")); - - return; - } - - int choice; - PRICE price, value, dummy; - if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM)) - { - msg_format(_("%s(%c)ã売å´ããã", "Selling %s (%c)."), o_name, index_to_label(item)); - msg_print(NULL); - - choice = sell_haggle(owner_ptr, q_ptr, &price); - if (st_ptr->store_open >= current_world_ptr->game_turn) return; - - if (choice == 0) - { - say_comment_1(owner_ptr); - sound(SOUND_SELL); - if (cur_store_num == STORE_BLACK) - chg_virtue(owner_ptr, V_JUSTICE, -1); - - if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME)) - chg_virtue(owner_ptr, V_NATURE, 1); - decrease_insults(); - - owner_ptr->au += price; - store_prt_gold(owner_ptr); - dummy = object_value(q_ptr) * q_ptr->number; - - identify_item(owner_ptr, o_ptr); - q_ptr = &forge; - object_copy(q_ptr, o_ptr); - q_ptr->number = amt; - q_ptr->ident |= IDENT_STORE; - - /* - * Hack -- If a rod or wand, let the shopkeeper know just - * how many charges he really paid for. -LM- - */ - if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND)) - { - q_ptr->pval = o_ptr->pval * amt / o_ptr->number; - } - - value = object_value(q_ptr) * q_ptr->number; - object_desc(owner_ptr, o_name, q_ptr, 0); - msg_format(_("%sã $%ldã§å£²å´ãã¾ããã", "You sold %s for %ld gold."), o_name, (long)price); - - if (record_sell) exe_write_diary(owner_ptr, DIARY_SELL, 0, o_name); - - if (!((o_ptr->tval == TV_FIGURINE) && (value > 0))) - { - purchase_analyze(owner_ptr, price, value, dummy); - } - - /* - * Hack -- Allocate charges between those wands or rods sold - * and retained, unless all are being sold. -LM- - */ - distribute_charges(o_ptr, q_ptr, amt); - q_ptr->timeout = 0; - inven_item_increase(owner_ptr, item, -amt); - inven_item_describe(owner_ptr, item); - if (o_ptr->number > 0) - autopick_alter_item(owner_ptr, item, FALSE); - - inven_item_optimize(owner_ptr, item); - handle_stuff(owner_ptr); - int item_pos = store_carry(q_ptr); - if (item_pos >= 0) - { - store_top = (item_pos / store_bottom) * store_bottom; - display_store_inventory(owner_ptr); - } - } - } - else if (cur_store_num == STORE_MUSEUM) - { - char o2_name[MAX_NLEN]; - object_desc(owner_ptr, o2_name, q_ptr, OD_NAME_ONLY); - - if (-1 == store_check_num(q_ptr)) - { - msg_print(_("ããã¨åãåç©ã¯æ¢ã«åç©é¤¨ã«ããããã§ãã", "The Museum already has one of those items.")); - } - else - { - msg_print(_("åç©é¤¨ã«å¯è´ãããã®ã¯åãåºããã¨ãã§ãã¾ããï¼ï¼", "You cannot take back items which have been donated to the Museum!!")); - } - - if (!get_check(format(_("æ¬å½ã«%sãå¯è´ãã¾ããï¼", "Really give %s to the Museum? "), o2_name))) return; - - identify_item(owner_ptr, q_ptr); - q_ptr->ident |= IDENT_FULL_KNOWN; - - distribute_charges(o_ptr, q_ptr, amt); - msg_format(_("%sãç½®ããã(%c)", "You drop %s (%c)."), o_name, index_to_label(item)); - choice = 0; - - vary_item(owner_ptr, item, -amt); - handle_stuff(owner_ptr); - - int item_pos = home_carry(owner_ptr, q_ptr); - if (item_pos >= 0) - { - store_top = (item_pos / store_bottom) * store_bottom; - display_store_inventory(owner_ptr); - } - } - else - { - distribute_charges(o_ptr, q_ptr, amt); - msg_format(_("%sãç½®ããã(%c)", "You drop %s (%c)."), o_name, index_to_label(item)); - choice = 0; - vary_item(owner_ptr, item, -amt); - handle_stuff(owner_ptr); - int item_pos = home_carry(owner_ptr, q_ptr); - if (item_pos >= 0) - { - store_top = (item_pos / store_bottom) * store_bottom; - display_store_inventory(owner_ptr); - } - } - - if ((choice == 0) && (item >= INVEN_RARM)) - { - calc_android_exp(owner_ptr); - verify_equip_slot(owner_ptr, item); - } -} - - -/*! - * @brief åºã®ã¢ã¤ãã ã調ã¹ãã³ãã³ãã®ã¡ã¤ã³ã«ã¼ãã³ / - * Examine an item in a store -JDL- - * @return ãªã - */ -static void store_examine(player_type *player_ptr) -{ - if (st_ptr->stock_num <= 0) - { - if (cur_store_num == STORE_HOME) - msg_print(_("æã家ã«ã¯ä½ãç½®ãã¦ããã¾ããã", "Your home is empty.")); - else if (cur_store_num == STORE_MUSEUM) - msg_print(_("åç©é¤¨ã«ã¯ä½ãç½®ãã¦ããã¾ããã", "Museum is empty.")); - else - msg_print(_("ç¾å¨ååã®å¨åº«ãåããã¦ãã¾ãã", "I am currently out of stock.")); - return; - } - - int i = (st_ptr->stock_num - store_top); - if (i > store_bottom) i = store_bottom; - - char out_val[160]; - sprintf(out_val, _("ã©ãã調ã¹ã¾ããï¼", "Which item do you want to examine? ")); - - COMMAND_CODE item; - if (!get_stock(&item, out_val, 0, i - 1)) return; - item = item + store_top; - object_type *o_ptr; - o_ptr = &st_ptr->stock[item]; - if (!OBJECT_IS_FULL_KNOWN(o_ptr)) - { - msg_print(_("ãã®ã¢ã¤ãã ã«ã¤ãã¦ç¹ã«ç¥ã£ã¦ãããã¨ã¯ãªãã", "You have no special knowledge about that item.")); - return; - } - - GAME_TEXT o_name[MAX_NLEN]; - object_desc(player_ptr, o_name, o_ptr, 0); - msg_format(_("%sã調ã¹ã¦ãã...", "Examining %s..."), o_name); - - if (!screen_object(player_ptr, o_ptr, SCROBJ_FORCE_DETAIL)) - msg_print(_("ç¹ã«å¤ãã£ãã¨ããã¯ãªãããã ã", "You see nothing special.")); - - return; -} - - -/*! - * @brief åç©é¤¨ã®ã¢ã¤ãã ãé¤å»ããã³ãã³ãã®ã¡ã¤ã³ã«ã¼ãã³ / - * Remove an item from museum (Originally from TOband) - * @param player_ptr ãã¬ã¼ã¤ã¼ã¸ã®åç §ãã¤ã³ã¿ - * @return ãªã - */ -static void museum_remove_object(player_type *player_ptr) -{ - if (st_ptr->stock_num <= 0) - { - msg_print(_("åç©é¤¨ã«ã¯ä½ãç½®ãã¦ããã¾ããã", "Museum is empty.")); - return; - } - - int i = st_ptr->stock_num - store_top; - if (i > store_bottom) i = store_bottom; - - char out_val[160]; - sprintf(out_val, _("ã©ã®ã¢ã¤ãã ã®å±ç¤ºãããããã¾ããï¼", "Which item do you want to order to remove? ")); - - COMMAND_CODE item; - if (!get_stock(&item, out_val, 0, i - 1)) return; - - item = item + store_top; - object_type *o_ptr; - o_ptr = &st_ptr->stock[item]; - - GAME_TEXT o_name[MAX_NLEN]; - object_desc(player_ptr, o_name, o_ptr, 0); - - msg_print(_("å±ç¤ºããããããã¢ã¤ãã ã¯äºåº¦ã¨è¦ããã¨ã¯ã§ãã¾ããï¼", "Once removed from the Museum, an item will be gone forever!")); - if (!get_check(format(_("æ¬å½ã«%sã®å±ç¤ºãããããã¾ããï¼", "Really order to remove %s from the Museum? "), o_name))) return; - - msg_format(_("%sã®å±ç¤ºããããããã", "You ordered to remove %s."), o_name); - - store_item_increase(item, -o_ptr->number); - store_item_optimize(item); - - (void)combine_and_reorder_home(STORE_MUSEUM); - if (st_ptr->stock_num == 0) store_top = 0; - - else if (store_top >= st_ptr->stock_num) store_top -= store_bottom; - display_store_inventory(player_ptr); -} - - -/* - * Hack -- set this to leave the store - */ -static bool leave_store = FALSE; - - -/*! - * @brief åºèå¦çã³ãã³ãé¸æã®ã¡ã¤ã³ã«ã¼ãã³ / - * Process a command in a store - * @param client_ptr 顧客ã¨ãªãã¯ãªã¼ãã£ã¼ã®åç §ãã¤ã³ã¿ - * @return ãªã - * @note - *
- * Note that we must allow the use of a few "special" commands - * in the stores which are not allowed in the dungeon, and we - * must disable some commands which are allowed in the dungeon - * but not in the stores, to prevent chaos. - *- */ -static void store_process_command(player_type *client_ptr) -{ - repeat_check(); - if (rogue_like_commands && command_cmd == 'l') - { - command_cmd = 'x'; - } - - switch (command_cmd) - { - case ESCAPE: - { - leave_store = TRUE; - break; - } - case '-': - { - /* æ¥æ¬èªç追å */ - /* 1 ãã¼ã¸æ»ãã³ãã³ã: æã家ã®ãã¼ã¸æ°ãå¤ãã®ã§éå®ããã¯ã By BUG */ - if (st_ptr->stock_num <= store_bottom) { - msg_print(_("ããã§å ¨é¨ã§ãã", "Entire inventory is shown.")); - } - else { - store_top -= store_bottom; - if (store_top < 0) - store_top = ((st_ptr->stock_num - 1) / store_bottom) * store_bottom; - if ((cur_store_num == STORE_HOME) && (powerup_home == FALSE)) - if (store_top >= store_bottom) store_top = store_bottom; - display_store_inventory(client_ptr); - } - - break; - } - case ' ': - { - if (st_ptr->stock_num <= store_bottom) - { - msg_print(_("ããã§å ¨é¨ã§ãã", "Entire inventory is shown.")); - } - else - { - store_top += store_bottom; - /* - * é ããªãã·ã§ã³(powerup_home)ãã»ããããã¦ããªãã¨ã㯠- * æã家ã§ã¯ 2 ãã¼ã¸ã¾ã§ãã表示ããªã - */ - if ((cur_store_num == STORE_HOME) && - (powerup_home == FALSE) && - (st_ptr->stock_num >= STORE_INVEN_MAX)) - { - if (store_top >= (STORE_INVEN_MAX - 1)) - { - store_top = 0; - } - } - else - { - if (store_top >= st_ptr->stock_num) store_top = 0; - } - - display_store_inventory(client_ptr); - } - - break; - } - case KTRL('R'): - { - do_cmd_redraw(client_ptr); - display_store(client_ptr); - break; - } - case 'g': - { - store_purchase(client_ptr); - break; - } - case 'd': - { - store_sell(client_ptr); - break; - } - case 'x': - { - store_examine(client_ptr); - break; - } - case '\r': - { - break; - } - case 'w': - { - do_cmd_wield(client_ptr); - break; - } - case 't': - { - do_cmd_takeoff(client_ptr); - break; - } - case 'k': - { - do_cmd_destroy(client_ptr); - break; - } - case 'e': - { - do_cmd_equip(client_ptr); - break; - } - case 'i': - { - do_cmd_inven(client_ptr); - break; - } - case 'I': - { - do_cmd_observe(client_ptr); - break; - } - case KTRL('I'): - { - toggle_inventory_equipment(client_ptr); - break; - } - case 'b': - { - if ((client_ptr->pclass == CLASS_MINDCRAFTER) || - (client_ptr->pclass == CLASS_BERSERKER) || - (client_ptr->pclass == CLASS_NINJA) || - (client_ptr->pclass == CLASS_MIRROR_MASTER) - ) do_cmd_mind_browse(client_ptr); - else if (client_ptr->pclass == CLASS_SMITH) - do_cmd_kaji(client_ptr, TRUE); - else if (client_ptr->pclass == CLASS_MAGIC_EATER) - do_cmd_magic_eater(client_ptr, TRUE, FALSE); - else if (client_ptr->pclass == CLASS_SNIPER) - do_cmd_snipe_browse(client_ptr); - else do_cmd_browse(client_ptr); - break; - } - case '{': - { - do_cmd_inscribe(client_ptr); - break; - } - case '}': - { - do_cmd_uninscribe(client_ptr); - break; - } - case '?': - { - do_cmd_help(client_ptr); - break; - } - case '/': - { - do_cmd_query_symbol(client_ptr); - break; - } - case 'C': - { - client_ptr->town_num = old_town_num; - do_cmd_player_status(client_ptr); - client_ptr->town_num = inner_town_num; - display_store(client_ptr); - break; - } - case '!': - { - (void)Term_user(0); - break; - } - case '"': - { - client_ptr->town_num = old_town_num; - do_cmd_pref(client_ptr); - client_ptr->town_num = inner_town_num; - break; - } - case '@': - { - client_ptr->town_num = old_town_num; - do_cmd_macros(client_ptr); - client_ptr->town_num = inner_town_num; - break; - } - case '%': - { - client_ptr->town_num = old_town_num; - do_cmd_visuals(client_ptr); - client_ptr->town_num = inner_town_num; - break; - } - case '&': - { - client_ptr->town_num = old_town_num; - do_cmd_colors(client_ptr); - client_ptr->town_num = inner_town_num; - break; - } - case '=': - { - do_cmd_options(); - (void)combine_and_reorder_home(STORE_HOME); - do_cmd_redraw(client_ptr); - display_store(client_ptr); - break; - } - case ':': - { - do_cmd_note(); - break; - } - case 'V': - { - do_cmd_version(); - break; - } - case KTRL('F'): - { - do_cmd_feeling(client_ptr); - break; - } - case KTRL('O'): - { - do_cmd_message_one(); - break; - } - case KTRL('P'): - { - do_cmd_messages(0); - break; - } - case '|': - { - do_cmd_diary(client_ptr); - break; - } - case '~': - { - do_cmd_knowledge(client_ptr); - break; - } - case '(': - { - do_cmd_load_screen(); - break; - } - case ')': - { - do_cmd_save_screen(client_ptr); - break; - } - default: - { - if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r')) - { - museum_remove_object(client_ptr); - } - else - { - msg_print(_("ãã®ã³ãã³ãã¯åºã®ä¸ã§ã¯ä½¿ãã¾ããã", "That command does not work in stores.")); - } - - break; - } - } -} - - -/*! - * @brief åºèå¦çå ¨ä½ã®ã¡ã¤ã³ã«ã¼ãã³ / - * Enter a store, and interact with it. * - * @param player_ptr ãã¬ã¼ã¤ã¼ã¸ã®åç §ãã¤ã³ã¿ - * @return ãªã - * @note - *
- * Note that we use the standard "request_command()" function - * to get a command, allowing us to use "command_arg" and all - * command macros and other nifty stuff, but we use the special - * "shopping" argument, to force certain commands to be converted - * into other commands, normally, we convert "p" (pray) and "m" - * (cast magic) into "g" (get), and "s" (search) into "d" (drop). - *- */ -void do_cmd_store(player_type *player_ptr) -{ - if (player_ptr->wild_mode) return; - TERM_LEN w, h; - Term_get_size(&w, &h); - - xtra_stock = MIN(14 + 26, ((h > 24) ? (h - 24) : 0)); - store_bottom = MIN_STOCK + xtra_stock; - - grid_type *g_ptr; - g_ptr = &player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x]; - - if (!cave_have_flag_grid(g_ptr, FF_STORE)) - { - msg_print(_("ããã«ã¯åºãããã¾ããã", "You see no store here.")); - return; - } - - int which = f_info[g_ptr->feat].subtype; - old_town_num = player_ptr->town_num; - if ((which == STORE_HOME) || (which == STORE_MUSEUM)) player_ptr->town_num = 1; - if (player_ptr->current_floor_ptr->dun_level) player_ptr->town_num = NO_TOWN; - inner_town_num = player_ptr->town_num; - - if ((town_info[player_ptr->town_num].store[which].store_open >= current_world_ptr->game_turn) || - (ironman_shops)) - { - msg_print(_("ãã¢ã«éµãããã£ã¦ããã", "The doors are locked.")); - player_ptr->town_num = old_town_num; - return; - } - - int maintain_num = (current_world_ptr->game_turn - town_info[player_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS); - if (maintain_num > 10) - maintain_num = 10; - if (maintain_num) - { - for (int i = 0; i < maintain_num; i++) - store_maint(player_ptr, player_ptr->town_num, which); - - town_info[player_ptr->town_num].store[which].last_visit = current_world_ptr->game_turn; - } - - forget_lite(player_ptr->current_floor_ptr); - forget_view(player_ptr->current_floor_ptr); - current_world_ptr->character_icky = TRUE; - command_arg = 0; - command_rep = 0; - command_new = 0; - get_com_no_macros = TRUE; - cur_store_num = which; - cur_store_feat = g_ptr->feat; - st_ptr = &town_info[player_ptr->town_num].store[cur_store_num]; - ot_ptr = &owners[cur_store_num][st_ptr->owner]; - store_top = 0; - play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD); - display_store(player_ptr); - leave_store = FALSE; - - while (!leave_store) - { - prt("", 1, 0); - clear_from(20 + xtra_stock); - prt(_(" ESC) 建ç©ããåºã", " ESC) Exit from Building."), 21 + xtra_stock, 0); - if (st_ptr->stock_num > store_bottom) - { - prt(_(" -)åãã¼ã¸", " -) Previous page"), 22 + xtra_stock, 0); - prt(_(" ã¹ãã¼ã¹) 次ãã¼ã¸", " SPACE) Next page"), 23 + xtra_stock, 0); - } - - if (cur_store_num == STORE_HOME) - { - prt(_("g) ã¢ã¤ãã ãåã", "g) Get an item."), 21 + xtra_stock, 27); - prt(_("d) ã¢ã¤ãã ãç½®ã", "d) Drop an item."), 22 + xtra_stock, 27); - prt(_("x) 家ã®ã¢ã¤ãã ã調ã¹ã", "x) eXamine an item in the home."), 23 + xtra_stock, 27); - } - else if (cur_store_num == STORE_MUSEUM) - { - prt(_("d) ã¢ã¤ãã ãç½®ã", "d) Drop an item."), 21 + xtra_stock, 27); - prt(_("r) ã¢ã¤ãã ã®å±ç¤ºãããã", "r) order to Remove an item."), 22 + xtra_stock, 27); - prt(_("x) åç©é¤¨ã®ã¢ã¤ãã ã調ã¹ã", "x) eXamine an item in the museum."), 23 + xtra_stock, 27); - } - else - { - prt(_("p) ååãè²·ã", "p) Purchase an item."), 21 + xtra_stock, 30); - prt(_("s) ã¢ã¤ãã ã売ã", "s) Sell an item."), 22 + xtra_stock, 30); - prt(_("x) ååã調ã¹ã", "x) eXamine an item in the shop"), 23 + xtra_stock, 30); - } - - prt(_("i/e) æã¡ç©/è£ åã®ä¸è¦§", "i/e) Inventry/Equipment list"), 21 + xtra_stock, 56); - if (rogue_like_commands) - { - prt(_("w/T) è£ åãã/ã¯ãã", "w/T) Wear/Take off equipment"), 22 + xtra_stock, 56); - } - else - { - prt(_("w/t) è£ åãã/ã¯ãã", "w/t) Wear/Take off equipment"), 22 + xtra_stock, 56); - } - - prt(_("ã³ãã³ã:", "You may: "), 20 + xtra_stock, 0); - request_command(player_ptr, TRUE); - store_process_command(player_ptr); - - /* - * Hack -- To redraw missiles damage and prices in store - * If player's charisma changes, or if player changes a bow, PU_BONUS is set - */ - bool need_redraw_store_inv = (player_ptr->update & PU_BONUS) ? TRUE : FALSE; - current_world_ptr->character_icky = TRUE; - handle_stuff(player_ptr); - if (player_ptr->inventory_list[INVEN_PACK].k_idx) - { - INVENTORY_IDX item = INVEN_PACK; - object_type *o_ptr = &player_ptr->inventory_list[item]; - if (cur_store_num != STORE_HOME) - { - if (cur_store_num == STORE_MUSEUM) - msg_print(_("ã¶ãã¯ããã¢ã¤ãã ãããµããããªã®ã§ãããã¦ã¦åç©é¤¨ããåºã...", "Your pack is so full that you flee the Museum...")); - else - msg_print(_("ã¶ãã¯ããã¢ã¤ãã ãããµããããªã®ã§ãããã¦ã¦åºããåºã...", "Your pack is so full that you flee the store...")); - - leave_store = TRUE; - } - else if (!store_check_num(o_ptr)) - { - msg_print(_("ã¶ãã¯ããã¢ã¤ãã ãããµããããªã®ã§ãããã¦ã¦å®¶ããåºã...", "Your pack is so full that you flee your home...")); - leave_store = TRUE; - } - else - { - int item_pos; - object_type forge; - object_type *q_ptr; - GAME_TEXT o_name[MAX_NLEN]; - msg_print(_("ã¶ãã¯ããã¢ã¤ãã ãããµãã¦ãã¾ã£ãï¼", "Your pack overflows!")); - q_ptr = &forge; - object_copy(q_ptr, o_ptr); - object_desc(player_ptr, o_name, q_ptr, 0); - msg_format(_("%sãè½ã¡ãã(%c)", "You drop %s (%c)."), o_name, index_to_label(item)); - vary_item(player_ptr, item, -255); - handle_stuff(player_ptr); - - item_pos = home_carry(player_ptr, q_ptr); - if (item_pos >= 0) - { - store_top = (item_pos / store_bottom) * store_bottom; - display_store_inventory(player_ptr); - } - } - } - - if (need_redraw_store_inv) display_store_inventory(player_ptr); - - if (st_ptr->store_open >= current_world_ptr->game_turn) leave_store = TRUE; - } - - select_floor_music(player_ptr); - player_ptr->town_num = old_town_num; - take_turn(player_ptr, 100); - current_world_ptr->character_icky = FALSE; - command_new = 0; - command_see = FALSE; - get_com_no_macros = FALSE; - - msg_erase(); - Term_clear(); - - player_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE); - player_ptr->update |= (PU_MONSTERS); - player_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY); - player_ptr->redraw |= (PR_MAP); - player_ptr->window |= (PW_OVERHEAD | PW_DUNGEON); -} - - -/*! - * @brief ç¾å¨ã®çºã®åºä¸»ã交代ããã / - * Shuffle one of the stores. - * @param which åºè種é¡ã®ID - * @return ãªã - */ -void store_shuffle(player_type *player_ptr, int which) -{ - if (which == STORE_HOME) return; - if (which == STORE_MUSEUM) return; - - cur_store_num = which; - st_ptr = &town_info[player_ptr->town_num].store[cur_store_num]; - int j = st_ptr->owner; - while (TRUE) - { - st_ptr->owner = (byte)randint0(MAX_OWNERS); - if (j == st_ptr->owner) continue; - int i; - for (i = 1; i < max_towns; i++) - { - if (i == player_ptr->town_num) continue; - if (st_ptr->owner == town_info[i].store[cur_store_num].owner) break; - } - - if (i == max_towns) break; - } - - ot_ptr = &owners[cur_store_num][st_ptr->owner]; - st_ptr->insult_cur = 0; - st_ptr->store_open = 0; - st_ptr->good_buy = 0; - st_ptr->bad_buy = 0; - for (int i = 0; i < st_ptr->stock_num; i++) - { - object_type *o_ptr; - o_ptr = &st_ptr->stock[i]; - if (object_is_artifact(o_ptr)) continue; - - o_ptr->discount = 50; - o_ptr->ident &= ~(IDENT_FIXED); - o_ptr->inscription = quark_add(_("売åºä¸", "on sale")); - } -} - - -/*! - * @brief åºã®åæããå¤åããã / - * Maintain the inventory at the stores. - * @param player_ptr ãã¬ã¼ã¤ã¼ã¸ã®åç §ãã¤ã³ã¿ - * @param town_num çºã®ID - * @param store_num åºè種é¡ã®ID - * @return ãªã - */ -void store_maint(player_type *player_ptr, int town_num, int store_num) -{ - cur_store_num = store_num; - if (store_num == STORE_HOME) return; - if (store_num == STORE_MUSEUM) return; - - st_ptr = &town_info[town_num].store[store_num]; - ot_ptr = &owners[store_num][st_ptr->owner]; - st_ptr->insult_cur = 0; - if (store_num == STORE_BLACK) - { - for (INVENTORY_IDX j = st_ptr->stock_num - 1; j >= 0; j--) - { - object_type *o_ptr = &st_ptr->stock[j]; - if (black_market_crap(player_ptr, o_ptr)) - { - store_item_increase(j, 0 - o_ptr->number); - store_item_optimize(j); - } - } - } - - INVENTORY_IDX j = st_ptr->stock_num; - j = j - randint1(STORE_TURNOVER); - if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP; - if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP; - if (j < 0) j = 0; - - while (st_ptr->stock_num > j) - store_delete(); - - j = st_ptr->stock_num; - j = j + randint1(STORE_TURNOVER); - if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP; - if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP; - if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1; - - while (st_ptr->stock_num < j) store_create(player_ptr); -} - - -/*! - * @brief åºèæ å ±ãåæåãã / - * Initialize the stores - * @param town_num çºã®ID - * @param store_num åºè種é¡ã®ID - * @return ãªã - */ -void store_init(int town_num, int store_num) -{ - cur_store_num = store_num; - st_ptr = &town_info[town_num].store[store_num]; - while (TRUE) - { - st_ptr->owner = (byte)randint0(MAX_OWNERS); - int i; - for (i = 1; i < max_towns; i++) - { - if (i == town_num) continue; - if (st_ptr->owner == town_info[i].store[store_num].owner) break; - } - - if (i == max_towns) break; - } - - ot_ptr = &owners[store_num][st_ptr->owner]; - - st_ptr->store_open = 0; - st_ptr->insult_cur = 0; - st_ptr->good_buy = 0; - st_ptr->bad_buy = 0; - st_ptr->stock_num = 0; - st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS; - for (int k = 0; k < st_ptr->stock_size; k++) - { - object_wipe(&st_ptr->stock[k]); - } -}