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"
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-help.h"
33 #include "cmd/cmd-item.h"
34 #include "cmd/cmd-macro.h"
35 #include "cmd/cmd-smith.h"
36 #include "cmd/cmd-visuals.h"
37 #include "cmd/cmd-zapwand.h"
38 #include "cmd/cmd-magiceat.h"
40 #include "market/store.h"
42 #include "cmd-spell.h"
44 #include "player-status.h"
45 #include "player-class.h"
46 #include "player-inventory.h"
47 #include "object-flavor.h"
48 #include "object-hook.h"
49 #include "floor-events.h"
52 #include "player-effects.h"
53 #include "player/race-info-table.h"
56 #include "objectkind.h"
58 #include "floor-town.h"
60 #include "view-mainwindow.h"
65 static int store_top = 0;
66 static int store_bottom = 0;
67 static int xtra_stock = 0;
68 static const owner_type *ot_ptr = NULL;
69 static s16b old_town_num = 0;
70 static s16b inner_town_num = 0;
73 * We store the current "store feat" here so everyone can access it
75 static int cur_store_feat;
78 * @brief 店舗価格を決定する. 無料にはならない /
79 * Determine the price of an item (qty one) in a store.
80 * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
82 * @param flip TRUEならば店主にとっての買取価格、FALSEなら売出価格を計算
86 * This function takes into account the player's charisma, and the
87 * shop-keepers friendliness, and the shop-keeper's base greed, but
88 * never lets a shop-keeper lose money in a transaction.
89 * The "greed" value should exceed 100 when the player is "buying" the
90 * item, and should be less than 100 when the player is "selling" it.
91 * Hack -- the black market always charges twice as much as it should.
92 * Charisma adjustment runs from 80 to 130
93 * Racial adjustment runs from 95 to 130
94 * Since greed/charisma/racial adjustments are centered at 100, we need
95 * to adjust (by 200) to extract a usable multiplier. Note that the
96 * "greed" value is always something (?).
99 static PRICE price_item(player_type *player_ptr, object_type *o_ptr, int greed, bool flip)
101 PRICE price = object_value(o_ptr);
102 if (price <= 0) return (0L);
104 int factor = rgold_adj[ot_ptr->owner_race][player_ptr->prace];
105 factor += adj_chr_gold[player_ptr->stat_ind[A_CHR]];
109 adjust = 100 + (300 - (greed + factor));
110 if (adjust > 100) adjust = 100;
111 if (cur_store_num == STORE_BLACK)
114 price = (price * adjust + 50L) / 100L;
118 adjust = 100 + ((greed + factor) - 300);
119 if (adjust < 100) adjust = 100;
120 if (cur_store_num == STORE_BLACK)
123 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
126 if (price <= 0L) return (1L);
132 * @brief 店舗に品を置くスペースがあるかどうかの判定を返す /
133 * Check to see if the shop will be carrying too many objects -RAK-
134 * @param o_ptr 店舗に置きたいオブジェクト構造体の参照ポインタ
135 * @return 置き場がないなら0、重ね合わせできるアイテムがあるなら-1、スペースがあるなら1を返す。
138 * Note that the shop, just like a player, will not accept things
139 * it cannot hold. Before, one could "nuke" potions this way.
140 * Return value is now int:
142 * -1 : Can be combined to existing slot.
143 * 1 : Cannot be combined but there are empty spaces.
146 static int store_check_num(object_type *o_ptr)
149 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
151 bool old_stack_force_notes = stack_force_notes;
152 bool old_stack_force_costs = stack_force_costs;
154 if (cur_store_num != STORE_HOME)
156 stack_force_notes = FALSE;
157 stack_force_costs = FALSE;
160 for (int i = 0; i < st_ptr->stock_num; i++)
162 j_ptr = &st_ptr->stock[i];
163 if (object_similar(j_ptr, o_ptr))
165 if (cur_store_num != STORE_HOME)
167 stack_force_notes = old_stack_force_notes;
168 stack_force_costs = old_stack_force_costs;
175 if (cur_store_num != STORE_HOME)
177 stack_force_notes = old_stack_force_notes;
178 stack_force_costs = old_stack_force_costs;
183 for (int i = 0; i < st_ptr->stock_num; i++)
185 j_ptr = &st_ptr->stock[i];
186 if (store_object_similar(j_ptr, o_ptr)) return -1;
190 /* Free space is always usable */
192 * オプション powerup_home が設定されていると
195 if ((cur_store_num == STORE_HOME) && (powerup_home == FALSE))
197 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10))
204 if (st_ptr->stock_num < st_ptr->stock_size)
215 * @brief 現在の町の指定された店舗のアイテムを整理する /
216 * Combine and reorder items in store.
217 * @param store_num 店舗ID
218 * @return 実際に整理が行われたならばTRUEを返す。
220 bool combine_and_reorder_home(int store_num)
222 store_type *old_st_ptr = st_ptr;
223 st_ptr = &town_info[1].store[store_num];
225 if (store_num != STORE_HOME)
227 stack_force_notes = FALSE;
228 stack_force_costs = FALSE;
231 bool combined = TRUE;
235 for (int i = st_ptr->stock_num - 1; i > 0; i--)
238 o_ptr = &st_ptr->stock[i];
239 if (!o_ptr->k_idx) continue;
240 for (int j = 0; j < i; j++)
243 j_ptr = &st_ptr->stock[j];
244 if (!j_ptr->k_idx) continue;
247 * Get maximum number of the stack if these
248 * are similar, get zero otherwise.
250 int max_num = object_similar_part(j_ptr, o_ptr);
251 if (max_num == 0 || j_ptr->number >= max_num) continue;
253 if (o_ptr->number + j_ptr->number <= max_num)
255 object_absorb(j_ptr, o_ptr);
258 for (k = i; k < st_ptr->stock_num; k++)
260 st_ptr->stock[k] = st_ptr->stock[k + 1];
263 object_wipe(&st_ptr->stock[k]);
268 ITEM_NUMBER old_num = o_ptr->number;
269 ITEM_NUMBER remain = j_ptr->number + o_ptr->number - max_num;
270 object_absorb(j_ptr, o_ptr);
271 o_ptr->number = remain;
272 if (o_ptr->tval == TV_ROD)
274 o_ptr->pval = o_ptr->pval * remain / old_num;
275 o_ptr->timeout = o_ptr->timeout * remain / old_num;
277 else if (o_ptr->tval == TV_WAND)
279 o_ptr->pval = o_ptr->pval * remain / old_num;
290 for (int i = 0; i < st_ptr->stock_num; i++)
293 o_ptr = &st_ptr->stock[i];
294 if (!o_ptr->k_idx) continue;
296 s32b o_value = object_value(o_ptr);
298 for (j = 0; j < st_ptr->stock_num; j++)
300 if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
303 if (j >= i) continue;
309 object_copy(j_ptr, &st_ptr->stock[i]);
310 for (int k = i; k > j; k--)
312 object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
315 object_copy(&st_ptr->stock[j], j_ptr);
319 bool old_stack_force_notes = stack_force_notes;
320 bool old_stack_force_costs = stack_force_costs;
321 if (store_num != STORE_HOME)
323 stack_force_notes = old_stack_force_notes;
324 stack_force_costs = old_stack_force_costs;
332 * @brief 我が家にオブジェクトを加える /
333 * Add the item "o_ptr" to the inventory of the "Home"
334 * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
338 * In all cases, return the slot (or -1) where the object was placed
339 * Note that this is a hacked up version of "inven_carry()".
340 * Also note that it may not correctly "adapt" to "knowledge" bacoming
341 * known, the player may have to pick stuff up and drop it again.
344 static int home_carry(player_type *player_ptr, object_type *o_ptr)
346 if (cur_store_num != STORE_HOME)
348 stack_force_notes = FALSE;
349 stack_force_costs = FALSE;
352 bool old_stack_force_notes = stack_force_notes;
353 bool old_stack_force_costs = stack_force_costs;
354 for (int slot = 0; slot < st_ptr->stock_num; slot++)
357 j_ptr = &st_ptr->stock[slot];
358 if (object_similar(j_ptr, o_ptr))
360 object_absorb(j_ptr, o_ptr);
361 if (cur_store_num != STORE_HOME)
363 stack_force_notes = old_stack_force_notes;
364 stack_force_costs = old_stack_force_costs;
371 if (cur_store_num != STORE_HOME)
373 stack_force_notes = old_stack_force_notes;
374 stack_force_costs = old_stack_force_costs;
379 * 隠し機能: オプション powerup_home が設定されていると
382 if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE))
384 if (st_ptr->stock_num >= st_ptr->stock_size)
391 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10))
397 PRICE value = object_value(o_ptr);
399 for (slot = 0; slot < st_ptr->stock_num; slot++)
401 if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
404 for (int i = st_ptr->stock_num; i > slot; i--)
406 st_ptr->stock[i] = st_ptr->stock[i - 1];
410 st_ptr->stock[slot] = *o_ptr;
411 chg_virtue(player_ptr, V_SACRIFICE, -1);
412 (void)combine_and_reorder_home(cur_store_num);
418 * @brief 店舗の割引対象外にするかどうかを判定 /
419 * Eliminate need to bargain if player has haggled well in the past
420 * @param minprice アイテムの最低販売価格
421 * @return 割引を禁止するならTRUEを返す。
423 static bool noneedtobargain(PRICE minprice)
425 PRICE good = st_ptr->good_buy;
426 PRICE bad = st_ptr->bad_buy;
427 if (minprice < 10L) return TRUE;
428 if (good == MAX_SHORT) return TRUE;
429 if (good > ((3 * bad) + (5 + (minprice / 50)))) return TRUE;
436 * @brief 店主の持つプレイヤーに対する売買の良し悪し経験を記憶する /
437 * Update the bargain info
438 * @param price 実際の取引価格
439 * @param minprice 店主の提示した価格
443 static void updatebargain(PRICE price, PRICE minprice, int num)
445 if (!manual_haggle) return;
446 if ((minprice / num) < 10L) return;
447 if (price == minprice)
449 if (st_ptr->good_buy < MAX_SHORT)
456 if (st_ptr->bad_buy < MAX_SHORT)
465 * @brief 店の商品リストを再表示する /
466 * Re-displays a single store entry
467 * @param player_ptr プレーヤーへの参照ポインタ
471 static void display_entry(player_type *player_ptr, int pos)
474 o_ptr = &st_ptr->stock[pos];
475 int i = (pos % store_bottom);
477 /* Label it, clear the line --(-- */
479 (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
480 prt(out_val, i + 6, 0);
485 TERM_COLOR a = object_attr(o_ptr);
486 SYMBOL_CODE c = object_char(o_ptr);
488 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
489 if (use_bigtile) cur_col++;
494 /* Describe an item in the home */
496 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
499 if (show_weights) maxwid -= 10;
501 GAME_TEXT o_name[MAX_NLEN];
502 object_desc(player_ptr, o_name, o_ptr, 0);
503 o_name[maxwid] = '\0';
504 c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col);
507 WEIGHT wgt = o_ptr->weight;
508 sprintf(out_val, _("%3d.%1d kg", "%3d.%d lb"), _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
509 put_str(out_val, i + 6, _(67, 68));
516 if (show_weights) maxwid -= 7;
518 GAME_TEXT o_name[MAX_NLEN];
519 object_desc(player_ptr, o_name, o_ptr, 0);
520 o_name[maxwid] = '\0';
521 c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col);
525 int wgt = o_ptr->weight;
526 sprintf(out_val, "%3d.%1d", _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
527 put_str(out_val, i + 6, _(60, 61));
531 if (o_ptr->ident & (IDENT_FIXED))
533 x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
534 (void)sprintf(out_val, _("%9ld固", "%9ld F"), (long)x);
535 put_str(out_val, i + 6, 68);
541 x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
542 if (!noneedtobargain(x)) x += x / 10;
544 (void)sprintf(out_val, "%9ld ", (long)x);
545 put_str(out_val, i + 6, 68);
549 x = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
550 (void)sprintf(out_val, "%9ld ", (long)x);
551 put_str(out_val, i + 6, 68);
556 * @brief 店の商品リストを表示する /
557 * Displays a store's inventory -RAK-
558 * @param player_ptr プレーヤーへの参照ポインタ
561 * All prices are listed as "per individual object". -BEN-
563 static void display_store_inventory(player_type *player_ptr)
566 for (k = 0; k < store_bottom; k++)
568 if (store_top + k >= st_ptr->stock_num) break;
570 display_entry(player_ptr, store_top + k);
573 for (int i = k; i < store_bottom + 1; i++)
576 put_str(_(" ", " "), 5, _(20, 22));
577 if (st_ptr->stock_num > store_bottom)
579 prt(_("-続く-", "-more-"), k + 6, 3);
580 put_str(format(_("(%dページ) ", "(Page %d) "), store_top / store_bottom + 1), 5, _(20, 22));
583 if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM)
585 k = st_ptr->stock_size;
586 if (cur_store_num == STORE_HOME && !powerup_home) k /= 10;
588 put_str(format(_("アイテム数: %4d/%4d", "Objects: %4d/%4d"), st_ptr->stock_num, k), 19 + xtra_stock, _(27, 30));
594 * @brief プレイヤーの所持金を表示する /
595 * Displays players gold -RAK-
596 * @param player_ptr プレーヤーへの参照ポインタ
600 static void store_prt_gold(player_type *player_ptr)
602 prt(_("手持ちのお金: ", "Gold Remaining: "), 19 + xtra_stock, 53);
604 sprintf(out_val, "%9ld", (long)player_ptr->au);
605 prt(out_val, 19 + xtra_stock, 68);
610 * @brief 店舗情報全体を表示するメインルーチン /
611 * Displays store (after clearing screen) -RAK-
612 * @param player_ptr プレーヤーへの参照ポインタ
616 static void display_store(player_type *player_ptr)
619 if (cur_store_num == STORE_HOME)
621 put_str(_("我が家", "Your Home"), 3, 31);
622 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
625 put_str(_(" 重さ", "Weight"), 5, 70);
628 store_prt_gold(player_ptr);
629 display_store_inventory(player_ptr);
633 if (cur_store_num == STORE_MUSEUM)
635 put_str(_("博物館", "Museum"), 3, 31);
636 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
639 put_str(_(" 重さ", "Weight"), 5, 70);
642 store_prt_gold(player_ptr);
643 display_store_inventory(player_ptr);
647 concptr store_name = (f_name + f_info[cur_store_feat].name);
648 concptr owner_name = (ot_ptr->owner_name);
649 concptr race_name = race_info[ot_ptr->owner_race].title;
651 sprintf(buf, "%s (%s)", owner_name, race_name);
654 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
657 put_str(_("商品の一覧", "Item Description"), 5, 5);
660 put_str(_(" 重さ", "Weight"), 5, 60);
663 put_str(_(" 価格", "Price"), 5, 72);
664 store_prt_gold(player_ptr);
665 display_store_inventory(player_ptr);
670 * @brief 店舗からアイテムを選択する /
671 * Get the ID of a store item and return its value -RAK-
672 * @param com_val 選択IDを返す参照ポインタ
673 * @param pmt メッセージキャプション
676 * @return 実際に選択したらTRUE、キャンセルしたらFALSE
678 static int get_stock(COMMAND_CODE *com_val, concptr pmt, int i, int j)
680 if (repeat_pull(com_val) && (*com_val >= i) && (*com_val <= j))
688 char hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
691 (void)sprintf(out_val, "(%s:%c-%c, ESCで中断) %s",
692 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "アイテム" : "商品"),
695 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
702 if (!get_com(out_val, &command, FALSE)) break;
705 if (islower(command))
707 else if (isupper(command))
708 k = A2I(tolower(command)) + 26;
712 if ((k >= i) && (k <= j))
722 if (command == ESCAPE) return FALSE;
724 repeat_push(*com_val);
730 * @brief 店主の不満度を増やし、プレイヤーを締め出す判定と処理を行う /
731 * Increase the insult counter and get angry if too many -RAK-
732 * @return プレイヤーを締め出す場合TRUEを返す
734 static int increase_insults(void)
736 st_ptr->insult_cur++;
737 if (st_ptr->insult_cur <= ot_ptr->insult_max) return FALSE;
741 st_ptr->insult_cur = 0;
742 st_ptr->good_buy = 0;
744 st_ptr->store_open = current_world_ptr->game_turn + TURNS_PER_TICK * TOWN_DAWN / 8 + randint1(TURNS_PER_TICK*TOWN_DAWN / 8);
751 * @brief 店主の不満度を減らす /
752 * Decrease insults -RAK-
753 * @return プレイヤーを締め出す場合TRUEを返す
755 static void decrease_insults(void)
757 if (st_ptr->insult_cur) st_ptr->insult_cur--;
762 * @brief 店主の不満度が増えた場合のみのメッセージを表示する /
763 * Have insulted while haggling -RAK-
764 * @return プレイヤーを締め出す場合TRUEを返す
766 static int haggle_insults(void)
768 if (increase_insults()) return TRUE;
775 * Mega-Hack -- Enable "increments"
777 static bool allow_inc = FALSE;
780 * Mega-Hack -- Last "increment" during haggling
782 static s32b last_inc = 0L;
785 * @brief 交渉価格を確認と認証の是非を行う /
788 * @param poffer 別途価格提示をした場合の値を返す参照ポインタ
789 * @param price 現在の交渉価格
790 * @param final 最終確定価格ならばTRUE
791 * @return プレイヤーを締め出す場合TRUEを返す
793 static int get_haggle(concptr pmt, s32b *poffer, PRICE price, int final)
796 if (!allow_inc) last_inc = 0L;
800 sprintf(buf, _("%s [承諾] ", "%s [accept] "), pmt);
802 else if (last_inc < 0)
804 sprintf(buf, _("%s [-$%ld] ", "%s [-%ld] "), pmt, (long)(ABS(last_inc)));
806 else if (last_inc > 0)
808 sprintf(buf, _("%s [+$%ld] ", "%s [+%ld] "), pmt, (long)(ABS(last_inc)));
812 sprintf(buf, "%s ", pmt);
816 GAME_TEXT out_val[160];
824 * Ask the user for a response.
825 * Don't allow to use numpad as cursor key.
827 res = askfor_aux(out_val, 32, FALSE);
829 if (!res) return FALSE;
832 for (p = out_val; *p == ' '; p++) /* loop */;
843 if (allow_inc && last_inc)
849 msg_print(_("値がおかしいです。", "Invalid response."));
854 if ((*p == '+' || *p == '-'))
876 * @brief 店主がプレイヤーからの交渉価格を判断する /
877 * Receive an offer (from the player)
879 * @param poffer 店主からの交渉価格を返す参照ポインタ
880 * @param last_offer 現在の交渉価格
881 * @param factor 店主の価格基準倍率
882 * @param price アイテムの実価値
883 * @param final 最終価格確定ならばTRUE
884 * @return プレイヤーの価格に対して不服ならばTRUEを返す /
885 * Return TRUE if offer is NOT okay
887 static bool receive_offer(concptr pmt, s32b *poffer, s32b last_offer, int factor, PRICE price, int final)
891 if (!get_haggle(pmt, poffer, price, final)) return TRUE;
892 if (((*poffer) * factor) >= (last_offer * factor)) break;
893 if (haggle_insults()) return TRUE;
895 (*poffer) = last_offer;
903 * @brief プレイヤーが購入する時の値切り処理メインルーチン /
904 * Haggling routine -RAK-
905 * @param player_ptr プレーヤーへの参照ポインタ
906 * @param o_ptr オブジェクトの構造体参照ポインタ
907 * @param price 最終価格を返す参照ポインタ
908 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
909 * Return TRUE if purchase is NOT successful
911 static bool purchase_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price)
913 s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
914 s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
915 int noneed = noneedtobargain(final_ask);
917 concptr pmt = _("提示価格", "Asking");
918 if (noneed || !manual_haggle)
922 msg_print(_("結局この金額にまとまった。", "You eventually agree upon the price."));
927 msg_print(_("すんなりとこの金額にまとまった。", "You quickly agree upon the price."));
929 final_ask += final_ask / 10;
933 pmt = _("最終提示価格", "Final Offer");
937 cur_ask *= o_ptr->number;
938 final_ask *= o_ptr->number;
939 s32b min_per = ot_ptr->haggle_per;
940 s32b max_per = min_per * 3;
941 s32b last_offer = object_value(o_ptr) * o_ptr->number;
942 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
943 if (last_offer <= 0) last_offer = 1;
953 bool loop_flag = TRUE;
955 while (!flag && loop_flag)
958 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
959 put_str(out_val, 1, 0);
960 cancel = receive_offer(_("提示する金額? ", "What do you offer? "), &offer, last_offer, 1, cur_ask, final);
965 else if (offer > cur_ask)
970 else if (offer == cur_ask)
983 s32b x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
986 if (haggle_insults())
992 else if (x1 > max_per)
995 if (x1 < max_per) x1 = max_per;
998 s32b x2 = rand_range(x1 - 2, x1 + 2);
999 s32b x3 = ((cur_ask - offer) * x2 / 100L) + 1;
1003 if (cur_ask < final_ask)
1006 cur_ask = final_ask;
1007 pmt = _("最終提示価格", "What do you offer? ");
1011 (void)(increase_insults());
1016 else if (offer >= cur_ask)
1026 (void)sprintf(out_val, _("前回の提示金額: $%ld", "Your last offer: %ld"), (long)last_offer);
1027 put_str(out_val, 1, 39);
1028 say_comment_2(cur_ask, annoyed);
1031 if (cancel) return TRUE;
1033 updatebargain(*price, final_ask, o_ptr->number);
1039 * @brief プレイヤーが売却する時の値切り処理メインルーチン /
1040 * Haggling routine -RAK-
1041 * @param player_ptr プレーヤーへの参照ポインタ
1042 * @param o_ptr オブジェクトの構造体参照ポインタ
1043 * @param price 最終価格を返す参照ポインタ
1044 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
1045 * Return TRUE if purchase is NOT successful
1047 static bool sell_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price)
1049 s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, TRUE);
1050 s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, TRUE);
1051 int noneed = noneedtobargain(final_ask);
1052 s32b purse = (s32b)(ot_ptr->max_cost);
1054 concptr pmt = _("提示金額", "Offer");
1055 if (noneed || !manual_haggle || (final_ask >= purse))
1057 if (!manual_haggle && !noneed)
1059 final_ask -= final_ask / 10;
1062 if (final_ask >= purse)
1064 msg_print(_("即座にこの金額にまとまった。", "You instantly agree upon the price."));
1070 msg_print(_("結局この金額にまとまった。", "You eventually agree upon the price."));
1075 msg_print(_("すんなりとこの金額にまとまった。", "You quickly agree upon the price."));
1079 cur_ask = final_ask;
1081 pmt = _("最終提示金額", "Final Offer");
1084 cur_ask *= o_ptr->number;
1085 final_ask *= o_ptr->number;
1087 s32b min_per = ot_ptr->haggle_per;
1088 s32b max_per = min_per * 3;
1089 s32b last_offer = object_value(o_ptr) * o_ptr->number;
1090 last_offer = last_offer * ot_ptr->max_inflate / 100L;
1096 bool cancel = FALSE;
1105 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
1106 put_str(out_val, 1, 0);
1107 cancel = receive_offer(_("提示する価格? ", "What price do you ask? "),
1108 &offer, last_offer, -1, cur_ask, final);
1114 else if (offer < cur_ask)
1119 else if (offer == cur_ask)
1129 if (flag || !loop_flag) break;
1134 s32b x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
1137 if (haggle_insults())
1143 else if (x1 > max_per)
1146 if (x1 < max_per) x1 = max_per;
1149 s32b x2 = rand_range(x1 - 2, x1 + 2);
1150 s32b x3 = ((offer - cur_ask) * x2 / 100L) + 1;
1154 if (cur_ask > final_ask)
1156 cur_ask = final_ask;
1158 pmt = _("最終提示金額", "Final Offer");
1165 /* 追加 $0 で買い取られてしまうのを防止 By FIRST*/
1168 (void)(increase_insults());
1171 else if (offer <= cur_ask)
1181 (void)sprintf(out_val, _("前回の提示価格 $%ld", "Your last bid %ld"), (long)last_offer);
1182 put_str(out_val, 1, 39);
1183 say_comment_3(cur_ask, annoyed);
1186 if (cancel) return TRUE;
1188 updatebargain(*price, final_ask, o_ptr->number);
1194 * @brief 店からの購入処理のメインルーチン /
1195 * Buy an item from a store -RAK-
1196 * @param player_ptr プレーヤーへの参照ポインタ
1199 static void store_purchase(player_type *player_ptr)
1201 if (cur_store_num == STORE_MUSEUM)
1203 msg_print(_("博物館から取り出すことはできません。", "Museum."));
1207 if (st_ptr->stock_num <= 0)
1209 if (cur_store_num == STORE_HOME)
1210 msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
1212 msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
1216 int i = (st_ptr->stock_num - store_top);
1217 if (i > store_bottom) i = store_bottom;
1221 /* ブラックマーケットの時は別のメッセージ */
1222 switch (cur_store_num)
1225 sprintf(out_val, "どのアイテムを取りますか? ");
1228 sprintf(out_val, "どれ? ");
1231 sprintf(out_val, "どの品物が欲しいんだい? ");
1235 if (cur_store_num == STORE_HOME)
1237 sprintf(out_val, "Which item do you want to take? ");
1241 sprintf(out_val, "Which item are you interested in? ");
1246 if (!get_stock(&item, out_val, 0, i - 1)) return;
1248 item = item + store_top;
1250 o_ptr = &st_ptr->stock[item];
1251 ITEM_NUMBER amt = 1;
1255 object_copy(j_ptr, o_ptr);
1258 * If a rod or wand, allocate total maximum timeouts or charges
1259 * between those purchased and left on the shelf.
1261 reduce_charges(j_ptr, o_ptr->number - amt);
1262 j_ptr->number = amt;
1263 if (!inven_carry_okay(j_ptr))
1265 msg_print(_("そんなにアイテムを持てない。", "You cannot carry that many different items."));
1269 PRICE best = price_item(player_ptr, j_ptr, ot_ptr->min_inflate, FALSE);
1270 if (o_ptr->number > 1)
1272 if ((cur_store_num != STORE_HOME) &&
1273 (o_ptr->ident & IDENT_FIXED))
1275 msg_format(_("一つにつき $%ldです。", "That costs %ld gold per item."), (long)(best));
1278 amt = get_quantity(NULL, o_ptr->number);
1279 if (amt <= 0) return;
1283 object_copy(j_ptr, o_ptr);
1286 * If a rod or wand, allocate total maximum timeouts or charges
1287 * between those purchased and left on the shelf.
1289 reduce_charges(j_ptr, o_ptr->number - amt);
1290 j_ptr->number = amt;
1291 if (!inven_carry_okay(j_ptr))
1293 msg_print(_("ザックにそのアイテムを入れる隙間がない。", "You cannot carry that many items."));
1298 COMMAND_CODE item_new;
1300 if (cur_store_num == STORE_HOME)
1302 bool combined_or_reordered;
1303 distribute_charges(o_ptr, j_ptr, amt);
1304 item_new = inven_carry(player_ptr, j_ptr);
1305 GAME_TEXT o_name[MAX_NLEN];
1306 object_desc(player_ptr, o_name, &player_ptr->inventory_list[item_new], 0);
1308 msg_format(_("%s(%c)を取った。", "You have %s (%c)."), o_name, index_to_label(item_new));
1309 handle_stuff(player_ptr);
1311 i = st_ptr->stock_num;
1312 store_item_increase(item, -amt);
1313 store_item_optimize(item);
1314 combined_or_reordered = combine_and_reorder_home(STORE_HOME);
1315 if (i == st_ptr->stock_num)
1317 if (combined_or_reordered) display_store_inventory(player_ptr);
1318 else display_entry(player_ptr, item);
1322 if (st_ptr->stock_num == 0) store_top = 0;
1323 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1324 display_store_inventory(player_ptr);
1326 chg_virtue(player_ptr, V_SACRIFICE, 1);
1332 if (o_ptr->ident & (IDENT_FIXED))
1335 price = (best * j_ptr->number);
1339 GAME_TEXT o_name[MAX_NLEN];
1340 object_desc(player_ptr, o_name, j_ptr, 0);
1341 msg_format(_("%s(%c)を購入する。", "Buying %s (%c)."), o_name, I2A(item));
1343 choice = purchase_haggle(player_ptr, j_ptr, &price);
1344 if (st_ptr->store_open >= current_world_ptr->game_turn) return;
1347 if (choice != 0) return;
1348 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
1349 if (player_ptr->au < price)
1351 msg_print(_("お金が足りません。", "You do not have enough gold."));
1355 say_comment_1(player_ptr);
1356 if (cur_store_num == STORE_BLACK)
1357 chg_virtue(player_ptr, V_JUSTICE, -1);
1358 if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
1359 chg_virtue(player_ptr, V_NATURE, -1);
1363 player_ptr->au -= price;
1364 store_prt_gold(player_ptr);
1365 object_aware(player_ptr, j_ptr);
1366 j_ptr->ident &= ~(IDENT_FIXED);
1367 GAME_TEXT o_name[MAX_NLEN];
1368 object_desc(player_ptr, o_name, j_ptr, 0);
1370 msg_format(_("%sを $%ldで購入しました。", "You bought %s for %ld gold."), o_name, (long)price);
1372 strcpy(record_o_name, o_name);
1373 record_turn = current_world_ptr->game_turn;
1375 if (record_buy) exe_write_diary(player_ptr, DIARY_BUY, 0, o_name);
1376 object_desc(player_ptr, o_name, o_ptr, OD_NAME_ONLY);
1377 if (record_rand_art && o_ptr->art_name)
1378 exe_write_diary(player_ptr, DIARY_ART, 0, o_name);
1380 j_ptr->inscription = 0;
1381 j_ptr->feeling = FEEL_NONE;
1382 j_ptr->ident &= ~(IDENT_STORE);
1383 item_new = inven_carry(player_ptr, j_ptr);
1385 object_desc(player_ptr, o_name, &player_ptr->inventory_list[item_new], 0);
1386 msg_format(_("%s(%c)を手に入れた。", "You have %s (%c)."), o_name, index_to_label(item_new));
1387 autopick_alter_item(player_ptr, item_new, FALSE);
1388 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1390 o_ptr->pval -= j_ptr->pval;
1393 handle_stuff(player_ptr);
1394 i = st_ptr->stock_num;
1395 store_item_increase(item, -amt);
1396 store_item_optimize(item);
1397 if (st_ptr->stock_num == 0)
1399 if (one_in_(STORE_SHUFFLE))
1402 msg_print(_("店主は引退した。", "The shopkeeper retires."));
1403 store_shuffle(player_ptr, cur_store_num);
1406 sprintf(buf, "%s (%s)",
1407 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
1408 put_str(buf, 3, 10);
1409 sprintf(buf, "%s (%ld)",
1410 (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
1415 msg_print(_("店主は新たな在庫を取り出した。", "The shopkeeper brings out some new stock."));
1418 for (i = 0; i < 10; i++)
1420 store_maint(player_ptr, player_ptr->town_num, cur_store_num);
1424 display_store_inventory(player_ptr);
1426 else if (st_ptr->stock_num != i)
1428 if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1429 display_store_inventory(player_ptr);
1433 display_entry(player_ptr, item);
1439 * @brief 店からの売却処理のメインルーチン /
1440 * Sell an item to the store (or home)
1441 * @param owner_ptr プレーヤーへの参照ポインタ
1444 static void store_sell(player_type *owner_ptr)
1447 if (cur_store_num == STORE_HOME)
1448 q = _("どのアイテムを置きますか? ", "Drop which item? ");
1449 else if (cur_store_num == STORE_MUSEUM)
1450 q = _("どのアイテムを寄贈しますか? ", "Give which item? ");
1452 q = _("どのアイテムを売りますか? ", "Sell which item? ");
1454 item_tester_hook = store_will_buy;
1456 /* 我が家でおかしなメッセージが出るオリジナルのバグを修正 */
1458 if (cur_store_num == STORE_HOME)
1460 s = _("置けるアイテムを持っていません。", "You don't have any item to drop.");
1462 else if (cur_store_num == STORE_MUSEUM)
1464 s = _("寄贈できるアイテムを持っていません。", "You don't have any item to give.");
1468 s = _("欲しい物がないですねえ。", "You have nothing that I want.");
1473 o_ptr = choose_object(owner_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1476 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
1478 msg_print(_("ふーむ、どうやらそれは呪われているようだね。", "Hmmm, it seems to be cursed."));
1483 if (o_ptr->number > 1)
1485 amt = get_quantity(NULL, o_ptr->number);
1486 if (amt <= 0) return;
1492 object_copy(q_ptr, o_ptr);
1493 q_ptr->number = amt;
1496 * Hack -- If a rod or wand, allocate total maximum
1497 * timeouts or charges to those being sold. -LM-
1499 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1501 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1504 GAME_TEXT o_name[MAX_NLEN];
1505 object_desc(owner_ptr, o_name, q_ptr, 0);
1507 /* Remove any inscription, feeling for stores */
1508 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
1510 q_ptr->inscription = 0;
1511 q_ptr->feeling = FEEL_NONE;
1514 /* Is there room in the store (or the home?) */
1515 if (!store_check_num(q_ptr))
1517 if (cur_store_num == STORE_HOME)
1518 msg_print(_("我が家にはもう置く場所がない。", "Your home is full."));
1520 else if (cur_store_num == STORE_MUSEUM)
1521 msg_print(_("博物館はもう満杯だ。", "Museum is full."));
1524 msg_print(_("すいませんが、店にはもう置く場所がありません。", "I have not the room in my store to keep it."));
1530 PRICE price, value, dummy;
1531 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
1533 msg_format(_("%s(%c)を売却する。", "Selling %s (%c)."), o_name, index_to_label(item));
1536 choice = sell_haggle(owner_ptr, q_ptr, &price);
1537 if (st_ptr->store_open >= current_world_ptr->game_turn) return;
1541 say_comment_1(owner_ptr);
1543 if (cur_store_num == STORE_BLACK)
1544 chg_virtue(owner_ptr, V_JUSTICE, -1);
1546 if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
1547 chg_virtue(owner_ptr, V_NATURE, 1);
1550 owner_ptr->au += price;
1551 store_prt_gold(owner_ptr);
1552 dummy = object_value(q_ptr) * q_ptr->number;
1554 identify_item(owner_ptr, o_ptr);
1556 object_copy(q_ptr, o_ptr);
1557 q_ptr->number = amt;
1558 q_ptr->ident |= IDENT_STORE;
1561 * Hack -- If a rod or wand, let the shopkeeper know just
1562 * how many charges he really paid for. -LM-
1564 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1566 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1569 value = object_value(q_ptr) * q_ptr->number;
1570 object_desc(owner_ptr, o_name, q_ptr, 0);
1571 msg_format(_("%sを $%ldで売却しました。", "You sold %s for %ld gold."), o_name, (long)price);
1573 if (record_sell) exe_write_diary(owner_ptr, DIARY_SELL, 0, o_name);
1575 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
1577 purchase_analyze(owner_ptr, price, value, dummy);
1581 * Hack -- Allocate charges between those wands or rods sold
1582 * and retained, unless all are being sold. -LM-
1584 distribute_charges(o_ptr, q_ptr, amt);
1586 inven_item_increase(owner_ptr, item, -amt);
1587 inven_item_describe(owner_ptr, item);
1588 if (o_ptr->number > 0)
1589 autopick_alter_item(owner_ptr, item, FALSE);
1591 inven_item_optimize(owner_ptr, item);
1592 handle_stuff(owner_ptr);
1593 int item_pos = store_carry(q_ptr);
1596 store_top = (item_pos / store_bottom) * store_bottom;
1597 display_store_inventory(owner_ptr);
1601 else if (cur_store_num == STORE_MUSEUM)
1603 char o2_name[MAX_NLEN];
1604 object_desc(owner_ptr, o2_name, q_ptr, OD_NAME_ONLY);
1606 if (-1 == store_check_num(q_ptr))
1608 msg_print(_("それと同じ品物は既に博物館にあるようです。", "The Museum already has one of those items."));
1612 msg_print(_("博物館に寄贈したものは取り出すことができません!!", "You cannot take back items which have been donated to the Museum!!"));
1615 if (!get_check(format(_("本当に%sを寄贈しますか?", "Really give %s to the Museum? "), o2_name))) return;
1617 identify_item(owner_ptr, q_ptr);
1618 q_ptr->ident |= IDENT_FULL_KNOWN;
1620 distribute_charges(o_ptr, q_ptr, amt);
1621 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
1624 vary_item(owner_ptr, item, -amt);
1625 handle_stuff(owner_ptr);
1627 int item_pos = home_carry(owner_ptr, q_ptr);
1630 store_top = (item_pos / store_bottom) * store_bottom;
1631 display_store_inventory(owner_ptr);
1636 distribute_charges(o_ptr, q_ptr, amt);
1637 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
1639 vary_item(owner_ptr, item, -amt);
1640 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);
1649 if ((choice == 0) && (item >= INVEN_RARM))
1651 calc_android_exp(owner_ptr);
1652 verify_equip_slot(owner_ptr, item);
1658 * @brief 店のアイテムを調べるコマンドのメインルーチン /
1659 * Examine an item in a store -JDL-
1662 static void store_examine(player_type *player_ptr)
1664 if (st_ptr->stock_num <= 0)
1666 if (cur_store_num == STORE_HOME)
1667 msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
1668 else if (cur_store_num == STORE_MUSEUM)
1669 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
1671 msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
1675 int i = (st_ptr->stock_num - store_top);
1676 if (i > store_bottom) i = store_bottom;
1679 sprintf(out_val, _("どれを調べますか?", "Which item do you want to examine? "));
1682 if (!get_stock(&item, out_val, 0, i - 1)) return;
1683 item = item + store_top;
1685 o_ptr = &st_ptr->stock[item];
1686 if (!OBJECT_IS_FULL_KNOWN(o_ptr))
1688 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1692 GAME_TEXT o_name[MAX_NLEN];
1693 object_desc(player_ptr, o_name, o_ptr, 0);
1694 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1696 if (!screen_object(player_ptr, o_ptr, SCROBJ_FORCE_DETAIL))
1697 msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1702 * @brief 博物館のアイテムを除去するコマンドのメインルーチン /
1703 * Remove an item from museum (Originally from TOband)
1704 * @param player_ptr プレーヤーへの参照ポインタ
1707 static void museum_remove_object(player_type *player_ptr)
1709 if (st_ptr->stock_num <= 0)
1711 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
1715 int i = st_ptr->stock_num - store_top;
1716 if (i > store_bottom) i = store_bottom;
1719 sprintf(out_val, _("どのアイテムの展示をやめさせますか?", "Which item do you want to order to remove? "));
1722 if (!get_stock(&item, out_val, 0, i - 1)) return;
1724 item = item + store_top;
1726 o_ptr = &st_ptr->stock[item];
1728 GAME_TEXT o_name[MAX_NLEN];
1729 object_desc(player_ptr, o_name, o_ptr, 0);
1731 msg_print(_("展示をやめさせたアイテムは二度と見ることはできません!", "Once removed from the Museum, an item will be gone forever!"));
1732 if (!get_check(format(_("本当に%sの展示をやめさせますか?", "Really order to remove %s from the Museum? "), o_name))) return;
1734 msg_format(_("%sの展示をやめさせた。", "You ordered to remove %s."), o_name);
1736 store_item_increase(item, -o_ptr->number);
1737 store_item_optimize(item);
1739 (void)combine_and_reorder_home(STORE_MUSEUM);
1740 if (st_ptr->stock_num == 0) store_top = 0;
1742 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1743 display_store_inventory(player_ptr);
1748 * Hack -- set this to leave the store
1750 static bool leave_store = FALSE;
1754 * @brief 店舗処理コマンド選択のメインルーチン /
1755 * Process a command in a store
1756 * @param client_ptr 顧客となるクリーチャーの参照ポインタ
1760 * Note that we must allow the use of a few "special" commands
1761 * in the stores which are not allowed in the dungeon, and we
1762 * must disable some commands which are allowed in the dungeon
1763 * but not in the stores, to prevent chaos.
1766 static void store_process_command(player_type *client_ptr)
1769 if (rogue_like_commands && command_cmd == 'l')
1774 switch (command_cmd)
1784 /* 1 ページ戻るコマンド: 我が家のページ数が多いので重宝するはず By BUG */
1785 if (st_ptr->stock_num <= store_bottom) {
1786 msg_print(_("これで全部です。", "Entire inventory is shown."));
1790 store_top -= store_bottom;
1792 store_top = ((st_ptr->stock_num - 1) / store_bottom) * store_bottom;
1793 if ((cur_store_num == STORE_HOME) && (powerup_home == FALSE))
1794 if (store_top >= store_bottom) store_top = store_bottom;
1795 display_store_inventory(client_ptr);
1802 if (st_ptr->stock_num <= store_bottom)
1804 msg_print(_("これで全部です。", "Entire inventory is shown."));
1808 store_top += store_bottom;
1810 * 隠しオプション(powerup_home)がセットされていないときは
1811 * 我が家では 2 ページまでしか表示しない
1813 if ((cur_store_num == STORE_HOME) &&
1814 (powerup_home == FALSE) &&
1815 (st_ptr->stock_num >= STORE_INVEN_MAX))
1817 if (store_top >= (STORE_INVEN_MAX - 1))
1824 if (store_top >= st_ptr->stock_num) store_top = 0;
1827 display_store_inventory(client_ptr);
1834 do_cmd_redraw(client_ptr);
1835 display_store(client_ptr);
1840 store_purchase(client_ptr);
1845 store_sell(client_ptr);
1850 store_examine(client_ptr);
1859 do_cmd_wield(client_ptr);
1864 do_cmd_takeoff(client_ptr);
1869 do_cmd_destroy(client_ptr);
1874 do_cmd_equip(client_ptr);
1879 do_cmd_inven(client_ptr);
1884 do_cmd_observe(client_ptr);
1889 toggle_inventory_equipment(client_ptr);
1894 if ((client_ptr->pclass == CLASS_MINDCRAFTER) ||
1895 (client_ptr->pclass == CLASS_BERSERKER) ||
1896 (client_ptr->pclass == CLASS_NINJA) ||
1897 (client_ptr->pclass == CLASS_MIRROR_MASTER)
1898 ) do_cmd_mind_browse(client_ptr);
1899 else if (client_ptr->pclass == CLASS_SMITH)
1900 do_cmd_kaji(client_ptr, TRUE);
1901 else if (client_ptr->pclass == CLASS_MAGIC_EATER)
1902 do_cmd_magic_eater(client_ptr, TRUE, FALSE);
1903 else if (client_ptr->pclass == CLASS_SNIPER)
1904 do_cmd_snipe_browse(client_ptr);
1905 else do_cmd_browse(client_ptr);
1910 do_cmd_inscribe(client_ptr);
1915 do_cmd_uninscribe(client_ptr);
1920 do_cmd_help(client_ptr);
1925 do_cmd_query_symbol(client_ptr);
1930 client_ptr->town_num = old_town_num;
1931 do_cmd_player_status(client_ptr);
1932 client_ptr->town_num = inner_town_num;
1933 display_store(client_ptr);
1943 client_ptr->town_num = old_town_num;
1944 do_cmd_pref(client_ptr);
1945 client_ptr->town_num = inner_town_num;
1950 client_ptr->town_num = old_town_num;
1951 do_cmd_macros(client_ptr);
1952 client_ptr->town_num = inner_town_num;
1957 client_ptr->town_num = old_town_num;
1958 do_cmd_visuals(client_ptr);
1959 client_ptr->town_num = inner_town_num;
1964 client_ptr->town_num = old_town_num;
1965 do_cmd_colors(client_ptr);
1966 client_ptr->town_num = inner_town_num;
1972 (void)combine_and_reorder_home(STORE_HOME);
1973 do_cmd_redraw(client_ptr);
1974 display_store(client_ptr);
1989 do_cmd_feeling(client_ptr);
1994 do_cmd_message_one();
2004 do_cmd_diary(client_ptr);
2009 do_cmd_knowledge(client_ptr);
2014 do_cmd_load_screen();
2019 do_cmd_save_screen(client_ptr);
2024 if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
2026 museum_remove_object(client_ptr);
2030 msg_print(_("そのコマンドは店の中では使えません。", "That command does not work in stores."));
2040 * @brief 店舗処理全体のメインルーチン /
2041 * Enter a store, and interact with it. *
2042 * @param player_ptr プレーヤーへの参照ポインタ
2046 * Note that we use the standard "request_command()" function
2047 * to get a command, allowing us to use "command_arg" and all
2048 * command macros and other nifty stuff, but we use the special
2049 * "shopping" argument, to force certain commands to be converted
2050 * into other commands, normally, we convert "p" (pray) and "m"
2051 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
2054 void do_cmd_store(player_type *player_ptr)
2056 if (player_ptr->wild_mode) return;
2058 Term_get_size(&w, &h);
2060 xtra_stock = MIN(14 + 26, ((h > 24) ? (h - 24) : 0));
2061 store_bottom = MIN_STOCK + xtra_stock;
2064 g_ptr = &player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x];
2066 if (!cave_have_flag_grid(g_ptr, FF_STORE))
2068 msg_print(_("ここには店がありません。", "You see no store here."));
2072 int which = f_info[g_ptr->feat].subtype;
2073 old_town_num = player_ptr->town_num;
2074 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) player_ptr->town_num = 1;
2075 if (player_ptr->current_floor_ptr->dun_level) player_ptr->town_num = NO_TOWN;
2076 inner_town_num = player_ptr->town_num;
2078 if ((town_info[player_ptr->town_num].store[which].store_open >= current_world_ptr->game_turn) ||
2081 msg_print(_("ドアに鍵がかかっている。", "The doors are locked."));
2082 player_ptr->town_num = old_town_num;
2086 int maintain_num = (current_world_ptr->game_turn - town_info[player_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
2087 if (maintain_num > 10)
2091 for (int i = 0; i < maintain_num; i++)
2092 store_maint(player_ptr, player_ptr->town_num, which);
2094 town_info[player_ptr->town_num].store[which].last_visit = current_world_ptr->game_turn;
2097 forget_lite(player_ptr->current_floor_ptr);
2098 forget_view(player_ptr->current_floor_ptr);
2099 current_world_ptr->character_icky = TRUE;
2103 get_com_no_macros = TRUE;
2104 cur_store_num = which;
2105 cur_store_feat = g_ptr->feat;
2106 st_ptr = &town_info[player_ptr->town_num].store[cur_store_num];
2107 ot_ptr = &owners[cur_store_num][st_ptr->owner];
2109 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
2110 display_store(player_ptr);
2111 leave_store = FALSE;
2113 while (!leave_store)
2116 clear_from(20 + xtra_stock);
2117 prt(_(" ESC) 建物から出る", " ESC) Exit from Building."), 21 + xtra_stock, 0);
2118 if (st_ptr->stock_num > store_bottom)
2120 prt(_(" -)前ページ", " -) Previous page"), 22 + xtra_stock, 0);
2121 prt(_(" スペース) 次ページ", " SPACE) Next page"), 23 + xtra_stock, 0);
2124 if (cur_store_num == STORE_HOME)
2126 prt(_("g) アイテムを取る", "g) Get an item."), 21 + xtra_stock, 27);
2127 prt(_("d) アイテムを置く", "d) Drop an item."), 22 + xtra_stock, 27);
2128 prt(_("x) 家のアイテムを調べる", "x) eXamine an item in the home."), 23 + xtra_stock, 27);
2130 else if (cur_store_num == STORE_MUSEUM)
2132 prt(_("d) アイテムを置く", "d) Drop an item."), 21 + xtra_stock, 27);
2133 prt(_("r) アイテムの展示をやめる", "r) order to Remove an item."), 22 + xtra_stock, 27);
2134 prt(_("x) 博物館のアイテムを調べる", "x) eXamine an item in the museum."), 23 + xtra_stock, 27);
2138 prt(_("p) 商品を買う", "p) Purchase an item."), 21 + xtra_stock, 30);
2139 prt(_("s) アイテムを売る", "s) Sell an item."), 22 + xtra_stock, 30);
2140 prt(_("x) 商品を調べる", "x) eXamine an item in the shop"), 23 + xtra_stock, 30);
2143 prt(_("i/e) 持ち物/装備の一覧", "i/e) Inventry/Equipment list"), 21 + xtra_stock, 56);
2144 if (rogue_like_commands)
2146 prt(_("w/T) 装備する/はずす", "w/T) Wear/Take off equipment"), 22 + xtra_stock, 56);
2150 prt(_("w/t) 装備する/はずす", "w/t) Wear/Take off equipment"), 22 + xtra_stock, 56);
2153 prt(_("コマンド:", "You may: "), 20 + xtra_stock, 0);
2154 request_command(player_ptr, TRUE);
2155 store_process_command(player_ptr);
2158 * Hack -- To redraw missiles damage and prices in store
2159 * If player's charisma changes, or if player changes a bow, PU_BONUS is set
2161 bool need_redraw_store_inv = (player_ptr->update & PU_BONUS) ? TRUE : FALSE;
2162 current_world_ptr->character_icky = TRUE;
2163 handle_stuff(player_ptr);
2164 if (player_ptr->inventory_list[INVEN_PACK].k_idx)
2166 INVENTORY_IDX item = INVEN_PACK;
2167 object_type *o_ptr = &player_ptr->inventory_list[item];
2168 if (cur_store_num != STORE_HOME)
2170 if (cur_store_num == STORE_MUSEUM)
2171 msg_print(_("ザックからアイテムがあふれそうなので、あわてて博物館から出た...", "Your pack is so full that you flee the Museum..."));
2173 msg_print(_("ザックからアイテムがあふれそうなので、あわてて店から出た...", "Your pack is so full that you flee the store..."));
2177 else if (!store_check_num(o_ptr))
2179 msg_print(_("ザックからアイテムがあふれそうなので、あわてて家から出た...", "Your pack is so full that you flee your home..."));
2187 GAME_TEXT o_name[MAX_NLEN];
2188 msg_print(_("ザックからアイテムがあふれてしまった!", "Your pack overflows!"));
2190 object_copy(q_ptr, o_ptr);
2191 object_desc(player_ptr, o_name, q_ptr, 0);
2192 msg_format(_("%sが落ちた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
2193 vary_item(player_ptr, item, -255);
2194 handle_stuff(player_ptr);
2196 item_pos = home_carry(player_ptr, q_ptr);
2199 store_top = (item_pos / store_bottom) * store_bottom;
2200 display_store_inventory(player_ptr);
2205 if (need_redraw_store_inv) display_store_inventory(player_ptr);
2207 if (st_ptr->store_open >= current_world_ptr->game_turn) leave_store = TRUE;
2210 select_floor_music(player_ptr);
2211 player_ptr->town_num = old_town_num;
2212 take_turn(player_ptr, 100);
2213 current_world_ptr->character_icky = FALSE;
2215 command_see = FALSE;
2216 get_com_no_macros = FALSE;
2221 player_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2222 player_ptr->update |= (PU_MONSTERS);
2223 player_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
2224 player_ptr->redraw |= (PR_MAP);
2225 player_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2230 * @brief 現在の町の店主を交代させる /
2231 * Shuffle one of the stores.
2232 * @param which 店舗種類のID
2235 void store_shuffle(player_type *player_ptr, int which)
2237 if (which == STORE_HOME) return;
2238 if (which == STORE_MUSEUM) return;
2240 cur_store_num = which;
2241 st_ptr = &town_info[player_ptr->town_num].store[cur_store_num];
2242 int j = st_ptr->owner;
2245 st_ptr->owner = (byte)randint0(MAX_OWNERS);
2246 if (j == st_ptr->owner) continue;
2248 for (i = 1; i < max_towns; i++)
2250 if (i == player_ptr->town_num) continue;
2251 if (st_ptr->owner == town_info[i].store[cur_store_num].owner) break;
2254 if (i == max_towns) break;
2257 ot_ptr = &owners[cur_store_num][st_ptr->owner];
2258 st_ptr->insult_cur = 0;
2259 st_ptr->store_open = 0;
2260 st_ptr->good_buy = 0;
2261 st_ptr->bad_buy = 0;
2262 for (int i = 0; i < st_ptr->stock_num; i++)
2265 o_ptr = &st_ptr->stock[i];
2266 if (object_is_artifact(o_ptr)) continue;
2268 o_ptr->discount = 50;
2269 o_ptr->ident &= ~(IDENT_FIXED);
2270 o_ptr->inscription = quark_add(_("売出中", "on sale"));
2276 * @brief 店の品揃えを変化させる /
2277 * Maintain the inventory at the stores.
2278 * @param player_ptr プレーヤーへの参照ポインタ
2279 * @param town_num 町のID
2280 * @param store_num 店舗種類のID
2283 void store_maint(player_type *player_ptr, int town_num, int store_num)
2285 cur_store_num = store_num;
2286 if (store_num == STORE_HOME) return;
2287 if (store_num == STORE_MUSEUM) return;
2289 st_ptr = &town_info[town_num].store[store_num];
2290 ot_ptr = &owners[store_num][st_ptr->owner];
2291 st_ptr->insult_cur = 0;
2292 if (store_num == STORE_BLACK)
2294 for (INVENTORY_IDX j = st_ptr->stock_num - 1; j >= 0; j--)
2296 object_type *o_ptr = &st_ptr->stock[j];
2297 if (black_market_crap(player_ptr, o_ptr))
2299 store_item_increase(j, 0 - o_ptr->number);
2300 store_item_optimize(j);
2305 INVENTORY_IDX j = st_ptr->stock_num;
2306 j = j - randint1(STORE_TURNOVER);
2307 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
2308 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
2311 while (st_ptr->stock_num > j)
2314 j = st_ptr->stock_num;
2315 j = j + randint1(STORE_TURNOVER);
2316 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
2317 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
2318 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
2320 while (st_ptr->stock_num < j) store_create(player_ptr, black_market_crap);
2325 * @brief 店舗情報を初期化する /
2326 * Initialize the stores
2327 * @param town_num 町のID
2328 * @param store_num 店舗種類のID
2331 void store_init(int town_num, int store_num)
2333 cur_store_num = store_num;
2334 st_ptr = &town_info[town_num].store[store_num];
2337 st_ptr->owner = (byte)randint0(MAX_OWNERS);
2339 for (i = 1; i < max_towns; i++)
2341 if (i == town_num) continue;
2342 if (st_ptr->owner == town_info[i].store[store_num].owner) break;
2345 if (i == max_towns) break;
2348 ot_ptr = &owners[store_num][st_ptr->owner];
2350 st_ptr->store_open = 0;
2351 st_ptr->insult_cur = 0;
2352 st_ptr->good_buy = 0;
2353 st_ptr->bad_buy = 0;
2354 st_ptr->stock_num = 0;
2355 st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
2356 for (int k = 0; k < st_ptr->stock_size; k++)
2358 object_wipe(&st_ptr->stock[k]);