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-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"
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 "floor-town.h"
62 #include "view-mainwindow.h"
67 static int store_top = 0;
68 static int store_bottom = 0;
69 static int xtra_stock = 0;
70 static const owner_type *ot_ptr = NULL;
71 static s16b old_town_num = 0;
72 static s16b inner_town_num = 0;
75 * We store the current "store feat" here so everyone can access it
77 static int cur_store_feat;
80 * @brief 店舗価格を決定する. 無料にはならない /
81 * Determine the price of an item (qty one) in a store.
82 * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
84 * @param flip TRUEならば店主にとっての買取価格、FALSEなら売出価格を計算
88 * This function takes into account the player's charisma, and the
89 * shop-keepers friendliness, and the shop-keeper's base greed, but
90 * never lets a shop-keeper lose money in a transaction.
91 * The "greed" value should exceed 100 when the player is "buying" the
92 * item, and should be less than 100 when the player is "selling" it.
93 * Hack -- the black market always charges twice as much as it should.
94 * Charisma adjustment runs from 80 to 130
95 * Racial adjustment runs from 95 to 130
96 * Since greed/charisma/racial adjustments are centered at 100, we need
97 * to adjust (by 200) to extract a usable multiplier. Note that the
98 * "greed" value is always something (?).
101 static PRICE price_item(player_type *player_ptr, object_type *o_ptr, int greed, bool flip)
103 PRICE price = object_value(o_ptr);
104 if (price <= 0) return (0L);
106 int factor = rgold_adj[ot_ptr->owner_race][player_ptr->prace];
107 factor += adj_chr_gold[player_ptr->stat_ind[A_CHR]];
111 adjust = 100 + (300 - (greed + factor));
112 if (adjust > 100) adjust = 100;
113 if (cur_store_num == STORE_BLACK)
116 price = (price * adjust + 50L) / 100L;
120 adjust = 100 + ((greed + factor) - 300);
121 if (adjust < 100) adjust = 100;
122 if (cur_store_num == STORE_BLACK)
125 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
128 if (price <= 0L) return (1L);
134 * @brief 店舗に品を置くスペースがあるかどうかの判定を返す /
135 * Check to see if the shop will be carrying too many objects -RAK-
136 * @param o_ptr 店舗に置きたいオブジェクト構造体の参照ポインタ
137 * @return 置き場がないなら0、重ね合わせできるアイテムがあるなら-1、スペースがあるなら1を返す。
140 * Note that the shop, just like a player, will not accept things
141 * it cannot hold. Before, one could "nuke" potions this way.
142 * Return value is now int:
144 * -1 : Can be combined to existing slot.
145 * 1 : Cannot be combined but there are empty spaces.
148 static int store_check_num(object_type *o_ptr)
151 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
153 bool old_stack_force_notes = stack_force_notes;
154 bool old_stack_force_costs = stack_force_costs;
156 if (cur_store_num != STORE_HOME)
158 stack_force_notes = FALSE;
159 stack_force_costs = FALSE;
162 for (int i = 0; i < st_ptr->stock_num; i++)
164 j_ptr = &st_ptr->stock[i];
165 if (object_similar(j_ptr, o_ptr))
167 if (cur_store_num != STORE_HOME)
169 stack_force_notes = old_stack_force_notes;
170 stack_force_costs = old_stack_force_costs;
177 if (cur_store_num != STORE_HOME)
179 stack_force_notes = old_stack_force_notes;
180 stack_force_costs = old_stack_force_costs;
185 for (int i = 0; i < st_ptr->stock_num; i++)
187 j_ptr = &st_ptr->stock[i];
188 if (store_object_similar(j_ptr, o_ptr)) return -1;
192 /* Free space is always usable */
194 * オプション powerup_home が設定されていると
197 if ((cur_store_num == STORE_HOME) && (powerup_home == FALSE))
199 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10))
206 if (st_ptr->stock_num < st_ptr->stock_size)
217 * @brief 現在の町の指定された店舗のアイテムを整理する /
218 * Combine and reorder items in store.
219 * @param store_num 店舗ID
220 * @return 実際に整理が行われたならばTRUEを返す。
222 bool combine_and_reorder_home(int store_num)
224 store_type *old_st_ptr = st_ptr;
225 st_ptr = &town_info[1].store[store_num];
227 if (store_num != STORE_HOME)
229 stack_force_notes = FALSE;
230 stack_force_costs = FALSE;
233 bool combined = TRUE;
237 for (int i = st_ptr->stock_num - 1; i > 0; i--)
240 o_ptr = &st_ptr->stock[i];
241 if (!o_ptr->k_idx) continue;
242 for (int j = 0; j < i; j++)
245 j_ptr = &st_ptr->stock[j];
246 if (!j_ptr->k_idx) continue;
249 * Get maximum number of the stack if these
250 * are similar, get zero otherwise.
252 int max_num = object_similar_part(j_ptr, o_ptr);
253 if (max_num == 0 || j_ptr->number >= max_num) continue;
255 if (o_ptr->number + j_ptr->number <= max_num)
257 object_absorb(j_ptr, o_ptr);
260 for (k = i; k < st_ptr->stock_num; k++)
262 st_ptr->stock[k] = st_ptr->stock[k + 1];
265 object_wipe(&st_ptr->stock[k]);
270 ITEM_NUMBER old_num = o_ptr->number;
271 ITEM_NUMBER remain = j_ptr->number + o_ptr->number - max_num;
272 object_absorb(j_ptr, o_ptr);
273 o_ptr->number = remain;
274 if (o_ptr->tval == TV_ROD)
276 o_ptr->pval = o_ptr->pval * remain / old_num;
277 o_ptr->timeout = o_ptr->timeout * remain / old_num;
279 else if (o_ptr->tval == TV_WAND)
281 o_ptr->pval = o_ptr->pval * remain / old_num;
292 for (int i = 0; i < st_ptr->stock_num; i++)
295 o_ptr = &st_ptr->stock[i];
296 if (!o_ptr->k_idx) continue;
298 s32b o_value = object_value(o_ptr);
300 for (j = 0; j < st_ptr->stock_num; j++)
302 if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
305 if (j >= i) continue;
311 object_copy(j_ptr, &st_ptr->stock[i]);
312 for (int k = i; k > j; k--)
314 object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
317 object_copy(&st_ptr->stock[j], j_ptr);
321 bool old_stack_force_notes = stack_force_notes;
322 bool old_stack_force_costs = stack_force_costs;
323 if (store_num != STORE_HOME)
325 stack_force_notes = old_stack_force_notes;
326 stack_force_costs = old_stack_force_costs;
334 * @brief 我が家にオブジェクトを加える /
335 * Add the item "o_ptr" to the inventory of the "Home"
336 * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
340 * In all cases, return the slot (or -1) where the object was placed
341 * Note that this is a hacked up version of "inven_carry()".
342 * Also note that it may not correctly "adapt" to "knowledge" bacoming
343 * known, the player may have to pick stuff up and drop it again.
346 static int home_carry(player_type *player_ptr, object_type *o_ptr)
348 if (cur_store_num != STORE_HOME)
350 stack_force_notes = FALSE;
351 stack_force_costs = FALSE;
354 bool old_stack_force_notes = stack_force_notes;
355 bool old_stack_force_costs = stack_force_costs;
356 for (int slot = 0; slot < st_ptr->stock_num; slot++)
359 j_ptr = &st_ptr->stock[slot];
360 if (object_similar(j_ptr, o_ptr))
362 object_absorb(j_ptr, o_ptr);
363 if (cur_store_num != STORE_HOME)
365 stack_force_notes = old_stack_force_notes;
366 stack_force_costs = old_stack_force_costs;
373 if (cur_store_num != STORE_HOME)
375 stack_force_notes = old_stack_force_notes;
376 stack_force_costs = old_stack_force_costs;
381 * 隠し機能: オプション powerup_home が設定されていると
384 if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE))
386 if (st_ptr->stock_num >= st_ptr->stock_size)
393 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10))
399 PRICE value = object_value(o_ptr);
401 for (slot = 0; slot < st_ptr->stock_num; slot++)
403 if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
406 for (int i = st_ptr->stock_num; i > slot; i--)
408 st_ptr->stock[i] = st_ptr->stock[i - 1];
412 st_ptr->stock[slot] = *o_ptr;
413 chg_virtue(player_ptr, V_SACRIFICE, -1);
414 (void)combine_and_reorder_home(cur_store_num);
420 * @brief 店舗の割引対象外にするかどうかを判定 /
421 * Eliminate need to bargain if player has haggled well in the past
422 * @param minprice アイテムの最低販売価格
423 * @return 割引を禁止するならTRUEを返す。
425 static bool noneedtobargain(PRICE minprice)
427 PRICE good = st_ptr->good_buy;
428 PRICE bad = st_ptr->bad_buy;
429 if (minprice < 10L) return TRUE;
430 if (good == MAX_SHORT) return TRUE;
431 if (good > ((3 * bad) + (5 + (minprice / 50)))) return TRUE;
438 * @brief 店主の持つプレイヤーに対する売買の良し悪し経験を記憶する /
439 * Update the bargain info
440 * @param price 実際の取引価格
441 * @param minprice 店主の提示した価格
445 static void updatebargain(PRICE price, PRICE minprice, int num)
447 if (!manual_haggle) return;
448 if ((minprice / num) < 10L) return;
449 if (price == minprice)
451 if (st_ptr->good_buy < MAX_SHORT)
458 if (st_ptr->bad_buy < MAX_SHORT)
467 * @brief 店の商品リストを再表示する /
468 * Re-displays a single store entry
469 * @param player_ptr プレーヤーへの参照ポインタ
473 static void display_entry(player_type *player_ptr, int pos)
476 o_ptr = &st_ptr->stock[pos];
477 int i = (pos % store_bottom);
479 /* Label it, clear the line --(-- */
481 (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
482 prt(out_val, i + 6, 0);
487 TERM_COLOR a = object_attr(o_ptr);
488 SYMBOL_CODE c = object_char(o_ptr);
490 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
491 if (use_bigtile) cur_col++;
496 /* Describe an item in the home */
498 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
501 if (show_weights) maxwid -= 10;
503 GAME_TEXT o_name[MAX_NLEN];
504 object_desc(player_ptr, o_name, o_ptr, 0);
505 o_name[maxwid] = '\0';
506 c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col);
509 WEIGHT wgt = o_ptr->weight;
510 sprintf(out_val, _("%3d.%1d kg", "%3d.%d lb"), _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
511 put_str(out_val, i + 6, _(67, 68));
518 if (show_weights) maxwid -= 7;
520 GAME_TEXT o_name[MAX_NLEN];
521 object_desc(player_ptr, o_name, o_ptr, 0);
522 o_name[maxwid] = '\0';
523 c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col);
527 int wgt = o_ptr->weight;
528 sprintf(out_val, "%3d.%1d", _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
529 put_str(out_val, i + 6, _(60, 61));
533 if (o_ptr->ident & (IDENT_FIXED))
535 x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
536 (void)sprintf(out_val, _("%9ld固", "%9ld F"), (long)x);
537 put_str(out_val, i + 6, 68);
543 x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
544 if (!noneedtobargain(x)) x += x / 10;
546 (void)sprintf(out_val, "%9ld ", (long)x);
547 put_str(out_val, i + 6, 68);
551 x = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
552 (void)sprintf(out_val, "%9ld ", (long)x);
553 put_str(out_val, i + 6, 68);
558 * @brief 店の商品リストを表示する /
559 * Displays a store's inventory -RAK-
560 * @param player_ptr プレーヤーへの参照ポインタ
563 * All prices are listed as "per individual object". -BEN-
565 static void display_store_inventory(player_type *player_ptr)
568 for (k = 0; k < store_bottom; k++)
570 if (store_top + k >= st_ptr->stock_num) break;
572 display_entry(player_ptr, store_top + k);
575 for (int i = k; i < store_bottom + 1; i++)
578 put_str(_(" ", " "), 5, _(20, 22));
579 if (st_ptr->stock_num > store_bottom)
581 prt(_("-続く-", "-more-"), k + 6, 3);
582 put_str(format(_("(%dページ) ", "(Page %d) "), store_top / store_bottom + 1), 5, _(20, 22));
585 if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM)
587 k = st_ptr->stock_size;
588 if (cur_store_num == STORE_HOME && !powerup_home) k /= 10;
590 put_str(format(_("アイテム数: %4d/%4d", "Objects: %4d/%4d"), st_ptr->stock_num, k), 19 + xtra_stock, _(27, 30));
596 * @brief プレイヤーの所持金を表示する /
597 * Displays players gold -RAK-
598 * @param player_ptr プレーヤーへの参照ポインタ
602 static void store_prt_gold(player_type *player_ptr)
604 prt(_("手持ちのお金: ", "Gold Remaining: "), 19 + xtra_stock, 53);
606 sprintf(out_val, "%9ld", (long)player_ptr->au);
607 prt(out_val, 19 + xtra_stock, 68);
612 * @brief 店舗情報全体を表示するメインルーチン /
613 * Displays store (after clearing screen) -RAK-
614 * @param player_ptr プレーヤーへの参照ポインタ
618 static void display_store(player_type *player_ptr)
621 if (cur_store_num == STORE_HOME)
623 put_str(_("我が家", "Your Home"), 3, 31);
624 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
627 put_str(_(" 重さ", "Weight"), 5, 70);
630 store_prt_gold(player_ptr);
631 display_store_inventory(player_ptr);
635 if (cur_store_num == STORE_MUSEUM)
637 put_str(_("博物館", "Museum"), 3, 31);
638 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
641 put_str(_(" 重さ", "Weight"), 5, 70);
644 store_prt_gold(player_ptr);
645 display_store_inventory(player_ptr);
649 concptr store_name = (f_name + f_info[cur_store_feat].name);
650 concptr owner_name = (ot_ptr->owner_name);
651 concptr race_name = race_info[ot_ptr->owner_race].title;
653 sprintf(buf, "%s (%s)", owner_name, race_name);
656 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
659 put_str(_("商品の一覧", "Item Description"), 5, 5);
662 put_str(_(" 重さ", "Weight"), 5, 60);
665 put_str(_(" 価格", "Price"), 5, 72);
666 store_prt_gold(player_ptr);
667 display_store_inventory(player_ptr);
672 * @brief 店舗からアイテムを選択する /
673 * Get the ID of a store item and return its value -RAK-
674 * @param com_val 選択IDを返す参照ポインタ
675 * @param pmt メッセージキャプション
678 * @return 実際に選択したらTRUE、キャンセルしたらFALSE
680 static int get_stock(COMMAND_CODE *com_val, concptr pmt, int i, int j)
682 if (repeat_pull(com_val) && (*com_val >= i) && (*com_val <= j))
690 char hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
693 (void)sprintf(out_val, "(%s:%c-%c, ESCで中断) %s",
694 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "アイテム" : "商品"),
697 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
704 if (!get_com(out_val, &command, FALSE)) break;
707 if (islower(command))
709 else if (isupper(command))
710 k = A2I(tolower(command)) + 26;
714 if ((k >= i) && (k <= j))
724 if (command == ESCAPE) return FALSE;
726 repeat_push(*com_val);
732 * @brief 店主の不満度を増やし、プレイヤーを締め出す判定と処理を行う /
733 * Increase the insult counter and get angry if too many -RAK-
734 * @return プレイヤーを締め出す場合TRUEを返す
736 static int increase_insults(void)
738 st_ptr->insult_cur++;
739 if (st_ptr->insult_cur <= ot_ptr->insult_max) return FALSE;
743 st_ptr->insult_cur = 0;
744 st_ptr->good_buy = 0;
746 st_ptr->store_open = current_world_ptr->game_turn + TURNS_PER_TICK * TOWN_DAWN / 8 + randint1(TURNS_PER_TICK*TOWN_DAWN / 8);
753 * @brief 店主の不満度を減らす /
754 * Decrease insults -RAK-
755 * @return プレイヤーを締め出す場合TRUEを返す
757 static void decrease_insults(void)
759 if (st_ptr->insult_cur) st_ptr->insult_cur--;
764 * @brief 店主の不満度が増えた場合のみのメッセージを表示する /
765 * Have insulted while haggling -RAK-
766 * @return プレイヤーを締め出す場合TRUEを返す
768 static int haggle_insults(void)
770 if (increase_insults()) return TRUE;
777 * Mega-Hack -- Enable "increments"
779 static bool allow_inc = FALSE;
782 * Mega-Hack -- Last "increment" during haggling
784 static s32b last_inc = 0L;
787 * @brief 交渉価格を確認と認証の是非を行う /
790 * @param poffer 別途価格提示をした場合の値を返す参照ポインタ
791 * @param price 現在の交渉価格
792 * @param final 最終確定価格ならばTRUE
793 * @return プレイヤーを締め出す場合TRUEを返す
795 static int get_haggle(concptr pmt, s32b *poffer, PRICE price, int final)
798 if (!allow_inc) last_inc = 0L;
802 sprintf(buf, _("%s [承諾] ", "%s [accept] "), pmt);
804 else if (last_inc < 0)
806 sprintf(buf, _("%s [-$%ld] ", "%s [-%ld] "), pmt, (long)(ABS(last_inc)));
808 else if (last_inc > 0)
810 sprintf(buf, _("%s [+$%ld] ", "%s [+%ld] "), pmt, (long)(ABS(last_inc)));
814 sprintf(buf, "%s ", pmt);
818 GAME_TEXT out_val[160];
826 * Ask the user for a response.
827 * Don't allow to use numpad as cursor key.
829 res = askfor_aux(out_val, 32, FALSE);
831 if (!res) return FALSE;
834 for (p = out_val; *p == ' '; p++) /* loop */;
845 if (allow_inc && last_inc)
851 msg_print(_("値がおかしいです。", "Invalid response."));
856 if ((*p == '+' || *p == '-'))
878 * @brief 店主がプレイヤーからの交渉価格を判断する /
879 * Receive an offer (from the player)
881 * @param poffer 店主からの交渉価格を返す参照ポインタ
882 * @param last_offer 現在の交渉価格
883 * @param factor 店主の価格基準倍率
884 * @param price アイテムの実価値
885 * @param final 最終価格確定ならばTRUE
886 * @return プレイヤーの価格に対して不服ならばTRUEを返す /
887 * Return TRUE if offer is NOT okay
889 static bool receive_offer(concptr pmt, s32b *poffer, s32b last_offer, int factor, PRICE price, int final)
893 if (!get_haggle(pmt, poffer, price, final)) return TRUE;
894 if (((*poffer) * factor) >= (last_offer * factor)) break;
895 if (haggle_insults()) return TRUE;
897 (*poffer) = last_offer;
905 * @brief プレイヤーが購入する時の値切り処理メインルーチン /
906 * Haggling routine -RAK-
907 * @param player_ptr プレーヤーへの参照ポインタ
908 * @param o_ptr オブジェクトの構造体参照ポインタ
909 * @param price 最終価格を返す参照ポインタ
910 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
911 * Return TRUE if purchase is NOT successful
913 static bool purchase_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price)
915 s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
916 s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
917 int noneed = noneedtobargain(final_ask);
919 concptr pmt = _("提示価格", "Asking");
920 if (noneed || !manual_haggle)
924 msg_print(_("結局この金額にまとまった。", "You eventually agree upon the price."));
929 msg_print(_("すんなりとこの金額にまとまった。", "You quickly agree upon the price."));
931 final_ask += final_ask / 10;
935 pmt = _("最終提示価格", "Final Offer");
939 cur_ask *= o_ptr->number;
940 final_ask *= o_ptr->number;
941 s32b min_per = ot_ptr->haggle_per;
942 s32b max_per = min_per * 3;
943 s32b last_offer = object_value(o_ptr) * o_ptr->number;
944 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
945 if (last_offer <= 0) last_offer = 1;
955 bool loop_flag = TRUE;
957 while (!flag && loop_flag)
960 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
961 put_str(out_val, 1, 0);
962 cancel = receive_offer(_("提示する金額? ", "What do you offer? "), &offer, last_offer, 1, cur_ask, final);
967 else if (offer > cur_ask)
972 else if (offer == cur_ask)
985 s32b x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
988 if (haggle_insults())
994 else if (x1 > max_per)
997 if (x1 < max_per) x1 = max_per;
1000 s32b x2 = rand_range(x1 - 2, x1 + 2);
1001 s32b x3 = ((cur_ask - offer) * x2 / 100L) + 1;
1005 if (cur_ask < final_ask)
1008 cur_ask = final_ask;
1009 pmt = _("最終提示価格", "What do you offer? ");
1013 (void)(increase_insults());
1018 else if (offer >= cur_ask)
1028 (void)sprintf(out_val, _("前回の提示金額: $%ld", "Your last offer: %ld"), (long)last_offer);
1029 put_str(out_val, 1, 39);
1030 say_comment_2(cur_ask, annoyed);
1033 if (cancel) return TRUE;
1035 updatebargain(*price, final_ask, o_ptr->number);
1041 * @brief プレイヤーが売却する時の値切り処理メインルーチン /
1042 * Haggling routine -RAK-
1043 * @param player_ptr プレーヤーへの参照ポインタ
1044 * @param o_ptr オブジェクトの構造体参照ポインタ
1045 * @param price 最終価格を返す参照ポインタ
1046 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
1047 * Return TRUE if purchase is NOT successful
1049 static bool sell_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price)
1051 s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, TRUE);
1052 s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, TRUE);
1053 int noneed = noneedtobargain(final_ask);
1054 s32b purse = (s32b)(ot_ptr->max_cost);
1056 concptr pmt = _("提示金額", "Offer");
1057 if (noneed || !manual_haggle || (final_ask >= purse))
1059 if (!manual_haggle && !noneed)
1061 final_ask -= final_ask / 10;
1064 if (final_ask >= purse)
1066 msg_print(_("即座にこの金額にまとまった。", "You instantly agree upon the price."));
1072 msg_print(_("結局この金額にまとまった。", "You eventually agree upon the price."));
1077 msg_print(_("すんなりとこの金額にまとまった。", "You quickly agree upon the price."));
1081 cur_ask = final_ask;
1083 pmt = _("最終提示金額", "Final Offer");
1086 cur_ask *= o_ptr->number;
1087 final_ask *= o_ptr->number;
1089 s32b min_per = ot_ptr->haggle_per;
1090 s32b max_per = min_per * 3;
1091 s32b last_offer = object_value(o_ptr) * o_ptr->number;
1092 last_offer = last_offer * ot_ptr->max_inflate / 100L;
1098 bool cancel = FALSE;
1107 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
1108 put_str(out_val, 1, 0);
1109 cancel = receive_offer(_("提示する価格? ", "What price do you ask? "),
1110 &offer, last_offer, -1, cur_ask, final);
1116 else if (offer < cur_ask)
1121 else if (offer == cur_ask)
1131 if (flag || !loop_flag) break;
1136 s32b x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
1139 if (haggle_insults())
1145 else if (x1 > max_per)
1148 if (x1 < max_per) x1 = max_per;
1151 s32b x2 = rand_range(x1 - 2, x1 + 2);
1152 s32b x3 = ((offer - cur_ask) * x2 / 100L) + 1;
1156 if (cur_ask > final_ask)
1158 cur_ask = final_ask;
1160 pmt = _("最終提示金額", "Final Offer");
1167 /* 追加 $0 で買い取られてしまうのを防止 By FIRST*/
1170 (void)(increase_insults());
1173 else if (offer <= cur_ask)
1183 (void)sprintf(out_val, _("前回の提示価格 $%ld", "Your last bid %ld"), (long)last_offer);
1184 put_str(out_val, 1, 39);
1185 say_comment_3(cur_ask, annoyed);
1188 if (cancel) return TRUE;
1190 updatebargain(*price, final_ask, o_ptr->number);
1196 * @brief 店からの購入処理のメインルーチン /
1197 * Buy an item from a store -RAK-
1198 * @param player_ptr プレーヤーへの参照ポインタ
1201 static void store_purchase(player_type *player_ptr)
1203 if (cur_store_num == STORE_MUSEUM)
1205 msg_print(_("博物館から取り出すことはできません。", "Museum."));
1209 if (st_ptr->stock_num <= 0)
1211 if (cur_store_num == STORE_HOME)
1212 msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
1214 msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
1218 int i = (st_ptr->stock_num - store_top);
1219 if (i > store_bottom) i = store_bottom;
1223 /* ブラックマーケットの時は別のメッセージ */
1224 switch (cur_store_num)
1227 sprintf(out_val, "どのアイテムを取りますか? ");
1230 sprintf(out_val, "どれ? ");
1233 sprintf(out_val, "どの品物が欲しいんだい? ");
1237 if (cur_store_num == STORE_HOME)
1239 sprintf(out_val, "Which item do you want to take? ");
1243 sprintf(out_val, "Which item are you interested in? ");
1248 if (!get_stock(&item, out_val, 0, i - 1)) return;
1250 item = item + store_top;
1252 o_ptr = &st_ptr->stock[item];
1253 ITEM_NUMBER amt = 1;
1257 object_copy(j_ptr, o_ptr);
1260 * If a rod or wand, allocate total maximum timeouts or charges
1261 * between those purchased and left on the shelf.
1263 reduce_charges(j_ptr, o_ptr->number - amt);
1264 j_ptr->number = amt;
1265 if (!inven_carry_okay(j_ptr))
1267 msg_print(_("そんなにアイテムを持てない。", "You cannot carry that many different items."));
1271 PRICE best = price_item(player_ptr, j_ptr, ot_ptr->min_inflate, FALSE);
1272 if (o_ptr->number > 1)
1274 if ((cur_store_num != STORE_HOME) &&
1275 (o_ptr->ident & IDENT_FIXED))
1277 msg_format(_("一つにつき $%ldです。", "That costs %ld gold per item."), (long)(best));
1280 amt = get_quantity(NULL, o_ptr->number);
1281 if (amt <= 0) return;
1285 object_copy(j_ptr, o_ptr);
1288 * If a rod or wand, allocate total maximum timeouts or charges
1289 * between those purchased and left on the shelf.
1291 reduce_charges(j_ptr, o_ptr->number - amt);
1292 j_ptr->number = amt;
1293 if (!inven_carry_okay(j_ptr))
1295 msg_print(_("ザックにそのアイテムを入れる隙間がない。", "You cannot carry that many items."));
1300 COMMAND_CODE item_new;
1302 if (cur_store_num == STORE_HOME)
1304 bool combined_or_reordered;
1305 distribute_charges(o_ptr, j_ptr, amt);
1306 item_new = inven_carry(player_ptr, j_ptr);
1307 GAME_TEXT o_name[MAX_NLEN];
1308 object_desc(player_ptr, o_name, &player_ptr->inventory_list[item_new], 0);
1310 msg_format(_("%s(%c)を取った。", "You have %s (%c)."), o_name, index_to_label(item_new));
1311 handle_stuff(player_ptr);
1313 i = st_ptr->stock_num;
1314 store_item_increase(item, -amt);
1315 store_item_optimize(item);
1316 combined_or_reordered = combine_and_reorder_home(STORE_HOME);
1317 if (i == st_ptr->stock_num)
1319 if (combined_or_reordered) display_store_inventory(player_ptr);
1320 else display_entry(player_ptr, item);
1324 if (st_ptr->stock_num == 0) store_top = 0;
1325 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1326 display_store_inventory(player_ptr);
1328 chg_virtue(player_ptr, V_SACRIFICE, 1);
1334 if (o_ptr->ident & (IDENT_FIXED))
1337 price = (best * j_ptr->number);
1341 GAME_TEXT o_name[MAX_NLEN];
1342 object_desc(player_ptr, o_name, j_ptr, 0);
1343 msg_format(_("%s(%c)を購入する。", "Buying %s (%c)."), o_name, I2A(item));
1345 choice = purchase_haggle(player_ptr, j_ptr, &price);
1346 if (st_ptr->store_open >= current_world_ptr->game_turn) return;
1349 if (choice != 0) return;
1350 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
1351 if (player_ptr->au < price)
1353 msg_print(_("お金が足りません。", "You do not have enough gold."));
1357 say_comment_1(player_ptr);
1358 if (cur_store_num == STORE_BLACK)
1359 chg_virtue(player_ptr, V_JUSTICE, -1);
1360 if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
1361 chg_virtue(player_ptr, V_NATURE, -1);
1365 player_ptr->au -= price;
1366 store_prt_gold(player_ptr);
1367 object_aware(player_ptr, j_ptr);
1368 j_ptr->ident &= ~(IDENT_FIXED);
1369 GAME_TEXT o_name[MAX_NLEN];
1370 object_desc(player_ptr, o_name, j_ptr, 0);
1372 msg_format(_("%sを $%ldで購入しました。", "You bought %s for %ld gold."), o_name, (long)price);
1374 strcpy(record_o_name, o_name);
1375 record_turn = current_world_ptr->game_turn;
1377 if (record_buy) exe_write_diary(player_ptr, DIARY_BUY, 0, o_name);
1378 object_desc(player_ptr, o_name, o_ptr, OD_NAME_ONLY);
1379 if (record_rand_art && o_ptr->art_name)
1380 exe_write_diary(player_ptr, DIARY_ART, 0, o_name);
1382 j_ptr->inscription = 0;
1383 j_ptr->feeling = FEEL_NONE;
1384 j_ptr->ident &= ~(IDENT_STORE);
1385 item_new = inven_carry(player_ptr, j_ptr);
1387 object_desc(player_ptr, o_name, &player_ptr->inventory_list[item_new], 0);
1388 msg_format(_("%s(%c)を手に入れた。", "You have %s (%c)."), o_name, index_to_label(item_new));
1389 autopick_alter_item(player_ptr, item_new, FALSE);
1390 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1392 o_ptr->pval -= j_ptr->pval;
1395 handle_stuff(player_ptr);
1396 i = st_ptr->stock_num;
1397 store_item_increase(item, -amt);
1398 store_item_optimize(item);
1399 if (st_ptr->stock_num == 0)
1401 if (one_in_(STORE_SHUFFLE))
1404 msg_print(_("店主は引退した。", "The shopkeeper retires."));
1405 store_shuffle(player_ptr, cur_store_num);
1408 sprintf(buf, "%s (%s)",
1409 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
1410 put_str(buf, 3, 10);
1411 sprintf(buf, "%s (%ld)",
1412 (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
1417 msg_print(_("店主は新たな在庫を取り出した。", "The shopkeeper brings out some new stock."));
1420 for (i = 0; i < 10; i++)
1422 store_maint(player_ptr, player_ptr->town_num, cur_store_num);
1426 display_store_inventory(player_ptr);
1428 else if (st_ptr->stock_num != i)
1430 if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1431 display_store_inventory(player_ptr);
1435 display_entry(player_ptr, item);
1441 * @brief 店からの売却処理のメインルーチン /
1442 * Sell an item to the store (or home)
1443 * @param owner_ptr プレーヤーへの参照ポインタ
1446 static void store_sell(player_type *owner_ptr)
1449 if (cur_store_num == STORE_HOME)
1450 q = _("どのアイテムを置きますか? ", "Drop which item? ");
1451 else if (cur_store_num == STORE_MUSEUM)
1452 q = _("どのアイテムを寄贈しますか? ", "Give which item? ");
1454 q = _("どのアイテムを売りますか? ", "Sell which item? ");
1456 item_tester_hook = store_will_buy;
1458 /* 我が家でおかしなメッセージが出るオリジナルのバグを修正 */
1460 if (cur_store_num == STORE_HOME)
1462 s = _("置けるアイテムを持っていません。", "You don't have any item to drop.");
1464 else if (cur_store_num == STORE_MUSEUM)
1466 s = _("寄贈できるアイテムを持っていません。", "You don't have any item to give.");
1470 s = _("欲しい物がないですねえ。", "You have nothing that I want.");
1475 o_ptr = choose_object(owner_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1478 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
1480 msg_print(_("ふーむ、どうやらそれは呪われているようだね。", "Hmmm, it seems to be cursed."));
1485 if (o_ptr->number > 1)
1487 amt = get_quantity(NULL, o_ptr->number);
1488 if (amt <= 0) return;
1494 object_copy(q_ptr, o_ptr);
1495 q_ptr->number = amt;
1498 * Hack -- If a rod or wand, allocate total maximum
1499 * timeouts or charges to those being sold. -LM-
1501 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1503 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1506 GAME_TEXT o_name[MAX_NLEN];
1507 object_desc(owner_ptr, o_name, q_ptr, 0);
1509 /* Remove any inscription, feeling for stores */
1510 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
1512 q_ptr->inscription = 0;
1513 q_ptr->feeling = FEEL_NONE;
1516 /* Is there room in the store (or the home?) */
1517 if (!store_check_num(q_ptr))
1519 if (cur_store_num == STORE_HOME)
1520 msg_print(_("我が家にはもう置く場所がない。", "Your home is full."));
1522 else if (cur_store_num == STORE_MUSEUM)
1523 msg_print(_("博物館はもう満杯だ。", "Museum is full."));
1526 msg_print(_("すいませんが、店にはもう置く場所がありません。", "I have not the room in my store to keep it."));
1532 PRICE price, value, dummy;
1533 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
1535 msg_format(_("%s(%c)を売却する。", "Selling %s (%c)."), o_name, index_to_label(item));
1538 choice = sell_haggle(owner_ptr, q_ptr, &price);
1539 if (st_ptr->store_open >= current_world_ptr->game_turn) return;
1543 say_comment_1(owner_ptr);
1545 if (cur_store_num == STORE_BLACK)
1546 chg_virtue(owner_ptr, V_JUSTICE, -1);
1548 if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
1549 chg_virtue(owner_ptr, V_NATURE, 1);
1552 owner_ptr->au += price;
1553 store_prt_gold(owner_ptr);
1554 dummy = object_value(q_ptr) * q_ptr->number;
1556 identify_item(owner_ptr, o_ptr);
1558 object_copy(q_ptr, o_ptr);
1559 q_ptr->number = amt;
1560 q_ptr->ident |= IDENT_STORE;
1563 * Hack -- If a rod or wand, let the shopkeeper know just
1564 * how many charges he really paid for. -LM-
1566 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1568 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1571 value = object_value(q_ptr) * q_ptr->number;
1572 object_desc(owner_ptr, o_name, q_ptr, 0);
1573 msg_format(_("%sを $%ldで売却しました。", "You sold %s for %ld gold."), o_name, (long)price);
1575 if (record_sell) exe_write_diary(owner_ptr, DIARY_SELL, 0, o_name);
1577 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
1579 purchase_analyze(owner_ptr, price, value, dummy);
1583 * Hack -- Allocate charges between those wands or rods sold
1584 * and retained, unless all are being sold. -LM-
1586 distribute_charges(o_ptr, q_ptr, amt);
1588 inven_item_increase(owner_ptr, item, -amt);
1589 inven_item_describe(owner_ptr, item);
1590 if (o_ptr->number > 0)
1591 autopick_alter_item(owner_ptr, item, FALSE);
1593 inven_item_optimize(owner_ptr, item);
1594 handle_stuff(owner_ptr);
1595 int item_pos = store_carry(q_ptr);
1598 store_top = (item_pos / store_bottom) * store_bottom;
1599 display_store_inventory(owner_ptr);
1603 else if (cur_store_num == STORE_MUSEUM)
1605 char o2_name[MAX_NLEN];
1606 object_desc(owner_ptr, o2_name, q_ptr, OD_NAME_ONLY);
1608 if (-1 == store_check_num(q_ptr))
1610 msg_print(_("それと同じ品物は既に博物館にあるようです。", "The Museum already has one of those items."));
1614 msg_print(_("博物館に寄贈したものは取り出すことができません!!", "You cannot take back items which have been donated to the Museum!!"));
1617 if (!get_check(format(_("本当に%sを寄贈しますか?", "Really give %s to the Museum? "), o2_name))) return;
1619 identify_item(owner_ptr, q_ptr);
1620 q_ptr->ident |= IDENT_FULL_KNOWN;
1622 distribute_charges(o_ptr, q_ptr, amt);
1623 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
1626 vary_item(owner_ptr, item, -amt);
1627 handle_stuff(owner_ptr);
1629 int item_pos = home_carry(owner_ptr, q_ptr);
1632 store_top = (item_pos / store_bottom) * store_bottom;
1633 display_store_inventory(owner_ptr);
1638 distribute_charges(o_ptr, q_ptr, amt);
1639 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
1641 vary_item(owner_ptr, item, -amt);
1642 handle_stuff(owner_ptr);
1643 int item_pos = home_carry(owner_ptr, q_ptr);
1646 store_top = (item_pos / store_bottom) * store_bottom;
1647 display_store_inventory(owner_ptr);
1651 if ((choice == 0) && (item >= INVEN_RARM))
1653 calc_android_exp(owner_ptr);
1654 verify_equip_slot(owner_ptr, item);
1660 * @brief 店のアイテムを調べるコマンドのメインルーチン /
1661 * Examine an item in a store -JDL-
1664 static void store_examine(player_type *player_ptr)
1666 if (st_ptr->stock_num <= 0)
1668 if (cur_store_num == STORE_HOME)
1669 msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
1670 else if (cur_store_num == STORE_MUSEUM)
1671 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
1673 msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
1677 int i = (st_ptr->stock_num - store_top);
1678 if (i > store_bottom) i = store_bottom;
1681 sprintf(out_val, _("どれを調べますか?", "Which item do you want to examine? "));
1684 if (!get_stock(&item, out_val, 0, i - 1)) return;
1685 item = item + store_top;
1687 o_ptr = &st_ptr->stock[item];
1688 if (!OBJECT_IS_FULL_KNOWN(o_ptr))
1690 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1694 GAME_TEXT o_name[MAX_NLEN];
1695 object_desc(player_ptr, o_name, o_ptr, 0);
1696 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1698 if (!screen_object(player_ptr, o_ptr, SCROBJ_FORCE_DETAIL))
1699 msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1704 * @brief 博物館のアイテムを除去するコマンドのメインルーチン /
1705 * Remove an item from museum (Originally from TOband)
1706 * @param player_ptr プレーヤーへの参照ポインタ
1709 static void museum_remove_object(player_type *player_ptr)
1711 if (st_ptr->stock_num <= 0)
1713 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
1717 int i = st_ptr->stock_num - store_top;
1718 if (i > store_bottom) i = store_bottom;
1721 sprintf(out_val, _("どのアイテムの展示をやめさせますか?", "Which item do you want to order to remove? "));
1724 if (!get_stock(&item, out_val, 0, i - 1)) return;
1726 item = item + store_top;
1728 o_ptr = &st_ptr->stock[item];
1730 GAME_TEXT o_name[MAX_NLEN];
1731 object_desc(player_ptr, o_name, o_ptr, 0);
1733 msg_print(_("展示をやめさせたアイテムは二度と見ることはできません!", "Once removed from the Museum, an item will be gone forever!"));
1734 if (!get_check(format(_("本当に%sの展示をやめさせますか?", "Really order to remove %s from the Museum? "), o_name))) return;
1736 msg_format(_("%sの展示をやめさせた。", "You ordered to remove %s."), o_name);
1738 store_item_increase(item, -o_ptr->number);
1739 store_item_optimize(item);
1741 (void)combine_and_reorder_home(STORE_MUSEUM);
1742 if (st_ptr->stock_num == 0) store_top = 0;
1744 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1745 display_store_inventory(player_ptr);
1750 * Hack -- set this to leave the store
1752 static bool leave_store = FALSE;
1756 * @brief 店舗処理コマンド選択のメインルーチン /
1757 * Process a command in a store
1758 * @param client_ptr 顧客となるクリーチャーの参照ポインタ
1762 * Note that we must allow the use of a few "special" commands
1763 * in the stores which are not allowed in the dungeon, and we
1764 * must disable some commands which are allowed in the dungeon
1765 * but not in the stores, to prevent chaos.
1768 static void store_process_command(player_type *client_ptr)
1771 if (rogue_like_commands && command_cmd == 'l')
1776 switch (command_cmd)
1786 /* 1 ページ戻るコマンド: 我が家のページ数が多いので重宝するはず By BUG */
1787 if (st_ptr->stock_num <= store_bottom) {
1788 msg_print(_("これで全部です。", "Entire inventory is shown."));
1792 store_top -= store_bottom;
1794 store_top = ((st_ptr->stock_num - 1) / store_bottom) * store_bottom;
1795 if ((cur_store_num == STORE_HOME) && (powerup_home == FALSE))
1796 if (store_top >= store_bottom) store_top = store_bottom;
1797 display_store_inventory(client_ptr);
1804 if (st_ptr->stock_num <= store_bottom)
1806 msg_print(_("これで全部です。", "Entire inventory is shown."));
1810 store_top += store_bottom;
1812 * 隠しオプション(powerup_home)がセットされていないときは
1813 * 我が家では 2 ページまでしか表示しない
1815 if ((cur_store_num == STORE_HOME) &&
1816 (powerup_home == FALSE) &&
1817 (st_ptr->stock_num >= STORE_INVEN_MAX))
1819 if (store_top >= (STORE_INVEN_MAX - 1))
1826 if (store_top >= st_ptr->stock_num) store_top = 0;
1829 display_store_inventory(client_ptr);
1836 do_cmd_redraw(client_ptr);
1837 display_store(client_ptr);
1842 store_purchase(client_ptr);
1847 store_sell(client_ptr);
1852 store_examine(client_ptr);
1861 do_cmd_wield(client_ptr);
1866 do_cmd_takeoff(client_ptr);
1871 do_cmd_destroy(client_ptr);
1876 do_cmd_equip(client_ptr);
1881 do_cmd_inven(client_ptr);
1886 do_cmd_observe(client_ptr);
1891 toggle_inventory_equipment(client_ptr);
1896 if ((client_ptr->pclass == CLASS_MINDCRAFTER) ||
1897 (client_ptr->pclass == CLASS_BERSERKER) ||
1898 (client_ptr->pclass == CLASS_NINJA) ||
1899 (client_ptr->pclass == CLASS_MIRROR_MASTER)
1900 ) do_cmd_mind_browse(client_ptr);
1901 else if (client_ptr->pclass == CLASS_SMITH)
1902 do_cmd_kaji(client_ptr, TRUE);
1903 else if (client_ptr->pclass == CLASS_MAGIC_EATER)
1904 do_cmd_magic_eater(client_ptr, TRUE, FALSE);
1905 else if (client_ptr->pclass == CLASS_SNIPER)
1906 do_cmd_snipe_browse(client_ptr);
1907 else do_cmd_browse(client_ptr);
1912 do_cmd_inscribe(client_ptr);
1917 do_cmd_uninscribe(client_ptr);
1922 do_cmd_help(client_ptr);
1927 do_cmd_query_symbol(client_ptr);
1932 client_ptr->town_num = old_town_num;
1933 do_cmd_player_status(client_ptr);
1934 client_ptr->town_num = inner_town_num;
1935 display_store(client_ptr);
1945 client_ptr->town_num = old_town_num;
1946 do_cmd_pref(client_ptr);
1947 client_ptr->town_num = inner_town_num;
1952 client_ptr->town_num = old_town_num;
1953 do_cmd_macros(client_ptr);
1954 client_ptr->town_num = inner_town_num;
1959 client_ptr->town_num = old_town_num;
1960 do_cmd_visuals(client_ptr);
1961 client_ptr->town_num = inner_town_num;
1966 client_ptr->town_num = old_town_num;
1967 do_cmd_colors(client_ptr);
1968 client_ptr->town_num = inner_town_num;
1974 (void)combine_and_reorder_home(STORE_HOME);
1975 do_cmd_redraw(client_ptr);
1976 display_store(client_ptr);
1991 do_cmd_feeling(client_ptr);
1996 do_cmd_message_one();
2006 do_cmd_diary(client_ptr);
2011 do_cmd_knowledge(client_ptr);
2016 do_cmd_load_screen();
2021 do_cmd_save_screen(client_ptr, handle_stuff);
2026 if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
2028 museum_remove_object(client_ptr);
2032 msg_print(_("そのコマンドは店の中では使えません。", "That command does not work in stores."));
2042 * @brief 店舗処理全体のメインルーチン /
2043 * Enter a store, and interact with it. *
2044 * @param player_ptr プレーヤーへの参照ポインタ
2048 * Note that we use the standard "request_command()" function
2049 * to get a command, allowing us to use "command_arg" and all
2050 * command macros and other nifty stuff, but we use the special
2051 * "shopping" argument, to force certain commands to be converted
2052 * into other commands, normally, we convert "p" (pray) and "m"
2053 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
2056 void do_cmd_store(player_type *player_ptr)
2058 if (player_ptr->wild_mode) return;
2060 Term_get_size(&w, &h);
2062 xtra_stock = MIN(14 + 26, ((h > 24) ? (h - 24) : 0));
2063 store_bottom = MIN_STOCK + xtra_stock;
2066 g_ptr = &player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x];
2068 if (!cave_have_flag_grid(g_ptr, FF_STORE))
2070 msg_print(_("ここには店がありません。", "You see no store here."));
2074 int which = f_info[g_ptr->feat].subtype;
2075 old_town_num = player_ptr->town_num;
2076 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) player_ptr->town_num = 1;
2077 if (player_ptr->current_floor_ptr->dun_level) player_ptr->town_num = NO_TOWN;
2078 inner_town_num = player_ptr->town_num;
2080 if ((town_info[player_ptr->town_num].store[which].store_open >= current_world_ptr->game_turn) ||
2083 msg_print(_("ドアに鍵がかかっている。", "The doors are locked."));
2084 player_ptr->town_num = old_town_num;
2088 int maintain_num = (current_world_ptr->game_turn - town_info[player_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
2089 if (maintain_num > 10)
2093 for (int i = 0; i < maintain_num; i++)
2094 store_maint(player_ptr, player_ptr->town_num, which);
2096 town_info[player_ptr->town_num].store[which].last_visit = current_world_ptr->game_turn;
2099 forget_lite(player_ptr->current_floor_ptr);
2100 forget_view(player_ptr->current_floor_ptr);
2101 current_world_ptr->character_icky = TRUE;
2105 get_com_no_macros = TRUE;
2106 cur_store_num = which;
2107 cur_store_feat = g_ptr->feat;
2108 st_ptr = &town_info[player_ptr->town_num].store[cur_store_num];
2109 ot_ptr = &owners[cur_store_num][st_ptr->owner];
2111 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
2112 display_store(player_ptr);
2113 leave_store = FALSE;
2115 while (!leave_store)
2118 clear_from(20 + xtra_stock);
2119 prt(_(" ESC) 建物から出る", " ESC) Exit from Building."), 21 + xtra_stock, 0);
2120 if (st_ptr->stock_num > store_bottom)
2122 prt(_(" -)前ページ", " -) Previous page"), 22 + xtra_stock, 0);
2123 prt(_(" スペース) 次ページ", " SPACE) Next page"), 23 + xtra_stock, 0);
2126 if (cur_store_num == STORE_HOME)
2128 prt(_("g) アイテムを取る", "g) Get an item."), 21 + xtra_stock, 27);
2129 prt(_("d) アイテムを置く", "d) Drop an item."), 22 + xtra_stock, 27);
2130 prt(_("x) 家のアイテムを調べる", "x) eXamine an item in the home."), 23 + xtra_stock, 27);
2132 else if (cur_store_num == STORE_MUSEUM)
2134 prt(_("d) アイテムを置く", "d) Drop an item."), 21 + xtra_stock, 27);
2135 prt(_("r) アイテムの展示をやめる", "r) order to Remove an item."), 22 + xtra_stock, 27);
2136 prt(_("x) 博物館のアイテムを調べる", "x) eXamine an item in the museum."), 23 + xtra_stock, 27);
2140 prt(_("p) 商品を買う", "p) Purchase an item."), 21 + xtra_stock, 30);
2141 prt(_("s) アイテムを売る", "s) Sell an item."), 22 + xtra_stock, 30);
2142 prt(_("x) 商品を調べる", "x) eXamine an item in the shop"), 23 + xtra_stock, 30);
2145 prt(_("i/e) 持ち物/装備の一覧", "i/e) Inventry/Equipment list"), 21 + xtra_stock, 56);
2146 if (rogue_like_commands)
2148 prt(_("w/T) 装備する/はずす", "w/T) Wear/Take off equipment"), 22 + xtra_stock, 56);
2152 prt(_("w/t) 装備する/はずす", "w/t) Wear/Take off equipment"), 22 + xtra_stock, 56);
2155 prt(_("コマンド:", "You may: "), 20 + xtra_stock, 0);
2156 request_command(player_ptr, TRUE);
2157 store_process_command(player_ptr);
2160 * Hack -- To redraw missiles damage and prices in store
2161 * If player's charisma changes, or if player changes a bow, PU_BONUS is set
2163 bool need_redraw_store_inv = (player_ptr->update & PU_BONUS) ? TRUE : FALSE;
2164 current_world_ptr->character_icky = TRUE;
2165 handle_stuff(player_ptr);
2166 if (player_ptr->inventory_list[INVEN_PACK].k_idx)
2168 INVENTORY_IDX item = INVEN_PACK;
2169 object_type *o_ptr = &player_ptr->inventory_list[item];
2170 if (cur_store_num != STORE_HOME)
2172 if (cur_store_num == STORE_MUSEUM)
2173 msg_print(_("ザックからアイテムがあふれそうなので、あわてて博物館から出た...", "Your pack is so full that you flee the Museum..."));
2175 msg_print(_("ザックからアイテムがあふれそうなので、あわてて店から出た...", "Your pack is so full that you flee the store..."));
2179 else if (!store_check_num(o_ptr))
2181 msg_print(_("ザックからアイテムがあふれそうなので、あわてて家から出た...", "Your pack is so full that you flee your home..."));
2189 GAME_TEXT o_name[MAX_NLEN];
2190 msg_print(_("ザックからアイテムがあふれてしまった!", "Your pack overflows!"));
2192 object_copy(q_ptr, o_ptr);
2193 object_desc(player_ptr, o_name, q_ptr, 0);
2194 msg_format(_("%sが落ちた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
2195 vary_item(player_ptr, item, -255);
2196 handle_stuff(player_ptr);
2198 item_pos = home_carry(player_ptr, q_ptr);
2201 store_top = (item_pos / store_bottom) * store_bottom;
2202 display_store_inventory(player_ptr);
2207 if (need_redraw_store_inv) display_store_inventory(player_ptr);
2209 if (st_ptr->store_open >= current_world_ptr->game_turn) leave_store = TRUE;
2212 select_floor_music(player_ptr);
2213 player_ptr->town_num = old_town_num;
2214 take_turn(player_ptr, 100);
2215 current_world_ptr->character_icky = FALSE;
2217 command_see = FALSE;
2218 get_com_no_macros = FALSE;
2223 player_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2224 player_ptr->update |= (PU_MONSTERS);
2225 player_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
2226 player_ptr->redraw |= (PR_MAP);
2227 player_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2232 * @brief 現在の町の店主を交代させる /
2233 * Shuffle one of the stores.
2234 * @param which 店舗種類のID
2237 void store_shuffle(player_type *player_ptr, int which)
2239 if (which == STORE_HOME) return;
2240 if (which == STORE_MUSEUM) return;
2242 cur_store_num = which;
2243 st_ptr = &town_info[player_ptr->town_num].store[cur_store_num];
2244 int j = st_ptr->owner;
2247 st_ptr->owner = (byte)randint0(MAX_OWNERS);
2248 if (j == st_ptr->owner) continue;
2250 for (i = 1; i < max_towns; i++)
2252 if (i == player_ptr->town_num) continue;
2253 if (st_ptr->owner == town_info[i].store[cur_store_num].owner) break;
2256 if (i == max_towns) break;
2259 ot_ptr = &owners[cur_store_num][st_ptr->owner];
2260 st_ptr->insult_cur = 0;
2261 st_ptr->store_open = 0;
2262 st_ptr->good_buy = 0;
2263 st_ptr->bad_buy = 0;
2264 for (int i = 0; i < st_ptr->stock_num; i++)
2267 o_ptr = &st_ptr->stock[i];
2268 if (object_is_artifact(o_ptr)) continue;
2270 o_ptr->discount = 50;
2271 o_ptr->ident &= ~(IDENT_FIXED);
2272 o_ptr->inscription = quark_add(_("売出中", "on sale"));
2278 * @brief 店の品揃えを変化させる /
2279 * Maintain the inventory at the stores.
2280 * @param player_ptr プレーヤーへの参照ポインタ
2281 * @param town_num 町のID
2282 * @param store_num 店舗種類のID
2285 void store_maint(player_type *player_ptr, int town_num, int store_num)
2287 cur_store_num = store_num;
2288 if (store_num == STORE_HOME) return;
2289 if (store_num == STORE_MUSEUM) return;
2291 st_ptr = &town_info[town_num].store[store_num];
2292 ot_ptr = &owners[store_num][st_ptr->owner];
2293 st_ptr->insult_cur = 0;
2294 if (store_num == STORE_BLACK)
2296 for (INVENTORY_IDX j = st_ptr->stock_num - 1; j >= 0; j--)
2298 object_type *o_ptr = &st_ptr->stock[j];
2299 if (black_market_crap(player_ptr, o_ptr))
2301 store_item_increase(j, 0 - o_ptr->number);
2302 store_item_optimize(j);
2307 INVENTORY_IDX j = st_ptr->stock_num;
2308 j = j - randint1(STORE_TURNOVER);
2309 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
2310 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
2313 while (st_ptr->stock_num > j)
2316 j = st_ptr->stock_num;
2317 j = j + randint1(STORE_TURNOVER);
2318 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
2319 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
2320 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
2322 while (st_ptr->stock_num < j) store_create(player_ptr, black_market_crap);
2327 * @brief 店舗情報を初期化する /
2328 * Initialize the stores
2329 * @param town_num 町のID
2330 * @param store_num 店舗種類のID
2333 void store_init(int town_num, int store_num)
2335 cur_store_num = store_num;
2336 st_ptr = &town_info[town_num].store[store_num];
2339 st_ptr->owner = (byte)randint0(MAX_OWNERS);
2341 for (i = 1; i < max_towns; i++)
2343 if (i == town_num) continue;
2344 if (st_ptr->owner == town_info[i].store[store_num].owner) break;
2347 if (i == max_towns) break;
2350 ot_ptr = &owners[store_num][st_ptr->owner];
2352 st_ptr->store_open = 0;
2353 st_ptr->insult_cur = 0;
2354 st_ptr->good_buy = 0;
2355 st_ptr->bad_buy = 0;
2356 st_ptr->stock_num = 0;
2357 st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
2358 for (int k = 0; k < st_ptr->stock_size; k++)
2360 object_wipe(&st_ptr->stock[k]);