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.
14 #include "market/say-comments.h"
15 #include "market/store-owners.h"
16 #include "market/store-util.h"
17 #include "market/gold-magnification-table.h"
18 #include "market/store-util.h"
19 #include "market/black-market.h"
20 #include "core/stuff-handler.h"
22 #include "main/music-definitions-table.h"
23 #include "main/sound-definitions-table.h"
27 #include "io/write-diary.h"
28 #include "cmd/cmd-basic.h"
29 #include "cmd/cmd-diary.h"
30 #include "cmd/cmd-draw.h"
31 #include "cmd/cmd-dump.h"
32 #include "cmd/cmd-knowledge.h"
33 #include "cmd/cmd-help.h"
34 #include "cmd/cmd-item.h"
35 #include "cmd/cmd-macro.h"
36 #include "cmd/cmd-process-screen.h"
37 #include "cmd/cmd-smith.h"
38 #include "cmd/cmd-visuals.h"
39 #include "cmd/cmd-zapwand.h"
40 #include "cmd/cmd-magiceat.h"
41 #include "spell/spells3.h"
42 #include "market/store.h"
44 #include "cmd-spell.h"
46 #include "player-status.h"
47 #include "player-class.h"
48 #include "player-inventory.h"
49 #include "object-flavor.h"
50 #include "object-hook.h"
51 #include "floor-events.h"
54 #include "player-effects.h"
55 #include "player/race-info-table.h"
58 #include "object/object-kind.h"
59 #include "autopick/autopick.h"
60 #include "autopick/autopick-pref-processor.h"
61 #include "floor-town.h"
63 #include "view/display-main-window.h"
68 static int store_top = 0;
69 static int store_bottom = 0;
70 static int xtra_stock = 0;
71 static const owner_type *ot_ptr = NULL;
72 static s16b old_town_num = 0;
73 static s16b inner_town_num = 0;
76 * We store the current "store feat" here so everyone can access it
78 static int cur_store_feat;
81 * @brief 店舗価格を決定する. 無料にはならない /
82 * Determine the price of an item (qty one) in a store.
83 * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
85 * @param flip TRUEならば店主にとっての買取価格、FALSEなら売出価格を計算
89 * This function takes into account the player's charisma, and the
90 * shop-keepers friendliness, and the shop-keeper's base greed, but
91 * never lets a shop-keeper lose money in a transaction.
92 * The "greed" value should exceed 100 when the player is "buying" the
93 * item, and should be less than 100 when the player is "selling" it.
94 * Hack -- the black market always charges twice as much as it should.
95 * Charisma adjustment runs from 80 to 130
96 * Racial adjustment runs from 95 to 130
97 * Since greed/charisma/racial adjustments are centered at 100, we need
98 * to adjust (by 200) to extract a usable multiplier. Note that the
99 * "greed" value is always something (?).
102 static PRICE price_item(player_type *player_ptr, object_type *o_ptr, int greed, bool flip)
104 PRICE price = object_value(o_ptr);
105 if (price <= 0) return (0L);
107 int factor = rgold_adj[ot_ptr->owner_race][player_ptr->prace];
108 factor += adj_chr_gold[player_ptr->stat_ind[A_CHR]];
112 adjust = 100 + (300 - (greed + factor));
113 if (adjust > 100) adjust = 100;
114 if (cur_store_num == STORE_BLACK)
117 price = (price * adjust + 50L) / 100L;
121 adjust = 100 + ((greed + factor) - 300);
122 if (adjust < 100) adjust = 100;
123 if (cur_store_num == STORE_BLACK)
126 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
129 if (price <= 0L) return (1L);
135 * @brief 店舗に品を置くスペースがあるかどうかの判定を返す /
136 * Check to see if the shop will be carrying too many objects -RAK-
137 * @param o_ptr 店舗に置きたいオブジェクト構造体の参照ポインタ
138 * @return 置き場がないなら0、重ね合わせできるアイテムがあるなら-1、スペースがあるなら1を返す。
141 * Note that the shop, just like a player, will not accept things
142 * it cannot hold. Before, one could "nuke" potions this way.
143 * Return value is now int:
145 * -1 : Can be combined to existing slot.
146 * 1 : Cannot be combined but there are empty spaces.
149 static int store_check_num(object_type *o_ptr)
152 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
154 bool old_stack_force_notes = stack_force_notes;
155 bool old_stack_force_costs = stack_force_costs;
157 if (cur_store_num != STORE_HOME)
159 stack_force_notes = FALSE;
160 stack_force_costs = FALSE;
163 for (int i = 0; i < st_ptr->stock_num; i++)
165 j_ptr = &st_ptr->stock[i];
166 if (object_similar(j_ptr, o_ptr))
168 if (cur_store_num != STORE_HOME)
170 stack_force_notes = old_stack_force_notes;
171 stack_force_costs = old_stack_force_costs;
178 if (cur_store_num != STORE_HOME)
180 stack_force_notes = old_stack_force_notes;
181 stack_force_costs = old_stack_force_costs;
186 for (int i = 0; i < st_ptr->stock_num; i++)
188 j_ptr = &st_ptr->stock[i];
189 if (store_object_similar(j_ptr, o_ptr)) return -1;
193 /* Free space is always usable */
195 * オプション powerup_home が設定されていると
198 if ((cur_store_num == STORE_HOME) && (powerup_home == FALSE))
200 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10))
207 if (st_ptr->stock_num < st_ptr->stock_size)
218 * @brief 現在の町の指定された店舗のアイテムを整理する /
219 * Combine and reorder items in store.
220 * @param store_num 店舗ID
221 * @return 実際に整理が行われたならばTRUEを返す。
223 bool combine_and_reorder_home(int store_num)
225 store_type *old_st_ptr = st_ptr;
226 st_ptr = &town_info[1].store[store_num];
228 if (store_num != STORE_HOME)
230 stack_force_notes = FALSE;
231 stack_force_costs = FALSE;
234 bool combined = TRUE;
238 for (int i = st_ptr->stock_num - 1; i > 0; i--)
241 o_ptr = &st_ptr->stock[i];
242 if (!o_ptr->k_idx) continue;
243 for (int j = 0; j < i; j++)
246 j_ptr = &st_ptr->stock[j];
247 if (!j_ptr->k_idx) continue;
250 * Get maximum number of the stack if these
251 * are similar, get zero otherwise.
253 int max_num = object_similar_part(j_ptr, o_ptr);
254 if (max_num == 0 || j_ptr->number >= max_num) continue;
256 if (o_ptr->number + j_ptr->number <= max_num)
258 object_absorb(j_ptr, o_ptr);
261 for (k = i; k < st_ptr->stock_num; k++)
263 st_ptr->stock[k] = st_ptr->stock[k + 1];
266 object_wipe(&st_ptr->stock[k]);
271 ITEM_NUMBER old_num = o_ptr->number;
272 ITEM_NUMBER remain = j_ptr->number + o_ptr->number - max_num;
273 object_absorb(j_ptr, o_ptr);
274 o_ptr->number = remain;
275 if (o_ptr->tval == TV_ROD)
277 o_ptr->pval = o_ptr->pval * remain / old_num;
278 o_ptr->timeout = o_ptr->timeout * remain / old_num;
280 else if (o_ptr->tval == TV_WAND)
282 o_ptr->pval = o_ptr->pval * remain / old_num;
293 for (int i = 0; i < st_ptr->stock_num; i++)
296 o_ptr = &st_ptr->stock[i];
297 if (!o_ptr->k_idx) continue;
299 s32b o_value = object_value(o_ptr);
301 for (j = 0; j < st_ptr->stock_num; j++)
303 if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
306 if (j >= i) continue;
312 object_copy(j_ptr, &st_ptr->stock[i]);
313 for (int k = i; k > j; k--)
315 object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
318 object_copy(&st_ptr->stock[j], j_ptr);
322 bool old_stack_force_notes = stack_force_notes;
323 bool old_stack_force_costs = stack_force_costs;
324 if (store_num != STORE_HOME)
326 stack_force_notes = old_stack_force_notes;
327 stack_force_costs = old_stack_force_costs;
335 * @brief 我が家にオブジェクトを加える /
336 * Add the item "o_ptr" to the inventory of the "Home"
337 * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
341 * In all cases, return the slot (or -1) where the object was placed
342 * Note that this is a hacked up version of "inven_carry()".
343 * Also note that it may not correctly "adapt" to "knowledge" bacoming
344 * known, the player may have to pick stuff up and drop it again.
347 static int home_carry(player_type *player_ptr, object_type *o_ptr)
349 if (cur_store_num != STORE_HOME)
351 stack_force_notes = FALSE;
352 stack_force_costs = FALSE;
355 bool old_stack_force_notes = stack_force_notes;
356 bool old_stack_force_costs = stack_force_costs;
357 for (int slot = 0; slot < st_ptr->stock_num; slot++)
360 j_ptr = &st_ptr->stock[slot];
361 if (object_similar(j_ptr, o_ptr))
363 object_absorb(j_ptr, o_ptr);
364 if (cur_store_num != STORE_HOME)
366 stack_force_notes = old_stack_force_notes;
367 stack_force_costs = old_stack_force_costs;
374 if (cur_store_num != STORE_HOME)
376 stack_force_notes = old_stack_force_notes;
377 stack_force_costs = old_stack_force_costs;
382 * 隠し機能: オプション powerup_home が設定されていると
385 if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE))
387 if (st_ptr->stock_num >= st_ptr->stock_size)
394 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10))
400 PRICE value = object_value(o_ptr);
402 for (slot = 0; slot < st_ptr->stock_num; slot++)
404 if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
407 for (int i = st_ptr->stock_num; i > slot; i--)
409 st_ptr->stock[i] = st_ptr->stock[i - 1];
413 st_ptr->stock[slot] = *o_ptr;
414 chg_virtue(player_ptr, V_SACRIFICE, -1);
415 (void)combine_and_reorder_home(cur_store_num);
421 * @brief 店舗の割引対象外にするかどうかを判定 /
422 * Eliminate need to bargain if player has haggled well in the past
423 * @param minprice アイテムの最低販売価格
424 * @return 割引を禁止するならTRUEを返す。
426 static bool noneedtobargain(PRICE minprice)
428 PRICE good = st_ptr->good_buy;
429 PRICE bad = st_ptr->bad_buy;
430 if (minprice < 10L) return TRUE;
431 if (good == MAX_SHORT) return TRUE;
432 if (good > ((3 * bad) + (5 + (minprice / 50)))) return TRUE;
439 * @brief 店主の持つプレイヤーに対する売買の良し悪し経験を記憶する /
440 * Update the bargain info
441 * @param price 実際の取引価格
442 * @param minprice 店主の提示した価格
446 static void updatebargain(PRICE price, PRICE minprice, int num)
448 if (!manual_haggle) return;
449 if ((minprice / num) < 10L) return;
450 if (price == minprice)
452 if (st_ptr->good_buy < MAX_SHORT)
459 if (st_ptr->bad_buy < MAX_SHORT)
468 * @brief 店の商品リストを再表示する /
469 * Re-displays a single store entry
470 * @param player_ptr プレーヤーへの参照ポインタ
474 static void display_entry(player_type *player_ptr, int pos)
477 o_ptr = &st_ptr->stock[pos];
478 int i = (pos % store_bottom);
480 /* Label it, clear the line --(-- */
482 (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
483 prt(out_val, i + 6, 0);
488 TERM_COLOR a = object_attr(o_ptr);
489 SYMBOL_CODE c = object_char(o_ptr);
491 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
492 if (use_bigtile) cur_col++;
497 /* Describe an item in the home */
499 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
502 if (show_weights) maxwid -= 10;
504 GAME_TEXT o_name[MAX_NLEN];
505 object_desc(player_ptr, o_name, o_ptr, 0);
506 o_name[maxwid] = '\0';
507 c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col);
510 WEIGHT wgt = o_ptr->weight;
511 sprintf(out_val, _("%3d.%1d kg", "%3d.%d lb"), _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
512 put_str(out_val, i + 6, _(67, 68));
519 if (show_weights) maxwid -= 7;
521 GAME_TEXT o_name[MAX_NLEN];
522 object_desc(player_ptr, o_name, o_ptr, 0);
523 o_name[maxwid] = '\0';
524 c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col);
528 int wgt = o_ptr->weight;
529 sprintf(out_val, "%3d.%1d", _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
530 put_str(out_val, i + 6, _(60, 61));
534 if (o_ptr->ident & (IDENT_FIXED))
536 x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
537 (void)sprintf(out_val, _("%9ld固", "%9ld F"), (long)x);
538 put_str(out_val, i + 6, 68);
544 x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
545 if (!noneedtobargain(x)) x += x / 10;
547 (void)sprintf(out_val, "%9ld ", (long)x);
548 put_str(out_val, i + 6, 68);
552 x = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
553 (void)sprintf(out_val, "%9ld ", (long)x);
554 put_str(out_val, i + 6, 68);
559 * @brief 店の商品リストを表示する /
560 * Displays a store's inventory -RAK-
561 * @param player_ptr プレーヤーへの参照ポインタ
564 * All prices are listed as "per individual object". -BEN-
566 static void display_store_inventory(player_type *player_ptr)
569 for (k = 0; k < store_bottom; k++)
571 if (store_top + k >= st_ptr->stock_num) break;
573 display_entry(player_ptr, store_top + k);
576 for (int i = k; i < store_bottom + 1; i++)
579 put_str(_(" ", " "), 5, _(20, 22));
580 if (st_ptr->stock_num > store_bottom)
582 prt(_("-続く-", "-more-"), k + 6, 3);
583 put_str(format(_("(%dページ) ", "(Page %d) "), store_top / store_bottom + 1), 5, _(20, 22));
586 if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM)
588 k = st_ptr->stock_size;
589 if (cur_store_num == STORE_HOME && !powerup_home) k /= 10;
591 put_str(format(_("アイテム数: %4d/%4d", "Objects: %4d/%4d"), st_ptr->stock_num, k), 19 + xtra_stock, _(27, 30));
597 * @brief プレイヤーの所持金を表示する /
598 * Displays players gold -RAK-
599 * @param player_ptr プレーヤーへの参照ポインタ
603 static void store_prt_gold(player_type *player_ptr)
605 prt(_("手持ちのお金: ", "Gold Remaining: "), 19 + xtra_stock, 53);
607 sprintf(out_val, "%9ld", (long)player_ptr->au);
608 prt(out_val, 19 + xtra_stock, 68);
613 * @brief 店舗情報全体を表示するメインルーチン /
614 * Displays store (after clearing screen) -RAK-
615 * @param player_ptr プレーヤーへの参照ポインタ
619 static void display_store(player_type *player_ptr)
622 if (cur_store_num == STORE_HOME)
624 put_str(_("我が家", "Your Home"), 3, 31);
625 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
628 put_str(_(" 重さ", "Weight"), 5, 70);
631 store_prt_gold(player_ptr);
632 display_store_inventory(player_ptr);
636 if (cur_store_num == STORE_MUSEUM)
638 put_str(_("博物館", "Museum"), 3, 31);
639 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
642 put_str(_(" 重さ", "Weight"), 5, 70);
645 store_prt_gold(player_ptr);
646 display_store_inventory(player_ptr);
650 concptr store_name = (f_name + f_info[cur_store_feat].name);
651 concptr owner_name = (ot_ptr->owner_name);
652 concptr race_name = race_info[ot_ptr->owner_race].title;
654 sprintf(buf, "%s (%s)", owner_name, race_name);
657 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
660 put_str(_("商品の一覧", "Item Description"), 5, 5);
663 put_str(_(" 重さ", "Weight"), 5, 60);
666 put_str(_(" 価格", "Price"), 5, 72);
667 store_prt_gold(player_ptr);
668 display_store_inventory(player_ptr);
673 * @brief 店舗からアイテムを選択する /
674 * Get the ID of a store item and return its value -RAK-
675 * @param com_val 選択IDを返す参照ポインタ
676 * @param pmt メッセージキャプション
679 * @return 実際に選択したらTRUE、キャンセルしたらFALSE
681 static int get_stock(COMMAND_CODE *com_val, concptr pmt, int i, int j)
683 if (repeat_pull(com_val) && (*com_val >= i) && (*com_val <= j))
691 char hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
694 (void)sprintf(out_val, "(%s:%c-%c, ESCで中断) %s",
695 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "アイテム" : "商品"),
698 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
705 if (!get_com(out_val, &command, FALSE)) break;
708 if (islower(command))
710 else if (isupper(command))
711 k = A2I(tolower(command)) + 26;
715 if ((k >= i) && (k <= j))
725 if (command == ESCAPE) return FALSE;
727 repeat_push(*com_val);
733 * @brief 店主の不満度を増やし、プレイヤーを締め出す判定と処理を行う /
734 * Increase the insult counter and get angry if too many -RAK-
735 * @return プレイヤーを締め出す場合TRUEを返す
737 static int increase_insults(void)
739 st_ptr->insult_cur++;
740 if (st_ptr->insult_cur <= ot_ptr->insult_max) return FALSE;
744 st_ptr->insult_cur = 0;
745 st_ptr->good_buy = 0;
747 st_ptr->store_open = current_world_ptr->game_turn + TURNS_PER_TICK * TOWN_DAWN / 8 + randint1(TURNS_PER_TICK*TOWN_DAWN / 8);
754 * @brief 店主の不満度を減らす /
755 * Decrease insults -RAK-
756 * @return プレイヤーを締め出す場合TRUEを返す
758 static void decrease_insults(void)
760 if (st_ptr->insult_cur) st_ptr->insult_cur--;
765 * @brief 店主の不満度が増えた場合のみのメッセージを表示する /
766 * Have insulted while haggling -RAK-
767 * @return プレイヤーを締め出す場合TRUEを返す
769 static int haggle_insults(void)
771 if (increase_insults()) return TRUE;
778 * Mega-Hack -- Enable "increments"
780 static bool allow_inc = FALSE;
783 * Mega-Hack -- Last "increment" during haggling
785 static s32b last_inc = 0L;
788 * @brief 交渉価格を確認と認証の是非を行う /
791 * @param poffer 別途価格提示をした場合の値を返す参照ポインタ
792 * @param price 現在の交渉価格
793 * @param final 最終確定価格ならばTRUE
794 * @return プレイヤーを締め出す場合TRUEを返す
796 static int get_haggle(concptr pmt, s32b *poffer, PRICE price, int final)
799 if (!allow_inc) last_inc = 0L;
803 sprintf(buf, _("%s [承諾] ", "%s [accept] "), pmt);
805 else if (last_inc < 0)
807 sprintf(buf, _("%s [-$%ld] ", "%s [-%ld] "), pmt, (long)(ABS(last_inc)));
809 else if (last_inc > 0)
811 sprintf(buf, _("%s [+$%ld] ", "%s [+%ld] "), pmt, (long)(ABS(last_inc)));
815 sprintf(buf, "%s ", pmt);
819 GAME_TEXT out_val[160];
827 * Ask the user for a response.
828 * Don't allow to use numpad as cursor key.
830 res = askfor_aux(out_val, 32, FALSE);
832 if (!res) return FALSE;
835 for (p = out_val; *p == ' '; p++) /* loop */;
846 if (allow_inc && last_inc)
852 msg_print(_("値がおかしいです。", "Invalid response."));
857 if ((*p == '+' || *p == '-'))
879 * @brief 店主がプレイヤーからの交渉価格を判断する /
880 * Receive an offer (from the player)
882 * @param poffer 店主からの交渉価格を返す参照ポインタ
883 * @param last_offer 現在の交渉価格
884 * @param factor 店主の価格基準倍率
885 * @param price アイテムの実価値
886 * @param final 最終価格確定ならばTRUE
887 * @return プレイヤーの価格に対して不服ならばTRUEを返す /
888 * Return TRUE if offer is NOT okay
890 static bool receive_offer(concptr pmt, s32b *poffer, s32b last_offer, int factor, PRICE price, int final)
894 if (!get_haggle(pmt, poffer, price, final)) return TRUE;
895 if (((*poffer) * factor) >= (last_offer * factor)) break;
896 if (haggle_insults()) return TRUE;
898 (*poffer) = last_offer;
906 * @brief プレイヤーが購入する時の値切り処理メインルーチン /
907 * Haggling routine -RAK-
908 * @param player_ptr プレーヤーへの参照ポインタ
909 * @param o_ptr オブジェクトの構造体参照ポインタ
910 * @param price 最終価格を返す参照ポインタ
911 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
912 * Return TRUE if purchase is NOT successful
914 static bool purchase_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price)
916 s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
917 s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
918 int noneed = noneedtobargain(final_ask);
920 concptr pmt = _("提示価格", "Asking");
921 if (noneed || !manual_haggle)
925 msg_print(_("結局この金額にまとまった。", "You eventually agree upon the price."));
930 msg_print(_("すんなりとこの金額にまとまった。", "You quickly agree upon the price."));
932 final_ask += final_ask / 10;
936 pmt = _("最終提示価格", "Final Offer");
940 cur_ask *= o_ptr->number;
941 final_ask *= o_ptr->number;
942 s32b min_per = ot_ptr->haggle_per;
943 s32b max_per = min_per * 3;
944 s32b last_offer = object_value(o_ptr) * o_ptr->number;
945 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
946 if (last_offer <= 0) last_offer = 1;
956 bool loop_flag = TRUE;
958 while (!flag && loop_flag)
961 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
962 put_str(out_val, 1, 0);
963 cancel = receive_offer(_("提示する金額? ", "What do you offer? "), &offer, last_offer, 1, cur_ask, final);
968 else if (offer > cur_ask)
973 else if (offer == cur_ask)
986 s32b x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
989 if (haggle_insults())
995 else if (x1 > max_per)
998 if (x1 < max_per) x1 = max_per;
1001 s32b x2 = rand_range(x1 - 2, x1 + 2);
1002 s32b x3 = ((cur_ask - offer) * x2 / 100L) + 1;
1006 if (cur_ask < final_ask)
1009 cur_ask = final_ask;
1010 pmt = _("最終提示価格", "What do you offer? ");
1014 (void)(increase_insults());
1019 else if (offer >= cur_ask)
1029 (void)sprintf(out_val, _("前回の提示金額: $%ld", "Your last offer: %ld"), (long)last_offer);
1030 put_str(out_val, 1, 39);
1031 say_comment_2(cur_ask, annoyed);
1034 if (cancel) return TRUE;
1036 updatebargain(*price, final_ask, o_ptr->number);
1042 * @brief プレイヤーが売却する時の値切り処理メインルーチン /
1043 * Haggling routine -RAK-
1044 * @param player_ptr プレーヤーへの参照ポインタ
1045 * @param o_ptr オブジェクトの構造体参照ポインタ
1046 * @param price 最終価格を返す参照ポインタ
1047 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
1048 * Return TRUE if purchase is NOT successful
1050 static bool sell_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price)
1052 s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, TRUE);
1053 s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, TRUE);
1054 int noneed = noneedtobargain(final_ask);
1055 s32b purse = (s32b)(ot_ptr->max_cost);
1057 concptr pmt = _("提示金額", "Offer");
1058 if (noneed || !manual_haggle || (final_ask >= purse))
1060 if (!manual_haggle && !noneed)
1062 final_ask -= final_ask / 10;
1065 if (final_ask >= purse)
1067 msg_print(_("即座にこの金額にまとまった。", "You instantly agree upon the price."));
1073 msg_print(_("結局この金額にまとまった。", "You eventually agree upon the price."));
1078 msg_print(_("すんなりとこの金額にまとまった。", "You quickly agree upon the price."));
1082 cur_ask = final_ask;
1084 pmt = _("最終提示金額", "Final Offer");
1087 cur_ask *= o_ptr->number;
1088 final_ask *= o_ptr->number;
1090 s32b min_per = ot_ptr->haggle_per;
1091 s32b max_per = min_per * 3;
1092 s32b last_offer = object_value(o_ptr) * o_ptr->number;
1093 last_offer = last_offer * ot_ptr->max_inflate / 100L;
1099 bool cancel = FALSE;
1108 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
1109 put_str(out_val, 1, 0);
1110 cancel = receive_offer(_("提示する価格? ", "What price do you ask? "),
1111 &offer, last_offer, -1, cur_ask, final);
1117 else if (offer < cur_ask)
1122 else if (offer == cur_ask)
1132 if (flag || !loop_flag) break;
1137 s32b x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
1140 if (haggle_insults())
1146 else if (x1 > max_per)
1149 if (x1 < max_per) x1 = max_per;
1152 s32b x2 = rand_range(x1 - 2, x1 + 2);
1153 s32b x3 = ((offer - cur_ask) * x2 / 100L) + 1;
1157 if (cur_ask > final_ask)
1159 cur_ask = final_ask;
1161 pmt = _("最終提示金額", "Final Offer");
1168 /* 追加 $0 で買い取られてしまうのを防止 By FIRST*/
1171 (void)(increase_insults());
1174 else if (offer <= cur_ask)
1184 (void)sprintf(out_val, _("前回の提示価格 $%ld", "Your last bid %ld"), (long)last_offer);
1185 put_str(out_val, 1, 39);
1186 say_comment_3(cur_ask, annoyed);
1189 if (cancel) return TRUE;
1191 updatebargain(*price, final_ask, o_ptr->number);
1197 * @brief 店からの購入処理のメインルーチン /
1198 * Buy an item from a store -RAK-
1199 * @param player_ptr プレーヤーへの参照ポインタ
1202 static void store_purchase(player_type *player_ptr)
1204 if (cur_store_num == STORE_MUSEUM)
1206 msg_print(_("博物館から取り出すことはできません。", "Museum."));
1210 if (st_ptr->stock_num <= 0)
1212 if (cur_store_num == STORE_HOME)
1213 msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
1215 msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
1219 int i = (st_ptr->stock_num - store_top);
1220 if (i > store_bottom) i = store_bottom;
1224 /* ブラックマーケットの時は別のメッセージ */
1225 switch (cur_store_num)
1228 sprintf(out_val, "どのアイテムを取りますか? ");
1231 sprintf(out_val, "どれ? ");
1234 sprintf(out_val, "どの品物が欲しいんだい? ");
1238 if (cur_store_num == STORE_HOME)
1240 sprintf(out_val, "Which item do you want to take? ");
1244 sprintf(out_val, "Which item are you interested in? ");
1249 if (!get_stock(&item, out_val, 0, i - 1)) return;
1251 item = item + store_top;
1253 o_ptr = &st_ptr->stock[item];
1254 ITEM_NUMBER amt = 1;
1258 object_copy(j_ptr, o_ptr);
1261 * If a rod or wand, allocate total maximum timeouts or charges
1262 * between those purchased and left on the shelf.
1264 reduce_charges(j_ptr, o_ptr->number - amt);
1265 j_ptr->number = amt;
1266 if (!inven_carry_okay(j_ptr))
1268 msg_print(_("そんなにアイテムを持てない。", "You cannot carry that many different items."));
1272 PRICE best = price_item(player_ptr, j_ptr, ot_ptr->min_inflate, FALSE);
1273 if (o_ptr->number > 1)
1275 if ((cur_store_num != STORE_HOME) &&
1276 (o_ptr->ident & IDENT_FIXED))
1278 msg_format(_("一つにつき $%ldです。", "That costs %ld gold per item."), (long)(best));
1281 amt = get_quantity(NULL, o_ptr->number);
1282 if (amt <= 0) return;
1286 object_copy(j_ptr, o_ptr);
1289 * If a rod or wand, allocate total maximum timeouts or charges
1290 * between those purchased and left on the shelf.
1292 reduce_charges(j_ptr, o_ptr->number - amt);
1293 j_ptr->number = amt;
1294 if (!inven_carry_okay(j_ptr))
1296 msg_print(_("ザックにそのアイテムを入れる隙間がない。", "You cannot carry that many items."));
1301 COMMAND_CODE item_new;
1303 if (cur_store_num == STORE_HOME)
1305 bool combined_or_reordered;
1306 distribute_charges(o_ptr, j_ptr, amt);
1307 item_new = inven_carry(player_ptr, j_ptr);
1308 GAME_TEXT o_name[MAX_NLEN];
1309 object_desc(player_ptr, o_name, &player_ptr->inventory_list[item_new], 0);
1311 msg_format(_("%s(%c)を取った。", "You have %s (%c)."), o_name, index_to_label(item_new));
1312 handle_stuff(player_ptr);
1314 i = st_ptr->stock_num;
1315 store_item_increase(item, -amt);
1316 store_item_optimize(item);
1317 combined_or_reordered = combine_and_reorder_home(STORE_HOME);
1318 if (i == st_ptr->stock_num)
1320 if (combined_or_reordered) display_store_inventory(player_ptr);
1321 else display_entry(player_ptr, item);
1325 if (st_ptr->stock_num == 0) store_top = 0;
1326 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1327 display_store_inventory(player_ptr);
1329 chg_virtue(player_ptr, V_SACRIFICE, 1);
1335 if (o_ptr->ident & (IDENT_FIXED))
1338 price = (best * j_ptr->number);
1342 GAME_TEXT o_name[MAX_NLEN];
1343 object_desc(player_ptr, o_name, j_ptr, 0);
1344 msg_format(_("%s(%c)を購入する。", "Buying %s (%c)."), o_name, I2A(item));
1346 choice = purchase_haggle(player_ptr, j_ptr, &price);
1347 if (st_ptr->store_open >= current_world_ptr->game_turn) return;
1350 if (choice != 0) return;
1351 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
1352 if (player_ptr->au < price)
1354 msg_print(_("お金が足りません。", "You do not have enough gold."));
1358 say_comment_1(player_ptr);
1359 if (cur_store_num == STORE_BLACK)
1360 chg_virtue(player_ptr, V_JUSTICE, -1);
1361 if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
1362 chg_virtue(player_ptr, V_NATURE, -1);
1366 player_ptr->au -= price;
1367 store_prt_gold(player_ptr);
1368 object_aware(player_ptr, j_ptr);
1369 j_ptr->ident &= ~(IDENT_FIXED);
1370 GAME_TEXT o_name[MAX_NLEN];
1371 object_desc(player_ptr, o_name, j_ptr, 0);
1373 msg_format(_("%sを $%ldで購入しました。", "You bought %s for %ld gold."), o_name, (long)price);
1375 strcpy(record_o_name, o_name);
1376 record_turn = current_world_ptr->game_turn;
1378 if (record_buy) exe_write_diary(player_ptr, DIARY_BUY, 0, o_name);
1379 object_desc(player_ptr, o_name, o_ptr, OD_NAME_ONLY);
1380 if (record_rand_art && o_ptr->art_name)
1381 exe_write_diary(player_ptr, DIARY_ART, 0, o_name);
1383 j_ptr->inscription = 0;
1384 j_ptr->feeling = FEEL_NONE;
1385 j_ptr->ident &= ~(IDENT_STORE);
1386 item_new = inven_carry(player_ptr, j_ptr);
1388 object_desc(player_ptr, o_name, &player_ptr->inventory_list[item_new], 0);
1389 msg_format(_("%s(%c)を手に入れた。", "You have %s (%c)."), o_name, index_to_label(item_new));
1390 autopick_alter_item(player_ptr, item_new, FALSE);
1391 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1393 o_ptr->pval -= j_ptr->pval;
1396 handle_stuff(player_ptr);
1397 i = st_ptr->stock_num;
1398 store_item_increase(item, -amt);
1399 store_item_optimize(item);
1400 if (st_ptr->stock_num == 0)
1402 if (one_in_(STORE_SHUFFLE))
1405 msg_print(_("店主は引退した。", "The shopkeeper retires."));
1406 store_shuffle(player_ptr, cur_store_num);
1409 sprintf(buf, "%s (%s)",
1410 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
1411 put_str(buf, 3, 10);
1412 sprintf(buf, "%s (%ld)",
1413 (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
1418 msg_print(_("店主は新たな在庫を取り出した。", "The shopkeeper brings out some new stock."));
1421 for (i = 0; i < 10; i++)
1423 store_maint(player_ptr, player_ptr->town_num, cur_store_num);
1427 display_store_inventory(player_ptr);
1429 else if (st_ptr->stock_num != i)
1431 if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1432 display_store_inventory(player_ptr);
1436 display_entry(player_ptr, item);
1442 * @brief 店からの売却処理のメインルーチン /
1443 * Sell an item to the store (or home)
1444 * @param owner_ptr プレーヤーへの参照ポインタ
1447 static void store_sell(player_type *owner_ptr)
1450 if (cur_store_num == STORE_HOME)
1451 q = _("どのアイテムを置きますか? ", "Drop which item? ");
1452 else if (cur_store_num == STORE_MUSEUM)
1453 q = _("どのアイテムを寄贈しますか? ", "Give which item? ");
1455 q = _("どのアイテムを売りますか? ", "Sell which item? ");
1457 item_tester_hook = store_will_buy;
1459 /* 我が家でおかしなメッセージが出るオリジナルのバグを修正 */
1461 if (cur_store_num == STORE_HOME)
1463 s = _("置けるアイテムを持っていません。", "You don't have any item to drop.");
1465 else if (cur_store_num == STORE_MUSEUM)
1467 s = _("寄贈できるアイテムを持っていません。", "You don't have any item to give.");
1471 s = _("欲しい物がないですねえ。", "You have nothing that I want.");
1476 o_ptr = choose_object(owner_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1479 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
1481 msg_print(_("ふーむ、どうやらそれは呪われているようだね。", "Hmmm, it seems to be cursed."));
1486 if (o_ptr->number > 1)
1488 amt = get_quantity(NULL, o_ptr->number);
1489 if (amt <= 0) return;
1495 object_copy(q_ptr, o_ptr);
1496 q_ptr->number = amt;
1499 * Hack -- If a rod or wand, allocate total maximum
1500 * timeouts or charges to those being sold. -LM-
1502 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1504 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1507 GAME_TEXT o_name[MAX_NLEN];
1508 object_desc(owner_ptr, o_name, q_ptr, 0);
1510 /* Remove any inscription, feeling for stores */
1511 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
1513 q_ptr->inscription = 0;
1514 q_ptr->feeling = FEEL_NONE;
1517 /* Is there room in the store (or the home?) */
1518 if (!store_check_num(q_ptr))
1520 if (cur_store_num == STORE_HOME)
1521 msg_print(_("我が家にはもう置く場所がない。", "Your home is full."));
1523 else if (cur_store_num == STORE_MUSEUM)
1524 msg_print(_("博物館はもう満杯だ。", "Museum is full."));
1527 msg_print(_("すいませんが、店にはもう置く場所がありません。", "I have not the room in my store to keep it."));
1533 PRICE price, value, dummy;
1534 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
1536 msg_format(_("%s(%c)を売却する。", "Selling %s (%c)."), o_name, index_to_label(item));
1539 choice = sell_haggle(owner_ptr, q_ptr, &price);
1540 if (st_ptr->store_open >= current_world_ptr->game_turn) return;
1544 say_comment_1(owner_ptr);
1546 if (cur_store_num == STORE_BLACK)
1547 chg_virtue(owner_ptr, V_JUSTICE, -1);
1549 if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
1550 chg_virtue(owner_ptr, V_NATURE, 1);
1553 owner_ptr->au += price;
1554 store_prt_gold(owner_ptr);
1555 dummy = object_value(q_ptr) * q_ptr->number;
1557 identify_item(owner_ptr, o_ptr);
1559 object_copy(q_ptr, o_ptr);
1560 q_ptr->number = amt;
1561 q_ptr->ident |= IDENT_STORE;
1564 * Hack -- If a rod or wand, let the shopkeeper know just
1565 * how many charges he really paid for. -LM-
1567 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1569 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1572 value = object_value(q_ptr) * q_ptr->number;
1573 object_desc(owner_ptr, o_name, q_ptr, 0);
1574 msg_format(_("%sを $%ldで売却しました。", "You sold %s for %ld gold."), o_name, (long)price);
1576 if (record_sell) exe_write_diary(owner_ptr, DIARY_SELL, 0, o_name);
1578 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
1580 purchase_analyze(owner_ptr, price, value, dummy);
1584 * Hack -- Allocate charges between those wands or rods sold
1585 * and retained, unless all are being sold. -LM-
1587 distribute_charges(o_ptr, q_ptr, amt);
1589 inven_item_increase(owner_ptr, item, -amt);
1590 inven_item_describe(owner_ptr, item);
1591 if (o_ptr->number > 0)
1592 autopick_alter_item(owner_ptr, item, FALSE);
1594 inven_item_optimize(owner_ptr, item);
1595 handle_stuff(owner_ptr);
1596 int item_pos = store_carry(q_ptr);
1599 store_top = (item_pos / store_bottom) * store_bottom;
1600 display_store_inventory(owner_ptr);
1604 else if (cur_store_num == STORE_MUSEUM)
1606 char o2_name[MAX_NLEN];
1607 object_desc(owner_ptr, o2_name, q_ptr, OD_NAME_ONLY);
1609 if (-1 == store_check_num(q_ptr))
1611 msg_print(_("それと同じ品物は既に博物館にあるようです。", "The Museum already has one of those items."));
1615 msg_print(_("博物館に寄贈したものは取り出すことができません!!", "You cannot take back items which have been donated to the Museum!!"));
1618 if (!get_check(format(_("本当に%sを寄贈しますか?", "Really give %s to the Museum? "), o2_name))) return;
1620 identify_item(owner_ptr, q_ptr);
1621 q_ptr->ident |= IDENT_FULL_KNOWN;
1623 distribute_charges(o_ptr, q_ptr, amt);
1624 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
1627 vary_item(owner_ptr, item, -amt);
1628 handle_stuff(owner_ptr);
1630 int item_pos = home_carry(owner_ptr, q_ptr);
1633 store_top = (item_pos / store_bottom) * store_bottom;
1634 display_store_inventory(owner_ptr);
1639 distribute_charges(o_ptr, q_ptr, amt);
1640 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
1642 vary_item(owner_ptr, item, -amt);
1643 handle_stuff(owner_ptr);
1644 int item_pos = home_carry(owner_ptr, q_ptr);
1647 store_top = (item_pos / store_bottom) * store_bottom;
1648 display_store_inventory(owner_ptr);
1652 if ((choice == 0) && (item >= INVEN_RARM))
1654 calc_android_exp(owner_ptr);
1655 verify_equip_slot(owner_ptr, item);
1661 * @brief 店のアイテムを調べるコマンドのメインルーチン /
1662 * Examine an item in a store -JDL-
1665 static void store_examine(player_type *player_ptr)
1667 if (st_ptr->stock_num <= 0)
1669 if (cur_store_num == STORE_HOME)
1670 msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
1671 else if (cur_store_num == STORE_MUSEUM)
1672 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
1674 msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
1678 int i = (st_ptr->stock_num - store_top);
1679 if (i > store_bottom) i = store_bottom;
1682 sprintf(out_val, _("どれを調べますか?", "Which item do you want to examine? "));
1685 if (!get_stock(&item, out_val, 0, i - 1)) return;
1686 item = item + store_top;
1688 o_ptr = &st_ptr->stock[item];
1689 if (!OBJECT_IS_FULL_KNOWN(o_ptr))
1691 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1695 GAME_TEXT o_name[MAX_NLEN];
1696 object_desc(player_ptr, o_name, o_ptr, 0);
1697 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1699 if (!screen_object(player_ptr, o_ptr, SCROBJ_FORCE_DETAIL))
1700 msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1705 * @brief 博物館のアイテムを除去するコマンドのメインルーチン /
1706 * Remove an item from museum (Originally from TOband)
1707 * @param player_ptr プレーヤーへの参照ポインタ
1710 static void museum_remove_object(player_type *player_ptr)
1712 if (st_ptr->stock_num <= 0)
1714 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
1718 int i = st_ptr->stock_num - store_top;
1719 if (i > store_bottom) i = store_bottom;
1722 sprintf(out_val, _("どのアイテムの展示をやめさせますか?", "Which item do you want to order to remove? "));
1725 if (!get_stock(&item, out_val, 0, i - 1)) return;
1727 item = item + store_top;
1729 o_ptr = &st_ptr->stock[item];
1731 GAME_TEXT o_name[MAX_NLEN];
1732 object_desc(player_ptr, o_name, o_ptr, 0);
1734 msg_print(_("展示をやめさせたアイテムは二度と見ることはできません!", "Once removed from the Museum, an item will be gone forever!"));
1735 if (!get_check(format(_("本当に%sの展示をやめさせますか?", "Really order to remove %s from the Museum? "), o_name))) return;
1737 msg_format(_("%sの展示をやめさせた。", "You ordered to remove %s."), o_name);
1739 store_item_increase(item, -o_ptr->number);
1740 store_item_optimize(item);
1742 (void)combine_and_reorder_home(STORE_MUSEUM);
1743 if (st_ptr->stock_num == 0) store_top = 0;
1745 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1746 display_store_inventory(player_ptr);
1751 * Hack -- set this to leave the store
1753 static bool leave_store = FALSE;
1757 * @brief 店舗処理コマンド選択のメインルーチン /
1758 * Process a command in a store
1759 * @param client_ptr 顧客となるクリーチャーの参照ポインタ
1763 * Note that we must allow the use of a few "special" commands
1764 * in the stores which are not allowed in the dungeon, and we
1765 * must disable some commands which are allowed in the dungeon
1766 * but not in the stores, to prevent chaos.
1769 static void store_process_command(player_type *client_ptr)
1772 if (rogue_like_commands && command_cmd == 'l')
1777 switch (command_cmd)
1787 /* 1 ページ戻るコマンド: 我が家のページ数が多いので重宝するはず By BUG */
1788 if (st_ptr->stock_num <= store_bottom) {
1789 msg_print(_("これで全部です。", "Entire inventory is shown."));
1793 store_top -= store_bottom;
1795 store_top = ((st_ptr->stock_num - 1) / store_bottom) * store_bottom;
1796 if ((cur_store_num == STORE_HOME) && (powerup_home == FALSE))
1797 if (store_top >= store_bottom) store_top = store_bottom;
1798 display_store_inventory(client_ptr);
1805 if (st_ptr->stock_num <= store_bottom)
1807 msg_print(_("これで全部です。", "Entire inventory is shown."));
1811 store_top += store_bottom;
1813 * 隠しオプション(powerup_home)がセットされていないときは
1814 * 我が家では 2 ページまでしか表示しない
1816 if ((cur_store_num == STORE_HOME) &&
1817 (powerup_home == FALSE) &&
1818 (st_ptr->stock_num >= STORE_INVEN_MAX))
1820 if (store_top >= (STORE_INVEN_MAX - 1))
1827 if (store_top >= st_ptr->stock_num) store_top = 0;
1830 display_store_inventory(client_ptr);
1837 do_cmd_redraw(client_ptr);
1838 display_store(client_ptr);
1843 store_purchase(client_ptr);
1848 store_sell(client_ptr);
1853 store_examine(client_ptr);
1862 do_cmd_wield(client_ptr);
1867 do_cmd_takeoff(client_ptr);
1872 do_cmd_destroy(client_ptr);
1877 do_cmd_equip(client_ptr);
1882 do_cmd_inven(client_ptr);
1887 do_cmd_observe(client_ptr);
1892 toggle_inventory_equipment(client_ptr);
1897 if ((client_ptr->pclass == CLASS_MINDCRAFTER) ||
1898 (client_ptr->pclass == CLASS_BERSERKER) ||
1899 (client_ptr->pclass == CLASS_NINJA) ||
1900 (client_ptr->pclass == CLASS_MIRROR_MASTER)
1901 ) do_cmd_mind_browse(client_ptr);
1902 else if (client_ptr->pclass == CLASS_SMITH)
1903 do_cmd_kaji(client_ptr, TRUE);
1904 else if (client_ptr->pclass == CLASS_MAGIC_EATER)
1905 do_cmd_magic_eater(client_ptr, TRUE, FALSE);
1906 else if (client_ptr->pclass == CLASS_SNIPER)
1907 do_cmd_snipe_browse(client_ptr);
1908 else do_cmd_browse(client_ptr);
1913 do_cmd_inscribe(client_ptr);
1918 do_cmd_uninscribe(client_ptr);
1923 do_cmd_help(client_ptr);
1928 do_cmd_query_symbol(client_ptr);
1933 client_ptr->town_num = old_town_num;
1934 do_cmd_player_status(client_ptr);
1935 client_ptr->town_num = inner_town_num;
1936 display_store(client_ptr);
1946 client_ptr->town_num = old_town_num;
1947 do_cmd_pref(client_ptr);
1948 client_ptr->town_num = inner_town_num;
1953 client_ptr->town_num = old_town_num;
1954 do_cmd_macros(client_ptr, process_autopick_file_command);
1955 client_ptr->town_num = inner_town_num;
1960 client_ptr->town_num = old_town_num;
1961 do_cmd_visuals(client_ptr, process_autopick_file_command);
1962 client_ptr->town_num = inner_town_num;
1967 client_ptr->town_num = old_town_num;
1968 do_cmd_colors(client_ptr, process_autopick_file_command);
1969 client_ptr->town_num = inner_town_num;
1975 (void)combine_and_reorder_home(STORE_HOME);
1976 do_cmd_redraw(client_ptr);
1977 display_store(client_ptr);
1992 do_cmd_feeling(client_ptr);
1997 do_cmd_message_one();
2007 do_cmd_diary(client_ptr);
2012 do_cmd_knowledge(client_ptr);
2017 do_cmd_load_screen();
2022 do_cmd_save_screen(client_ptr, handle_stuff, process_autopick_file_command);
2027 if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
2029 museum_remove_object(client_ptr);
2033 msg_print(_("そのコマンドは店の中では使えません。", "That command does not work in stores."));
2043 * @brief 店舗処理全体のメインルーチン /
2044 * Enter a store, and interact with it. *
2045 * @param player_ptr プレーヤーへの参照ポインタ
2049 * Note that we use the standard "request_command()" function
2050 * to get a command, allowing us to use "command_arg" and all
2051 * command macros and other nifty stuff, but we use the special
2052 * "shopping" argument, to force certain commands to be converted
2053 * into other commands, normally, we convert "p" (pray) and "m"
2054 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
2057 void do_cmd_store(player_type *player_ptr)
2059 if (player_ptr->wild_mode) return;
2061 Term_get_size(&w, &h);
2063 xtra_stock = MIN(14 + 26, ((h > 24) ? (h - 24) : 0));
2064 store_bottom = MIN_STOCK + xtra_stock;
2067 g_ptr = &player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x];
2069 if (!cave_have_flag_grid(g_ptr, FF_STORE))
2071 msg_print(_("ここには店がありません。", "You see no store here."));
2075 int which = f_info[g_ptr->feat].subtype;
2076 old_town_num = player_ptr->town_num;
2077 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) player_ptr->town_num = 1;
2078 if (player_ptr->current_floor_ptr->dun_level) player_ptr->town_num = NO_TOWN;
2079 inner_town_num = player_ptr->town_num;
2081 if ((town_info[player_ptr->town_num].store[which].store_open >= current_world_ptr->game_turn) ||
2084 msg_print(_("ドアに鍵がかかっている。", "The doors are locked."));
2085 player_ptr->town_num = old_town_num;
2089 int maintain_num = (current_world_ptr->game_turn - town_info[player_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
2090 if (maintain_num > 10)
2094 for (int i = 0; i < maintain_num; i++)
2095 store_maint(player_ptr, player_ptr->town_num, which);
2097 town_info[player_ptr->town_num].store[which].last_visit = current_world_ptr->game_turn;
2100 forget_lite(player_ptr->current_floor_ptr);
2101 forget_view(player_ptr->current_floor_ptr);
2102 current_world_ptr->character_icky = TRUE;
2106 get_com_no_macros = TRUE;
2107 cur_store_num = which;
2108 cur_store_feat = g_ptr->feat;
2109 st_ptr = &town_info[player_ptr->town_num].store[cur_store_num];
2110 ot_ptr = &owners[cur_store_num][st_ptr->owner];
2112 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
2113 display_store(player_ptr);
2114 leave_store = FALSE;
2116 while (!leave_store)
2119 clear_from(20 + xtra_stock);
2120 prt(_(" ESC) 建物から出る", " ESC) Exit from Building."), 21 + xtra_stock, 0);
2121 if (st_ptr->stock_num > store_bottom)
2123 prt(_(" -)前ページ", " -) Previous page"), 22 + xtra_stock, 0);
2124 prt(_(" スペース) 次ページ", " SPACE) Next page"), 23 + xtra_stock, 0);
2127 if (cur_store_num == STORE_HOME)
2129 prt(_("g) アイテムを取る", "g) Get an item."), 21 + xtra_stock, 27);
2130 prt(_("d) アイテムを置く", "d) Drop an item."), 22 + xtra_stock, 27);
2131 prt(_("x) 家のアイテムを調べる", "x) eXamine an item in the home."), 23 + xtra_stock, 27);
2133 else if (cur_store_num == STORE_MUSEUM)
2135 prt(_("d) アイテムを置く", "d) Drop an item."), 21 + xtra_stock, 27);
2136 prt(_("r) アイテムの展示をやめる", "r) order to Remove an item."), 22 + xtra_stock, 27);
2137 prt(_("x) 博物館のアイテムを調べる", "x) eXamine an item in the museum."), 23 + xtra_stock, 27);
2141 prt(_("p) 商品を買う", "p) Purchase an item."), 21 + xtra_stock, 30);
2142 prt(_("s) アイテムを売る", "s) Sell an item."), 22 + xtra_stock, 30);
2143 prt(_("x) 商品を調べる", "x) eXamine an item in the shop"), 23 + xtra_stock, 30);
2146 prt(_("i/e) 持ち物/装備の一覧", "i/e) Inventry/Equipment list"), 21 + xtra_stock, 56);
2147 if (rogue_like_commands)
2149 prt(_("w/T) 装備する/はずす", "w/T) Wear/Take off equipment"), 22 + xtra_stock, 56);
2153 prt(_("w/t) 装備する/はずす", "w/t) Wear/Take off equipment"), 22 + xtra_stock, 56);
2156 prt(_("コマンド:", "You may: "), 20 + xtra_stock, 0);
2157 request_command(player_ptr, TRUE);
2158 store_process_command(player_ptr);
2161 * Hack -- To redraw missiles damage and prices in store
2162 * If player's charisma changes, or if player changes a bow, PU_BONUS is set
2164 bool need_redraw_store_inv = (player_ptr->update & PU_BONUS) ? TRUE : FALSE;
2165 current_world_ptr->character_icky = TRUE;
2166 handle_stuff(player_ptr);
2167 if (player_ptr->inventory_list[INVEN_PACK].k_idx)
2169 INVENTORY_IDX item = INVEN_PACK;
2170 object_type *o_ptr = &player_ptr->inventory_list[item];
2171 if (cur_store_num != STORE_HOME)
2173 if (cur_store_num == STORE_MUSEUM)
2174 msg_print(_("ザックからアイテムがあふれそうなので、あわてて博物館から出た...", "Your pack is so full that you flee the Museum..."));
2176 msg_print(_("ザックからアイテムがあふれそうなので、あわてて店から出た...", "Your pack is so full that you flee the store..."));
2180 else if (!store_check_num(o_ptr))
2182 msg_print(_("ザックからアイテムがあふれそうなので、あわてて家から出た...", "Your pack is so full that you flee your home..."));
2190 GAME_TEXT o_name[MAX_NLEN];
2191 msg_print(_("ザックからアイテムがあふれてしまった!", "Your pack overflows!"));
2193 object_copy(q_ptr, o_ptr);
2194 object_desc(player_ptr, o_name, q_ptr, 0);
2195 msg_format(_("%sが落ちた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
2196 vary_item(player_ptr, item, -255);
2197 handle_stuff(player_ptr);
2199 item_pos = home_carry(player_ptr, q_ptr);
2202 store_top = (item_pos / store_bottom) * store_bottom;
2203 display_store_inventory(player_ptr);
2208 if (need_redraw_store_inv) display_store_inventory(player_ptr);
2210 if (st_ptr->store_open >= current_world_ptr->game_turn) leave_store = TRUE;
2213 select_floor_music(player_ptr);
2214 player_ptr->town_num = old_town_num;
2215 take_turn(player_ptr, 100);
2216 current_world_ptr->character_icky = FALSE;
2218 command_see = FALSE;
2219 get_com_no_macros = FALSE;
2224 player_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2225 player_ptr->update |= (PU_MONSTERS);
2226 player_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
2227 player_ptr->redraw |= (PR_MAP);
2228 player_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2233 * @brief 現在の町の店主を交代させる /
2234 * Shuffle one of the stores.
2235 * @param which 店舗種類のID
2238 void store_shuffle(player_type *player_ptr, int which)
2240 if (which == STORE_HOME) return;
2241 if (which == STORE_MUSEUM) return;
2243 cur_store_num = which;
2244 st_ptr = &town_info[player_ptr->town_num].store[cur_store_num];
2245 int j = st_ptr->owner;
2248 st_ptr->owner = (byte)randint0(MAX_OWNERS);
2249 if (j == st_ptr->owner) continue;
2251 for (i = 1; i < max_towns; i++)
2253 if (i == player_ptr->town_num) continue;
2254 if (st_ptr->owner == town_info[i].store[cur_store_num].owner) break;
2257 if (i == max_towns) break;
2260 ot_ptr = &owners[cur_store_num][st_ptr->owner];
2261 st_ptr->insult_cur = 0;
2262 st_ptr->store_open = 0;
2263 st_ptr->good_buy = 0;
2264 st_ptr->bad_buy = 0;
2265 for (int i = 0; i < st_ptr->stock_num; i++)
2268 o_ptr = &st_ptr->stock[i];
2269 if (object_is_artifact(o_ptr)) continue;
2271 o_ptr->discount = 50;
2272 o_ptr->ident &= ~(IDENT_FIXED);
2273 o_ptr->inscription = quark_add(_("売出中", "on sale"));
2279 * @brief 店の品揃えを変化させる /
2280 * Maintain the inventory at the stores.
2281 * @param player_ptr プレーヤーへの参照ポインタ
2282 * @param town_num 町のID
2283 * @param store_num 店舗種類のID
2286 void store_maint(player_type *player_ptr, int town_num, int store_num)
2288 cur_store_num = store_num;
2289 if (store_num == STORE_HOME) return;
2290 if (store_num == STORE_MUSEUM) return;
2292 st_ptr = &town_info[town_num].store[store_num];
2293 ot_ptr = &owners[store_num][st_ptr->owner];
2294 st_ptr->insult_cur = 0;
2295 if (store_num == STORE_BLACK)
2297 for (INVENTORY_IDX j = st_ptr->stock_num - 1; j >= 0; j--)
2299 object_type *o_ptr = &st_ptr->stock[j];
2300 if (black_market_crap(player_ptr, o_ptr))
2302 store_item_increase(j, 0 - o_ptr->number);
2303 store_item_optimize(j);
2308 INVENTORY_IDX j = st_ptr->stock_num;
2309 j = j - randint1(STORE_TURNOVER);
2310 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
2311 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
2314 while (st_ptr->stock_num > j)
2317 j = st_ptr->stock_num;
2318 j = j + randint1(STORE_TURNOVER);
2319 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
2320 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
2321 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
2323 while (st_ptr->stock_num < j) store_create(player_ptr, black_market_crap);
2328 * @brief 店舗情報を初期化する /
2329 * Initialize the stores
2330 * @param town_num 町のID
2331 * @param store_num 店舗種類のID
2334 void store_init(int town_num, int store_num)
2336 cur_store_num = store_num;
2337 st_ptr = &town_info[town_num].store[store_num];
2340 st_ptr->owner = (byte)randint0(MAX_OWNERS);
2342 for (i = 1; i < max_towns; i++)
2344 if (i == town_num) continue;
2345 if (st_ptr->owner == town_info[i].store[store_num].owner) break;
2348 if (i == max_towns) break;
2351 ot_ptr = &owners[store_num][st_ptr->owner];
2353 st_ptr->store_open = 0;
2354 st_ptr->insult_cur = 0;
2355 st_ptr->good_buy = 0;
2356 st_ptr->bad_buy = 0;
2357 st_ptr->stock_num = 0;
2358 st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
2359 for (int k = 0; k < st_ptr->stock_size; k++)
2361 object_wipe(&st_ptr->stock[k]);