3 * @brief 店の処理 / Store commands
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 * This software may be copied and distributed for educational, research, and\n
8 * not for profit purposes provided that this copyright and statement are\n
9 * included in all such copies.\n
10 * 2014 Deskull rearranged comment for Doxygen.
13 #include "store/store.h"
14 #include "autopick/autopick-pref-processor.h"
15 #include "autopick/autopick.h"
16 #include "cmd-action/cmd-spell.h"
17 #include "cmd-io/cmd-diary.h"
18 #include "cmd-io/cmd-dump.h"
19 #include "cmd-io/cmd-help.h"
20 #include "cmd-io/cmd-knowledge.h"
21 #include "cmd-io/cmd-macro.h"
22 #include "cmd-io/cmd-process-screen.h"
23 #include "cmd-item/cmd-item.h"
24 #include "cmd-item/cmd-magiceat.h"
25 #include "cmd-item/cmd-smith.h"
26 #include "cmd-item/cmd-zapwand.h"
27 #include "cmd/cmd-basic.h"
28 #include "cmd/cmd-draw.h"
29 #include "cmd/cmd-visuals.h"
30 #include "combat/snipe.h"
31 #include "core/stuff-handler.h"
32 #include "floor/floor-events.h"
33 #include "floor/floor-town.h"
34 #include "floor/floor.h"
35 #include "floor/wild.h"
36 #include "inventory/inventory-object.h"
37 #include "inventory/player-inventory.h"
38 #include "io/files-util.h"
39 #include "io/write-diary.h"
40 #include "locale/japanese.h"
41 #include "main/music-definitions-table.h"
42 #include "main/sound-definitions-table.h"
43 #include "market/gold-magnification-table.h"
44 #include "mind/mind.h"
45 #include "object-enchant/item-feeling.h"
46 #include "object/item-use-flags.h"
47 #include "perception/object-perception.h"
48 #include "object/object-flavor.h"
49 #include "object/object-generator.h"
50 #include "object/object-hook.h"
51 #include "object/object-kind.h"
52 #include "object/object-stack.h"
53 #include "object/object-value.h"
54 #include "object-enchant/special-object-flags.h"
55 #include "player/avatar.h"
56 #include "player/player-class.h"
57 #include "player/player-effects.h"
58 #include "player/player-status.h"
59 #include "player/race-info-table.h"
60 #include "spell/spells3.h"
61 #include "store/black-market.h"
62 #include "store/rumor.h"
63 #include "store/say-comments.h"
64 #include "store/store-owners.h"
65 #include "store/store-util.h"
66 #include "system/angband.h"
67 #include "term/gameterm.h"
68 #include "util/object-sort.h"
69 #include "util/util.h"
70 #include "view/display-main-window.h"
71 #include "view/object-describer.h"
72 #include "world/world.h"
76 static int store_top = 0;
77 static int store_bottom = 0;
78 static int xtra_stock = 0;
79 static const owner_type *ot_ptr = NULL;
80 static s16b old_town_num = 0;
81 static s16b inner_town_num = 0;
84 * We store the current "store feat" here so everyone can access it
86 static int cur_store_feat;
89 * @brief 店舗価格を決定する. 無料にはならない /
90 * Determine the price of an item (qty one) in a store.
91 * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
93 * @param flip TRUEならば店主にとっての買取価格、FALSEなら売出価格を計算
97 * This function takes into account the player's charisma, and the
98 * shop-keepers friendliness, and the shop-keeper's base greed, but
99 * never lets a shop-keeper lose money in a transaction.
100 * The "greed" value should exceed 100 when the player is "buying" the
101 * item, and should be less than 100 when the player is "selling" it.
102 * Hack -- the black market always charges twice as much as it should.
103 * Charisma adjustment runs from 80 to 130
104 * Racial adjustment runs from 95 to 130
105 * Since greed/charisma/racial adjustments are centered at 100, we need
106 * to adjust (by 200) to extract a usable multiplier. Note that the
107 * "greed" value is always something (?).
110 static PRICE price_item(player_type *player_ptr, object_type *o_ptr, int greed, bool flip)
112 PRICE price = object_value(o_ptr);
113 if (price <= 0) return (0L);
115 int factor = rgold_adj[ot_ptr->owner_race][player_ptr->prace];
116 factor += adj_chr_gold[player_ptr->stat_ind[A_CHR]];
120 adjust = 100 + (300 - (greed + factor));
121 if (adjust > 100) adjust = 100;
122 if (cur_store_num == STORE_BLACK)
125 price = (price * adjust + 50L) / 100L;
129 adjust = 100 + ((greed + factor) - 300);
130 if (adjust < 100) adjust = 100;
131 if (cur_store_num == STORE_BLACK)
134 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
137 if (price <= 0L) return (1L);
143 * @brief 店舗に品を置くスペースがあるかどうかの判定を返す /
144 * Check to see if the shop will be carrying too many objects -RAK-
145 * @param o_ptr 店舗に置きたいオブジェクト構造体の参照ポインタ
146 * @return 置き場がないなら0、重ね合わせできるアイテムがあるなら-1、スペースがあるなら1を返す。
149 * Note that the shop, just like a player, will not accept things
150 * it cannot hold. Before, one could "nuke" potions this way.
151 * Return value is now int:
153 * -1 : Can be combined to existing slot.
154 * 1 : Cannot be combined but there are empty spaces.
157 static int store_check_num(object_type *o_ptr)
160 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
162 bool old_stack_force_notes = stack_force_notes;
163 bool old_stack_force_costs = stack_force_costs;
165 if (cur_store_num != STORE_HOME)
167 stack_force_notes = FALSE;
168 stack_force_costs = FALSE;
171 for (int i = 0; i < st_ptr->stock_num; i++)
173 j_ptr = &st_ptr->stock[i];
174 if (object_similar(j_ptr, o_ptr))
176 if (cur_store_num != STORE_HOME)
178 stack_force_notes = old_stack_force_notes;
179 stack_force_costs = old_stack_force_costs;
186 if (cur_store_num != STORE_HOME)
188 stack_force_notes = old_stack_force_notes;
189 stack_force_costs = old_stack_force_costs;
194 for (int i = 0; i < st_ptr->stock_num; i++)
196 j_ptr = &st_ptr->stock[i];
197 if (store_object_similar(j_ptr, o_ptr)) return -1;
201 /* Free space is always usable */
203 * オプション powerup_home が設定されていると
206 if ((cur_store_num == STORE_HOME) && (powerup_home == FALSE))
208 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10))
215 if (st_ptr->stock_num < st_ptr->stock_size)
226 * @brief 現在の町の指定された店舗のアイテムを整理する /
227 * Combine and reorder items in store.
228 * @param store_num 店舗ID
229 * @return 実際に整理が行われたならばTRUEを返す。
231 bool combine_and_reorder_home(int store_num)
233 bool old_stack_force_notes = stack_force_notes;
234 bool old_stack_force_costs = stack_force_costs;
235 store_type *old_st_ptr = st_ptr;
236 st_ptr = &town_info[1].store[store_num];
238 if (store_num != STORE_HOME)
240 stack_force_notes = FALSE;
241 stack_force_costs = FALSE;
244 bool combined = TRUE;
248 for (int i = st_ptr->stock_num - 1; i > 0; i--)
251 o_ptr = &st_ptr->stock[i];
252 if (!o_ptr->k_idx) continue;
253 for (int j = 0; j < i; j++)
256 j_ptr = &st_ptr->stock[j];
257 if (!j_ptr->k_idx) continue;
260 * Get maximum number of the stack if these
261 * are similar, get zero otherwise.
263 int max_num = object_similar_part(j_ptr, o_ptr);
264 if (max_num == 0 || j_ptr->number >= max_num) continue;
266 if (o_ptr->number + j_ptr->number <= max_num)
268 object_absorb(j_ptr, o_ptr);
271 for (k = i; k < st_ptr->stock_num; k++)
273 st_ptr->stock[k] = st_ptr->stock[k + 1];
276 object_wipe(&st_ptr->stock[k]);
281 ITEM_NUMBER old_num = o_ptr->number;
282 ITEM_NUMBER remain = j_ptr->number + o_ptr->number - max_num;
283 object_absorb(j_ptr, o_ptr);
284 o_ptr->number = remain;
285 if (o_ptr->tval == TV_ROD)
287 o_ptr->pval = o_ptr->pval * remain / old_num;
288 o_ptr->timeout = o_ptr->timeout * remain / old_num;
290 else if (o_ptr->tval == TV_WAND)
292 o_ptr->pval = o_ptr->pval * remain / old_num;
303 for (int i = 0; i < st_ptr->stock_num; i++)
306 o_ptr = &st_ptr->stock[i];
307 if (!o_ptr->k_idx) continue;
309 s32b o_value = object_value(o_ptr);
311 for (j = 0; j < st_ptr->stock_num; j++)
313 if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
316 if (j >= i) continue;
322 object_copy(j_ptr, &st_ptr->stock[i]);
323 for (int k = i; k > j; k--)
325 object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
328 object_copy(&st_ptr->stock[j], j_ptr);
332 if (store_num != STORE_HOME)
334 stack_force_notes = old_stack_force_notes;
335 stack_force_costs = old_stack_force_costs;
343 * @brief 我が家にオブジェクトを加える /
344 * Add the item "o_ptr" to the inventory of the "Home"
345 * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
349 * In all cases, return the slot (or -1) where the object was placed
350 * Note that this is a hacked up version of "store_item_to_inventory()".
351 * Also note that it may not correctly "adapt" to "knowledge" bacoming
352 * known, the player may have to pick stuff up and drop it again.
355 static int home_carry(player_type *player_ptr, object_type *o_ptr)
357 bool old_stack_force_notes = stack_force_notes;
358 bool old_stack_force_costs = stack_force_costs;
359 if (cur_store_num != STORE_HOME)
361 stack_force_notes = FALSE;
362 stack_force_costs = FALSE;
365 for (int slot = 0; slot < st_ptr->stock_num; slot++)
368 j_ptr = &st_ptr->stock[slot];
369 if (object_similar(j_ptr, o_ptr))
371 object_absorb(j_ptr, o_ptr);
372 if (cur_store_num != STORE_HOME)
374 stack_force_notes = old_stack_force_notes;
375 stack_force_costs = old_stack_force_costs;
382 if (cur_store_num != STORE_HOME)
384 stack_force_notes = old_stack_force_notes;
385 stack_force_costs = old_stack_force_costs;
390 * 隠し機能: オプション powerup_home が設定されていると
393 if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE))
395 if (st_ptr->stock_num >= st_ptr->stock_size)
402 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10))
408 PRICE value = object_value(o_ptr);
410 for (slot = 0; slot < st_ptr->stock_num; slot++)
412 if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
415 for (int i = st_ptr->stock_num; i > slot; i--)
417 st_ptr->stock[i] = st_ptr->stock[i - 1];
421 st_ptr->stock[slot] = *o_ptr;
422 chg_virtue(player_ptr, V_SACRIFICE, -1);
423 (void)combine_and_reorder_home(cur_store_num);
429 * @brief 店舗の割引対象外にするかどうかを判定 /
430 * Eliminate need to bargain if player has haggled well in the past
431 * @param minprice アイテムの最低販売価格
432 * @return 割引を禁止するならTRUEを返す。
434 static bool noneedtobargain(PRICE minprice)
436 PRICE good = st_ptr->good_buy;
437 PRICE bad = st_ptr->bad_buy;
438 if (minprice < 10L) return TRUE;
439 if (good == MAX_SHORT) return TRUE;
440 if (good > ((3 * bad) + (5 + (minprice / 50)))) return TRUE;
447 * @brief 店主の持つプレイヤーに対する売買の良し悪し経験を記憶する /
448 * Update the bargain info
449 * @param price 実際の取引価格
450 * @param minprice 店主の提示した価格
454 static void updatebargain(PRICE price, PRICE minprice, int num)
456 if (!manual_haggle) return;
457 if ((minprice / num) < 10L) return;
458 if (price == minprice)
460 if (st_ptr->good_buy < MAX_SHORT)
467 if (st_ptr->bad_buy < MAX_SHORT)
476 * @brief 店の商品リストを再表示する /
477 * Re-displays a single store entry
478 * @param player_ptr プレーヤーへの参照ポインタ
482 static void display_entry(player_type *player_ptr, int pos)
485 o_ptr = &st_ptr->stock[pos];
486 int i = (pos % store_bottom);
488 /* Label it, clear the line --(-- */
490 (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
491 prt(out_val, i + 6, 0);
496 TERM_COLOR a = object_attr(o_ptr);
497 SYMBOL_CODE c = object_char(o_ptr);
499 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
500 if (use_bigtile) cur_col++;
505 /* Describe an item in the home */
507 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
510 if (show_weights) maxwid -= 10;
512 GAME_TEXT o_name[MAX_NLEN];
513 object_desc(player_ptr, o_name, o_ptr, 0);
514 o_name[maxwid] = '\0';
515 c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col);
518 WEIGHT wgt = o_ptr->weight;
519 sprintf(out_val, _("%3d.%1d kg", "%3d.%d lb"), _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
520 put_str(out_val, i + 6, _(67, 68));
527 if (show_weights) maxwid -= 7;
529 GAME_TEXT o_name[MAX_NLEN];
530 object_desc(player_ptr, o_name, o_ptr, 0);
531 o_name[maxwid] = '\0';
532 c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col);
536 int wgt = o_ptr->weight;
537 sprintf(out_val, "%3d.%1d", _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
538 put_str(out_val, i + 6, _(60, 61));
542 if (o_ptr->ident & (IDENT_FIXED))
544 x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
545 (void)sprintf(out_val, _("%9ld固", "%9ld F"), (long)x);
546 put_str(out_val, i + 6, 68);
552 x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
553 if (!noneedtobargain(x)) x += x / 10;
555 (void)sprintf(out_val, "%9ld ", (long)x);
556 put_str(out_val, i + 6, 68);
560 x = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
561 (void)sprintf(out_val, "%9ld ", (long)x);
562 put_str(out_val, i + 6, 68);
567 * @brief 店の商品リストを表示する /
568 * Displays a store's inventory -RAK-
569 * @param player_ptr プレーヤーへの参照ポインタ
572 * All prices are listed as "per individual object". -BEN-
574 static void display_store_inventory(player_type *player_ptr)
577 for (k = 0; k < store_bottom; k++)
579 if (store_top + k >= st_ptr->stock_num) break;
581 display_entry(player_ptr, store_top + k);
584 for (int i = k; i < store_bottom + 1; i++)
587 put_str(_(" ", " "), 5, _(20, 22));
588 if (st_ptr->stock_num > store_bottom)
590 prt(_("-続く-", "-more-"), k + 6, 3);
591 put_str(format(_("(%dページ) ", "(Page %d) "), store_top / store_bottom + 1), 5, _(20, 22));
594 if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM)
596 k = st_ptr->stock_size;
597 if (cur_store_num == STORE_HOME && !powerup_home) k /= 10;
599 put_str(format(_("アイテム数: %4d/%4d", "Objects: %4d/%4d"), st_ptr->stock_num, k), 19 + xtra_stock, _(27, 30));
605 * @brief プレイヤーの所持金を表示する /
606 * Displays players gold -RAK-
607 * @param player_ptr プレーヤーへの参照ポインタ
611 static void store_prt_gold(player_type *player_ptr)
613 prt(_("手持ちのお金: ", "Gold Remaining: "), 19 + xtra_stock, 53);
615 sprintf(out_val, "%9ld", (long)player_ptr->au);
616 prt(out_val, 19 + xtra_stock, 68);
621 * @brief 店舗情報全体を表示するメインルーチン /
622 * Displays store (after clearing screen) -RAK-
623 * @param player_ptr プレーヤーへの参照ポインタ
627 static void display_store(player_type *player_ptr)
630 if (cur_store_num == STORE_HOME)
632 put_str(_("我が家", "Your Home"), 3, 31);
633 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
636 put_str(_(" 重さ", "Weight"), 5, 70);
639 store_prt_gold(player_ptr);
640 display_store_inventory(player_ptr);
644 if (cur_store_num == STORE_MUSEUM)
646 put_str(_("博物館", "Museum"), 3, 31);
647 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
650 put_str(_(" 重さ", "Weight"), 5, 70);
653 store_prt_gold(player_ptr);
654 display_store_inventory(player_ptr);
658 concptr store_name = (f_name + f_info[cur_store_feat].name);
659 concptr owner_name = (ot_ptr->owner_name);
660 concptr race_name = race_info[ot_ptr->owner_race].title;
662 sprintf(buf, "%s (%s)", owner_name, race_name);
665 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
668 put_str(_("商品の一覧", "Item Description"), 5, 5);
671 put_str(_(" 重さ", "Weight"), 5, 60);
674 put_str(_(" 価格", "Price"), 5, 72);
675 store_prt_gold(player_ptr);
676 display_store_inventory(player_ptr);
681 * @brief 店舗からアイテムを選択する /
682 * Get the ID of a store item and return its value -RAK-
683 * @param com_val 選択IDを返す参照ポインタ
684 * @param pmt メッセージキャプション
687 * @return 実際に選択したらTRUE、キャンセルしたらFALSE
689 static int get_stock(COMMAND_CODE *com_val, concptr pmt, int i, int j)
691 if (repeat_pull(com_val) && (*com_val >= i) && (*com_val <= j))
699 char hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
702 (void)sprintf(out_val, "(%s:%c-%c, ESCで中断) %s",
703 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "アイテム" : "商品"),
706 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
713 if (!get_com(out_val, &command, FALSE)) break;
716 if (islower(command))
718 else if (isupper(command))
719 k = A2I(tolower(command)) + 26;
723 if ((k >= i) && (k <= j))
733 if (command == ESCAPE) return FALSE;
735 repeat_push(*com_val);
741 * @brief 店主の不満度を増やし、プレイヤーを締め出す判定と処理を行う /
742 * Increase the insult counter and get angry if too many -RAK-
743 * @return プレイヤーを締め出す場合TRUEを返す
745 static int increase_insults(void)
747 st_ptr->insult_cur++;
748 if (st_ptr->insult_cur <= ot_ptr->insult_max) return FALSE;
752 st_ptr->insult_cur = 0;
753 st_ptr->good_buy = 0;
755 st_ptr->store_open = current_world_ptr->game_turn + TURNS_PER_TICK * TOWN_DAWN / 8 + randint1(TURNS_PER_TICK*TOWN_DAWN / 8);
762 * @brief 店主の不満度を減らす /
763 * Decrease insults -RAK-
764 * @return プレイヤーを締め出す場合TRUEを返す
766 static void decrease_insults(void)
768 if (st_ptr->insult_cur) st_ptr->insult_cur--;
773 * @brief 店主の不満度が増えた場合のみのメッセージを表示する /
774 * Have insulted while haggling -RAK-
775 * @return プレイヤーを締め出す場合TRUEを返す
777 static int haggle_insults(void)
779 if (increase_insults()) return TRUE;
786 * Mega-Hack -- Enable "increments"
788 static bool allow_inc = FALSE;
791 * Mega-Hack -- Last "increment" during haggling
793 static s32b last_inc = 0L;
796 * @brief 交渉価格を確認と認証の是非を行う /
799 * @param poffer 別途価格提示をした場合の値を返す参照ポインタ
800 * @param price 現在の交渉価格
801 * @param final 最終確定価格ならばTRUE
802 * @return プレイヤーを締め出す場合TRUEを返す
804 static int get_haggle(concptr pmt, s32b *poffer, PRICE price, int final)
807 if (!allow_inc) last_inc = 0L;
811 sprintf(buf, _("%s [承諾] ", "%s [accept] "), pmt);
813 else if (last_inc < 0)
815 sprintf(buf, _("%s [-$%ld] ", "%s [-%ld] "), pmt, (long)(ABS(last_inc)));
817 else if (last_inc > 0)
819 sprintf(buf, _("%s [+$%ld] ", "%s [+%ld] "), pmt, (long)(ABS(last_inc)));
823 sprintf(buf, "%s ", pmt);
827 GAME_TEXT out_val[160];
835 * Ask the user for a response.
836 * Don't allow to use numpad as cursor key.
838 res = askfor_aux(out_val, 32, FALSE);
840 if (!res) return FALSE;
843 for (p = out_val; *p == ' '; p++) /* loop */;
854 if (allow_inc && last_inc)
860 msg_print(_("値がおかしいです。", "Invalid response."));
866 if ((*p == '+' || *p == '-'))
888 * @brief 店主がプレイヤーからの交渉価格を判断する /
889 * Receive an offer (from the player)
891 * @param poffer 店主からの交渉価格を返す参照ポインタ
892 * @param last_offer 現在の交渉価格
893 * @param factor 店主の価格基準倍率
894 * @param price アイテムの実価値
895 * @param final 最終価格確定ならばTRUE
896 * @return プレイヤーの価格に対して不服ならばTRUEを返す /
897 * Return TRUE if offer is NOT okay
899 static bool receive_offer(concptr pmt, s32b *poffer, s32b last_offer, int factor, PRICE price, int final)
903 if (!get_haggle(pmt, poffer, price, final)) return TRUE;
904 if (((*poffer) * factor) >= (last_offer * factor)) break;
905 if (haggle_insults()) return TRUE;
907 (*poffer) = last_offer;
915 * @brief プレイヤーが購入する時の値切り処理メインルーチン /
916 * Haggling routine -RAK-
917 * @param player_ptr プレーヤーへの参照ポインタ
918 * @param o_ptr オブジェクトの構造体参照ポインタ
919 * @param price 最終価格を返す参照ポインタ
920 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
921 * Return TRUE if purchase is NOT successful
923 static bool purchase_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price)
925 s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
926 s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
927 int noneed = noneedtobargain(final_ask);
929 concptr pmt = _("提示価格", "Asking");
930 if (noneed || !manual_haggle)
934 msg_print(_("結局この金額にまとまった。", "You eventually agree upon the price."));
939 msg_print(_("すんなりとこの金額にまとまった。", "You quickly agree upon the price."));
941 final_ask += final_ask / 10;
945 pmt = _("最終提示価格", "Final Offer");
949 cur_ask *= o_ptr->number;
950 final_ask *= o_ptr->number;
951 s32b min_per = ot_ptr->haggle_per;
952 s32b max_per = min_per * 3;
953 s32b last_offer = object_value(o_ptr) * o_ptr->number;
954 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
955 if (last_offer <= 0) last_offer = 1;
965 bool loop_flag = TRUE;
967 while (!flag && loop_flag)
970 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
971 put_str(out_val, 1, 0);
972 cancel = receive_offer(_("提示する金額? ", "What do you offer? "), &offer, last_offer, 1, cur_ask, final);
977 else if (offer > cur_ask)
982 else if (offer == cur_ask)
995 s32b x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
998 if (haggle_insults())
1004 else if (x1 > max_per)
1007 if (x1 < max_per) x1 = max_per;
1010 s32b x2 = rand_range(x1 - 2, x1 + 2);
1011 s32b x3 = ((cur_ask - offer) * x2 / 100L) + 1;
1015 if (cur_ask < final_ask)
1018 cur_ask = final_ask;
1019 pmt = _("最終提示価格", "What do you offer? ");
1023 (void)(increase_insults());
1028 else if (offer >= cur_ask)
1040 (void)sprintf(out_val, _("前回の提示金額: $%ld", "Your last offer: %ld"), (long)last_offer);
1041 put_str(out_val, 1, 39);
1042 say_comment_2(cur_ask, annoyed);
1045 if (cancel) return TRUE;
1047 updatebargain(*price, final_ask, o_ptr->number);
1053 * @brief プレイヤーが売却する時の値切り処理メインルーチン /
1054 * Haggling routine -RAK-
1055 * @param player_ptr プレーヤーへの参照ポインタ
1056 * @param o_ptr オブジェクトの構造体参照ポインタ
1057 * @param price 最終価格を返す参照ポインタ
1058 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
1059 * Return TRUE if purchase is NOT successful
1061 static bool sell_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price)
1063 s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, TRUE);
1064 s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, TRUE);
1065 int noneed = noneedtobargain(final_ask);
1066 s32b purse = (s32b)(ot_ptr->max_cost);
1068 concptr pmt = _("提示金額", "Offer");
1069 if (noneed || !manual_haggle || (final_ask >= purse))
1071 if (!manual_haggle && !noneed)
1073 final_ask -= final_ask / 10;
1076 if (final_ask >= purse)
1078 msg_print(_("即座にこの金額にまとまった。", "You instantly agree upon the price."));
1084 msg_print(_("結局この金額にまとまった。", "You eventually agree upon the price."));
1089 msg_print(_("すんなりとこの金額にまとまった。", "You quickly agree upon the price."));
1093 cur_ask = final_ask;
1095 pmt = _("最終提示金額", "Final Offer");
1098 cur_ask *= o_ptr->number;
1099 final_ask *= o_ptr->number;
1101 s32b min_per = ot_ptr->haggle_per;
1102 s32b max_per = min_per * 3;
1103 s32b last_offer = object_value(o_ptr) * o_ptr->number;
1104 last_offer = last_offer * ot_ptr->max_inflate / 100L;
1110 bool cancel = FALSE;
1119 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
1120 put_str(out_val, 1, 0);
1121 cancel = receive_offer(_("提示する価格? ", "What price do you ask? "),
1122 &offer, last_offer, -1, cur_ask, final);
1128 else if (offer < cur_ask)
1133 else if (offer == cur_ask)
1143 if (flag || !loop_flag) break;
1148 s32b x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
1151 if (haggle_insults())
1157 else if (x1 > max_per)
1160 if (x1 < max_per) x1 = max_per;
1163 s32b x2 = rand_range(x1 - 2, x1 + 2);
1164 s32b x3 = ((offer - cur_ask) * x2 / 100L) + 1;
1168 if (cur_ask > final_ask)
1170 cur_ask = final_ask;
1172 pmt = _("最終提示金額", "Final Offer");
1179 /* 追加 $0 で買い取られてしまうのを防止 By FIRST*/
1182 (void)(increase_insults());
1185 else if (offer <= cur_ask)
1195 (void)sprintf(out_val, _("前回の提示価格 $%ld", "Your last bid %ld"), (long)last_offer);
1196 put_str(out_val, 1, 39);
1197 say_comment_3(cur_ask, annoyed);
1200 if (cancel) return TRUE;
1202 updatebargain(*price, final_ask, o_ptr->number);
1208 * @brief 店からの購入処理のメインルーチン /
1209 * Buy an item from a store -RAK-
1210 * @param player_ptr プレーヤーへの参照ポインタ
1213 static void store_purchase(player_type *player_ptr)
1215 if (cur_store_num == STORE_MUSEUM)
1217 msg_print(_("博物館から取り出すことはできません。", "Museum."));
1221 if (st_ptr->stock_num <= 0)
1223 if (cur_store_num == STORE_HOME)
1224 msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
1226 msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
1230 int i = (st_ptr->stock_num - store_top);
1231 if (i > store_bottom) i = store_bottom;
1235 /* ブラックマーケットの時は別のメッセージ */
1236 switch (cur_store_num)
1239 sprintf(out_val, "どのアイテムを取りますか? ");
1242 sprintf(out_val, "どれ? ");
1245 sprintf(out_val, "どの品物が欲しいんだい? ");
1249 if (cur_store_num == STORE_HOME)
1251 sprintf(out_val, "Which item do you want to take? ");
1255 sprintf(out_val, "Which item are you interested in? ");
1260 if (!get_stock(&item, out_val, 0, i - 1)) return;
1262 item = item + store_top;
1264 o_ptr = &st_ptr->stock[item];
1265 ITEM_NUMBER amt = 1;
1269 object_copy(j_ptr, o_ptr);
1272 * If a rod or wand, allocate total maximum timeouts or charges
1273 * between those purchased and left on the shelf.
1275 reduce_charges(j_ptr, o_ptr->number - amt);
1276 j_ptr->number = amt;
1277 if (!check_store_item_to_inventory(j_ptr))
1279 msg_print(_("そんなにアイテムを持てない。", "You cannot carry that many different items."));
1283 PRICE best = price_item(player_ptr, j_ptr, ot_ptr->min_inflate, FALSE);
1284 if (o_ptr->number > 1)
1286 if ((cur_store_num != STORE_HOME) &&
1287 (o_ptr->ident & IDENT_FIXED))
1289 msg_format(_("一つにつき $%ldです。", "That costs %ld gold per item."), (long)(best));
1292 amt = get_quantity(NULL, o_ptr->number);
1293 if (amt <= 0) return;
1297 object_copy(j_ptr, o_ptr);
1300 * If a rod or wand, allocate total maximum timeouts or charges
1301 * between those purchased and left on the shelf.
1303 reduce_charges(j_ptr, o_ptr->number - amt);
1304 j_ptr->number = amt;
1305 if (!check_store_item_to_inventory(j_ptr))
1307 msg_print(_("ザックにそのアイテムを入れる隙間がない。", "You cannot carry that many items."));
1312 COMMAND_CODE item_new;
1314 if (cur_store_num == STORE_HOME)
1316 bool combined_or_reordered;
1317 distribute_charges(o_ptr, j_ptr, amt);
1318 item_new = store_item_to_inventory(player_ptr, j_ptr);
1319 GAME_TEXT o_name[MAX_NLEN];
1320 object_desc(player_ptr, o_name, &player_ptr->inventory_list[item_new], 0);
1322 msg_format(_("%s(%c)を取った。", "You have %s (%c)."), o_name, index_to_label(item_new));
1323 handle_stuff(player_ptr);
1325 i = st_ptr->stock_num;
1326 store_item_increase(item, -amt);
1327 store_item_optimize(item);
1328 combined_or_reordered = combine_and_reorder_home(STORE_HOME);
1329 if (i == st_ptr->stock_num)
1331 if (combined_or_reordered) display_store_inventory(player_ptr);
1332 else display_entry(player_ptr, item);
1336 if (st_ptr->stock_num == 0) store_top = 0;
1337 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1338 display_store_inventory(player_ptr);
1340 chg_virtue(player_ptr, V_SACRIFICE, 1);
1346 if (o_ptr->ident & (IDENT_FIXED))
1349 price = (best * j_ptr->number);
1353 GAME_TEXT o_name[MAX_NLEN];
1354 object_desc(player_ptr, o_name, j_ptr, 0);
1355 msg_format(_("%s(%c)を購入する。", "Buying %s (%c)."), o_name, I2A(item));
1357 choice = purchase_haggle(player_ptr, j_ptr, &price);
1358 if (st_ptr->store_open >= current_world_ptr->game_turn) return;
1361 if (choice != 0) return;
1362 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
1363 if (player_ptr->au < price)
1365 msg_print(_("お金が足りません。", "You do not have enough gold."));
1369 say_comment_1(player_ptr);
1370 if (cur_store_num == STORE_BLACK)
1371 chg_virtue(player_ptr, V_JUSTICE, -1);
1372 if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
1373 chg_virtue(player_ptr, V_NATURE, -1);
1377 player_ptr->au -= price;
1378 store_prt_gold(player_ptr);
1379 object_aware(player_ptr, j_ptr);
1380 j_ptr->ident &= ~(IDENT_FIXED);
1381 GAME_TEXT o_name[MAX_NLEN];
1382 object_desc(player_ptr, o_name, j_ptr, 0);
1384 msg_format(_("%sを $%ldで購入しました。", "You bought %s for %ld gold."), o_name, (long)price);
1386 strcpy(record_o_name, o_name);
1387 record_turn = current_world_ptr->game_turn;
1389 if (record_buy) exe_write_diary(player_ptr, DIARY_BUY, 0, o_name);
1390 object_desc(player_ptr, o_name, o_ptr, OD_NAME_ONLY);
1391 if (record_rand_art && o_ptr->art_name)
1392 exe_write_diary(player_ptr, DIARY_ART, 0, o_name);
1394 j_ptr->inscription = 0;
1395 j_ptr->feeling = FEEL_NONE;
1396 j_ptr->ident &= ~(IDENT_STORE);
1397 item_new = store_item_to_inventory(player_ptr, j_ptr);
1399 object_desc(player_ptr, o_name, &player_ptr->inventory_list[item_new], 0);
1400 msg_format(_("%s(%c)を手に入れた。", "You have %s (%c)."), o_name, index_to_label(item_new));
1401 autopick_alter_item(player_ptr, item_new, FALSE);
1402 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1404 o_ptr->pval -= j_ptr->pval;
1407 handle_stuff(player_ptr);
1408 i = st_ptr->stock_num;
1409 store_item_increase(item, -amt);
1410 store_item_optimize(item);
1411 if (st_ptr->stock_num == 0)
1413 if (one_in_(STORE_SHUFFLE))
1416 msg_print(_("店主は引退した。", "The shopkeeper retires."));
1417 store_shuffle(player_ptr, cur_store_num);
1420 sprintf(buf, "%s (%s)",
1421 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
1422 put_str(buf, 3, 10);
1423 sprintf(buf, "%s (%ld)",
1424 (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
1429 msg_print(_("店主は新たな在庫を取り出した。", "The shopkeeper brings out some new stock."));
1432 for (i = 0; i < 10; i++)
1434 store_maint(player_ptr, player_ptr->town_num, cur_store_num);
1438 display_store_inventory(player_ptr);
1440 else if (st_ptr->stock_num != i)
1442 if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1443 display_store_inventory(player_ptr);
1447 display_entry(player_ptr, item);
1453 * @brief 店からの売却処理のメインルーチン /
1454 * Sell an item to the store (or home)
1455 * @param owner_ptr プレーヤーへの参照ポインタ
1458 static void store_sell(player_type *owner_ptr)
1461 if (cur_store_num == STORE_HOME)
1462 q = _("どのアイテムを置きますか? ", "Drop which item? ");
1463 else if (cur_store_num == STORE_MUSEUM)
1464 q = _("どのアイテムを寄贈しますか? ", "Give which item? ");
1466 q = _("どのアイテムを売りますか? ", "Sell which item? ");
1468 item_tester_hook = store_will_buy;
1470 /* 我が家でおかしなメッセージが出るオリジナルのバグを修正 */
1472 if (cur_store_num == STORE_HOME)
1474 s = _("置けるアイテムを持っていません。", "You don't have any item to drop.");
1476 else if (cur_store_num == STORE_MUSEUM)
1478 s = _("寄贈できるアイテムを持っていません。", "You don't have any item to give.");
1482 s = _("欲しい物がないですねえ。", "You have nothing that I want.");
1487 o_ptr = choose_object(owner_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1490 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
1492 msg_print(_("ふーむ、どうやらそれは呪われているようだね。", "Hmmm, it seems to be cursed."));
1497 if (o_ptr->number > 1)
1499 amt = get_quantity(NULL, o_ptr->number);
1500 if (amt <= 0) return;
1506 object_copy(q_ptr, o_ptr);
1507 q_ptr->number = amt;
1510 * Hack -- If a rod or wand, allocate total maximum
1511 * timeouts or charges to those being sold. -LM-
1513 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1515 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1518 GAME_TEXT o_name[MAX_NLEN];
1519 object_desc(owner_ptr, o_name, q_ptr, 0);
1521 /* Remove any inscription, feeling for stores */
1522 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
1524 q_ptr->inscription = 0;
1525 q_ptr->feeling = FEEL_NONE;
1528 /* Is there room in the store (or the home?) */
1529 if (!store_check_num(q_ptr))
1531 if (cur_store_num == STORE_HOME)
1532 msg_print(_("我が家にはもう置く場所がない。", "Your home is full."));
1534 else if (cur_store_num == STORE_MUSEUM)
1535 msg_print(_("博物館はもう満杯だ。", "Museum is full."));
1538 msg_print(_("すいませんが、店にはもう置く場所がありません。", "I have not the room in my store to keep it."));
1544 PRICE price, value, dummy;
1545 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
1547 msg_format(_("%s(%c)を売却する。", "Selling %s (%c)."), o_name, index_to_label(item));
1550 choice = sell_haggle(owner_ptr, q_ptr, &price);
1551 if (st_ptr->store_open >= current_world_ptr->game_turn) return;
1555 say_comment_1(owner_ptr);
1557 if (cur_store_num == STORE_BLACK)
1558 chg_virtue(owner_ptr, V_JUSTICE, -1);
1560 if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
1561 chg_virtue(owner_ptr, V_NATURE, 1);
1564 owner_ptr->au += price;
1565 store_prt_gold(owner_ptr);
1566 dummy = object_value(q_ptr) * q_ptr->number;
1568 identify_item(owner_ptr, o_ptr);
1570 object_copy(q_ptr, o_ptr);
1571 q_ptr->number = amt;
1572 q_ptr->ident |= IDENT_STORE;
1575 * Hack -- If a rod or wand, let the shopkeeper know just
1576 * how many charges he really paid for. -LM-
1578 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1580 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1583 value = object_value(q_ptr) * q_ptr->number;
1584 object_desc(owner_ptr, o_name, q_ptr, 0);
1585 msg_format(_("%sを $%ldで売却しました。", "You sold %s for %ld gold."), o_name, (long)price);
1587 if (record_sell) exe_write_diary(owner_ptr, DIARY_SELL, 0, o_name);
1589 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
1591 purchase_analyze(owner_ptr, price, value, dummy);
1595 * Hack -- Allocate charges between those wands or rods sold
1596 * and retained, unless all are being sold. -LM-
1598 distribute_charges(o_ptr, q_ptr, amt);
1600 inven_item_increase(owner_ptr, item, -amt);
1601 inven_item_describe(owner_ptr, item);
1602 if (o_ptr->number > 0)
1603 autopick_alter_item(owner_ptr, item, FALSE);
1605 inven_item_optimize(owner_ptr, item);
1606 handle_stuff(owner_ptr);
1607 int item_pos = store_carry(q_ptr);
1610 store_top = (item_pos / store_bottom) * store_bottom;
1611 display_store_inventory(owner_ptr);
1615 else if (cur_store_num == STORE_MUSEUM)
1617 char o2_name[MAX_NLEN];
1618 object_desc(owner_ptr, o2_name, q_ptr, OD_NAME_ONLY);
1620 if (-1 == store_check_num(q_ptr))
1622 msg_print(_("それと同じ品物は既に博物館にあるようです。", "The Museum already has one of those items."));
1626 msg_print(_("博物館に寄贈したものは取り出すことができません!!", "You cannot take back items which have been donated to the Museum!!"));
1629 if (!get_check(format(_("本当に%sを寄贈しますか?", "Really give %s to the Museum? "), o2_name))) return;
1631 identify_item(owner_ptr, q_ptr);
1632 q_ptr->ident |= IDENT_FULL_KNOWN;
1634 distribute_charges(o_ptr, q_ptr, amt);
1635 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
1638 vary_item(owner_ptr, item, -amt);
1639 handle_stuff(owner_ptr);
1641 int item_pos = home_carry(owner_ptr, q_ptr);
1644 store_top = (item_pos / store_bottom) * store_bottom;
1645 display_store_inventory(owner_ptr);
1650 distribute_charges(o_ptr, q_ptr, amt);
1651 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
1653 vary_item(owner_ptr, item, -amt);
1654 handle_stuff(owner_ptr);
1655 int item_pos = home_carry(owner_ptr, q_ptr);
1658 store_top = (item_pos / store_bottom) * store_bottom;
1659 display_store_inventory(owner_ptr);
1663 if ((choice == 0) && (item >= INVEN_RARM))
1665 calc_android_exp(owner_ptr);
1666 verify_equip_slot(owner_ptr, item);
1672 * @brief 店のアイテムを調べるコマンドのメインルーチン /
1673 * Examine an item in a store -JDL-
1676 static void store_examine(player_type *player_ptr)
1678 if (st_ptr->stock_num <= 0)
1680 if (cur_store_num == STORE_HOME)
1681 msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
1682 else if (cur_store_num == STORE_MUSEUM)
1683 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
1685 msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
1689 int i = (st_ptr->stock_num - store_top);
1690 if (i > store_bottom) i = store_bottom;
1693 sprintf(out_val, _("どれを調べますか?", "Which item do you want to examine? "));
1696 if (!get_stock(&item, out_val, 0, i - 1)) return;
1697 item = item + store_top;
1699 o_ptr = &st_ptr->stock[item];
1700 if (!object_is_fully_known(o_ptr))
1702 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1706 GAME_TEXT o_name[MAX_NLEN];
1707 object_desc(player_ptr, o_name, o_ptr, 0);
1708 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1710 if (!screen_object(player_ptr, o_ptr, SCROBJ_FORCE_DETAIL))
1711 msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1716 * @brief 博物館のアイテムを除去するコマンドのメインルーチン /
1717 * Remove an item from museum (Originally from TOband)
1718 * @param player_ptr プレーヤーへの参照ポインタ
1721 static void museum_remove_object(player_type *player_ptr)
1723 if (st_ptr->stock_num <= 0)
1725 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
1729 int i = st_ptr->stock_num - store_top;
1730 if (i > store_bottom) i = store_bottom;
1733 sprintf(out_val, _("どのアイテムの展示をやめさせますか?", "Which item do you want to order to remove? "));
1736 if (!get_stock(&item, out_val, 0, i - 1)) return;
1738 item = item + store_top;
1740 o_ptr = &st_ptr->stock[item];
1742 GAME_TEXT o_name[MAX_NLEN];
1743 object_desc(player_ptr, o_name, o_ptr, 0);
1745 msg_print(_("展示をやめさせたアイテムは二度と見ることはできません!", "Once removed from the Museum, an item will be gone forever!"));
1746 if (!get_check(format(_("本当に%sの展示をやめさせますか?", "Really order to remove %s from the Museum? "), o_name))) return;
1748 msg_format(_("%sの展示をやめさせた。", "You ordered to remove %s."), o_name);
1750 store_item_increase(item, -o_ptr->number);
1751 store_item_optimize(item);
1753 (void)combine_and_reorder_home(STORE_MUSEUM);
1754 if (st_ptr->stock_num == 0) store_top = 0;
1756 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1757 display_store_inventory(player_ptr);
1762 * Hack -- set this to leave the store
1764 static bool leave_store = FALSE;
1768 * @brief 店舗処理コマンド選択のメインルーチン /
1769 * Process a command in a store
1770 * @param client_ptr 顧客となるクリーチャーの参照ポインタ
1774 * Note that we must allow the use of a few "special" commands
1775 * in the stores which are not allowed in the dungeon, and we
1776 * must disable some commands which are allowed in the dungeon
1777 * but not in the stores, to prevent chaos.
1780 static void store_process_command(player_type *client_ptr)
1783 if (rogue_like_commands && command_cmd == 'l')
1788 switch (command_cmd)
1798 /* 1 ページ戻るコマンド: 我が家のページ数が多いので重宝するはず By BUG */
1799 if (st_ptr->stock_num <= store_bottom) {
1800 msg_print(_("これで全部です。", "Entire inventory is shown."));
1804 store_top -= store_bottom;
1806 store_top = ((st_ptr->stock_num - 1) / store_bottom) * store_bottom;
1807 if ((cur_store_num == STORE_HOME) && (powerup_home == FALSE))
1808 if (store_top >= store_bottom) store_top = store_bottom;
1809 display_store_inventory(client_ptr);
1816 if (st_ptr->stock_num <= store_bottom)
1818 msg_print(_("これで全部です。", "Entire inventory is shown."));
1822 store_top += store_bottom;
1824 * 隠しオプション(powerup_home)がセットされていないときは
1825 * 我が家では 2 ページまでしか表示しない
1827 if ((cur_store_num == STORE_HOME) &&
1828 (powerup_home == FALSE) &&
1829 (st_ptr->stock_num >= STORE_INVEN_MAX))
1831 if (store_top >= (STORE_INVEN_MAX - 1))
1838 if (store_top >= st_ptr->stock_num) store_top = 0;
1841 display_store_inventory(client_ptr);
1848 do_cmd_redraw(client_ptr);
1849 display_store(client_ptr);
1854 store_purchase(client_ptr);
1859 store_sell(client_ptr);
1864 store_examine(client_ptr);
1873 do_cmd_wield(client_ptr);
1878 do_cmd_takeoff(client_ptr);
1883 do_cmd_destroy(client_ptr);
1888 do_cmd_equip(client_ptr);
1893 do_cmd_inven(client_ptr);
1898 do_cmd_observe(client_ptr);
1903 toggle_inventory_equipment(client_ptr);
1908 if ((client_ptr->pclass == CLASS_MINDCRAFTER) ||
1909 (client_ptr->pclass == CLASS_BERSERKER) ||
1910 (client_ptr->pclass == CLASS_NINJA) ||
1911 (client_ptr->pclass == CLASS_MIRROR_MASTER)
1912 ) do_cmd_mind_browse(client_ptr);
1913 else if (client_ptr->pclass == CLASS_SMITH)
1914 do_cmd_kaji(client_ptr, TRUE);
1915 else if (client_ptr->pclass == CLASS_MAGIC_EATER)
1916 do_cmd_magic_eater(client_ptr, TRUE, FALSE);
1917 else if (client_ptr->pclass == CLASS_SNIPER)
1918 do_cmd_snipe_browse(client_ptr);
1919 else do_cmd_browse(client_ptr);
1924 do_cmd_inscribe(client_ptr);
1929 do_cmd_uninscribe(client_ptr);
1934 do_cmd_help(client_ptr);
1939 do_cmd_query_symbol(client_ptr);
1944 client_ptr->town_num = old_town_num;
1945 do_cmd_player_status(client_ptr);
1946 client_ptr->town_num = inner_town_num;
1947 display_store(client_ptr);
1957 client_ptr->town_num = old_town_num;
1958 do_cmd_pref(client_ptr);
1959 client_ptr->town_num = inner_town_num;
1964 client_ptr->town_num = old_town_num;
1965 do_cmd_macros(client_ptr, process_autopick_file_command);
1966 client_ptr->town_num = inner_town_num;
1971 client_ptr->town_num = old_town_num;
1972 do_cmd_visuals(client_ptr, process_autopick_file_command);
1973 client_ptr->town_num = inner_town_num;
1978 client_ptr->town_num = old_town_num;
1979 do_cmd_colors(client_ptr, process_autopick_file_command);
1980 client_ptr->town_num = inner_town_num;
1986 (void)combine_and_reorder_home(STORE_HOME);
1987 do_cmd_redraw(client_ptr);
1988 display_store(client_ptr);
2003 do_cmd_feeling(client_ptr);
2008 do_cmd_message_one();
2018 do_cmd_diary(client_ptr);
2023 do_cmd_knowledge(client_ptr);
2028 do_cmd_load_screen();
2033 do_cmd_save_screen(client_ptr, process_autopick_file_command);
2038 if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
2040 museum_remove_object(client_ptr);
2044 msg_print(_("そのコマンドは店の中では使えません。", "That command does not work in stores."));
2054 * @brief 店舗処理全体のメインルーチン /
2055 * Enter a store, and interact with it. *
2056 * @param player_ptr プレーヤーへの参照ポインタ
2060 * Note that we use the standard "request_command()" function
2061 * to get a command, allowing us to use "command_arg" and all
2062 * command macros and other nifty stuff, but we use the special
2063 * "shopping" argument, to force certain commands to be converted
2064 * into other commands, normally, we convert "p" (pray) and "m"
2065 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
2068 void do_cmd_store(player_type *player_ptr)
2070 if (player_ptr->wild_mode) return;
2072 Term_get_size(&w, &h);
2074 xtra_stock = MIN(14 + 26, ((h > 24) ? (h - 24) : 0));
2075 store_bottom = MIN_STOCK + xtra_stock;
2078 g_ptr = &player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x];
2080 if (!cave_have_flag_grid(g_ptr, FF_STORE))
2082 msg_print(_("ここには店がありません。", "You see no store here."));
2086 int which = f_info[g_ptr->feat].subtype;
2087 old_town_num = player_ptr->town_num;
2088 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) player_ptr->town_num = 1;
2089 if (player_ptr->current_floor_ptr->dun_level) player_ptr->town_num = NO_TOWN;
2090 inner_town_num = player_ptr->town_num;
2092 if ((town_info[player_ptr->town_num].store[which].store_open >= current_world_ptr->game_turn) ||
2095 msg_print(_("ドアに鍵がかかっている。", "The doors are locked."));
2096 player_ptr->town_num = old_town_num;
2100 int maintain_num = (current_world_ptr->game_turn - town_info[player_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
2101 if (maintain_num > 10)
2105 for (int i = 0; i < maintain_num; i++)
2106 store_maint(player_ptr, player_ptr->town_num, which);
2108 town_info[player_ptr->town_num].store[which].last_visit = current_world_ptr->game_turn;
2111 forget_lite(player_ptr->current_floor_ptr);
2112 forget_view(player_ptr->current_floor_ptr);
2113 current_world_ptr->character_icky = TRUE;
2117 get_com_no_macros = TRUE;
2118 cur_store_num = which;
2119 cur_store_feat = g_ptr->feat;
2120 st_ptr = &town_info[player_ptr->town_num].store[cur_store_num];
2121 ot_ptr = &owners[cur_store_num][st_ptr->owner];
2123 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
2124 display_store(player_ptr);
2125 leave_store = FALSE;
2127 while (!leave_store)
2130 clear_from(20 + xtra_stock);
2131 prt(_(" ESC) 建物から出る", " ESC) Exit from Building."), 21 + xtra_stock, 0);
2132 if (st_ptr->stock_num > store_bottom)
2134 prt(_(" -)前ページ", " -) Previous page"), 22 + xtra_stock, 0);
2135 prt(_(" スペース) 次ページ", " SPACE) Next page"), 23 + xtra_stock, 0);
2138 if (cur_store_num == STORE_HOME)
2140 prt(_("g) アイテムを取る", "g) Get an item."), 21 + xtra_stock, 27);
2141 prt(_("d) アイテムを置く", "d) Drop an item."), 22 + xtra_stock, 27);
2142 prt(_("x) 家のアイテムを調べる", "x) eXamine an item in the home."), 23 + xtra_stock, 27);
2144 else if (cur_store_num == STORE_MUSEUM)
2146 prt(_("d) アイテムを置く", "d) Drop an item."), 21 + xtra_stock, 27);
2147 prt(_("r) アイテムの展示をやめる", "r) order to Remove an item."), 22 + xtra_stock, 27);
2148 prt(_("x) 博物館のアイテムを調べる", "x) eXamine an item in the museum."), 23 + xtra_stock, 27);
2152 prt(_("p) 商品を買う", "p) Purchase an item."), 21 + xtra_stock, 30);
2153 prt(_("s) アイテムを売る", "s) Sell an item."), 22 + xtra_stock, 30);
2154 prt(_("x) 商品を調べる", "x) eXamine an item in the shop"), 23 + xtra_stock, 30);
2157 prt(_("i/e) 持ち物/装備の一覧", "i/e) Inventry/Equipment list"), 21 + xtra_stock, 56);
2158 if (rogue_like_commands)
2160 prt(_("w/T) 装備する/はずす", "w/T) Wear/Take off equipment"), 22 + xtra_stock, 56);
2164 prt(_("w/t) 装備する/はずす", "w/t) Wear/Take off equipment"), 22 + xtra_stock, 56);
2167 prt(_("コマンド:", "You may: "), 20 + xtra_stock, 0);
2168 request_command(player_ptr, TRUE);
2169 store_process_command(player_ptr);
2172 * Hack -- To redraw missiles damage and prices in store
2173 * If player's charisma changes, or if player changes a bow, PU_BONUS is set
2175 bool need_redraw_store_inv = (player_ptr->update & PU_BONUS) ? TRUE : FALSE;
2176 current_world_ptr->character_icky = TRUE;
2177 handle_stuff(player_ptr);
2178 if (player_ptr->inventory_list[INVEN_PACK].k_idx)
2180 INVENTORY_IDX item = INVEN_PACK;
2181 object_type *o_ptr = &player_ptr->inventory_list[item];
2182 if (cur_store_num != STORE_HOME)
2184 if (cur_store_num == STORE_MUSEUM)
2185 msg_print(_("ザックからアイテムがあふれそうなので、あわてて博物館から出た...", "Your pack is so full that you flee the Museum..."));
2187 msg_print(_("ザックからアイテムがあふれそうなので、あわてて店から出た...", "Your pack is so full that you flee the store..."));
2191 else if (!store_check_num(o_ptr))
2193 msg_print(_("ザックからアイテムがあふれそうなので、あわてて家から出た...", "Your pack is so full that you flee your home..."));
2201 GAME_TEXT o_name[MAX_NLEN];
2202 msg_print(_("ザックからアイテムがあふれてしまった!", "Your pack overflows!"));
2204 object_copy(q_ptr, o_ptr);
2205 object_desc(player_ptr, o_name, q_ptr, 0);
2206 msg_format(_("%sが落ちた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
2207 vary_item(player_ptr, item, -255);
2208 handle_stuff(player_ptr);
2210 item_pos = home_carry(player_ptr, q_ptr);
2213 store_top = (item_pos / store_bottom) * store_bottom;
2214 display_store_inventory(player_ptr);
2219 if (need_redraw_store_inv) display_store_inventory(player_ptr);
2221 if (st_ptr->store_open >= current_world_ptr->game_turn) leave_store = TRUE;
2224 select_floor_music(player_ptr);
2225 player_ptr->town_num = old_town_num;
2226 take_turn(player_ptr, 100);
2227 current_world_ptr->character_icky = FALSE;
2229 command_see = FALSE;
2230 get_com_no_macros = FALSE;
2235 player_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2236 player_ptr->update |= (PU_MONSTERS);
2237 player_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
2238 player_ptr->redraw |= (PR_MAP);
2239 player_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2244 * @brief 現在の町の店主を交代させる /
2245 * Shuffle one of the stores.
2246 * @param which 店舗種類のID
2249 void store_shuffle(player_type *player_ptr, int which)
2251 if (which == STORE_HOME) return;
2252 if (which == STORE_MUSEUM) return;
2254 cur_store_num = which;
2255 st_ptr = &town_info[player_ptr->town_num].store[cur_store_num];
2256 int j = st_ptr->owner;
2259 st_ptr->owner = (byte)randint0(MAX_OWNERS);
2260 if (j == st_ptr->owner) continue;
2262 for (i = 1; i < max_towns; i++)
2264 if (i == player_ptr->town_num) continue;
2265 if (st_ptr->owner == town_info[i].store[cur_store_num].owner) break;
2268 if (i == max_towns) break;
2271 ot_ptr = &owners[cur_store_num][st_ptr->owner];
2272 st_ptr->insult_cur = 0;
2273 st_ptr->store_open = 0;
2274 st_ptr->good_buy = 0;
2275 st_ptr->bad_buy = 0;
2276 for (int i = 0; i < st_ptr->stock_num; i++)
2279 o_ptr = &st_ptr->stock[i];
2280 if (object_is_artifact(o_ptr)) continue;
2282 o_ptr->discount = 50;
2283 o_ptr->ident &= ~(IDENT_FIXED);
2284 o_ptr->inscription = quark_add(_("売出中", "on sale"));
2290 * @brief 店の品揃えを変化させる /
2291 * Maintain the inventory at the stores.
2292 * @param player_ptr プレーヤーへの参照ポインタ
2293 * @param town_num 町のID
2294 * @param store_num 店舗種類のID
2297 void store_maint(player_type *player_ptr, int town_num, int store_num)
2299 cur_store_num = store_num;
2300 if (store_num == STORE_HOME) return;
2301 if (store_num == STORE_MUSEUM) return;
2303 st_ptr = &town_info[town_num].store[store_num];
2304 ot_ptr = &owners[store_num][st_ptr->owner];
2305 st_ptr->insult_cur = 0;
2306 if (store_num == STORE_BLACK)
2308 for (INVENTORY_IDX j = st_ptr->stock_num - 1; j >= 0; j--)
2310 object_type *o_ptr = &st_ptr->stock[j];
2311 if (black_market_crap(player_ptr, o_ptr))
2313 store_item_increase(j, 0 - o_ptr->number);
2314 store_item_optimize(j);
2319 INVENTORY_IDX j = st_ptr->stock_num;
2320 j = j - randint1(STORE_TURNOVER);
2321 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
2322 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
2325 while (st_ptr->stock_num > j)
2328 j = st_ptr->stock_num;
2329 j = j + randint1(STORE_TURNOVER);
2330 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
2331 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
2332 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
2334 while (st_ptr->stock_num < j) store_create(player_ptr, black_market_crap);
2339 * @brief 店舗情報を初期化する /
2340 * Initialize the stores
2341 * @param town_num 町のID
2342 * @param store_num 店舗種類のID
2345 void store_init(int town_num, int store_num)
2347 cur_store_num = store_num;
2348 st_ptr = &town_info[town_num].store[store_num];
2351 st_ptr->owner = (byte)randint0(MAX_OWNERS);
2353 for (i = 1; i < max_towns; i++)
2355 if (i == town_num) continue;
2356 if (st_ptr->owner == town_info[i].store[store_num].owner) break;
2359 if (i == max_towns) break;
2362 ot_ptr = &owners[store_num][st_ptr->owner];
2364 st_ptr->store_open = 0;
2365 st_ptr->insult_cur = 0;
2366 st_ptr->good_buy = 0;
2367 st_ptr->bad_buy = 0;
2368 st_ptr->stock_num = 0;
2369 st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
2370 for (int k = 0; k < st_ptr->stock_size; k++)
2372 object_wipe(&st_ptr->stock[k]);