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"
26 #include "io/write-diary.h"
27 #include "cmd/cmd-basic.h"
28 #include "cmd/cmd-diary.h"
29 #include "cmd/cmd-draw.h"
30 #include "cmd/cmd-dump.h"
31 #include "cmd/cmd-help.h"
32 #include "cmd/cmd-item.h"
33 #include "cmd/cmd-macro.h"
34 #include "cmd/cmd-smith.h"
35 #include "cmd/cmd-visuals.h"
36 #include "cmd/cmd-zapwand.h"
37 #include "cmd/cmd-magiceat.h"
39 #include "market/store.h"
41 #include "cmd-spell.h"
43 #include "player-status.h"
44 #include "player-class.h"
45 #include "player-inventory.h"
46 #include "object-flavor.h"
47 #include "object-hook.h"
48 #include "floor-events.h"
51 #include "player-effects.h"
52 #include "player/race-info-table.h"
55 #include "objectkind.h"
57 #include "floor-town.h"
59 #include "view-mainwindow.h"
64 static int store_top = 0;
65 static int store_bottom = 0;
66 static int xtra_stock = 0;
67 static const owner_type *ot_ptr = NULL;
68 static s16b old_town_num = 0;
69 static s16b inner_town_num = 0;
72 * We store the current "store feat" here so everyone can access it
74 static int cur_store_feat;
77 * @brief 店舗価格を決定する. 無料にはならない /
78 * Determine the price of an item (qty one) in a store.
79 * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
81 * @param flip TRUEならば店主にとっての買取価格、FALSEなら売出価格を計算
85 * This function takes into account the player's charisma, and the
86 * shop-keepers friendliness, and the shop-keeper's base greed, but
87 * never lets a shop-keeper lose money in a transaction.
88 * The "greed" value should exceed 100 when the player is "buying" the
89 * item, and should be less than 100 when the player is "selling" it.
90 * Hack -- the black market always charges twice as much as it should.
91 * Charisma adjustment runs from 80 to 130
92 * Racial adjustment runs from 95 to 130
93 * Since greed/charisma/racial adjustments are centered at 100, we need
94 * to adjust (by 200) to extract a usable multiplier. Note that the
95 * "greed" value is always something (?).
98 static PRICE price_item(player_type *player_ptr, object_type *o_ptr, int greed, bool flip)
100 PRICE price = object_value(o_ptr);
101 if (price <= 0) return (0L);
103 int factor = rgold_adj[ot_ptr->owner_race][player_ptr->prace];
104 factor += adj_chr_gold[player_ptr->stat_ind[A_CHR]];
108 adjust = 100 + (300 - (greed + factor));
109 if (adjust > 100) adjust = 100;
110 if (cur_store_num == STORE_BLACK)
113 price = (price * adjust + 50L) / 100L;
117 adjust = 100 + ((greed + factor) - 300);
118 if (adjust < 100) adjust = 100;
119 if (cur_store_num == STORE_BLACK)
122 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
125 if (price <= 0L) return (1L);
131 * @brief 店舗に品を置くスペースがあるかどうかの判定を返す /
132 * Check to see if the shop will be carrying too many objects -RAK-
133 * @param o_ptr 店舗に置きたいオブジェクト構造体の参照ポインタ
134 * @return 置き場がないなら0、重ね合わせできるアイテムがあるなら-1、スペースがあるなら1を返す。
137 * Note that the shop, just like a player, will not accept things
138 * it cannot hold. Before, one could "nuke" potions this way.
139 * Return value is now int:
141 * -1 : Can be combined to existing slot.
142 * 1 : Cannot be combined but there are empty spaces.
145 static int store_check_num(object_type *o_ptr)
148 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
150 bool old_stack_force_notes = stack_force_notes;
151 bool old_stack_force_costs = stack_force_costs;
153 if (cur_store_num != STORE_HOME)
155 stack_force_notes = FALSE;
156 stack_force_costs = FALSE;
159 for (int i = 0; i < st_ptr->stock_num; i++)
161 j_ptr = &st_ptr->stock[i];
162 if (object_similar(j_ptr, o_ptr))
164 if (cur_store_num != STORE_HOME)
166 stack_force_notes = old_stack_force_notes;
167 stack_force_costs = old_stack_force_costs;
174 if (cur_store_num != STORE_HOME)
176 stack_force_notes = old_stack_force_notes;
177 stack_force_costs = old_stack_force_costs;
182 for (int i = 0; i < st_ptr->stock_num; i++)
184 j_ptr = &st_ptr->stock[i];
185 if (store_object_similar(j_ptr, o_ptr)) return -1;
189 /* Free space is always usable */
191 * オプション powerup_home が設定されていると
194 if ((cur_store_num == STORE_HOME) && (powerup_home == FALSE))
196 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10))
203 if (st_ptr->stock_num < st_ptr->stock_size)
214 * @brief 現在の町の指定された店舗のアイテムを整理する /
215 * Combine and reorder items in store.
216 * @param store_num 店舗ID
217 * @return 実際に整理が行われたならばTRUEを返す。
219 bool combine_and_reorder_home(int store_num)
221 store_type *old_st_ptr = st_ptr;
222 st_ptr = &town_info[1].store[store_num];
224 if (store_num != STORE_HOME)
226 stack_force_notes = FALSE;
227 stack_force_costs = FALSE;
230 bool combined = TRUE;
234 for (int i = st_ptr->stock_num - 1; i > 0; i--)
237 o_ptr = &st_ptr->stock[i];
238 if (!o_ptr->k_idx) continue;
239 for (int j = 0; j < i; j++)
242 j_ptr = &st_ptr->stock[j];
243 if (!j_ptr->k_idx) continue;
246 * Get maximum number of the stack if these
247 * are similar, get zero otherwise.
249 int max_num = object_similar_part(j_ptr, o_ptr);
250 if (max_num == 0 || j_ptr->number >= max_num) continue;
252 if (o_ptr->number + j_ptr->number <= max_num)
254 object_absorb(j_ptr, o_ptr);
257 for (k = i; k < st_ptr->stock_num; k++)
259 st_ptr->stock[k] = st_ptr->stock[k + 1];
262 object_wipe(&st_ptr->stock[k]);
267 ITEM_NUMBER old_num = o_ptr->number;
268 ITEM_NUMBER remain = j_ptr->number + o_ptr->number - max_num;
269 object_absorb(j_ptr, o_ptr);
270 o_ptr->number = remain;
271 if (o_ptr->tval == TV_ROD)
273 o_ptr->pval = o_ptr->pval * remain / old_num;
274 o_ptr->timeout = o_ptr->timeout * remain / old_num;
276 else if (o_ptr->tval == TV_WAND)
278 o_ptr->pval = o_ptr->pval * remain / old_num;
289 for (int i = 0; i < st_ptr->stock_num; i++)
292 o_ptr = &st_ptr->stock[i];
293 if (!o_ptr->k_idx) continue;
295 s32b o_value = object_value(o_ptr);
297 for (j = 0; j < st_ptr->stock_num; j++)
299 if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
302 if (j >= i) continue;
308 object_copy(j_ptr, &st_ptr->stock[i]);
309 for (int k = i; k > j; k--)
311 object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
314 object_copy(&st_ptr->stock[j], j_ptr);
318 bool old_stack_force_notes = stack_force_notes;
319 bool old_stack_force_costs = stack_force_costs;
320 if (store_num != STORE_HOME)
322 stack_force_notes = old_stack_force_notes;
323 stack_force_costs = old_stack_force_costs;
331 * @brief 我が家にオブジェクトを加える /
332 * Add the item "o_ptr" to the inventory of the "Home"
333 * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
337 * In all cases, return the slot (or -1) where the object was placed
338 * Note that this is a hacked up version of "inven_carry()".
339 * Also note that it may not correctly "adapt" to "knowledge" bacoming
340 * known, the player may have to pick stuff up and drop it again.
343 static int home_carry(player_type *player_ptr, object_type *o_ptr)
345 if (cur_store_num != STORE_HOME)
347 stack_force_notes = FALSE;
348 stack_force_costs = FALSE;
351 bool old_stack_force_notes = stack_force_notes;
352 bool old_stack_force_costs = stack_force_costs;
353 for (int slot = 0; slot < st_ptr->stock_num; slot++)
356 j_ptr = &st_ptr->stock[slot];
357 if (object_similar(j_ptr, o_ptr))
359 object_absorb(j_ptr, o_ptr);
360 if (cur_store_num != STORE_HOME)
362 stack_force_notes = old_stack_force_notes;
363 stack_force_costs = old_stack_force_costs;
370 if (cur_store_num != STORE_HOME)
372 stack_force_notes = old_stack_force_notes;
373 stack_force_costs = old_stack_force_costs;
378 * 隠し機能: オプション powerup_home が設定されていると
381 if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE))
383 if (st_ptr->stock_num >= st_ptr->stock_size)
390 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10))
396 PRICE value = object_value(o_ptr);
398 for (slot = 0; slot < st_ptr->stock_num; slot++)
400 if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
403 for (int i = st_ptr->stock_num; i > slot; i--)
405 st_ptr->stock[i] = st_ptr->stock[i - 1];
409 st_ptr->stock[slot] = *o_ptr;
410 chg_virtue(player_ptr, V_SACRIFICE, -1);
411 (void)combine_and_reorder_home(cur_store_num);
417 * @brief 店舗の割引対象外にするかどうかを判定 /
418 * Eliminate need to bargain if player has haggled well in the past
419 * @param minprice アイテムの最低販売価格
420 * @return 割引を禁止するならTRUEを返す。
422 static bool noneedtobargain(PRICE minprice)
424 PRICE good = st_ptr->good_buy;
425 PRICE bad = st_ptr->bad_buy;
426 if (minprice < 10L) return TRUE;
427 if (good == MAX_SHORT) return TRUE;
428 if (good > ((3 * bad) + (5 + (minprice / 50)))) return TRUE;
435 * @brief 店主の持つプレイヤーに対する売買の良し悪し経験を記憶する /
436 * Update the bargain info
437 * @param price 実際の取引価格
438 * @param minprice 店主の提示した価格
442 static void updatebargain(PRICE price, PRICE minprice, int num)
444 if (!manual_haggle) return;
445 if ((minprice / num) < 10L) return;
446 if (price == minprice)
448 if (st_ptr->good_buy < MAX_SHORT)
455 if (st_ptr->bad_buy < MAX_SHORT)
464 * @brief 店の商品リストを再表示する /
465 * Re-displays a single store entry
466 * @param player_ptr プレーヤーへの参照ポインタ
470 static void display_entry(player_type *player_ptr, int pos)
473 o_ptr = &st_ptr->stock[pos];
474 int i = (pos % store_bottom);
476 /* Label it, clear the line --(-- */
478 (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
479 prt(out_val, i + 6, 0);
484 TERM_COLOR a = object_attr(o_ptr);
485 SYMBOL_CODE c = object_char(o_ptr);
487 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
488 if (use_bigtile) cur_col++;
493 /* Describe an item in the home */
495 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
498 if (show_weights) maxwid -= 10;
500 GAME_TEXT o_name[MAX_NLEN];
501 object_desc(player_ptr, o_name, o_ptr, 0);
502 o_name[maxwid] = '\0';
503 c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col);
506 WEIGHT wgt = o_ptr->weight;
507 sprintf(out_val, _("%3d.%1d kg", "%3d.%d lb"), _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
508 put_str(out_val, i + 6, _(67, 68));
515 if (show_weights) maxwid -= 7;
517 GAME_TEXT o_name[MAX_NLEN];
518 object_desc(player_ptr, o_name, o_ptr, 0);
519 o_name[maxwid] = '\0';
520 c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col);
524 int wgt = o_ptr->weight;
525 sprintf(out_val, "%3d.%1d", _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
526 put_str(out_val, i + 6, _(60, 61));
530 if (o_ptr->ident & (IDENT_FIXED))
532 x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
533 (void)sprintf(out_val, _("%9ld固", "%9ld F"), (long)x);
534 put_str(out_val, i + 6, 68);
540 x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
541 if (!noneedtobargain(x)) x += x / 10;
543 (void)sprintf(out_val, "%9ld ", (long)x);
544 put_str(out_val, i + 6, 68);
548 x = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
549 (void)sprintf(out_val, "%9ld ", (long)x);
550 put_str(out_val, i + 6, 68);
555 * @brief 店の商品リストを表示する /
556 * Displays a store's inventory -RAK-
557 * @param player_ptr プレーヤーへの参照ポインタ
560 * All prices are listed as "per individual object". -BEN-
562 static void display_store_inventory(player_type *player_ptr)
565 for (k = 0; k < store_bottom; k++)
567 if (store_top + k >= st_ptr->stock_num) break;
569 display_entry(player_ptr, store_top + k);
572 for (int i = k; i < store_bottom + 1; i++)
575 put_str(_(" ", " "), 5, _(20, 22));
576 if (st_ptr->stock_num > store_bottom)
578 prt(_("-続く-", "-more-"), k + 6, 3);
579 put_str(format(_("(%dページ) ", "(Page %d) "), store_top / store_bottom + 1), 5, _(20, 22));
582 if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM)
584 k = st_ptr->stock_size;
585 if (cur_store_num == STORE_HOME && !powerup_home) k /= 10;
587 put_str(format(_("アイテム数: %4d/%4d", "Objects: %4d/%4d"), st_ptr->stock_num, k), 19 + xtra_stock, _(27, 30));
593 * @brief プレイヤーの所持金を表示する /
594 * Displays players gold -RAK-
595 * @param player_ptr プレーヤーへの参照ポインタ
599 static void store_prt_gold(player_type *player_ptr)
601 prt(_("手持ちのお金: ", "Gold Remaining: "), 19 + xtra_stock, 53);
603 sprintf(out_val, "%9ld", (long)player_ptr->au);
604 prt(out_val, 19 + xtra_stock, 68);
609 * @brief 店舗情報全体を表示するメインルーチン /
610 * Displays store (after clearing screen) -RAK-
611 * @param player_ptr プレーヤーへの参照ポインタ
615 static void display_store(player_type *player_ptr)
618 if (cur_store_num == STORE_HOME)
620 put_str(_("我が家", "Your Home"), 3, 31);
621 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
624 put_str(_(" 重さ", "Weight"), 5, 70);
627 store_prt_gold(player_ptr);
628 display_store_inventory(player_ptr);
632 if (cur_store_num == STORE_MUSEUM)
634 put_str(_("博物館", "Museum"), 3, 31);
635 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
638 put_str(_(" 重さ", "Weight"), 5, 70);
641 store_prt_gold(player_ptr);
642 display_store_inventory(player_ptr);
646 concptr store_name = (f_name + f_info[cur_store_feat].name);
647 concptr owner_name = (ot_ptr->owner_name);
648 concptr race_name = race_info[ot_ptr->owner_race].title;
650 sprintf(buf, "%s (%s)", owner_name, race_name);
653 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
656 put_str(_("商品の一覧", "Item Description"), 5, 5);
659 put_str(_(" 重さ", "Weight"), 5, 60);
662 put_str(_(" 価格", "Price"), 5, 72);
663 store_prt_gold(player_ptr);
664 display_store_inventory(player_ptr);
669 * @brief 店舗からアイテムを選択する /
670 * Get the ID of a store item and return its value -RAK-
671 * @param com_val 選択IDを返す参照ポインタ
672 * @param pmt メッセージキャプション
675 * @return 実際に選択したらTRUE、キャンセルしたらFALSE
677 static int get_stock(COMMAND_CODE *com_val, concptr pmt, int i, int j)
679 if (repeat_pull(com_val) && (*com_val >= i) && (*com_val <= j))
687 char hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
690 (void)sprintf(out_val, "(%s:%c-%c, ESCで中断) %s",
691 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "アイテム" : "商品"),
694 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
701 if (!get_com(out_val, &command, FALSE)) break;
704 if (islower(command))
706 else if (isupper(command))
707 k = A2I(tolower(command)) + 26;
711 if ((k >= i) && (k <= j))
721 if (command == ESCAPE) return FALSE;
723 repeat_push(*com_val);
729 * @brief 店主の不満度を増やし、プレイヤーを締め出す判定と処理を行う /
730 * Increase the insult counter and get angry if too many -RAK-
731 * @return プレイヤーを締め出す場合TRUEを返す
733 static int increase_insults(void)
735 st_ptr->insult_cur++;
736 if (st_ptr->insult_cur <= ot_ptr->insult_max) return FALSE;
740 st_ptr->insult_cur = 0;
741 st_ptr->good_buy = 0;
743 st_ptr->store_open = current_world_ptr->game_turn + TURNS_PER_TICK * TOWN_DAWN / 8 + randint1(TURNS_PER_TICK*TOWN_DAWN / 8);
750 * @brief 店主の不満度を減らす /
751 * Decrease insults -RAK-
752 * @return プレイヤーを締め出す場合TRUEを返す
754 static void decrease_insults(void)
756 if (st_ptr->insult_cur) st_ptr->insult_cur--;
761 * @brief 店主の不満度が増えた場合のみのメッセージを表示する /
762 * Have insulted while haggling -RAK-
763 * @return プレイヤーを締め出す場合TRUEを返す
765 static int haggle_insults(void)
767 if (increase_insults()) return TRUE;
774 * Mega-Hack -- Enable "increments"
776 static bool allow_inc = FALSE;
779 * Mega-Hack -- Last "increment" during haggling
781 static s32b last_inc = 0L;
784 * @brief 交渉価格を確認と認証の是非を行う /
787 * @param poffer 別途価格提示をした場合の値を返す参照ポインタ
788 * @param price 現在の交渉価格
789 * @param final 最終確定価格ならばTRUE
790 * @return プレイヤーを締め出す場合TRUEを返す
792 static int get_haggle(concptr pmt, s32b *poffer, PRICE price, int final)
795 if (!allow_inc) last_inc = 0L;
799 sprintf(buf, _("%s [承諾] ", "%s [accept] "), pmt);
801 else if (last_inc < 0)
803 sprintf(buf, _("%s [-$%ld] ", "%s [-%ld] "), pmt, (long)(ABS(last_inc)));
805 else if (last_inc > 0)
807 sprintf(buf, _("%s [+$%ld] ", "%s [+%ld] "), pmt, (long)(ABS(last_inc)));
811 sprintf(buf, "%s ", pmt);
815 GAME_TEXT out_val[160];
823 * Ask the user for a response.
824 * Don't allow to use numpad as cursor key.
826 res = askfor_aux(out_val, 32, FALSE);
828 if (!res) return FALSE;
831 for (p = out_val; *p == ' '; p++) /* loop */;
842 if (allow_inc && last_inc)
848 msg_print(_("値がおかしいです。", "Invalid response."));
853 if ((*p == '+' || *p == '-'))
875 * @brief 店主がプレイヤーからの交渉価格を判断する /
876 * Receive an offer (from the player)
878 * @param poffer 店主からの交渉価格を返す参照ポインタ
879 * @param last_offer 現在の交渉価格
880 * @param factor 店主の価格基準倍率
881 * @param price アイテムの実価値
882 * @param final 最終価格確定ならばTRUE
883 * @return プレイヤーの価格に対して不服ならばTRUEを返す /
884 * Return TRUE if offer is NOT okay
886 static bool receive_offer(concptr pmt, s32b *poffer, s32b last_offer, int factor, PRICE price, int final)
890 if (!get_haggle(pmt, poffer, price, final)) return TRUE;
891 if (((*poffer) * factor) >= (last_offer * factor)) break;
892 if (haggle_insults()) return TRUE;
894 (*poffer) = last_offer;
902 * @brief プレイヤーが購入する時の値切り処理メインルーチン /
903 * Haggling routine -RAK-
904 * @param player_ptr プレーヤーへの参照ポインタ
905 * @param o_ptr オブジェクトの構造体参照ポインタ
906 * @param price 最終価格を返す参照ポインタ
907 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
908 * Return TRUE if purchase is NOT successful
910 static bool purchase_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price)
912 s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
913 s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
914 int noneed = noneedtobargain(final_ask);
916 concptr pmt = _("提示価格", "Asking");
917 if (noneed || !manual_haggle)
921 msg_print(_("結局この金額にまとまった。", "You eventually agree upon the price."));
926 msg_print(_("すんなりとこの金額にまとまった。", "You quickly agree upon the price."));
928 final_ask += final_ask / 10;
932 pmt = _("最終提示価格", "Final Offer");
936 cur_ask *= o_ptr->number;
937 final_ask *= o_ptr->number;
938 s32b min_per = ot_ptr->haggle_per;
939 s32b max_per = min_per * 3;
940 s32b last_offer = object_value(o_ptr) * o_ptr->number;
941 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
942 if (last_offer <= 0) last_offer = 1;
952 bool loop_flag = TRUE;
954 while (!flag && loop_flag)
957 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
958 put_str(out_val, 1, 0);
959 cancel = receive_offer(_("提示する金額? ", "What do you offer? "), &offer, last_offer, 1, cur_ask, final);
964 else if (offer > cur_ask)
969 else if (offer == cur_ask)
982 s32b x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
985 if (haggle_insults())
991 else if (x1 > max_per)
994 if (x1 < max_per) x1 = max_per;
997 s32b x2 = rand_range(x1 - 2, x1 + 2);
998 s32b x3 = ((cur_ask - offer) * x2 / 100L) + 1;
1002 if (cur_ask < final_ask)
1005 cur_ask = final_ask;
1006 pmt = _("最終提示価格", "What do you offer? ");
1010 (void)(increase_insults());
1015 else if (offer >= cur_ask)
1025 (void)sprintf(out_val, _("前回の提示金額: $%ld", "Your last offer: %ld"), (long)last_offer);
1026 put_str(out_val, 1, 39);
1027 say_comment_2(cur_ask, annoyed);
1030 if (cancel) return TRUE;
1032 updatebargain(*price, final_ask, o_ptr->number);
1038 * @brief プレイヤーが売却する時の値切り処理メインルーチン /
1039 * Haggling routine -RAK-
1040 * @param player_ptr プレーヤーへの参照ポインタ
1041 * @param o_ptr オブジェクトの構造体参照ポインタ
1042 * @param price 最終価格を返す参照ポインタ
1043 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
1044 * Return TRUE if purchase is NOT successful
1046 static bool sell_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price)
1048 s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, TRUE);
1049 s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, TRUE);
1050 int noneed = noneedtobargain(final_ask);
1051 s32b purse = (s32b)(ot_ptr->max_cost);
1053 concptr pmt = _("提示金額", "Offer");
1054 if (noneed || !manual_haggle || (final_ask >= purse))
1056 if (!manual_haggle && !noneed)
1058 final_ask -= final_ask / 10;
1061 if (final_ask >= purse)
1063 msg_print(_("即座にこの金額にまとまった。", "You instantly agree upon the price."));
1069 msg_print(_("結局この金額にまとまった。", "You eventually agree upon the price."));
1074 msg_print(_("すんなりとこの金額にまとまった。", "You quickly agree upon the price."));
1078 cur_ask = final_ask;
1080 pmt = _("最終提示金額", "Final Offer");
1083 cur_ask *= o_ptr->number;
1084 final_ask *= o_ptr->number;
1086 s32b min_per = ot_ptr->haggle_per;
1087 s32b max_per = min_per * 3;
1088 s32b last_offer = object_value(o_ptr) * o_ptr->number;
1089 last_offer = last_offer * ot_ptr->max_inflate / 100L;
1095 bool cancel = FALSE;
1104 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
1105 put_str(out_val, 1, 0);
1106 cancel = receive_offer(_("提示する価格? ", "What price do you ask? "),
1107 &offer, last_offer, -1, cur_ask, final);
1113 else if (offer < cur_ask)
1118 else if (offer == cur_ask)
1128 if (flag || !loop_flag) break;
1133 s32b x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
1136 if (haggle_insults())
1142 else if (x1 > max_per)
1145 if (x1 < max_per) x1 = max_per;
1148 s32b x2 = rand_range(x1 - 2, x1 + 2);
1149 s32b x3 = ((offer - cur_ask) * x2 / 100L) + 1;
1153 if (cur_ask > final_ask)
1155 cur_ask = final_ask;
1157 pmt = _("最終提示金額", "Final Offer");
1164 /* 追加 $0 で買い取られてしまうのを防止 By FIRST*/
1167 (void)(increase_insults());
1170 else if (offer <= cur_ask)
1180 (void)sprintf(out_val, _("前回の提示価格 $%ld", "Your last bid %ld"), (long)last_offer);
1181 put_str(out_val, 1, 39);
1182 say_comment_3(cur_ask, annoyed);
1185 if (cancel) return TRUE;
1187 updatebargain(*price, final_ask, o_ptr->number);
1193 * @brief 店からの購入処理のメインルーチン /
1194 * Buy an item from a store -RAK-
1195 * @param player_ptr プレーヤーへの参照ポインタ
1198 static void store_purchase(player_type *player_ptr)
1200 if (cur_store_num == STORE_MUSEUM)
1202 msg_print(_("博物館から取り出すことはできません。", "Museum."));
1206 if (st_ptr->stock_num <= 0)
1208 if (cur_store_num == STORE_HOME)
1209 msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
1211 msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
1215 int i = (st_ptr->stock_num - store_top);
1216 if (i > store_bottom) i = store_bottom;
1220 /* ブラックマーケットの時は別のメッセージ */
1221 switch (cur_store_num)
1224 sprintf(out_val, "どのアイテムを取りますか? ");
1227 sprintf(out_val, "どれ? ");
1230 sprintf(out_val, "どの品物が欲しいんだい? ");
1234 if (cur_store_num == STORE_HOME)
1236 sprintf(out_val, "Which item do you want to take? ");
1240 sprintf(out_val, "Which item are you interested in? ");
1245 if (!get_stock(&item, out_val, 0, i - 1)) return;
1247 item = item + store_top;
1249 o_ptr = &st_ptr->stock[item];
1250 ITEM_NUMBER amt = 1;
1254 object_copy(j_ptr, o_ptr);
1257 * If a rod or wand, allocate total maximum timeouts or charges
1258 * between those purchased and left on the shelf.
1260 reduce_charges(j_ptr, o_ptr->number - amt);
1261 j_ptr->number = amt;
1262 if (!inven_carry_okay(j_ptr))
1264 msg_print(_("そんなにアイテムを持てない。", "You cannot carry that many different items."));
1268 PRICE best = price_item(player_ptr, j_ptr, ot_ptr->min_inflate, FALSE);
1269 if (o_ptr->number > 1)
1271 if ((cur_store_num != STORE_HOME) &&
1272 (o_ptr->ident & IDENT_FIXED))
1274 msg_format(_("一つにつき $%ldです。", "That costs %ld gold per item."), (long)(best));
1277 amt = get_quantity(NULL, o_ptr->number);
1278 if (amt <= 0) return;
1282 object_copy(j_ptr, o_ptr);
1285 * If a rod or wand, allocate total maximum timeouts or charges
1286 * between those purchased and left on the shelf.
1288 reduce_charges(j_ptr, o_ptr->number - amt);
1289 j_ptr->number = amt;
1290 if (!inven_carry_okay(j_ptr))
1292 msg_print(_("ザックにそのアイテムを入れる隙間がない。", "You cannot carry that many items."));
1297 COMMAND_CODE item_new;
1299 if (cur_store_num == STORE_HOME)
1301 bool combined_or_reordered;
1302 distribute_charges(o_ptr, j_ptr, amt);
1303 item_new = inven_carry(player_ptr, j_ptr);
1304 GAME_TEXT o_name[MAX_NLEN];
1305 object_desc(player_ptr, o_name, &player_ptr->inventory_list[item_new], 0);
1307 msg_format(_("%s(%c)を取った。", "You have %s (%c)."), o_name, index_to_label(item_new));
1308 handle_stuff(player_ptr);
1310 i = st_ptr->stock_num;
1311 store_item_increase(item, -amt);
1312 store_item_optimize(item);
1313 combined_or_reordered = combine_and_reorder_home(STORE_HOME);
1314 if (i == st_ptr->stock_num)
1316 if (combined_or_reordered) display_store_inventory(player_ptr);
1317 else display_entry(player_ptr, item);
1321 if (st_ptr->stock_num == 0) store_top = 0;
1322 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1323 display_store_inventory(player_ptr);
1325 chg_virtue(player_ptr, V_SACRIFICE, 1);
1331 if (o_ptr->ident & (IDENT_FIXED))
1334 price = (best * j_ptr->number);
1338 GAME_TEXT o_name[MAX_NLEN];
1339 object_desc(player_ptr, o_name, j_ptr, 0);
1340 msg_format(_("%s(%c)を購入する。", "Buying %s (%c)."), o_name, I2A(item));
1342 choice = purchase_haggle(player_ptr, j_ptr, &price);
1343 if (st_ptr->store_open >= current_world_ptr->game_turn) return;
1346 if (choice != 0) return;
1347 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
1348 if (player_ptr->au < price)
1350 msg_print(_("お金が足りません。", "You do not have enough gold."));
1354 say_comment_1(player_ptr);
1355 if (cur_store_num == STORE_BLACK)
1356 chg_virtue(player_ptr, V_JUSTICE, -1);
1357 if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
1358 chg_virtue(player_ptr, V_NATURE, -1);
1362 player_ptr->au -= price;
1363 store_prt_gold(player_ptr);
1364 object_aware(player_ptr, j_ptr);
1365 j_ptr->ident &= ~(IDENT_FIXED);
1366 GAME_TEXT o_name[MAX_NLEN];
1367 object_desc(player_ptr, o_name, j_ptr, 0);
1369 msg_format(_("%sを $%ldで購入しました。", "You bought %s for %ld gold."), o_name, (long)price);
1371 strcpy(record_o_name, o_name);
1372 record_turn = current_world_ptr->game_turn;
1374 if (record_buy) exe_write_diary(player_ptr, DIARY_BUY, 0, o_name);
1375 object_desc(player_ptr, o_name, o_ptr, OD_NAME_ONLY);
1376 if (record_rand_art && o_ptr->art_name)
1377 exe_write_diary(player_ptr, DIARY_ART, 0, o_name);
1379 j_ptr->inscription = 0;
1380 j_ptr->feeling = FEEL_NONE;
1381 j_ptr->ident &= ~(IDENT_STORE);
1382 item_new = inven_carry(player_ptr, j_ptr);
1384 object_desc(player_ptr, o_name, &player_ptr->inventory_list[item_new], 0);
1385 msg_format(_("%s(%c)を手に入れた。", "You have %s (%c)."), o_name, index_to_label(item_new));
1386 autopick_alter_item(player_ptr, item_new, FALSE);
1387 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1389 o_ptr->pval -= j_ptr->pval;
1392 handle_stuff(player_ptr);
1393 i = st_ptr->stock_num;
1394 store_item_increase(item, -amt);
1395 store_item_optimize(item);
1396 if (st_ptr->stock_num == 0)
1398 if (one_in_(STORE_SHUFFLE))
1401 msg_print(_("店主は引退した。", "The shopkeeper retires."));
1402 store_shuffle(player_ptr, cur_store_num);
1405 sprintf(buf, "%s (%s)",
1406 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
1407 put_str(buf, 3, 10);
1408 sprintf(buf, "%s (%ld)",
1409 (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
1414 msg_print(_("店主は新たな在庫を取り出した。", "The shopkeeper brings out some new stock."));
1417 for (i = 0; i < 10; i++)
1419 store_maint(player_ptr, player_ptr->town_num, cur_store_num);
1423 display_store_inventory(player_ptr);
1425 else if (st_ptr->stock_num != i)
1427 if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1428 display_store_inventory(player_ptr);
1432 display_entry(player_ptr, item);
1438 * @brief 店からの売却処理のメインルーチン /
1439 * Sell an item to the store (or home)
1440 * @param owner_ptr プレーヤーへの参照ポインタ
1443 static void store_sell(player_type *owner_ptr)
1446 if (cur_store_num == STORE_HOME)
1447 q = _("どのアイテムを置きますか? ", "Drop which item? ");
1448 else if (cur_store_num == STORE_MUSEUM)
1449 q = _("どのアイテムを寄贈しますか? ", "Give which item? ");
1451 q = _("どのアイテムを売りますか? ", "Sell which item? ");
1453 item_tester_hook = store_will_buy;
1455 /* 我が家でおかしなメッセージが出るオリジナルのバグを修正 */
1457 if (cur_store_num == STORE_HOME)
1459 s = _("置けるアイテムを持っていません。", "You don't have any item to drop.");
1461 else if (cur_store_num == STORE_MUSEUM)
1463 s = _("寄贈できるアイテムを持っていません。", "You don't have any item to give.");
1467 s = _("欲しい物がないですねえ。", "You have nothing that I want.");
1472 o_ptr = choose_object(owner_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1475 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
1477 msg_print(_("ふーむ、どうやらそれは呪われているようだね。", "Hmmm, it seems to be cursed."));
1482 if (o_ptr->number > 1)
1484 amt = get_quantity(NULL, o_ptr->number);
1485 if (amt <= 0) return;
1491 object_copy(q_ptr, o_ptr);
1492 q_ptr->number = amt;
1495 * Hack -- If a rod or wand, allocate total maximum
1496 * timeouts or charges to those being sold. -LM-
1498 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1500 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1503 GAME_TEXT o_name[MAX_NLEN];
1504 object_desc(owner_ptr, o_name, q_ptr, 0);
1506 /* Remove any inscription, feeling for stores */
1507 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
1509 q_ptr->inscription = 0;
1510 q_ptr->feeling = FEEL_NONE;
1513 /* Is there room in the store (or the home?) */
1514 if (!store_check_num(q_ptr))
1516 if (cur_store_num == STORE_HOME)
1517 msg_print(_("我が家にはもう置く場所がない。", "Your home is full."));
1519 else if (cur_store_num == STORE_MUSEUM)
1520 msg_print(_("博物館はもう満杯だ。", "Museum is full."));
1523 msg_print(_("すいませんが、店にはもう置く場所がありません。", "I have not the room in my store to keep it."));
1529 PRICE price, value, dummy;
1530 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
1532 msg_format(_("%s(%c)を売却する。", "Selling %s (%c)."), o_name, index_to_label(item));
1535 choice = sell_haggle(owner_ptr, q_ptr, &price);
1536 if (st_ptr->store_open >= current_world_ptr->game_turn) return;
1540 say_comment_1(owner_ptr);
1542 if (cur_store_num == STORE_BLACK)
1543 chg_virtue(owner_ptr, V_JUSTICE, -1);
1545 if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
1546 chg_virtue(owner_ptr, V_NATURE, 1);
1549 owner_ptr->au += price;
1550 store_prt_gold(owner_ptr);
1551 dummy = object_value(q_ptr) * q_ptr->number;
1553 identify_item(owner_ptr, o_ptr);
1555 object_copy(q_ptr, o_ptr);
1556 q_ptr->number = amt;
1557 q_ptr->ident |= IDENT_STORE;
1560 * Hack -- If a rod or wand, let the shopkeeper know just
1561 * how many charges he really paid for. -LM-
1563 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1565 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1568 value = object_value(q_ptr) * q_ptr->number;
1569 object_desc(owner_ptr, o_name, q_ptr, 0);
1570 msg_format(_("%sを $%ldで売却しました。", "You sold %s for %ld gold."), o_name, (long)price);
1572 if (record_sell) exe_write_diary(owner_ptr, DIARY_SELL, 0, o_name);
1574 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
1576 purchase_analyze(owner_ptr, price, value, dummy);
1580 * Hack -- Allocate charges between those wands or rods sold
1581 * and retained, unless all are being sold. -LM-
1583 distribute_charges(o_ptr, q_ptr, amt);
1585 inven_item_increase(owner_ptr, item, -amt);
1586 inven_item_describe(owner_ptr, item);
1587 if (o_ptr->number > 0)
1588 autopick_alter_item(owner_ptr, item, FALSE);
1590 inven_item_optimize(owner_ptr, item);
1591 handle_stuff(owner_ptr);
1592 int item_pos = store_carry(q_ptr);
1595 store_top = (item_pos / store_bottom) * store_bottom;
1596 display_store_inventory(owner_ptr);
1600 else if (cur_store_num == STORE_MUSEUM)
1602 char o2_name[MAX_NLEN];
1603 object_desc(owner_ptr, o2_name, q_ptr, OD_NAME_ONLY);
1605 if (-1 == store_check_num(q_ptr))
1607 msg_print(_("それと同じ品物は既に博物館にあるようです。", "The Museum already has one of those items."));
1611 msg_print(_("博物館に寄贈したものは取り出すことができません!!", "You cannot take back items which have been donated to the Museum!!"));
1614 if (!get_check(format(_("本当に%sを寄贈しますか?", "Really give %s to the Museum? "), o2_name))) return;
1616 identify_item(owner_ptr, q_ptr);
1617 q_ptr->ident |= IDENT_FULL_KNOWN;
1619 distribute_charges(o_ptr, q_ptr, amt);
1620 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
1623 vary_item(owner_ptr, item, -amt);
1624 handle_stuff(owner_ptr);
1626 int item_pos = home_carry(owner_ptr, q_ptr);
1629 store_top = (item_pos / store_bottom) * store_bottom;
1630 display_store_inventory(owner_ptr);
1635 distribute_charges(o_ptr, q_ptr, amt);
1636 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
1638 vary_item(owner_ptr, item, -amt);
1639 handle_stuff(owner_ptr);
1640 int item_pos = home_carry(owner_ptr, q_ptr);
1643 store_top = (item_pos / store_bottom) * store_bottom;
1644 display_store_inventory(owner_ptr);
1648 if ((choice == 0) && (item >= INVEN_RARM))
1650 calc_android_exp(owner_ptr);
1651 verify_equip_slot(owner_ptr, item);
1657 * @brief 店のアイテムを調べるコマンドのメインルーチン /
1658 * Examine an item in a store -JDL-
1661 static void store_examine(player_type *player_ptr)
1663 if (st_ptr->stock_num <= 0)
1665 if (cur_store_num == STORE_HOME)
1666 msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
1667 else if (cur_store_num == STORE_MUSEUM)
1668 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
1670 msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
1674 int i = (st_ptr->stock_num - store_top);
1675 if (i > store_bottom) i = store_bottom;
1678 sprintf(out_val, _("どれを調べますか?", "Which item do you want to examine? "));
1681 if (!get_stock(&item, out_val, 0, i - 1)) return;
1682 item = item + store_top;
1684 o_ptr = &st_ptr->stock[item];
1685 if (!OBJECT_IS_FULL_KNOWN(o_ptr))
1687 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1691 GAME_TEXT o_name[MAX_NLEN];
1692 object_desc(player_ptr, o_name, o_ptr, 0);
1693 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1695 if (!screen_object(player_ptr, o_ptr, SCROBJ_FORCE_DETAIL))
1696 msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1701 * @brief 博物館のアイテムを除去するコマンドのメインルーチン /
1702 * Remove an item from museum (Originally from TOband)
1703 * @param player_ptr プレーヤーへの参照ポインタ
1706 static void museum_remove_object(player_type *player_ptr)
1708 if (st_ptr->stock_num <= 0)
1710 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
1714 int i = st_ptr->stock_num - store_top;
1715 if (i > store_bottom) i = store_bottom;
1718 sprintf(out_val, _("どのアイテムの展示をやめさせますか?", "Which item do you want to order to remove? "));
1721 if (!get_stock(&item, out_val, 0, i - 1)) return;
1723 item = item + store_top;
1725 o_ptr = &st_ptr->stock[item];
1727 GAME_TEXT o_name[MAX_NLEN];
1728 object_desc(player_ptr, o_name, o_ptr, 0);
1730 msg_print(_("展示をやめさせたアイテムは二度と見ることはできません!", "Once removed from the Museum, an item will be gone forever!"));
1731 if (!get_check(format(_("本当に%sの展示をやめさせますか?", "Really order to remove %s from the Museum? "), o_name))) return;
1733 msg_format(_("%sの展示をやめさせた。", "You ordered to remove %s."), o_name);
1735 store_item_increase(item, -o_ptr->number);
1736 store_item_optimize(item);
1738 (void)combine_and_reorder_home(STORE_MUSEUM);
1739 if (st_ptr->stock_num == 0) store_top = 0;
1741 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
1742 display_store_inventory(player_ptr);
1747 * Hack -- set this to leave the store
1749 static bool leave_store = FALSE;
1753 * @brief 店舗処理コマンド選択のメインルーチン /
1754 * Process a command in a store
1755 * @param client_ptr 顧客となるクリーチャーの参照ポインタ
1759 * Note that we must allow the use of a few "special" commands
1760 * in the stores which are not allowed in the dungeon, and we
1761 * must disable some commands which are allowed in the dungeon
1762 * but not in the stores, to prevent chaos.
1765 static void store_process_command(player_type *client_ptr)
1768 if (rogue_like_commands && command_cmd == 'l')
1773 switch (command_cmd)
1783 /* 1 ページ戻るコマンド: 我が家のページ数が多いので重宝するはず By BUG */
1784 if (st_ptr->stock_num <= store_bottom) {
1785 msg_print(_("これで全部です。", "Entire inventory is shown."));
1789 store_top -= store_bottom;
1791 store_top = ((st_ptr->stock_num - 1) / store_bottom) * store_bottom;
1792 if ((cur_store_num == STORE_HOME) && (powerup_home == FALSE))
1793 if (store_top >= store_bottom) store_top = store_bottom;
1794 display_store_inventory(client_ptr);
1801 if (st_ptr->stock_num <= store_bottom)
1803 msg_print(_("これで全部です。", "Entire inventory is shown."));
1807 store_top += store_bottom;
1809 * 隠しオプション(powerup_home)がセットされていないときは
1810 * 我が家では 2 ページまでしか表示しない
1812 if ((cur_store_num == STORE_HOME) &&
1813 (powerup_home == FALSE) &&
1814 (st_ptr->stock_num >= STORE_INVEN_MAX))
1816 if (store_top >= (STORE_INVEN_MAX - 1))
1823 if (store_top >= st_ptr->stock_num) store_top = 0;
1826 display_store_inventory(client_ptr);
1833 do_cmd_redraw(client_ptr);
1834 display_store(client_ptr);
1839 store_purchase(client_ptr);
1844 store_sell(client_ptr);
1849 store_examine(client_ptr);
1858 do_cmd_wield(client_ptr);
1863 do_cmd_takeoff(client_ptr);
1868 do_cmd_destroy(client_ptr);
1873 do_cmd_equip(client_ptr);
1878 do_cmd_inven(client_ptr);
1883 do_cmd_observe(client_ptr);
1888 toggle_inventory_equipment(client_ptr);
1893 if ((client_ptr->pclass == CLASS_MINDCRAFTER) ||
1894 (client_ptr->pclass == CLASS_BERSERKER) ||
1895 (client_ptr->pclass == CLASS_NINJA) ||
1896 (client_ptr->pclass == CLASS_MIRROR_MASTER)
1897 ) do_cmd_mind_browse(client_ptr);
1898 else if (client_ptr->pclass == CLASS_SMITH)
1899 do_cmd_kaji(client_ptr, TRUE);
1900 else if (client_ptr->pclass == CLASS_MAGIC_EATER)
1901 do_cmd_magic_eater(client_ptr, TRUE, FALSE);
1902 else if (client_ptr->pclass == CLASS_SNIPER)
1903 do_cmd_snipe_browse(client_ptr);
1904 else do_cmd_browse(client_ptr);
1909 do_cmd_inscribe(client_ptr);
1914 do_cmd_uninscribe(client_ptr);
1919 do_cmd_help(client_ptr);
1924 do_cmd_query_symbol(client_ptr);
1929 client_ptr->town_num = old_town_num;
1930 do_cmd_player_status(client_ptr);
1931 client_ptr->town_num = inner_town_num;
1932 display_store(client_ptr);
1942 client_ptr->town_num = old_town_num;
1943 do_cmd_pref(client_ptr);
1944 client_ptr->town_num = inner_town_num;
1949 client_ptr->town_num = old_town_num;
1950 do_cmd_macros(client_ptr);
1951 client_ptr->town_num = inner_town_num;
1956 client_ptr->town_num = old_town_num;
1957 do_cmd_visuals(client_ptr);
1958 client_ptr->town_num = inner_town_num;
1963 client_ptr->town_num = old_town_num;
1964 do_cmd_colors(client_ptr);
1965 client_ptr->town_num = inner_town_num;
1971 (void)combine_and_reorder_home(STORE_HOME);
1972 do_cmd_redraw(client_ptr);
1973 display_store(client_ptr);
1988 do_cmd_feeling(client_ptr);
1993 do_cmd_message_one();
2003 do_cmd_diary(client_ptr);
2008 do_cmd_knowledge(client_ptr);
2013 do_cmd_load_screen();
2018 do_cmd_save_screen(client_ptr);
2023 if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
2025 museum_remove_object(client_ptr);
2029 msg_print(_("そのコマンドは店の中では使えません。", "That command does not work in stores."));
2039 * @brief 店舗処理全体のメインルーチン /
2040 * Enter a store, and interact with it. *
2041 * @param player_ptr プレーヤーへの参照ポインタ
2045 * Note that we use the standard "request_command()" function
2046 * to get a command, allowing us to use "command_arg" and all
2047 * command macros and other nifty stuff, but we use the special
2048 * "shopping" argument, to force certain commands to be converted
2049 * into other commands, normally, we convert "p" (pray) and "m"
2050 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
2053 void do_cmd_store(player_type *player_ptr)
2055 if (player_ptr->wild_mode) return;
2057 Term_get_size(&w, &h);
2059 xtra_stock = MIN(14 + 26, ((h > 24) ? (h - 24) : 0));
2060 store_bottom = MIN_STOCK + xtra_stock;
2063 g_ptr = &player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x];
2065 if (!cave_have_flag_grid(g_ptr, FF_STORE))
2067 msg_print(_("ここには店がありません。", "You see no store here."));
2071 int which = f_info[g_ptr->feat].subtype;
2072 old_town_num = player_ptr->town_num;
2073 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) player_ptr->town_num = 1;
2074 if (player_ptr->current_floor_ptr->dun_level) player_ptr->town_num = NO_TOWN;
2075 inner_town_num = player_ptr->town_num;
2077 if ((town_info[player_ptr->town_num].store[which].store_open >= current_world_ptr->game_turn) ||
2080 msg_print(_("ドアに鍵がかかっている。", "The doors are locked."));
2081 player_ptr->town_num = old_town_num;
2085 int maintain_num = (current_world_ptr->game_turn - town_info[player_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
2086 if (maintain_num > 10)
2090 for (int i = 0; i < maintain_num; i++)
2091 store_maint(player_ptr, player_ptr->town_num, which);
2093 town_info[player_ptr->town_num].store[which].last_visit = current_world_ptr->game_turn;
2096 forget_lite(player_ptr->current_floor_ptr);
2097 forget_view(player_ptr->current_floor_ptr);
2098 current_world_ptr->character_icky = TRUE;
2102 get_com_no_macros = TRUE;
2103 cur_store_num = which;
2104 cur_store_feat = g_ptr->feat;
2105 st_ptr = &town_info[player_ptr->town_num].store[cur_store_num];
2106 ot_ptr = &owners[cur_store_num][st_ptr->owner];
2108 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
2109 display_store(player_ptr);
2110 leave_store = FALSE;
2112 while (!leave_store)
2115 clear_from(20 + xtra_stock);
2116 prt(_(" ESC) 建物から出る", " ESC) Exit from Building."), 21 + xtra_stock, 0);
2117 if (st_ptr->stock_num > store_bottom)
2119 prt(_(" -)前ページ", " -) Previous page"), 22 + xtra_stock, 0);
2120 prt(_(" スペース) 次ページ", " SPACE) Next page"), 23 + xtra_stock, 0);
2123 if (cur_store_num == STORE_HOME)
2125 prt(_("g) アイテムを取る", "g) Get an item."), 21 + xtra_stock, 27);
2126 prt(_("d) アイテムを置く", "d) Drop an item."), 22 + xtra_stock, 27);
2127 prt(_("x) 家のアイテムを調べる", "x) eXamine an item in the home."), 23 + xtra_stock, 27);
2129 else if (cur_store_num == STORE_MUSEUM)
2131 prt(_("d) アイテムを置く", "d) Drop an item."), 21 + xtra_stock, 27);
2132 prt(_("r) アイテムの展示をやめる", "r) order to Remove an item."), 22 + xtra_stock, 27);
2133 prt(_("x) 博物館のアイテムを調べる", "x) eXamine an item in the museum."), 23 + xtra_stock, 27);
2137 prt(_("p) 商品を買う", "p) Purchase an item."), 21 + xtra_stock, 30);
2138 prt(_("s) アイテムを売る", "s) Sell an item."), 22 + xtra_stock, 30);
2139 prt(_("x) 商品を調べる", "x) eXamine an item in the shop"), 23 + xtra_stock, 30);
2142 prt(_("i/e) 持ち物/装備の一覧", "i/e) Inventry/Equipment list"), 21 + xtra_stock, 56);
2143 if (rogue_like_commands)
2145 prt(_("w/T) 装備する/はずす", "w/T) Wear/Take off equipment"), 22 + xtra_stock, 56);
2149 prt(_("w/t) 装備する/はずす", "w/t) Wear/Take off equipment"), 22 + xtra_stock, 56);
2152 prt(_("コマンド:", "You may: "), 20 + xtra_stock, 0);
2153 request_command(player_ptr, TRUE);
2154 store_process_command(player_ptr);
2157 * Hack -- To redraw missiles damage and prices in store
2158 * If player's charisma changes, or if player changes a bow, PU_BONUS is set
2160 bool need_redraw_store_inv = (player_ptr->update & PU_BONUS) ? TRUE : FALSE;
2161 current_world_ptr->character_icky = TRUE;
2162 handle_stuff(player_ptr);
2163 if (player_ptr->inventory_list[INVEN_PACK].k_idx)
2165 INVENTORY_IDX item = INVEN_PACK;
2166 object_type *o_ptr = &player_ptr->inventory_list[item];
2167 if (cur_store_num != STORE_HOME)
2169 if (cur_store_num == STORE_MUSEUM)
2170 msg_print(_("ザックからアイテムがあふれそうなので、あわてて博物館から出た...", "Your pack is so full that you flee the Museum..."));
2172 msg_print(_("ザックからアイテムがあふれそうなので、あわてて店から出た...", "Your pack is so full that you flee the store..."));
2176 else if (!store_check_num(o_ptr))
2178 msg_print(_("ザックからアイテムがあふれそうなので、あわてて家から出た...", "Your pack is so full that you flee your home..."));
2186 GAME_TEXT o_name[MAX_NLEN];
2187 msg_print(_("ザックからアイテムがあふれてしまった!", "Your pack overflows!"));
2189 object_copy(q_ptr, o_ptr);
2190 object_desc(player_ptr, o_name, q_ptr, 0);
2191 msg_format(_("%sが落ちた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
2192 vary_item(player_ptr, item, -255);
2193 handle_stuff(player_ptr);
2195 item_pos = home_carry(player_ptr, q_ptr);
2198 store_top = (item_pos / store_bottom) * store_bottom;
2199 display_store_inventory(player_ptr);
2204 if (need_redraw_store_inv) display_store_inventory(player_ptr);
2206 if (st_ptr->store_open >= current_world_ptr->game_turn) leave_store = TRUE;
2209 select_floor_music(player_ptr);
2210 player_ptr->town_num = old_town_num;
2211 take_turn(player_ptr, 100);
2212 current_world_ptr->character_icky = FALSE;
2214 command_see = FALSE;
2215 get_com_no_macros = FALSE;
2220 player_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2221 player_ptr->update |= (PU_MONSTERS);
2222 player_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
2223 player_ptr->redraw |= (PR_MAP);
2224 player_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2229 * @brief 現在の町の店主を交代させる /
2230 * Shuffle one of the stores.
2231 * @param which 店舗種類のID
2234 void store_shuffle(player_type *player_ptr, int which)
2236 if (which == STORE_HOME) return;
2237 if (which == STORE_MUSEUM) return;
2239 cur_store_num = which;
2240 st_ptr = &town_info[player_ptr->town_num].store[cur_store_num];
2241 int j = st_ptr->owner;
2244 st_ptr->owner = (byte)randint0(MAX_OWNERS);
2245 if (j == st_ptr->owner) continue;
2247 for (i = 1; i < max_towns; i++)
2249 if (i == player_ptr->town_num) continue;
2250 if (st_ptr->owner == town_info[i].store[cur_store_num].owner) break;
2253 if (i == max_towns) break;
2256 ot_ptr = &owners[cur_store_num][st_ptr->owner];
2257 st_ptr->insult_cur = 0;
2258 st_ptr->store_open = 0;
2259 st_ptr->good_buy = 0;
2260 st_ptr->bad_buy = 0;
2261 for (int i = 0; i < st_ptr->stock_num; i++)
2264 o_ptr = &st_ptr->stock[i];
2265 if (object_is_artifact(o_ptr)) continue;
2267 o_ptr->discount = 50;
2268 o_ptr->ident &= ~(IDENT_FIXED);
2269 o_ptr->inscription = quark_add(_("売出中", "on sale"));
2275 * @brief 店の品揃えを変化させる /
2276 * Maintain the inventory at the stores.
2277 * @param player_ptr プレーヤーへの参照ポインタ
2278 * @param town_num 町のID
2279 * @param store_num 店舗種類のID
2282 void store_maint(player_type *player_ptr, int town_num, int store_num)
2284 cur_store_num = store_num;
2285 if (store_num == STORE_HOME) return;
2286 if (store_num == STORE_MUSEUM) return;
2288 st_ptr = &town_info[town_num].store[store_num];
2289 ot_ptr = &owners[store_num][st_ptr->owner];
2290 st_ptr->insult_cur = 0;
2291 if (store_num == STORE_BLACK)
2293 for (INVENTORY_IDX j = st_ptr->stock_num - 1; j >= 0; j--)
2295 object_type *o_ptr = &st_ptr->stock[j];
2296 if (black_market_crap(player_ptr, o_ptr))
2298 store_item_increase(j, 0 - o_ptr->number);
2299 store_item_optimize(j);
2304 INVENTORY_IDX j = st_ptr->stock_num;
2305 j = j - randint1(STORE_TURNOVER);
2306 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
2307 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
2310 while (st_ptr->stock_num > j)
2313 j = st_ptr->stock_num;
2314 j = j + randint1(STORE_TURNOVER);
2315 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
2316 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
2317 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
2319 while (st_ptr->stock_num < j) store_create(player_ptr, black_market_crap);
2324 * @brief 店舗情報を初期化する /
2325 * Initialize the stores
2326 * @param town_num 町のID
2327 * @param store_num 店舗種類のID
2330 void store_init(int town_num, int store_num)
2332 cur_store_num = store_num;
2333 st_ptr = &town_info[town_num].store[store_num];
2336 st_ptr->owner = (byte)randint0(MAX_OWNERS);
2338 for (i = 1; i < max_towns; i++)
2340 if (i == town_num) continue;
2341 if (st_ptr->owner == town_info[i].store[store_num].owner) break;
2344 if (i == max_towns) break;
2347 ot_ptr = &owners[store_num][st_ptr->owner];
2349 st_ptr->store_open = 0;
2350 st_ptr->insult_cur = 0;
2351 st_ptr->good_buy = 0;
2352 st_ptr->bad_buy = 0;
2353 st_ptr->stock_num = 0;
2354 st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
2355 for (int k = 0; k < st_ptr->stock_size; k++)
2357 object_wipe(&st_ptr->stock[k]);