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"
25 #include "io/write-diary.h"
26 #include "cmd/cmd-basic.h"
27 #include "cmd/cmd-diary.h"
28 #include "cmd/cmd-draw.h"
29 #include "cmd/cmd-dump.h"
30 #include "cmd/cmd-help.h"
31 #include "cmd/cmd-item.h"
32 #include "cmd/cmd-macro.h"
33 #include "cmd/cmd-smith.h"
34 #include "cmd/cmd-visuals.h"
35 #include "cmd/cmd-zapwand.h"
36 #include "cmd/cmd-magiceat.h"
40 #include "cmd-spell.h"
42 #include "player-status.h"
43 #include "player-class.h"
44 #include "player-inventory.h"
45 #include "object-flavor.h"
46 #include "object-hook.h"
47 #include "floor-events.h"
50 #include "player-effects.h"
51 #include "player-race.h"
54 #include "objectkind.h"
56 #include "floor-town.h"
58 #include "view-mainwindow.h"
63 static int store_top = 0;
64 static int store_bottom = 0;
65 static int xtra_stock = 0;
66 static const owner_type *ot_ptr = NULL;
67 static s16b old_town_num = 0;
68 static s16b inner_town_num = 0;
71 * We store the current "store feat" here so everyone can access it
73 static int cur_store_feat;
76 * @brief 店舗価格を決定する. 無料にはならない /
77 * Determine the price of an item (qty one) in a store.
78 * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
80 * @param flip TRUEならば店主にとっての買取価格、FALSEなら売出価格を計算
84 * This function takes into account the player's charisma, and the
85 * shop-keepers friendliness, and the shop-keeper's base greed, but
86 * never lets a shop-keeper lose money in a transaction.
87 * The "greed" value should exceed 100 when the player is "buying" the
88 * item, and should be less than 100 when the player is "selling" it.
89 * Hack -- the black market always charges twice as much as it should.
90 * Charisma adjustment runs from 80 to 130
91 * Racial adjustment runs from 95 to 130
92 * Since greed/charisma/racial adjustments are centered at 100, we need
93 * to adjust (by 200) to extract a usable multiplier. Note that the
94 * "greed" value is always something (?).
97 static PRICE price_item(player_type *player_ptr, object_type *o_ptr, int greed, bool flip)
99 PRICE price = object_value(o_ptr);
100 if (price <= 0) return (0L);
102 int factor = rgold_adj[ot_ptr->owner_race][player_ptr->prace];
103 factor += adj_chr_gold[player_ptr->stat_ind[A_CHR]];
107 adjust = 100 + (300 - (greed + factor));
108 if (adjust > 100) adjust = 100;
109 if (cur_store_num == STORE_BLACK)
112 price = (price * adjust + 50L) / 100L;
116 adjust = 100 + ((greed + factor) - 300);
117 if (adjust < 100) adjust = 100;
118 if (cur_store_num == STORE_BLACK)
121 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
124 if (price <= 0L) return (1L);
130 * @brief 店舗に品を置くスペースがあるかどうかの判定を返す /
131 * Check to see if the shop will be carrying too many objects -RAK-
132 * @param o_ptr 店舗に置きたいオブジェクト構造体の参照ポインタ
133 * @return 置き場がないなら0、重ね合わせできるアイテムがあるなら-1、スペースがあるなら1を返す。
136 * Note that the shop, just like a player, will not accept things
137 * it cannot hold. Before, one could "nuke" potions this way.
138 * Return value is now int:
140 * -1 : Can be combined to existing slot.
141 * 1 : Cannot be combined but there are empty spaces.
144 static int store_check_num(object_type *o_ptr)
147 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
149 bool old_stack_force_notes = stack_force_notes;
150 bool old_stack_force_costs = stack_force_costs;
152 if (cur_store_num != STORE_HOME)
154 stack_force_notes = FALSE;
155 stack_force_costs = FALSE;
158 for (int i = 0; i < st_ptr->stock_num; i++)
160 j_ptr = &st_ptr->stock[i];
161 if (object_similar(j_ptr, o_ptr))
163 if (cur_store_num != STORE_HOME)
165 stack_force_notes = old_stack_force_notes;
166 stack_force_costs = old_stack_force_costs;
173 if (cur_store_num != STORE_HOME)
175 stack_force_notes = old_stack_force_notes;
176 stack_force_costs = old_stack_force_costs;
181 for (int i = 0; i < st_ptr->stock_num; i++)
183 j_ptr = &st_ptr->stock[i];
184 if (store_object_similar(j_ptr, o_ptr)) return -1;
188 /* Free space is always usable */
190 * オプション powerup_home が設定されていると
193 if ((cur_store_num == STORE_HOME) && (powerup_home == FALSE))
195 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10))
202 if (st_ptr->stock_num < st_ptr->stock_size)
213 * @brief 現在の町の指定された店舗のアイテムを整理する /
214 * Combine and reorder items in store.
215 * @param store_num 店舗ID
216 * @return 実際に整理が行われたならばTRUEを返す。
218 bool combine_and_reorder_home(int store_num)
220 store_type *old_st_ptr = st_ptr;
221 st_ptr = &town_info[1].store[store_num];
223 if (store_num != STORE_HOME)
225 stack_force_notes = FALSE;
226 stack_force_costs = FALSE;
229 bool combined = TRUE;
233 for (int i = st_ptr->stock_num - 1; i > 0; i--)
236 o_ptr = &st_ptr->stock[i];
237 if (!o_ptr->k_idx) continue;
238 for (int j = 0; j < i; j++)
241 j_ptr = &st_ptr->stock[j];
242 if (!j_ptr->k_idx) continue;
245 * Get maximum number of the stack if these
246 * are similar, get zero otherwise.
248 int max_num = object_similar_part(j_ptr, o_ptr);
249 if (max_num == 0 || j_ptr->number >= max_num) continue;
251 if (o_ptr->number + j_ptr->number <= max_num)
253 object_absorb(j_ptr, o_ptr);
256 for (k = i; k < st_ptr->stock_num; k++)
258 st_ptr->stock[k] = st_ptr->stock[k + 1];
261 object_wipe(&st_ptr->stock[k]);
266 ITEM_NUMBER old_num = o_ptr->number;
267 ITEM_NUMBER remain = j_ptr->number + o_ptr->number - max_num;
268 object_absorb(j_ptr, o_ptr);
269 o_ptr->number = remain;
270 if (o_ptr->tval == TV_ROD)
272 o_ptr->pval = o_ptr->pval * remain / old_num;
273 o_ptr->timeout = o_ptr->timeout * remain / old_num;
275 else if (o_ptr->tval == TV_WAND)
277 o_ptr->pval = o_ptr->pval * remain / old_num;
288 for (int i = 0; i < st_ptr->stock_num; i++)
291 o_ptr = &st_ptr->stock[i];
292 if (!o_ptr->k_idx) continue;
294 s32b o_value = object_value(o_ptr);
296 for (j = 0; j < st_ptr->stock_num; j++)
298 if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
301 if (j >= i) continue;
307 object_copy(j_ptr, &st_ptr->stock[i]);
308 for (int k = i; k > j; k--)
310 object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
313 object_copy(&st_ptr->stock[j], j_ptr);
317 bool old_stack_force_notes = stack_force_notes;
318 bool old_stack_force_costs = stack_force_costs;
319 if (store_num != STORE_HOME)
321 stack_force_notes = old_stack_force_notes;
322 stack_force_costs = old_stack_force_costs;
330 * @brief 我が家にオブジェクトを加える /
331 * Add the item "o_ptr" to the inventory of the "Home"
332 * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
336 * In all cases, return the slot (or -1) where the object was placed
337 * Note that this is a hacked up version of "inven_carry()".
338 * Also note that it may not correctly "adapt" to "knowledge" bacoming
339 * known, the player may have to pick stuff up and drop it again.
342 static int home_carry(player_type *player_ptr, object_type *o_ptr)
344 if (cur_store_num != STORE_HOME)
346 stack_force_notes = FALSE;
347 stack_force_costs = FALSE;
350 bool old_stack_force_notes = stack_force_notes;
351 bool old_stack_force_costs = stack_force_costs;
352 for (int slot = 0; slot < st_ptr->stock_num; slot++)
355 j_ptr = &st_ptr->stock[slot];
356 if (object_similar(j_ptr, o_ptr))
358 object_absorb(j_ptr, o_ptr);
359 if (cur_store_num != STORE_HOME)
361 stack_force_notes = old_stack_force_notes;
362 stack_force_costs = old_stack_force_costs;
369 if (cur_store_num != STORE_HOME)
371 stack_force_notes = old_stack_force_notes;
372 stack_force_costs = old_stack_force_costs;
377 * 隠し機能: オプション powerup_home が設定されていると
380 if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE))
382 if (st_ptr->stock_num >= st_ptr->stock_size)
389 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10))
395 PRICE value = object_value(o_ptr);
397 for (slot = 0; slot < st_ptr->stock_num; slot++)
399 if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
402 for (int i = st_ptr->stock_num; i > slot; i--)
404 st_ptr->stock[i] = st_ptr->stock[i - 1];
408 st_ptr->stock[slot] = *o_ptr;
409 chg_virtue(player_ptr, V_SACRIFICE, -1);
410 (void)combine_and_reorder_home(cur_store_num);
416 * @brief 店舗の割引対象外にするかどうかを判定 /
417 * Eliminate need to bargain if player has haggled well in the past
418 * @param minprice アイテムの最低販売価格
419 * @return 割引を禁止するならTRUEを返す。
421 static bool noneedtobargain(PRICE minprice)
423 PRICE good = st_ptr->good_buy;
424 PRICE bad = st_ptr->bad_buy;
425 if (minprice < 10L) return TRUE;
426 if (good == MAX_SHORT) return TRUE;
427 if (good > ((3 * bad) + (5 + (minprice / 50)))) return TRUE;
434 * @brief 店主の持つプレイヤーに対する売買の良し悪し経験を記憶する /
435 * Update the bargain info
436 * @param price 実際の取引価格
437 * @param minprice 店主の提示した価格
441 static void updatebargain(PRICE price, PRICE minprice, int num)
443 if (!manual_haggle) return;
444 if ((minprice / num) < 10L) return;
445 if (price == minprice)
447 if (st_ptr->good_buy < MAX_SHORT)
454 if (st_ptr->bad_buy < MAX_SHORT)
463 * @brief 店の商品リストを再表示する /
464 * Re-displays a single store entry
465 * @param player_ptr プレーヤーへの参照ポインタ
469 static void display_entry(player_type *player_ptr, int pos)
472 o_ptr = &st_ptr->stock[pos];
473 int i = (pos % store_bottom);
475 /* Label it, clear the line --(-- */
477 (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
478 prt(out_val, i + 6, 0);
483 TERM_COLOR a = object_attr(o_ptr);
484 SYMBOL_CODE c = object_char(o_ptr);
486 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
487 if (use_bigtile) cur_col++;
492 /* Describe an item in the home */
494 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
497 if (show_weights) maxwid -= 10;
499 GAME_TEXT o_name[MAX_NLEN];
500 object_desc(player_ptr, o_name, o_ptr, 0);
501 o_name[maxwid] = '\0';
502 c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col);
505 WEIGHT wgt = o_ptr->weight;
506 sprintf(out_val, _("%3d.%1d kg", "%3d.%d lb"), _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
507 put_str(out_val, i + 6, _(67, 68));
514 if (show_weights) maxwid -= 7;
516 GAME_TEXT o_name[MAX_NLEN];
517 object_desc(player_ptr, o_name, o_ptr, 0);
518 o_name[maxwid] = '\0';
519 c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col);
523 int wgt = o_ptr->weight;
524 sprintf(out_val, "%3d.%1d", _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
525 put_str(out_val, i + 6, _(60, 61));
529 if (o_ptr->ident & (IDENT_FIXED))
531 x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
532 (void)sprintf(out_val, _("%9ld固", "%9ld F"), (long)x);
533 put_str(out_val, i + 6, 68);
539 x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
540 if (!noneedtobargain(x)) x += x / 10;
542 (void)sprintf(out_val, "%9ld ", (long)x);
543 put_str(out_val, i + 6, 68);
547 x = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
548 (void)sprintf(out_val, "%9ld ", (long)x);
549 put_str(out_val, i + 6, 68);
554 * @brief 店の商品リストを表示する /
555 * Displays a store's inventory -RAK-
556 * @param player_ptr プレーヤーへの参照ポインタ
559 * All prices are listed as "per individual object". -BEN-
561 static void display_store_inventory(player_type *player_ptr)
564 for (k = 0; k < store_bottom; k++)
566 if (store_top + k >= st_ptr->stock_num) break;
568 display_entry(player_ptr, store_top + k);
571 for (int i = k; i < store_bottom + 1; i++)
574 put_str(_(" ", " "), 5, _(20, 22));
575 if (st_ptr->stock_num > store_bottom)
577 prt(_("-続く-", "-more-"), k + 6, 3);
578 put_str(format(_("(%dページ) ", "(Page %d) "), store_top / store_bottom + 1), 5, _(20, 22));
581 if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM)
583 k = st_ptr->stock_size;
584 if (cur_store_num == STORE_HOME && !powerup_home) k /= 10;
586 put_str(format(_("アイテム数: %4d/%4d", "Objects: %4d/%4d"), st_ptr->stock_num, k), 19 + xtra_stock, _(27, 30));
592 * @brief プレイヤーの所持金を表示する /
593 * Displays players gold -RAK-
594 * @param player_ptr プレーヤーへの参照ポインタ
598 static void store_prt_gold(player_type *player_ptr)
600 prt(_("手持ちのお金: ", "Gold Remaining: "), 19 + xtra_stock, 53);
602 sprintf(out_val, "%9ld", (long)player_ptr->au);
603 prt(out_val, 19 + xtra_stock, 68);
608 * @brief 店舗情報全体を表示するメインルーチン /
609 * Displays store (after clearing screen) -RAK-
610 * @param player_ptr プレーヤーへの参照ポインタ
614 static void display_store(player_type *player_ptr)
617 if (cur_store_num == STORE_HOME)
619 put_str(_("我が家", "Your Home"), 3, 31);
620 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
623 put_str(_(" 重さ", "Weight"), 5, 70);
626 store_prt_gold(player_ptr);
627 display_store_inventory(player_ptr);
631 if (cur_store_num == STORE_MUSEUM)
633 put_str(_("博物館", "Museum"), 3, 31);
634 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
637 put_str(_(" 重さ", "Weight"), 5, 70);
640 store_prt_gold(player_ptr);
641 display_store_inventory(player_ptr);
645 concptr store_name = (f_name + f_info[cur_store_feat].name);
646 concptr owner_name = (ot_ptr->owner_name);
647 concptr race_name = race_info[ot_ptr->owner_race].title;
649 sprintf(buf, "%s (%s)", owner_name, race_name);
652 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
655 put_str(_("商品の一覧", "Item Description"), 5, 5);
658 put_str(_(" 重さ", "Weight"), 5, 60);
661 put_str(_(" 価格", "Price"), 5, 72);
662 store_prt_gold(player_ptr);
663 display_store_inventory(player_ptr);
668 * @brief 店舗からアイテムを選択する /
669 * Get the ID of a store item and return its value -RAK-
670 * @param com_val 選択IDを返す参照ポインタ
671 * @param pmt メッセージキャプション
674 * @return 実際に選択したらTRUE、キャンセルしたらFALSE
676 static int get_stock(COMMAND_CODE *com_val, concptr pmt, int i, int j)
678 if (repeat_pull(com_val) && (*com_val >= i) && (*com_val <= j))
686 char hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
689 (void)sprintf(out_val, "(%s:%c-%c, ESCで中断) %s",
690 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "アイテム" : "商品"),
693 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
700 if (!get_com(out_val, &command, FALSE)) break;
703 if (islower(command))
705 else if (isupper(command))
706 k = A2I(tolower(command)) + 26;
710 if ((k >= i) && (k <= j))
720 if (command == ESCAPE) return FALSE;
722 repeat_push(*com_val);
728 * @brief 店主の不満度を増やし、プレイヤーを締め出す判定と処理を行う /
729 * Increase the insult counter and get angry if too many -RAK-
730 * @return プレイヤーを締め出す場合TRUEを返す
732 static int increase_insults(void)
734 st_ptr->insult_cur++;
735 if (st_ptr->insult_cur <= ot_ptr->insult_max) return FALSE;
739 st_ptr->insult_cur = 0;
740 st_ptr->good_buy = 0;
742 st_ptr->store_open = current_world_ptr->game_turn + TURNS_PER_TICK * TOWN_DAWN / 8 + randint1(TURNS_PER_TICK*TOWN_DAWN / 8);
749 * @brief 店主の不満度を減らす /
750 * Decrease insults -RAK-
751 * @return プレイヤーを締め出す場合TRUEを返す
753 static void decrease_insults(void)
755 if (st_ptr->insult_cur) st_ptr->insult_cur--;
760 * @brief 店主の不満度が増えた場合のみのメッセージを表示する /
761 * Have insulted while haggling -RAK-
762 * @return プレイヤーを締め出す場合TRUEを返す
764 static int haggle_insults(void)
766 if (increase_insults()) return TRUE;
773 * Mega-Hack -- Enable "increments"
775 static bool allow_inc = FALSE;
778 * Mega-Hack -- Last "increment" during haggling
780 static s32b last_inc = 0L;
783 * @brief 交渉価格を確認と認証の是非を行う /
786 * @param poffer 別途価格提示をした場合の値を返す参照ポインタ
787 * @param price 現在の交渉価格
788 * @param final 最終確定価格ならばTRUE
789 * @return プレイヤーを締め出す場合TRUEを返す
791 static int get_haggle(concptr pmt, s32b *poffer, PRICE price, int final)
794 if (!allow_inc) last_inc = 0L;
798 sprintf(buf, _("%s [承諾] ", "%s [accept] "), pmt);
800 else if (last_inc < 0)
802 sprintf(buf, _("%s [-$%ld] ", "%s [-%ld] "), pmt, (long)(ABS(last_inc)));
804 else if (last_inc > 0)
806 sprintf(buf, _("%s [+$%ld] ", "%s [+%ld] "), pmt, (long)(ABS(last_inc)));
810 sprintf(buf, "%s ", pmt);
814 GAME_TEXT out_val[160];
822 * Ask the user for a response.
823 * Don't allow to use numpad as cursor key.
825 res = askfor_aux(out_val, 32, FALSE);
827 if (!res) return FALSE;
830 for (p = out_val; *p == ' '; p++) /* loop */;
841 if (allow_inc && last_inc)
847 msg_print(_("値がおかしいです。", "Invalid response."));
852 if ((*p == '+' || *p == '-'))
874 * @brief 店主がプレイヤーからの交渉価格を判断する /
875 * Receive an offer (from the player)
877 * @param poffer 店主からの交渉価格を返す参照ポインタ
878 * @param last_offer 現在の交渉価格
879 * @param factor 店主の価格基準倍率
880 * @param price アイテムの実価値
881 * @param final 最終価格確定ならばTRUE
882 * @return プレイヤーの価格に対して不服ならばTRUEを返す /
883 * Return TRUE if offer is NOT okay
885 static bool receive_offer(concptr pmt, s32b *poffer, s32b last_offer, int factor, PRICE price, int final)
889 if (!get_haggle(pmt, poffer, price, final)) return TRUE;
890 if (((*poffer) * factor) >= (last_offer * factor)) break;
891 if (haggle_insults()) return TRUE;
893 (*poffer) = last_offer;
901 * @brief プレイヤーが購入する時の値切り処理メインルーチン /
902 * Haggling routine -RAK-
903 * @param player_ptr プレーヤーへの参照ポインタ
904 * @param o_ptr オブジェクトの構造体参照ポインタ
905 * @param price 最終価格を返す参照ポインタ
906 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
907 * Return TRUE if purchase is NOT successful
909 static bool purchase_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price)
911 s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
912 s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
913 int noneed = noneedtobargain(final_ask);
915 concptr pmt = _("提示価格", "Asking");
916 if (noneed || !manual_haggle)
920 msg_print(_("結局この金額にまとまった。", "You eventually agree upon the price."));
925 msg_print(_("すんなりとこの金額にまとまった。", "You quickly agree upon the price."));
927 final_ask += final_ask / 10;
931 pmt = _("最終提示価格", "Final Offer");
935 cur_ask *= o_ptr->number;
936 final_ask *= o_ptr->number;
937 s32b min_per = ot_ptr->haggle_per;
938 s32b max_per = min_per * 3;
939 s32b last_offer = object_value(o_ptr) * o_ptr->number;
940 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
941 if (last_offer <= 0) last_offer = 1;
951 bool loop_flag = TRUE;
953 while (!flag && loop_flag)
956 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
957 put_str(out_val, 1, 0);
958 cancel = receive_offer(_("提示する金額? ", "What do you offer? "), &offer, last_offer, 1, cur_ask, final);
963 else if (offer > cur_ask)
968 else if (offer == cur_ask)
981 s32b x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
984 if (haggle_insults())
990 else if (x1 > max_per)
993 if (x1 < max_per) x1 = max_per;
996 s32b x2 = rand_range(x1 - 2, x1 + 2);
997 s32b x3 = ((cur_ask - offer) * x2 / 100L) + 1;
1001 if (cur_ask < final_ask)
1004 cur_ask = final_ask;
1005 pmt = _("最終提示価格", "What do you offer? ");
1009 (void)(increase_insults());
1014 else if (offer >= cur_ask)
1024 (void)sprintf(out_val, _("前回の提示金額: $%ld", "Your last offer: %ld"), (long)last_offer);
1025 put_str(out_val, 1, 39);
1026 say_comment_2(cur_ask, annoyed);
1029 if (cancel) return TRUE;
1031 updatebargain(*price, final_ask, o_ptr->number);
1037 * @brief プレイヤーが売却する時の値切り処理メインルーチン /
1038 * Haggling routine -RAK-
1039 * @param player_ptr プレーヤーへの参照ポインタ
1040 * @param o_ptr オブジェクトの構造体参照ポインタ
1041 * @param price 最終価格を返す参照ポインタ
1042 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
1043 * Return TRUE if purchase is NOT successful
1045 static bool sell_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price)
1047 s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, TRUE);
1048 s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, TRUE);
1049 int noneed = noneedtobargain(final_ask);
1050 s32b purse = (s32b)(ot_ptr->max_cost);
1052 concptr pmt = _("提示金額", "Offer");
1053 if (noneed || !manual_haggle || (final_ask >= purse))
1055 if (!manual_haggle && !noneed)
1057 final_ask -= final_ask / 10;
1060 if (final_ask >= purse)
1062 msg_print(_("即座にこの金額にまとまった。", "You instantly agree upon the price."));
1068 msg_print(_("結局この金額にまとまった。", "You eventually agree upon the price."));
1073 msg_print(_("すんなりとこの金額にまとまった。", "You quickly agree upon the price."));
1077 cur_ask = final_ask;
1079 pmt = _("最終提示金額", "Final Offer");
1082 cur_ask *= o_ptr->number;
1083 final_ask *= o_ptr->number;
1085 s32b min_per = ot_ptr->haggle_per;
1086 s32b max_per = min_per * 3;
1087 s32b last_offer = object_value(o_ptr) * o_ptr->number;
1088 last_offer = last_offer * ot_ptr->max_inflate / 100L;
1094 bool cancel = FALSE;
1103 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
1104 put_str(out_val, 1, 0);
1105 cancel = receive_offer(_("提示する価格? ", "What price do you ask? "),
1106 &offer, last_offer, -1, cur_ask, final);
1112 else if (offer < cur_ask)
1117 else if (offer == cur_ask)
1127 if (flag || !loop_flag) break;
1132 s32b x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
1135 if (haggle_insults())
1141 else if (x1 > max_per)
1144 if (x1 < max_per) x1 = max_per;
1147 s32b x2 = rand_range(x1 - 2, x1 + 2);
1148 s32b x3 = ((offer - cur_ask) * x2 / 100L) + 1;
1152 if (cur_ask > final_ask)
1154 cur_ask = final_ask;
1156 pmt = _("最終提示金額", "Final Offer");
1163 /* 追加 $0 で買い取られてしまうのを防止 By FIRST*/
1166 (void)(increase_insults());
1169 else if (offer <= cur_ask)
1179 (void)sprintf(out_val, _("前回の提示価格 $%ld", "Your last bid %ld"), (long)last_offer);
1180 put_str(out_val, 1, 39);
1181 say_comment_3(cur_ask, annoyed);
1184 if (cancel) return TRUE;
1186 updatebargain(*price, final_ask, o_ptr->number);
1192 * @brief 店からの購入処理のメインルーチン /
1193 * Buy an item from a store -RAK-
1194 * @param player_ptr プレーヤーへの参照ポインタ
1197 static void store_purchase(player_type *player_ptr)
1199 if (cur_store_num == STORE_MUSEUM)
1201 msg_print(_("博物館から取り出すことはできません。", "Museum."));
1205 if (st_ptr->stock_num <= 0)
1207 if (cur_store_num == STORE_HOME)
1208 msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
1210 msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
1214 int i = (st_ptr->stock_num - store_top);
1215 if (i > store_bottom) i = store_bottom;
1219 /* ブラックマーケットの時は別のメッセージ */
1220 switch (cur_store_num)
1223 sprintf(out_val, "どのアイテムを取りますか? ");
1226 sprintf(out_val, "どれ? ");
1229 sprintf(out_val, "どの品物が欲しいんだい? ");
1233 if (cur_store_num == STORE_HOME)
1235 sprintf(out_val, "Which item do you want to take? ");
1239 sprintf(out_val, "Which item are you interested in? ");
1244 if (!get_stock(&item, out_val, 0, i - 1)) return;
1246 item = item + store_top;
1248 o_ptr = &st_ptr->stock[item];
1249 ITEM_NUMBER amt = 1;
1253 object_copy(j_ptr, o_ptr);
1256 * If a rod or wand, allocate total maximum timeouts or charges
1257 * between those purchased and left on the shelf.
1259 reduce_charges(j_ptr, o_ptr->number - amt);
1260 j_ptr->number = amt;
1261 if (!inven_carry_okay(j_ptr))
1263 msg_print(_("そんなにアイテムを持てない。", "You cannot carry that many different items."));
1267 PRICE best = price_item(player_ptr, j_ptr, ot_ptr->min_inflate, FALSE);
1268 if (o_ptr->number > 1)
1270 if ((cur_store_num != STORE_HOME) &&
1271 (o_ptr->ident & IDENT_FIXED))
1273 msg_format(_("一つにつき $%ldです。", "That costs %ld gold per item."), (long)(best));
1276 amt = get_quantity(NULL, o_ptr->number);
1277 if (amt <= 0) return;
1281 object_copy(j_ptr, o_ptr);
1284 * If a rod or wand, allocate total maximum timeouts or charges
1285 * between those purchased and left on the shelf.
1287 reduce_charges(j_ptr, o_ptr->number - amt);
1288 j_ptr->number = amt;
1289 if (!inven_carry_okay(j_ptr))
1291 msg_print(_("ザックにそのアイテムを入れる隙間がない。", "You cannot carry that many items."));
1296 COMMAND_CODE item_new;
1298 if (cur_store_num == STORE_HOME)
1300 bool combined_or_reordered;
1301 distribute_charges(o_ptr, j_ptr, amt);
1302 item_new = inven_carry(player_ptr, j_ptr);
1303 GAME_TEXT o_name[MAX_NLEN];
1304 object_desc(player_ptr, o_name, &player_ptr->inventory_list[item_new], 0);
1306 msg_format(_("%s(%c)を取った。", "You have %s (%c)."), o_name, index_to_label(item_new));
1307 handle_stuff(player_ptr);
1309 i = st_ptr->stock_num;
1310 store_item_increase(item, -amt);
1311 store_item_optimize(item);
1312 combined_or_reordered = combine_and_reorder_home(STORE_HOME);
1313 if (i == st_ptr->stock_num)
1315 if (combined_or_reordered) display_store_inventory(player_ptr);
1316 else display_entry(player_ptr, item);
1320 if (st_ptr->stock_num == 0) store_top = 0;
1321 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1322 display_store_inventory(player_ptr);
1324 chg_virtue(player_ptr, V_SACRIFICE, 1);
1330 if (o_ptr->ident & (IDENT_FIXED))
1333 price = (best * j_ptr->number);
1337 GAME_TEXT o_name[MAX_NLEN];
1338 object_desc(player_ptr, o_name, j_ptr, 0);
1339 msg_format(_("%s(%c)を購入する。", "Buying %s (%c)."), o_name, I2A(item));
1341 choice = purchase_haggle(player_ptr, j_ptr, &price);
1342 if (st_ptr->store_open >= current_world_ptr->game_turn) return;
1345 if (choice != 0) return;
1346 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
1347 if (player_ptr->au < price)
1349 msg_print(_("お金が足りません。", "You do not have enough gold."));
1353 say_comment_1(player_ptr);
1354 if (cur_store_num == STORE_BLACK)
1355 chg_virtue(player_ptr, V_JUSTICE, -1);
1356 if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
1357 chg_virtue(player_ptr, V_NATURE, -1);
1361 player_ptr->au -= price;
1362 store_prt_gold(player_ptr);
1363 object_aware(player_ptr, j_ptr);
1364 j_ptr->ident &= ~(IDENT_FIXED);
1365 GAME_TEXT o_name[MAX_NLEN];
1366 object_desc(player_ptr, o_name, j_ptr, 0);
1368 msg_format(_("%sを $%ldで購入しました。", "You bought %s for %ld gold."), o_name, (long)price);
1370 strcpy(record_o_name, o_name);
1371 record_turn = current_world_ptr->game_turn;
1373 if (record_buy) exe_write_diary(player_ptr, DIARY_BUY, 0, o_name);
1374 object_desc(player_ptr, o_name, o_ptr, OD_NAME_ONLY);
1375 if (record_rand_art && o_ptr->art_name)
1376 exe_write_diary(player_ptr, DIARY_ART, 0, o_name);
1378 j_ptr->inscription = 0;
1379 j_ptr->feeling = FEEL_NONE;
1380 j_ptr->ident &= ~(IDENT_STORE);
1381 item_new = inven_carry(player_ptr, j_ptr);
1383 object_desc(player_ptr, o_name, &player_ptr->inventory_list[item_new], 0);
1384 msg_format(_("%s(%c)を手に入れた。", "You have %s (%c)."), o_name, index_to_label(item_new));
1385 autopick_alter_item(player_ptr, item_new, FALSE);
1386 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1388 o_ptr->pval -= j_ptr->pval;
1391 handle_stuff(player_ptr);
1392 i = st_ptr->stock_num;
1393 store_item_increase(item, -amt);
1394 store_item_optimize(item);
1395 if (st_ptr->stock_num == 0)
1397 if (one_in_(STORE_SHUFFLE))
1400 msg_print(_("店主は引退した。", "The shopkeeper retires."));
1401 store_shuffle(player_ptr, cur_store_num);
1404 sprintf(buf, "%s (%s)",
1405 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
1406 put_str(buf, 3, 10);
1407 sprintf(buf, "%s (%ld)",
1408 (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
1413 msg_print(_("店主は新たな在庫を取り出した。", "The shopkeeper brings out some new stock."));
1416 for (i = 0; i < 10; i++)
1418 store_maint(player_ptr, player_ptr->town_num, cur_store_num);
1422 display_store_inventory(player_ptr);
1424 else if (st_ptr->stock_num != i)
1426 if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1427 display_store_inventory(player_ptr);
1431 display_entry(player_ptr, item);
1437 * @brief 店からの売却処理のメインルーチン /
1438 * Sell an item to the store (or home)
1439 * @param owner_ptr プレーヤーへの参照ポインタ
1442 static void store_sell(player_type *owner_ptr)
1445 if (cur_store_num == STORE_HOME)
1446 q = _("どのアイテムを置きますか? ", "Drop which item? ");
1447 else if (cur_store_num == STORE_MUSEUM)
1448 q = _("どのアイテムを寄贈しますか? ", "Give which item? ");
1450 q = _("どのアイテムを売りますか? ", "Sell which item? ");
1452 item_tester_hook = store_will_buy;
1454 /* 我が家でおかしなメッセージが出るオリジナルのバグを修正 */
1456 if (cur_store_num == STORE_HOME)
1458 s = _("置けるアイテムを持っていません。", "You don't have any item to drop.");
1460 else if (cur_store_num == STORE_MUSEUM)
1462 s = _("寄贈できるアイテムを持っていません。", "You don't have any item to give.");
1466 s = _("欲しい物がないですねえ。", "You have nothing that I want.");
1471 o_ptr = choose_object(owner_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1474 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
1476 msg_print(_("ふーむ、どうやらそれは呪われているようだね。", "Hmmm, it seems to be cursed."));
1481 if (o_ptr->number > 1)
1483 amt = get_quantity(NULL, o_ptr->number);
1484 if (amt <= 0) return;
1490 object_copy(q_ptr, o_ptr);
1491 q_ptr->number = amt;
1494 * Hack -- If a rod or wand, allocate total maximum
1495 * timeouts or charges to those being sold. -LM-
1497 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1499 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1502 GAME_TEXT o_name[MAX_NLEN];
1503 object_desc(owner_ptr, o_name, q_ptr, 0);
1505 /* Remove any inscription, feeling for stores */
1506 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
1508 q_ptr->inscription = 0;
1509 q_ptr->feeling = FEEL_NONE;
1512 /* Is there room in the store (or the home?) */
1513 if (!store_check_num(q_ptr))
1515 if (cur_store_num == STORE_HOME)
1516 msg_print(_("我が家にはもう置く場所がない。", "Your home is full."));
1518 else if (cur_store_num == STORE_MUSEUM)
1519 msg_print(_("博物館はもう満杯だ。", "Museum is full."));
1522 msg_print(_("すいませんが、店にはもう置く場所がありません。", "I have not the room in my store to keep it."));
1528 PRICE price, value, dummy;
1529 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
1531 msg_format(_("%s(%c)を売却する。", "Selling %s (%c)."), o_name, index_to_label(item));
1534 choice = sell_haggle(owner_ptr, q_ptr, &price);
1535 if (st_ptr->store_open >= current_world_ptr->game_turn) return;
1539 say_comment_1(owner_ptr);
1541 if (cur_store_num == STORE_BLACK)
1542 chg_virtue(owner_ptr, V_JUSTICE, -1);
1544 if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
1545 chg_virtue(owner_ptr, V_NATURE, 1);
1548 owner_ptr->au += price;
1549 store_prt_gold(owner_ptr);
1550 dummy = object_value(q_ptr) * q_ptr->number;
1552 identify_item(owner_ptr, o_ptr);
1554 object_copy(q_ptr, o_ptr);
1555 q_ptr->number = amt;
1556 q_ptr->ident |= IDENT_STORE;
1559 * Hack -- If a rod or wand, let the shopkeeper know just
1560 * how many charges he really paid for. -LM-
1562 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1564 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1567 value = object_value(q_ptr) * q_ptr->number;
1568 object_desc(owner_ptr, o_name, q_ptr, 0);
1569 msg_format(_("%sを $%ldで売却しました。", "You sold %s for %ld gold."), o_name, (long)price);
1571 if (record_sell) exe_write_diary(owner_ptr, DIARY_SELL, 0, o_name);
1573 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
1575 purchase_analyze(owner_ptr, price, value, dummy);
1579 * Hack -- Allocate charges between those wands or rods sold
1580 * and retained, unless all are being sold. -LM-
1582 distribute_charges(o_ptr, q_ptr, amt);
1584 inven_item_increase(owner_ptr, item, -amt);
1585 inven_item_describe(owner_ptr, item);
1586 if (o_ptr->number > 0)
1587 autopick_alter_item(owner_ptr, item, FALSE);
1589 inven_item_optimize(owner_ptr, item);
1590 handle_stuff(owner_ptr);
1591 int item_pos = store_carry(q_ptr);
1594 store_top = (item_pos / store_bottom) * store_bottom;
1595 display_store_inventory(owner_ptr);
1599 else if (cur_store_num == STORE_MUSEUM)
1601 char o2_name[MAX_NLEN];
1602 object_desc(owner_ptr, o2_name, q_ptr, OD_NAME_ONLY);
1604 if (-1 == store_check_num(q_ptr))
1606 msg_print(_("それと同じ品物は既に博物館にあるようです。", "The Museum already has one of those items."));
1610 msg_print(_("博物館に寄贈したものは取り出すことができません!!", "You cannot take back items which have been donated to the Museum!!"));
1613 if (!get_check(format(_("本当に%sを寄贈しますか?", "Really give %s to the Museum? "), o2_name))) return;
1615 identify_item(owner_ptr, q_ptr);
1616 q_ptr->ident |= IDENT_FULL_KNOWN;
1618 distribute_charges(o_ptr, q_ptr, amt);
1619 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
1622 vary_item(owner_ptr, item, -amt);
1623 handle_stuff(owner_ptr);
1625 int item_pos = home_carry(owner_ptr, q_ptr);
1628 store_top = (item_pos / store_bottom) * store_bottom;
1629 display_store_inventory(owner_ptr);
1634 distribute_charges(o_ptr, q_ptr, amt);
1635 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
1637 vary_item(owner_ptr, item, -amt);
1638 handle_stuff(owner_ptr);
1639 int item_pos = home_carry(owner_ptr, q_ptr);
1642 store_top = (item_pos / store_bottom) * store_bottom;
1643 display_store_inventory(owner_ptr);
1647 if ((choice == 0) && (item >= INVEN_RARM))
1649 calc_android_exp(owner_ptr);
1650 verify_equip_slot(owner_ptr, item);
1656 * @brief 店のアイテムを調べるコマンドのメインルーチン /
1657 * Examine an item in a store -JDL-
1660 static void store_examine(player_type *player_ptr)
1662 if (st_ptr->stock_num <= 0)
1664 if (cur_store_num == STORE_HOME)
1665 msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
1666 else if (cur_store_num == STORE_MUSEUM)
1667 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
1669 msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
1673 int i = (st_ptr->stock_num - store_top);
1674 if (i > store_bottom) i = store_bottom;
1677 sprintf(out_val, _("どれを調べますか?", "Which item do you want to examine? "));
1680 if (!get_stock(&item, out_val, 0, i - 1)) return;
1681 item = item + store_top;
1683 o_ptr = &st_ptr->stock[item];
1684 if (!OBJECT_IS_FULL_KNOWN(o_ptr))
1686 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1690 GAME_TEXT o_name[MAX_NLEN];
1691 object_desc(player_ptr, o_name, o_ptr, 0);
1692 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1694 if (!screen_object(player_ptr, o_ptr, SCROBJ_FORCE_DETAIL))
1695 msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1700 * @brief 博物館のアイテムを除去するコマンドのメインルーチン /
1701 * Remove an item from museum (Originally from TOband)
1702 * @param player_ptr プレーヤーへの参照ポインタ
1705 static void museum_remove_object(player_type *player_ptr)
1707 if (st_ptr->stock_num <= 0)
1709 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
1713 int i = st_ptr->stock_num - store_top;
1714 if (i > store_bottom) i = store_bottom;
1717 sprintf(out_val, _("どのアイテムの展示をやめさせますか?", "Which item do you want to order to remove? "));
1720 if (!get_stock(&item, out_val, 0, i - 1)) return;
1722 item = item + store_top;
1724 o_ptr = &st_ptr->stock[item];
1726 GAME_TEXT o_name[MAX_NLEN];
1727 object_desc(player_ptr, o_name, o_ptr, 0);
1729 msg_print(_("展示をやめさせたアイテムは二度と見ることはできません!", "Once removed from the Museum, an item will be gone forever!"));
1730 if (!get_check(format(_("本当に%sの展示をやめさせますか?", "Really order to remove %s from the Museum? "), o_name))) return;
1732 msg_format(_("%sの展示をやめさせた。", "You ordered to remove %s."), o_name);
1734 store_item_increase(item, -o_ptr->number);
1735 store_item_optimize(item);
1737 (void)combine_and_reorder_home(STORE_MUSEUM);
1738 if (st_ptr->stock_num == 0) store_top = 0;
1740 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1741 display_store_inventory(player_ptr);
1746 * Hack -- set this to leave the store
1748 static bool leave_store = FALSE;
1752 * @brief 店舗処理コマンド選択のメインルーチン /
1753 * Process a command in a store
1754 * @param client_ptr 顧客となるクリーチャーの参照ポインタ
1758 * Note that we must allow the use of a few "special" commands
1759 * in the stores which are not allowed in the dungeon, and we
1760 * must disable some commands which are allowed in the dungeon
1761 * but not in the stores, to prevent chaos.
1764 static void store_process_command(player_type *client_ptr)
1767 if (rogue_like_commands && command_cmd == 'l')
1772 switch (command_cmd)
1782 /* 1 ページ戻るコマンド: 我が家のページ数が多いので重宝するはず By BUG */
1783 if (st_ptr->stock_num <= store_bottom) {
1784 msg_print(_("これで全部です。", "Entire inventory is shown."));
1788 store_top -= store_bottom;
1790 store_top = ((st_ptr->stock_num - 1) / store_bottom) * store_bottom;
1791 if ((cur_store_num == STORE_HOME) && (powerup_home == FALSE))
1792 if (store_top >= store_bottom) store_top = store_bottom;
1793 display_store_inventory(client_ptr);
1800 if (st_ptr->stock_num <= store_bottom)
1802 msg_print(_("これで全部です。", "Entire inventory is shown."));
1806 store_top += store_bottom;
1808 * 隠しオプション(powerup_home)がセットされていないときは
1809 * 我が家では 2 ページまでしか表示しない
1811 if ((cur_store_num == STORE_HOME) &&
1812 (powerup_home == FALSE) &&
1813 (st_ptr->stock_num >= STORE_INVEN_MAX))
1815 if (store_top >= (STORE_INVEN_MAX - 1))
1822 if (store_top >= st_ptr->stock_num) store_top = 0;
1825 display_store_inventory(client_ptr);
1832 do_cmd_redraw(client_ptr);
1833 display_store(client_ptr);
1838 store_purchase(client_ptr);
1843 store_sell(client_ptr);
1848 store_examine(client_ptr);
1857 do_cmd_wield(client_ptr);
1862 do_cmd_takeoff(client_ptr);
1867 do_cmd_destroy(client_ptr);
1872 do_cmd_equip(client_ptr);
1877 do_cmd_inven(client_ptr);
1882 do_cmd_observe(client_ptr);
1887 toggle_inventory_equipment(client_ptr);
1892 if ((client_ptr->pclass == CLASS_MINDCRAFTER) ||
1893 (client_ptr->pclass == CLASS_BERSERKER) ||
1894 (client_ptr->pclass == CLASS_NINJA) ||
1895 (client_ptr->pclass == CLASS_MIRROR_MASTER)
1896 ) do_cmd_mind_browse(client_ptr);
1897 else if (client_ptr->pclass == CLASS_SMITH)
1898 do_cmd_kaji(client_ptr, TRUE);
1899 else if (client_ptr->pclass == CLASS_MAGIC_EATER)
1900 do_cmd_magic_eater(client_ptr, TRUE, FALSE);
1901 else if (client_ptr->pclass == CLASS_SNIPER)
1902 do_cmd_snipe_browse(client_ptr);
1903 else do_cmd_browse(client_ptr);
1908 do_cmd_inscribe(client_ptr);
1913 do_cmd_uninscribe(client_ptr);
1918 do_cmd_help(client_ptr);
1923 do_cmd_query_symbol(client_ptr);
1928 client_ptr->town_num = old_town_num;
1929 do_cmd_player_status(client_ptr);
1930 client_ptr->town_num = inner_town_num;
1931 display_store(client_ptr);
1941 client_ptr->town_num = old_town_num;
1942 do_cmd_pref(client_ptr);
1943 client_ptr->town_num = inner_town_num;
1948 client_ptr->town_num = old_town_num;
1949 do_cmd_macros(client_ptr);
1950 client_ptr->town_num = inner_town_num;
1955 client_ptr->town_num = old_town_num;
1956 do_cmd_visuals(client_ptr);
1957 client_ptr->town_num = inner_town_num;
1962 client_ptr->town_num = old_town_num;
1963 do_cmd_colors(client_ptr);
1964 client_ptr->town_num = inner_town_num;
1970 (void)combine_and_reorder_home(STORE_HOME);
1971 do_cmd_redraw(client_ptr);
1972 display_store(client_ptr);
1987 do_cmd_feeling(client_ptr);
1992 do_cmd_message_one();
2002 do_cmd_diary(client_ptr);
2007 do_cmd_knowledge(client_ptr);
2012 do_cmd_load_screen();
2017 do_cmd_save_screen(client_ptr);
2022 if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
2024 museum_remove_object(client_ptr);
2028 msg_print(_("そのコマンドは店の中では使えません。", "That command does not work in stores."));
2038 * @brief 店舗処理全体のメインルーチン /
2039 * Enter a store, and interact with it. *
2040 * @param player_ptr プレーヤーへの参照ポインタ
2044 * Note that we use the standard "request_command()" function
2045 * to get a command, allowing us to use "command_arg" and all
2046 * command macros and other nifty stuff, but we use the special
2047 * "shopping" argument, to force certain commands to be converted
2048 * into other commands, normally, we convert "p" (pray) and "m"
2049 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
2052 void do_cmd_store(player_type *player_ptr)
2054 if (player_ptr->wild_mode) return;
2056 Term_get_size(&w, &h);
2058 xtra_stock = MIN(14 + 26, ((h > 24) ? (h - 24) : 0));
2059 store_bottom = MIN_STOCK + xtra_stock;
2062 g_ptr = &player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x];
2064 if (!cave_have_flag_grid(g_ptr, FF_STORE))
2066 msg_print(_("ここには店がありません。", "You see no store here."));
2070 int which = f_info[g_ptr->feat].subtype;
2071 old_town_num = player_ptr->town_num;
2072 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) player_ptr->town_num = 1;
2073 if (player_ptr->current_floor_ptr->dun_level) player_ptr->town_num = NO_TOWN;
2074 inner_town_num = player_ptr->town_num;
2076 if ((town_info[player_ptr->town_num].store[which].store_open >= current_world_ptr->game_turn) ||
2079 msg_print(_("ドアに鍵がかかっている。", "The doors are locked."));
2080 player_ptr->town_num = old_town_num;
2084 int maintain_num = (current_world_ptr->game_turn - town_info[player_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
2085 if (maintain_num > 10)
2089 for (int i = 0; i < maintain_num; i++)
2090 store_maint(player_ptr, player_ptr->town_num, which);
2092 town_info[player_ptr->town_num].store[which].last_visit = current_world_ptr->game_turn;
2095 forget_lite(player_ptr->current_floor_ptr);
2096 forget_view(player_ptr->current_floor_ptr);
2097 current_world_ptr->character_icky = TRUE;
2101 get_com_no_macros = TRUE;
2102 cur_store_num = which;
2103 cur_store_feat = g_ptr->feat;
2104 st_ptr = &town_info[player_ptr->town_num].store[cur_store_num];
2105 ot_ptr = &owners[cur_store_num][st_ptr->owner];
2107 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
2108 display_store(player_ptr);
2109 leave_store = FALSE;
2111 while (!leave_store)
2114 clear_from(20 + xtra_stock);
2115 prt(_(" ESC) 建物から出る", " ESC) Exit from Building."), 21 + xtra_stock, 0);
2116 if (st_ptr->stock_num > store_bottom)
2118 prt(_(" -)前ページ", " -) Previous page"), 22 + xtra_stock, 0);
2119 prt(_(" スペース) 次ページ", " SPACE) Next page"), 23 + xtra_stock, 0);
2122 if (cur_store_num == STORE_HOME)
2124 prt(_("g) アイテムを取る", "g) Get an item."), 21 + xtra_stock, 27);
2125 prt(_("d) アイテムを置く", "d) Drop an item."), 22 + xtra_stock, 27);
2126 prt(_("x) 家のアイテムを調べる", "x) eXamine an item in the home."), 23 + xtra_stock, 27);
2128 else if (cur_store_num == STORE_MUSEUM)
2130 prt(_("d) アイテムを置く", "d) Drop an item."), 21 + xtra_stock, 27);
2131 prt(_("r) アイテムの展示をやめる", "r) order to Remove an item."), 22 + xtra_stock, 27);
2132 prt(_("x) 博物館のアイテムを調べる", "x) eXamine an item in the museum."), 23 + xtra_stock, 27);
2136 prt(_("p) 商品を買う", "p) Purchase an item."), 21 + xtra_stock, 30);
2137 prt(_("s) アイテムを売る", "s) Sell an item."), 22 + xtra_stock, 30);
2138 prt(_("x) 商品を調べる", "x) eXamine an item in the shop"), 23 + xtra_stock, 30);
2141 prt(_("i/e) 持ち物/装備の一覧", "i/e) Inventry/Equipment list"), 21 + xtra_stock, 56);
2142 if (rogue_like_commands)
2144 prt(_("w/T) 装備する/はずす", "w/T) Wear/Take off equipment"), 22 + xtra_stock, 56);
2148 prt(_("w/t) 装備する/はずす", "w/t) Wear/Take off equipment"), 22 + xtra_stock, 56);
2151 prt(_("コマンド:", "You may: "), 20 + xtra_stock, 0);
2152 request_command(player_ptr, TRUE);
2153 store_process_command(player_ptr);
2156 * Hack -- To redraw missiles damage and prices in store
2157 * If player's charisma changes, or if player changes a bow, PU_BONUS is set
2159 bool need_redraw_store_inv = (player_ptr->update & PU_BONUS) ? TRUE : FALSE;
2160 current_world_ptr->character_icky = TRUE;
2161 handle_stuff(player_ptr);
2162 if (player_ptr->inventory_list[INVEN_PACK].k_idx)
2164 INVENTORY_IDX item = INVEN_PACK;
2165 object_type *o_ptr = &player_ptr->inventory_list[item];
2166 if (cur_store_num != STORE_HOME)
2168 if (cur_store_num == STORE_MUSEUM)
2169 msg_print(_("ザックからアイテムがあふれそうなので、あわてて博物館から出た...", "Your pack is so full that you flee the Museum..."));
2171 msg_print(_("ザックからアイテムがあふれそうなので、あわてて店から出た...", "Your pack is so full that you flee the store..."));
2175 else if (!store_check_num(o_ptr))
2177 msg_print(_("ザックからアイテムがあふれそうなので、あわてて家から出た...", "Your pack is so full that you flee your home..."));
2185 GAME_TEXT o_name[MAX_NLEN];
2186 msg_print(_("ザックからアイテムがあふれてしまった!", "Your pack overflows!"));
2188 object_copy(q_ptr, o_ptr);
2189 object_desc(player_ptr, o_name, q_ptr, 0);
2190 msg_format(_("%sが落ちた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
2191 vary_item(player_ptr, item, -255);
2192 handle_stuff(player_ptr);
2194 item_pos = home_carry(player_ptr, q_ptr);
2197 store_top = (item_pos / store_bottom) * store_bottom;
2198 display_store_inventory(player_ptr);
2203 if (need_redraw_store_inv) display_store_inventory(player_ptr);
2205 if (st_ptr->store_open >= current_world_ptr->game_turn) leave_store = TRUE;
2208 select_floor_music(player_ptr);
2209 player_ptr->town_num = old_town_num;
2210 take_turn(player_ptr, 100);
2211 current_world_ptr->character_icky = FALSE;
2213 command_see = FALSE;
2214 get_com_no_macros = FALSE;
2219 player_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2220 player_ptr->update |= (PU_MONSTERS);
2221 player_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
2222 player_ptr->redraw |= (PR_MAP);
2223 player_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2228 * @brief 現在の町の店主を交代させる /
2229 * Shuffle one of the stores.
2230 * @param which 店舗種類のID
2233 void store_shuffle(player_type *player_ptr, int which)
2235 if (which == STORE_HOME) return;
2236 if (which == STORE_MUSEUM) return;
2238 cur_store_num = which;
2239 st_ptr = &town_info[player_ptr->town_num].store[cur_store_num];
2240 int j = st_ptr->owner;
2243 st_ptr->owner = (byte)randint0(MAX_OWNERS);
2244 if (j == st_ptr->owner) continue;
2246 for (i = 1; i < max_towns; i++)
2248 if (i == player_ptr->town_num) continue;
2249 if (st_ptr->owner == town_info[i].store[cur_store_num].owner) break;
2252 if (i == max_towns) break;
2255 ot_ptr = &owners[cur_store_num][st_ptr->owner];
2256 st_ptr->insult_cur = 0;
2257 st_ptr->store_open = 0;
2258 st_ptr->good_buy = 0;
2259 st_ptr->bad_buy = 0;
2260 for (int i = 0; i < st_ptr->stock_num; i++)
2263 o_ptr = &st_ptr->stock[i];
2264 if (object_is_artifact(o_ptr)) continue;
2266 o_ptr->discount = 50;
2267 o_ptr->ident &= ~(IDENT_FIXED);
2268 o_ptr->inscription = quark_add(_("売出中", "on sale"));
2274 * @brief 店の品揃えを変化させる /
2275 * Maintain the inventory at the stores.
2276 * @param player_ptr プレーヤーへの参照ポインタ
2277 * @param town_num 町のID
2278 * @param store_num 店舗種類のID
2281 void store_maint(player_type *player_ptr, int town_num, int store_num)
2283 cur_store_num = store_num;
2284 if (store_num == STORE_HOME) return;
2285 if (store_num == STORE_MUSEUM) return;
2287 st_ptr = &town_info[town_num].store[store_num];
2288 ot_ptr = &owners[store_num][st_ptr->owner];
2289 st_ptr->insult_cur = 0;
2290 if (store_num == STORE_BLACK)
2292 for (INVENTORY_IDX j = st_ptr->stock_num - 1; j >= 0; j--)
2294 object_type *o_ptr = &st_ptr->stock[j];
2295 if (black_market_crap(player_ptr, o_ptr))
2297 store_item_increase(j, 0 - o_ptr->number);
2298 store_item_optimize(j);
2303 INVENTORY_IDX j = st_ptr->stock_num;
2304 j = j - randint1(STORE_TURNOVER);
2305 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
2306 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
2309 while (st_ptr->stock_num > j)
2312 j = st_ptr->stock_num;
2313 j = j + randint1(STORE_TURNOVER);
2314 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
2315 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
2316 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
2318 while (st_ptr->stock_num < j) store_create(player_ptr, black_market_crap);
2323 * @brief 店舗情報を初期化する /
2324 * Initialize the stores
2325 * @param town_num 町のID
2326 * @param store_num 店舗種類のID
2329 void store_init(int town_num, int store_num)
2331 cur_store_num = store_num;
2332 st_ptr = &town_info[town_num].store[store_num];
2335 st_ptr->owner = (byte)randint0(MAX_OWNERS);
2337 for (i = 1; i < max_towns; i++)
2339 if (i == town_num) continue;
2340 if (st_ptr->owner == town_info[i].store[store_num].owner) break;
2343 if (i == max_towns) break;
2346 ot_ptr = &owners[store_num][st_ptr->owner];
2348 st_ptr->store_open = 0;
2349 st_ptr->insult_cur = 0;
2350 st_ptr->good_buy = 0;
2351 st_ptr->bad_buy = 0;
2352 st_ptr->stock_num = 0;
2353 st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
2354 for (int k = 0; k < st_ptr->stock_size; k++)
2356 object_wipe(&st_ptr->stock[k]);