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.
15 #include "cmd-zapwand.h"
16 #include "cmd-magiceat.h"
20 static int cur_store_num = 0;
21 static int store_top = 0;
22 static int store_bottom = 0;
23 static int xtra_stock = 0;
24 static store_type *st_ptr = NULL;
25 static const owner_type *ot_ptr = NULL;
26 static s16b old_town_num = 0;
27 static s16b inner_town_num = 0;
28 #define RUMOR_CHANCE 8
30 #define MAX_COMMENT_1 6
32 static cptr comment_1[MAX_COMMENT_1] =
53 /*! ブラックマーケット追加メッセージ(承諾) */
54 static cptr comment_1_B[MAX_COMMENT_1] = {
63 #define MAX_COMMENT_2A 2
65 static cptr comment_2a[MAX_COMMENT_2A] =
68 "私の忍耐力を試しているのかい? $%s が最後だ。",
69 "我慢にも限度があるぞ。 $%s が最後だ。"
71 "You try my patience. %s is final.",
72 "My patience grows thin. %s is final."
77 #define MAX_COMMENT_2B 12
79 static cptr comment_2b[MAX_COMMENT_2B] =
82 " $%s ぐらいは出さなきゃダメだよ。",
85 "何て奴だ! $%s 以下はあり得ないぞ。",
86 "それじゃ少なすぎる! $%s は欲しいところだ。",
87 "バカにしている! $%s はもらわないと。",
89 "おいおい! $%s を考えてくれないか?",
90 "1000匹のオークのノミに苦しめられるがいい! $%s だ。",
91 "お前の大切なものに災いあれ! $%s でどうだ。",
92 "モルゴスに賞味されるがいい!本当は $%s なんだろう?",
93 "お前の母親はオーガか! $%s は出すつもりなんだろ?"
95 "I can take no less than %s gold pieces.",
96 "I will accept no less than %s gold pieces.",
97 "Ha! No less than %s gold pieces.",
98 "You knave! No less than %s gold pieces.",
99 "That's a pittance! I want %s gold pieces.",
100 "That's an insult! I want %s gold pieces.",
101 "As if! How about %s gold pieces?",
102 "My arse! How about %s gold pieces?",
103 "May the fleas of 1000 orcs molest you! Try %s gold pieces.",
104 "May your most favourite parts go moldy! Try %s gold pieces.",
105 "May Morgoth find you tasty! Perhaps %s gold pieces?",
106 "Your mother was an Ogre! Perhaps %s gold pieces?"
112 /*! ブラックマーケット用追加メッセージ(売るとき) */
113 static cptr comment_2b_B[MAX_COMMENT_2B] = {
114 "いくら俺様がお人好しとはいえ $%s が限界だね。嫌なら帰りな。",
115 "金がないのかい、あんた?まずは家に帰って $%s 揃えてきな。",
116 "物の価値が分からん奴だな。これは $%s が普通なんだよ。",
117 "俺の付けた値段に文句があるのか? $%s が限界だ。",
118 "ひょっとして新手の冗談かい? $%s 持ってないなら帰りな。",
119 "うちは他の店とは違うんだよ。$%s ぐらいは出しな。",
120 "買う気がないなら帰りな。 $%s だと言っているんだ。",
121 "話にならないね。 $%s くらい持っているんだろ?",
122 "は?なんだそりゃ? $%s の間違いか、ひょっとして?",
123 "出口はあっちだよ。それとも $%s 出せるのかい、あんたに。",
124 "命知らずな奴だな。 $%s 出せば今日の所は勘弁してやるよ。",
125 "うちの店は貧乏人お断りだ。 $%s ぐらい出せないのかい?"
128 #define MAX_COMMENT_3A 2
130 static cptr comment_3a[MAX_COMMENT_3A] =
133 "私の忍耐力を試しているのかい? $%s が最後だ。",
134 "我慢にも限度があるぞ。 $%s が最後だ。"
136 "You try my patience. %s is final.",
137 "My patience grows thin. %s is final."
143 #define MAX_COMMENT_3B 12
145 static cptr comment_3b[MAX_COMMENT_3B] =
148 "本音を言うと $%s でいいんだろ?",
150 " $%s ぐらいなら出してもいいが。",
151 " $%s 以上払うなんて考えられないね。",
152 "まあ落ちついて。 $%s でどうだい?",
153 "そのガラクタなら $%s で引き取るよ。",
154 "それじゃ高すぎる! $%s がいいとこだろ。",
155 "どうせいらないんだろ! $%s でいいだろ?",
156 "だめだめ! $%s がずっとお似合いだよ。",
157 "バカにしている! $%s がせいぜいだ。",
158 " $%s なら嬉しいところだがなあ。",
159 " $%s 、それ以上はビタ一文出さないよ!"
161 "Perhaps %s gold pieces?",
162 "How about %s gold pieces?",
163 "I will pay no more than %s gold pieces.",
164 "I can afford no more than %s gold pieces.",
165 "Be reasonable. How about %s gold pieces?",
166 "I'll buy it as scrap for %s gold pieces.",
167 "That is too much! How about %s gold pieces?",
168 "That looks war surplus! Say %s gold pieces?",
169 "Never! %s is more like it.",
170 "That's an insult! %s is more like it.",
171 "%s gold pieces and be thankful for it!",
172 "%s gold pieces and not a copper more!"
178 /*! ブラックマーケット用追加メッセージ(買い取り) */
179 static cptr comment_3b_B[MAX_COMMENT_3B] = {
180 " $%s ってところだね。そのどうしようもないガラクタは。",
181 "この俺が $%s って言っているんだから、その通りにした方が身のためだぞ。",
182 "俺の優しさに甘えるのもいい加減にしておけ。 $%s だ。",
183 "その品なら $%s で売ってくれているがね、常識ある紳士はみんな。",
184 "こりゃまた、がめつい奴だな。いくら俺が温厚とはいえ $%s が限界だ。",
185 " $%s だ。別に俺はそんなガラクタ欲しくはないんだから。",
186 "俺の鑑定額が気に入らないのか? $%s 、嫌なら帰りな。",
187 " $%s で引き取ってやるよ。喜んで受け取りな、貧乏人。",
188 "物の価値が分からん奴は始末におえんな。それは $%s なんだよ。",
189 "そんなに金が欲しいのか、あんた? $%s で満足できんのか?",
190 "入る店間違えてんじゃないのか? $%s で嫌なら他をあたってくれ。",
191 "俺の言い値にケチをつける奴がいるとは! その度胸に免じて $%s だ。"
194 #define MAX_COMMENT_4A 4
196 static cptr comment_4a[MAX_COMMENT_4A] =
199 "もうたくさんだ!何度も私をわずらわせないでくれ!",
200 "うがー!一日の我慢の限度を超えている!",
201 "もういい!時間の無駄以外のなにものでもない!",
202 "もうやってられないよ!顔も見たくない!"
204 "Enough! You have abused me once too often!",
205 "Arghhh! I have had enough abuse for one day!",
206 "That does it! You shall waste my time no more!",
207 "This is getting nowhere! I'm going to Londis!"
213 /*! ブラックマーケット用追加メッセージ(怒りの頂点) */
214 static cptr comment_4a_B[MAX_COMMENT_4A] = {
215 "なめやがって!温厚な俺様でも限界があるってことを知れ!",
216 "俺をここまで怒らせて...命があるだけでもありがたいと思え!",
217 "ふざけてるのか!冷やかしなら相手を見てからにしろ!",
218 "いいかげんにしろ!今度こんなまねしたらただじゃおかねえぞ!"
221 #define MAX_COMMENT_4B 4
223 static cptr comment_4b[MAX_COMMENT_4B] =
232 "Get out of my sight!",
233 "Begone, you scoundrel!",
240 /*! ブラックマーケット用追加メッセージ(追い出し) */
241 static cptr comment_4b_B[MAX_COMMENT_4B] = {
248 #define MAX_COMMENT_5 8
250 static cptr comment_5[MAX_COMMENT_5] =
264 "You will have to do better than that!",
265 "Do you wish to do business or not?",
266 "You've got to be kidding!",
267 "You'd better be kidding!",
268 "You try my patience.",
269 "Hmmm, nice weather we're having."
275 /*! ブラックマーケット用追加メッセージ(怒り) */
276 static cptr comment_5_B[MAX_COMMENT_5] = {
287 #define MAX_COMMENT_6 4
289 static cptr comment_6[MAX_COMMENT_6] =
297 "I must have heard you wrong.",
298 "I'm sorry, I missed that.",
299 "I'm sorry, what was that?",
300 "Sorry, what was that again?"
308 * @brief 取引成功時の店主のメッセージ処理 /
312 static void say_comment_1(void)
315 /* ブラックマーケットのときは別のメッセージを出す */
316 if ( cur_store_num == STORE_BLACK ) {
317 msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
320 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
323 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
327 if (one_in_(RUMOR_CHANCE))
330 msg_print("店主は耳うちした:");
332 msg_print("The shopkeeper whispers something into your ear:");
340 * @brief プレイヤーがアイテムを買う時の価格代案メッセージ処理 /
341 * Continue haggling (player is buying)
342 * @param value 店主の提示価格
343 * @param annoyed 店主のいらつき度
346 static void say_comment_2(PRICE value, int annoyed)
350 /* Prepare a string to insert */
351 sprintf(tmp_val, "%ld", (long)value);
356 /* Formatted message */
357 msg_format(comment_2a[randint0(MAX_COMMENT_2A)], tmp_val);
363 /* Formatted message */
365 /* ブラックマーケットの時は別のメッセージを出す */
366 if ( cur_store_num == STORE_BLACK ){
367 msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val);
370 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
373 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
381 * @brief プレイヤーがアイテムを売る時の価格代案メッセージ処理 /
382 * Continue haggling (player is selling)
383 * @param value 店主の提示価格
384 * @param annoyed 店主のいらつき度
387 static void say_comment_3(PRICE value, int annoyed)
391 /* Prepare a string to insert */
392 sprintf(tmp_val, "%ld", (long)value);
397 /* Formatted message */
398 msg_format(comment_3a[randint0(MAX_COMMENT_3A)], tmp_val);
404 /* Formatted message */
406 /* ブラックマーケットの時は別のメッセージを出す */
407 if ( cur_store_num == STORE_BLACK ){
408 msg_format(comment_3b_B[randint0(MAX_COMMENT_3B)], tmp_val);
411 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
414 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
422 * @brief 店主がプレイヤーを追い出す時のメッセージ処理 /
423 * Kick 'da bum out. -RAK-
426 static void say_comment_4(void)
429 /* ブラックマーケットの時は別のメッセージを出す */
430 if ( cur_store_num == STORE_BLACK ){
431 msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
432 msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
435 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
436 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
439 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
440 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
447 * @brief 店主がプレイヤーに取り合わない時のメッセージ処理 /
448 * You are insulting me
451 static void say_comment_5(void)
454 /* ブラックマーケットの時は別のメッセージを出す */
455 if ( cur_store_num == STORE_BLACK ){
456 msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
459 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
462 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
469 * @brief 店主がプレイヤーの提示を理解できなかった時のメッセージ処理 /
470 * That makes no sense.
473 static void say_comment_6(void)
475 msg_print(comment_6[randint0(MAX_COMMENT_6)]);
479 #define MAX_COMMENT_7A 4
481 static cptr comment_7a[MAX_COMMENT_7A] =
486 "誰かがむせび泣く声が聞こえる...。",
491 "You hear someone sobbing...",
492 "The shopkeeper howls in agony!"
497 #define MAX_COMMENT_7B 4
499 static cptr comment_7b[MAX_COMMENT_7B] =
509 "The shopkeeper curses at you.",
510 "The shopkeeper glares at you."
515 #define MAX_COMMENT_7C 4
517 static cptr comment_7c[MAX_COMMENT_7C] =
526 "You've made my day!",
527 "The shopkeeper giggles.",
528 "The shopkeeper laughs loudly."
533 #define MAX_COMMENT_7D 4
535 static cptr comment_7d[MAX_COMMENT_7D] =
539 "こんなおいしい思いをしたら、真面目に働けなくなるなぁ。",
544 "I think I'll retire!",
545 "The shopkeeper jumps for joy.",
546 "The shopkeeper smiles gleefully."
553 * @brief 店主が交渉を終えた際の反応を返す処理 /
554 * Let a shop-keeper React to a purchase
555 * @param price アイテムの取引額
556 * @param value アイテムの実際価値
557 * @param guess 店主が当初予想していた価値
560 * We paid "price", it was worth "value", and we thought it was worth "guess"
562 static void purchase_analyze(PRICE price, PRICE value, PRICE guess)
564 /* Item was worthless, but we bought it */
565 if ((value <= 0) && (price > value))
567 msg_print(comment_7a[randint0(MAX_COMMENT_7A)]);
569 chg_virtue(V_HONOUR, -1);
570 chg_virtue(V_JUSTICE, -1);
575 /* Item was cheaper than we thought, and we paid more than necessary */
576 else if ((value < guess) && (price > value))
578 msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
580 chg_virtue(V_JUSTICE, -1);
582 chg_virtue(V_HONOUR, -1);
587 /* Item was a good bargain, and we got away with it */
588 else if ((value > guess) && (value < (4 * guess)) && (price < value))
590 msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
593 chg_virtue(V_HONOUR, -1);
595 chg_virtue(V_HONOUR, 1);
600 /* Item was a great bargain, and we got away with it */
601 else if ((value > guess) && (price < value))
603 msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
606 chg_virtue(V_HONOUR, -1);
608 chg_virtue(V_HONOUR, 1);
610 if (10 * price < value)
611 chg_virtue(V_SACRIFICE, 1);
620 * We store the current "store feat" here so everyone can access it
622 static int cur_store_feat;
626 * Buying and selling adjustments for race combinations.
627 * Entry[owner][player] gives the basic "cost inflation".
629 static byte rgold_adj[MAX_RACES][MAX_RACES] =
631 /*Hum, HfE, Elf, Hal, Gno, Dwa, HfO, HfT, Dun, HiE, Barbarian,
632 HfOg, HGn, HTn, Cyc, Yek, Klc, Kbd, Nbl, DkE, Drc, Mind Flayer,
633 Imp, Glm, Skl, Zombie, Vampire, Spectre, Fairy, Beastman, Ent,
634 Angel, Demon, Kutar */
637 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
638 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
639 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
640 100, 120, 110, 105 },
643 { 110, 100, 100, 105, 110, 120, 125, 130, 110, 100, 110,
644 120, 115, 108, 115, 110, 110, 120, 120, 115, 115, 110,
645 120, 110, 110, 110, 120, 110, 100, 125, 100, 95, 140,
646 110, 115, 110, 110 },
649 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
650 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
651 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
652 110, 110, 105, 110 },
655 { 115, 110, 105, 95, 105, 110, 115, 130, 115, 105, 115,
656 125, 120, 120, 125, 115, 110, 120, 120, 120, 115, 115,
657 120, 110, 120, 120, 130, 110, 110, 130, 110, 95, 140,
658 115, 120, 105, 115 },
661 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
662 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
663 120, 101, 110, 110, 120, 120, 115, 130, 115, 95, 140,
664 115, 110, 110, 115 },
667 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
668 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
669 120, 105, 115, 115, 115, 115, 120, 130, 120, 95, 140,
670 115, 110, 115, 115 },
673 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
674 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
675 115, 125, 120, 120, 115, 120, 125, 115, 125, 95, 140,
676 115, 110, 115, 115 },
679 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
680 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
681 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
682 110, 110, 115, 110 },
685 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
686 120, 120, 105, 120, 115, 105, 115, 120, 110, 105, 105,
687 120, 105, 120, 120, 125, 120, 105, 135, 105, 95, 140,
688 100, 110, 110, 100 },
691 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
692 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
693 125, 115, 120, 120, 125, 120, 100, 125, 100, 95, 140,
694 110, 110, 105, 110 },
696 /* Human / Barbarian (copied from human) */
697 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
698 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
699 115, 105, 125, 125, 130, 125, 115, 120, 115, 95, 140,
700 100, 120, 110, 100 },
702 /* Half-Ogre: theoretical, copied from half-troll */
703 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
704 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
705 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
706 110, 110, 115, 110 },
708 /* Half-Giant: theoretical, copied from half-troll */
709 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
710 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
711 110, 115, 112, 112, 115, 112, 130, 120, 130, 95, 140,
712 110, 110, 115, 110 },
714 /* Half-Titan: theoretical, copied from High_Elf */
715 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
716 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
717 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
718 110, 110, 115, 110 },
720 /* Cyclops: theoretical, copied from half-troll */
721 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
722 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
723 110, 115, 112, 112, 115, 112, 130, 130, 130, 95, 140,
724 110, 110, 115, 110 },
726 /* Yeek: theoretical, copied from Half-Orc */
727 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
728 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
729 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
730 115, 110, 115, 115 },
732 /* Klackon: theoretical, copied from Gnome */
733 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
734 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
735 120, 101, 110, 110, 120, 120, 130, 130, 130, 95, 140,
736 115, 110, 115, 115 },
738 /* Kobold: theoretical, copied from Half-Orc */
739 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
740 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
741 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
742 115, 110, 115, 115 },
744 /* Nibelung: theoretical, copied from Dwarf */
745 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
746 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
747 120, 105, 115, 115, 120, 120, 130, 130, 130, 95, 140,
748 115, 135, 115, 115 },
751 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
752 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
753 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
754 110, 101, 115, 110 },
756 /* Draconian: theoretical, copied from High_Elf */
757 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
758 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
759 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
760 110, 110, 115, 110 },
762 /* Mind Flayer: theoretical, copied from High_Elf */
763 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
764 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
765 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
766 110, 110, 115, 110 },
768 /* Imp: theoretical, copied from High_Elf */
769 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
770 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
771 125, 115, 120, 120, 120, 120, 130, 130, 130, 120, 120,
772 110, 110, 115, 110 },
774 /* Golem: theoretical, copied from High_Elf */
775 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
776 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
777 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
778 110, 110, 115, 110 },
780 /* Skeleton: theoretical, copied from half-orc */
781 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
782 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
783 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
784 115, 110, 125, 115 },
786 /* Zombie: Theoretical, copied from half-orc */
787 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
788 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
789 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
790 115, 110, 125, 115 },
792 /* Vampire: Theoretical, copied from half-orc */
793 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
794 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
795 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
796 115, 110, 125, 115 },
798 /* Spectre: Theoretical, copied from half-orc */
799 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
800 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
801 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
802 115, 110, 125, 115 },
804 /* Sprite: Theoretical, copied from half-orc */
805 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
806 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
807 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
808 115, 110, 105, 115 },
810 /* Beastman: Theoretical, copied from half-orc */
811 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
812 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
813 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
814 115, 110, 115, 115 },
817 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
818 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
819 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
820 110, 110, 105, 110 },
823 { 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
824 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
825 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 160,
829 { 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
830 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
831 140, 140, 140, 140, 140, 140, 140, 140, 140, 160, 120,
832 140, 140, 140, 140 },
835 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
836 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
837 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
838 100, 120, 110, 100 },
841 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
842 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
843 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
844 110, 101, 115, 110 },
847 { 110, 110, 105, 105, 110, 115, 115, 115, 110, 105, 110,
848 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
849 115, 115, 125, 125, 125, 125, 105, 115, 105, 95, 140,
850 110, 115, 100, 110 },
853 { 105, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
854 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
855 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
856 100, 120, 110, 100 },
863 * Determine the price of an item (qty one) in a store.
864 * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
865 * @param greed 店主の強欲度
866 * @param flip TRUEならば店主にとっての買取価格、FALSEなら売出価格を計算
870 * This function takes into account the player's charisma, and the
871 * shop-keepers friendliness, and the shop-keeper's base greed, but
872 * never lets a shop-keeper lose money in a transaction.
873 * The "greed" value should exceed 100 when the player is "buying" the
874 * item, and should be less than 100 when the player is "selling" it.
875 * Hack -- the black market always charges twice as much as it should.
876 * Charisma adjustment runs from 80 to 130
877 * Racial adjustment runs from 95 to 130
878 * Since greed/charisma/racial adjustments are centered at 100, we need
879 * to adjust (by 200) to extract a usable multiplier. Note that the
880 * "greed" value is always something (?).
883 static s32b price_item(object_type *o_ptr, int greed, bool flip)
890 /* Get the value of one of the items */
891 price = object_value(o_ptr);
893 /* Worthless items */
894 if (price <= 0) return (0L);
897 /* Compute the racial factor */
898 factor = rgold_adj[ot_ptr->owner_race][p_ptr->prace];
900 /* Add in the charisma factor */
901 factor += adj_chr_gold[p_ptr->stat_ind[A_CHR]];
907 /* Adjust for greed */
908 adjust = 100 + (300 - (greed + factor));
910 /* Never get "silly" */
911 if (adjust > 100) adjust = 100;
913 /* Mega-Hack -- Black market sucks */
914 if (cur_store_num == STORE_BLACK)
917 /* Compute the final price (with rounding) */
918 /* Hack -- prevent underflow */
919 price = (price * adjust + 50L) / 100L;
922 /* Shop is selling */
925 /* Adjust for greed */
926 adjust = 100 + ((greed + factor) - 300);
928 /* Never get "silly" */
929 if (adjust < 100) adjust = 100;
931 /* Mega-Hack -- Black market sucks */
932 if (cur_store_num == STORE_BLACK)
935 /* Compute the final price (with rounding) */
936 /* Hack -- prevent overflow */
937 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
940 /* Note -- Never become "free" */
941 if (price <= 0L) return (1L);
943 /* Return the price */
949 * @brief 安価な消耗品の販売数を増やし、低確率で割引にする /
950 * Certain "cheap" objects should be created in "piles"
951 * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
955 * Some objects can be sold at a "discount" (in small piles)
958 static void mass_produce(object_type *o_ptr)
961 DISCOUNT_RATE discount = 0;
963 s32b cost = object_value(o_ptr);
966 /* Analyze the type */
969 /* Food, Flasks, and Lites */
974 if (cost <= 5L) size += damroll(3, 5);
975 if (cost <= 20L) size += damroll(3, 5);
976 if (cost <= 50L) size += damroll(2, 2);
983 if (cost <= 60L) size += damroll(3, 5);
984 if (cost <= 240L) size += damroll(1, 5);
985 if (o_ptr->sval == SV_SCROLL_STAR_IDENTIFY) size += damroll(3, 5);
986 if (o_ptr->sval == SV_SCROLL_STAR_REMOVE_CURSE) size += damroll(1, 4);
991 case TV_SORCERY_BOOK:
999 case TV_CRUSADE_BOOK:
1001 case TV_HISSATSU_BOOK:
1004 if (cost <= 50L) size += damroll(2, 3);
1005 if (cost <= 500L) size += damroll(1, 3);
1023 if (object_is_artifact(o_ptr)) break;
1024 if (object_is_ego(o_ptr)) break;
1025 if (cost <= 10L) size += damroll(3, 5);
1026 if (cost <= 100L) size += damroll(3, 5);
1035 if (cost <= 5L) size += damroll(5, 5);
1036 if (cost <= 50L) size += damroll(5, 5);
1037 if (cost <= 500L) size += damroll(5, 5);
1043 if (cost <= 100L) size += damroll(2, 2);
1044 if (cost <= 1000L) size += damroll(2, 2);
1057 * Because many rods (and a few wands and staffs) are useful mainly
1058 * in quantity, the Black Market will occasionally have a bunch of
1065 if ((cur_store_num == STORE_BLACK) && one_in_(3))
1067 if (cost < 1601L) size += damroll(1, 5);
1068 else if (cost < 3201L) size += damroll(1, 3);
1075 /* Pick a discount */
1080 else if (one_in_(25))
1084 else if (one_in_(150))
1088 else if (one_in_(300))
1092 else if (one_in_(500))
1097 if (o_ptr->art_name)
1102 /* Save the discount */
1103 o_ptr->discount = discount;
1105 /* Save the total pile size */
1106 o_ptr->number = size - (size * discount / 100);
1108 /* Ensure that mass-produced rods and wands get the correct pvals. */
1109 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1111 o_ptr->pval *= (PARAMETER_VALUE)o_ptr->number;
1118 * @brief 店舗に並べた品を同一品であるかどうか判定する /
1119 * Determine if a store item can "absorb" another item
1120 * @param o_ptr 判定するオブジェクト構造体の参照ポインタ1
1121 * @param j_ptr 判定するオブジェクト構造体の参照ポインタ2
1122 * @return 同一扱いできるならTRUEを返す
1125 * See "object_similar()" for the same function for the "player"
1128 static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
1132 /* Hack -- Identical items cannot be stacked */
1133 if (o_ptr == j_ptr) return (0);
1135 /* Different objects cannot be stacked */
1136 if (o_ptr->k_idx != j_ptr->k_idx) return (0);
1138 /* Different charges (etc) cannot be stacked, unless wands or rods. */
1139 if ((o_ptr->pval != j_ptr->pval) && (o_ptr->tval != TV_WAND) && (o_ptr->tval != TV_ROD)) return (0);
1141 /* Require many identical values */
1142 if (o_ptr->to_h != j_ptr->to_h) return (0);
1143 if (o_ptr->to_d != j_ptr->to_d) return (0);
1144 if (o_ptr->to_a != j_ptr->to_a) return (0);
1146 /* Require identical "ego-item" names */
1147 if (o_ptr->name2 != j_ptr->name2) return (0);
1149 /* Artifacts don't stack! */
1150 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return (0);
1152 /* Hack -- Identical art_flags! */
1153 for (i = 0; i < TR_FLAG_SIZE; i++)
1154 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return (0);
1156 /* Hack -- Never stack "powerful" items */
1157 if (o_ptr->xtra1 || j_ptr->xtra1) return (0);
1159 /* Hack -- Never stack recharging items */
1160 if (o_ptr->timeout || j_ptr->timeout) return (0);
1162 /* Require many identical values */
1163 if (o_ptr->ac != j_ptr->ac) return (0);
1164 if (o_ptr->dd != j_ptr->dd) return (0);
1165 if (o_ptr->ds != j_ptr->ds) return (0);
1167 /* Hack -- Never stack chests */
1168 if (o_ptr->tval == TV_CHEST) return (0);
1169 if (o_ptr->tval == TV_STATUE) return (0);
1170 if (o_ptr->tval == TV_CAPTURE) return (0);
1172 /* Require matching discounts */
1173 if (o_ptr->discount != j_ptr->discount) return (0);
1175 /* They match, so they must be similar */
1181 * @brief 店舗に並べた品を重ね合わせできるかどうか判定する /
1182 * Allow a store item to absorb another item
1183 * @param o_ptr 判定するオブジェクト構造体の参照ポインタ1
1184 * @param j_ptr 判定するオブジェクト構造体の参照ポインタ2
1185 * @return 重ね合わせできるならTRUEを返す
1188 * See "object_similar()" for the same function for the "player"
1191 static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
1193 int max_num = (o_ptr->tval == TV_ROD) ?
1194 MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99;
1195 int total = o_ptr->number + j_ptr->number;
1196 int diff = (total > max_num) ? total - max_num : 0;
1198 /* Combine quantity, lose excess items */
1199 o_ptr->number = (total > max_num) ? max_num : total;
1201 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
1202 if (o_ptr->tval == TV_ROD)
1204 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1207 /* Hack -- if wands are stacking, combine the charges. -LM- */
1208 if (o_ptr->tval == TV_WAND)
1210 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1216 * @brief 店舗に品を置くスペースがあるかどうかの判定を返す /
1217 * Check to see if the shop will be carrying too many objects -RAK-
1218 * @param o_ptr 店舗に置きたいオブジェクト構造体の参照ポインタ
1219 * @return 置き場がないなら0、重ね合わせできるアイテムがあるなら-1、スペースがあるなら1を返す。
1222 * Note that the shop, just like a player, will not accept things
1223 * it cannot hold. Before, one could "nuke" potions this way.
1224 * Return value is now int:
1226 * -1 : Can be combined to existing slot.
1227 * 1 : Cannot be combined but there are empty spaces.
1230 static int store_check_num(object_type *o_ptr)
1235 /* The "home" acts like the player */
1236 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
1238 bool old_stack_force_notes = stack_force_notes;
1239 bool old_stack_force_costs = stack_force_costs;
1241 if (cur_store_num != STORE_HOME)
1243 stack_force_notes = FALSE;
1244 stack_force_costs = FALSE;
1247 /* Check all the items */
1248 for (i = 0; i < st_ptr->stock_num; i++)
1250 /* Get the existing item */
1251 j_ptr = &st_ptr->stock[i];
1253 /* Can the new object be combined with the old one? */
1254 if (object_similar(j_ptr, o_ptr))
1256 if (cur_store_num != STORE_HOME)
1258 stack_force_notes = old_stack_force_notes;
1259 stack_force_costs = old_stack_force_costs;
1266 if (cur_store_num != STORE_HOME)
1268 stack_force_notes = old_stack_force_notes;
1269 stack_force_costs = old_stack_force_costs;
1273 /* Normal stores do special stuff */
1276 /* Check all the items */
1277 for (i = 0; i < st_ptr->stock_num; i++)
1279 /* Get the existing item */
1280 j_ptr = &st_ptr->stock[i];
1282 /* Can the new object be combined with the old one? */
1283 if (store_object_similar(j_ptr, o_ptr)) return -1;
1287 /* Free space is always usable */
1289 * オプション powerup_home が設定されていると
1292 if ((cur_store_num == STORE_HOME) && ( powerup_home == FALSE )) {
1293 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) {
1298 if (st_ptr->stock_num < st_ptr->stock_size) {
1303 /* But there was no room at the inn... */
1308 * @brief オブジェクトが祝福されているかの判定を返す /
1309 * @param o_ptr 判定したいオブジェクト構造体の参照ポインタ
1310 * @return アイテムが祝福されたアイテムならばTRUEを返す
1312 static bool is_blessed(object_type *o_ptr)
1314 BIT_FLAGS flgs[TR_FLAG_SIZE];
1315 object_flags(o_ptr, flgs);
1316 if (have_flag(flgs, TR_BLESSED)) return (TRUE);
1317 else return (FALSE);
1323 * @brief オブジェクトが所定の店舗で引き取れるかどうかを返す /
1324 * Determine if the current store will purchase the given item
1325 * @param o_ptr 判定したいオブジェクト構造体の参照ポインタ
1326 * @return アイテムが買い取れるならばTRUEを返す
1328 * Note that a shop-keeper must refuse to buy "worthless" items
1330 static bool store_will_buy(object_type *o_ptr)
1332 /* Hack -- The Home is simple */
1333 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) return (TRUE);
1335 /* Switch on the store */
1336 switch (cur_store_num)
1341 /* Analyze the type */
1342 switch (o_ptr->tval)
1345 if (o_ptr->sval != SV_POTION_WATER) return FALSE;
1357 case TV_BOTTLE: /* 'Green', recycling Angband */
1372 /* Analyze the type */
1373 switch (o_ptr->tval)
1394 /* Analyze the type */
1395 switch (o_ptr->tval)
1404 case TV_HISSATSU_BOOK:
1408 if(o_ptr->sval == SV_WIZSTAFF) return (FALSE);
1420 /* Analyze the type */
1421 switch (o_ptr->tval)
1424 case TV_CRUSADE_BOOK:
1434 monster_race *r_ptr = &r_info[o_ptr->pval];
1437 if (!(r_ptr->flags3 & RF3_EVIL))
1440 if (r_ptr->flags3 & RF3_GOOD) break;
1442 /* Accept animals */
1443 if (r_ptr->flags3 & RF3_ANIMAL) break;
1446 if (my_strchr("?!", r_ptr->d_char)) break;
1452 if (is_blessed(o_ptr)) break;
1461 case STORE_ALCHEMIST:
1463 /* Analyze the type */
1464 switch (o_ptr->tval)
1478 /* Analyze the type */
1479 switch (o_ptr->tval)
1481 case TV_SORCERY_BOOK:
1482 case TV_NATURE_BOOK:
1486 case TV_ARCANE_BOOK:
1488 case TV_DAEMON_BOOK:
1502 if(o_ptr->sval == SV_WIZSTAFF) break;
1503 else return (FALSE);
1510 /* Bookstore Shop */
1513 /* Analyze the type */
1514 switch (o_ptr->tval)
1516 case TV_SORCERY_BOOK:
1517 case TV_NATURE_BOOK:
1522 case TV_ARCANE_BOOK:
1524 case TV_DAEMON_BOOK:
1525 case TV_CRUSADE_BOOK:
1536 /* Ignore "worthless" items */
1537 if (object_value(o_ptr) <= 0) return (FALSE);
1545 * @brief 現在の町の指定された店舗のアイテムを整理する /
1546 * Combine and reorder items in store.
1547 * @param store_num 店舗ID
1548 * @return 実際に整理が行われたならばTRUEを返す。
1550 bool combine_and_reorder_home(int store_num)
1554 object_type forge, *o_ptr, *j_ptr;
1555 bool flag = FALSE, combined;
1556 store_type *old_st_ptr = st_ptr;
1557 bool old_stack_force_notes = stack_force_notes;
1558 bool old_stack_force_costs = stack_force_costs;
1560 st_ptr = &town[1].store[store_num];
1561 if (store_num != STORE_HOME)
1563 stack_force_notes = FALSE;
1564 stack_force_costs = FALSE;
1571 /* Combine the items in the home (backwards) */
1572 for (i = st_ptr->stock_num - 1; i > 0; i--)
1574 o_ptr = &st_ptr->stock[i];
1576 /* Skip empty items */
1577 if (!o_ptr->k_idx) continue;
1579 /* Scan the items above that item */
1580 for (j = 0; j < i; j++)
1584 j_ptr = &st_ptr->stock[j];
1586 /* Skip empty items */
1587 if (!j_ptr->k_idx) continue;
1590 * Get maximum number of the stack if these
1591 * are similar, get zero otherwise.
1593 max_num = object_similar_part(j_ptr, o_ptr);
1595 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
1596 if (max_num && j_ptr->number < max_num)
1598 if (o_ptr->number + j_ptr->number <= max_num)
1600 /* Add together the item counts */
1601 object_absorb(j_ptr, o_ptr);
1603 /* One object is gone */
1604 st_ptr->stock_num--;
1606 /* Slide everything down */
1607 for (k = i; k < st_ptr->stock_num; k++)
1609 /* Structure copy */
1610 st_ptr->stock[k] = st_ptr->stock[k + 1];
1613 /* Erase the "final" slot */
1614 object_wipe(&st_ptr->stock[k]);
1618 ITEM_NUMBER old_num = o_ptr->number;
1619 ITEM_NUMBER remain = j_ptr->number + o_ptr->number - max_num;
1621 /* Add together the item counts */
1622 object_absorb(j_ptr, o_ptr);
1624 o_ptr->number = remain;
1626 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1627 if (o_ptr->tval == TV_ROD)
1629 o_ptr->pval = o_ptr->pval * remain / old_num;
1630 o_ptr->timeout = o_ptr->timeout * remain / old_num;
1633 /* Hack -- if wands are stacking, combine the charges. -LM- */
1634 else if (o_ptr->tval == TV_WAND)
1636 o_ptr->pval = o_ptr->pval * remain / old_num;
1652 /* Re-order the items in the home (forwards) */
1653 for (i = 0; i < st_ptr->stock_num; i++)
1655 o_ptr = &st_ptr->stock[i];
1657 /* Skip empty slots */
1658 if (!o_ptr->k_idx) continue;
1660 /* Get the "value" of the item */
1661 o_value = object_value(o_ptr);
1663 /* Scan every occupied slot */
1664 for (j = 0; j < st_ptr->stock_num; j++)
1666 if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
1669 /* Never move down */
1670 if (j >= i) continue;
1675 /* Get local object */
1678 /* Save a copy of the moving item */
1679 object_copy(j_ptr, &st_ptr->stock[i]);
1681 /* Slide the objects */
1682 for (k = i; k > j; k--)
1684 /* Slide the item */
1685 object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
1688 /* Insert the moving item */
1689 object_copy(&st_ptr->stock[j], j_ptr);
1692 st_ptr = old_st_ptr;
1693 if (store_num != STORE_HOME)
1695 stack_force_notes = old_stack_force_notes;
1696 stack_force_costs = old_stack_force_costs;
1704 * @brief 我が家にオブジェクトを加える /
1705 * Add the item "o_ptr" to the inventory of the "Home"
1706 * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
1710 * In all cases, return the slot (or -1) where the object was placed
1711 * Note that this is a hacked up version of "inven_carry()".
1712 * Also note that it may not correctly "adapt" to "knowledge" bacoming
1713 * known, the player may have to pick stuff up and drop it again.
1716 static int home_carry(object_type *o_ptr)
1722 bool old_stack_force_notes = stack_force_notes;
1723 bool old_stack_force_costs = stack_force_costs;
1725 if (cur_store_num != STORE_HOME)
1727 stack_force_notes = FALSE;
1728 stack_force_costs = FALSE;
1731 /* Check each existing item (try to combine) */
1732 for (slot = 0; slot < st_ptr->stock_num; slot++)
1734 /* Get the existing item */
1735 j_ptr = &st_ptr->stock[slot];
1737 /* The home acts just like the player */
1738 if (object_similar(j_ptr, o_ptr))
1740 /* Save the new number of items */
1741 object_absorb(j_ptr, o_ptr);
1743 if (cur_store_num != STORE_HOME)
1745 stack_force_notes = old_stack_force_notes;
1746 stack_force_costs = old_stack_force_costs;
1754 if (cur_store_num != STORE_HOME)
1756 stack_force_notes = old_stack_force_notes;
1757 stack_force_costs = old_stack_force_costs;
1762 * 隠し機能: オプション powerup_home が設定されていると
1766 if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE)) {
1767 if (st_ptr->stock_num >= st_ptr->stock_size) {
1772 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10)) {
1778 /* Determine the "value" of the item */
1779 value = object_value(o_ptr);
1781 /* Check existing slots to see if we must "slide" */
1782 for (slot = 0; slot < st_ptr->stock_num; slot++)
1784 if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
1787 /* Slide the others up */
1788 for (i = st_ptr->stock_num; i > slot; i--)
1790 st_ptr->stock[i] = st_ptr->stock[i-1];
1793 /* More stuff now */
1794 st_ptr->stock_num++;
1796 /* Insert the new item */
1797 st_ptr->stock[slot] = *o_ptr;
1799 chg_virtue(V_SACRIFICE, -1);
1801 (void)combine_and_reorder_home(cur_store_num);
1803 /* Return the location */
1809 * @brief 店舗にオブジェクトを加える /
1810 * Add the item "o_ptr" to a real stores inventory.
1811 * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
1815 * In all cases, return the slot (or -1) where the object was placed
1816 * Note that this is a hacked up version of "inven_carry()".
1817 * Also note that it may not correctly "adapt" to "knowledge" bacoming
1818 * known, the player may have to pick stuff up and drop it again.
1821 static int store_carry(object_type *o_ptr)
1824 s32b value, j_value;
1828 /* Evaluate the object */
1829 value = object_value(o_ptr);
1831 /* Cursed/Worthless items "disappear" when sold */
1832 if (value <= 0) return (-1);
1834 /* All store items are fully *identified* */
1835 o_ptr->ident |= IDENT_MENTAL;
1837 /* Erase the inscription */
1838 o_ptr->inscription = 0;
1840 /* Erase the "feeling" */
1841 o_ptr->feeling = FEEL_NONE;
1843 /* Check each existing item (try to combine) */
1844 for (slot = 0; slot < st_ptr->stock_num; slot++)
1846 /* Get the existing item */
1847 j_ptr = &st_ptr->stock[slot];
1849 /* Can the existing items be incremented? */
1850 if (store_object_similar(j_ptr, o_ptr))
1852 /* Hack -- extra items disappear */
1853 store_object_absorb(j_ptr, o_ptr);
1861 if (st_ptr->stock_num >= st_ptr->stock_size) return (-1);
1864 /* Check existing slots to see if we must "slide" */
1865 for (slot = 0; slot < st_ptr->stock_num; slot++)
1868 j_ptr = &st_ptr->stock[slot];
1870 /* Objects sort by decreasing type */
1871 if (o_ptr->tval > j_ptr->tval) break;
1872 if (o_ptr->tval < j_ptr->tval) continue;
1874 /* Objects sort by increasing sval */
1875 if (o_ptr->sval < j_ptr->sval) break;
1876 if (o_ptr->sval > j_ptr->sval) continue;
1879 * Hack: otherwise identical rods sort by
1880 * increasing recharge time --dsb
1882 if (o_ptr->tval == TV_ROD)
1884 if (o_ptr->pval < j_ptr->pval) break;
1885 if (o_ptr->pval > j_ptr->pval) continue;
1888 /* Evaluate that slot */
1889 j_value = object_value(j_ptr);
1891 /* Objects sort by decreasing value */
1892 if (value > j_value) break;
1893 if (value < j_value) continue;
1896 /* Slide the others up */
1897 for (i = st_ptr->stock_num; i > slot; i--)
1899 st_ptr->stock[i] = st_ptr->stock[i-1];
1902 /* More stuff now */
1903 st_ptr->stock_num++;
1905 /* Insert the new item */
1906 st_ptr->stock[slot] = *o_ptr;
1908 /* Return the location */
1914 * @brief 店舗のオブジェクト数を増やす /
1915 * Add the item "o_ptr" to a real stores inventory.
1916 * @param item 増やしたいアイテムのID
1921 * Increase, by a given amount, the number of a certain item
1922 * in a certain store. This can result in zero items.
1924 * @todo numは本来ITEM_NUMBER型にしたい。
1926 static void store_item_increase(INVENTORY_IDX item, int num)
1931 o_ptr = &st_ptr->stock[item];
1933 /* Verify the number */
1934 cnt = o_ptr->number + num;
1935 if (cnt > 255) cnt = 255;
1936 else if (cnt < 0) cnt = 0;
1937 num = cnt - o_ptr->number;
1939 /* Save the new number */
1940 o_ptr->number += (ITEM_NUMBER)num;
1945 * @brief 店舗のオブジェクト数を削除する /
1946 * Remove a slot if it is empty
1947 * @param item 削除したいアイテムのID
1950 static void store_item_optimize(INVENTORY_IDX item)
1955 o_ptr = &st_ptr->stock[item];
1958 if (!o_ptr->k_idx) return;
1960 /* Must have no items */
1961 if (o_ptr->number) return;
1964 st_ptr->stock_num--;
1966 /* Slide everyone */
1967 for (j = item; j < st_ptr->stock_num; j++)
1969 st_ptr->stock[j] = st_ptr->stock[j + 1];
1972 /* Nuke the final slot */
1973 object_wipe(&st_ptr->stock[j]);
1977 * @brief ブラックマーケット用の無価値品の排除判定 /
1978 * This function will keep 'crap' out of the black market.
1979 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1980 * @return ブラックマーケットにとって無価値な品ならばTRUEを返す
1983 * Crap is defined as any item that is "available" elsewhere
1984 * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com>
1987 static bool black_market_crap(object_type *o_ptr)
1991 /* Ego items are never crap */
1992 if (object_is_ego(o_ptr)) return (FALSE);
1994 /* Good items are never crap */
1995 if (o_ptr->to_a > 0) return (FALSE);
1996 if (o_ptr->to_h > 0) return (FALSE);
1997 if (o_ptr->to_d > 0) return (FALSE);
1999 /* Check all stores */
2000 for (i = 0; i < MAX_STORES; i++)
2002 if (i == STORE_HOME) continue;
2003 if (i == STORE_MUSEUM) continue;
2005 /* Check every item in the store */
2006 for (j = 0; j < town[p_ptr->town_num].store[i].stock_num; j++)
2008 object_type *j_ptr = &town[p_ptr->town_num].store[i].stock[j];
2010 /* Duplicate item "type", assume crappy */
2011 if (o_ptr->k_idx == j_ptr->k_idx) return (TRUE);
2021 * @brief 店舗の品揃え変化のためにアイテムを削除する /
2022 * Attempt to delete (some of) a random item from the store
2026 * Hack -- we attempt to "maintain" piles of items when possible.
2029 static void store_delete(void)
2034 /* Pick a random slot */
2035 what = (INVENTORY_IDX)randint0(st_ptr->stock_num);
2037 /* Determine how many items are here */
2038 num = st_ptr->stock[what].number;
2040 /* Hack -- sometimes, only destroy half the items */
2041 if (randint0(100) < 50) num = (num + 1) / 2;
2043 /* Hack -- sometimes, only destroy a single item */
2044 if (randint0(100) < 50) num = 1;
2046 /* Hack -- decrement the maximum timeouts and total charges of rods and wands. -LM- */
2047 if ((st_ptr->stock[what].tval == TV_ROD) || (st_ptr->stock[what].tval == TV_WAND))
2049 st_ptr->stock[what].pval -= num * st_ptr->stock[what].pval / st_ptr->stock[what].number;
2052 /* Actually destroy (part of) the item */
2053 store_item_increase(what, -num);
2054 store_item_optimize(what);
2059 * @brief 店舗の品揃え変化のためにアイテムを追加する /
2060 * Creates a random item and gives it to a store
2064 * This algorithm needs to be rethought. A lot.
2065 * Currently, "normal" stores use a pre-built array.
2066 * Note -- the "level" given to "obj_get_num()" is a "favored"
2067 * level, that is, there is a much higher chance of getting
2068 * items with a level approaching that of the given level...
2069 * Should we check for "permission" to have the given item?
2072 static void store_create(void)
2082 /* Paranoia -- no room left */
2083 if (st_ptr->stock_num >= st_ptr->stock_size) return;
2086 /* Hack -- consider up to four items */
2087 for (tries = 0; tries < 4; tries++)
2090 if (cur_store_num == STORE_BLACK)
2092 /* Pick a level for object/magic */
2093 level = 25 + randint0(25);
2095 /* Random item (usually of given level) */
2096 i = get_obj_num(level);
2098 /* Handle failure */
2105 /* Hack -- Pick an item to sell */
2106 i = st_ptr->table[randint0(st_ptr->table_num)];
2108 /* Hack -- fake level for apply_magic() */
2109 level = rand_range(1, STORE_OBJ_LEVEL);
2113 /* Get local object */
2116 /* Create a new object of the chosen kind */
2117 object_prep(q_ptr, i);
2119 /* Apply some "low-level" magic (no artifacts) */
2120 apply_magic(q_ptr, level, AM_NO_FIXED_ART);
2122 /* Require valid object */
2123 if (!store_will_buy(q_ptr)) continue;
2125 /* Hack -- Charge lite's */
2126 if (q_ptr->tval == TV_LITE)
2128 if (q_ptr->sval == SV_LITE_TORCH) q_ptr->xtra4 = FUEL_TORCH / 2;
2129 if (q_ptr->sval == SV_LITE_LANTERN) q_ptr->xtra4 = FUEL_LAMP / 2;
2133 /* The item is "known" */
2134 object_known(q_ptr);
2136 /* Mark it storebought */
2137 q_ptr->ident |= IDENT_STORE;
2139 /* Mega-Hack -- no chests in stores */
2140 if (q_ptr->tval == TV_CHEST) continue;
2142 /* Prune the black market */
2143 if (cur_store_num == STORE_BLACK)
2145 /* Hack -- No "crappy" items */
2146 if (black_market_crap(q_ptr)) continue;
2148 /* Hack -- No "cheap" items */
2149 if (object_value(q_ptr) < 10) continue;
2151 /* No "worthless" items */
2152 /* if (object_value(q_ptr) <= 0) continue; */
2155 /* Prune normal stores */
2158 /* No "worthless" items */
2159 if (object_value(q_ptr) <= 0) continue;
2163 /* Mass produce and/or Apply discount */
2164 mass_produce(q_ptr);
2166 /* Attempt to carry the (known) item */
2167 (void)store_carry(q_ptr);
2169 /* Definitely done */
2176 * @brief 店舗の割引対象外にするかどうかを判定 /
2177 * Eliminate need to bargain if player has haggled well in the past
2178 * @param minprice アイテムの最低販売価格
2179 * @return 割引を禁止するならTRUEを返す。
2181 static bool noneedtobargain(PRICE minprice)
2183 s32b good = st_ptr->good_buy;
2184 s32b bad = st_ptr->bad_buy;
2186 /* Cheap items are "boring" */
2187 if (minprice < 10L) return (TRUE);
2189 /* Perfect haggling */
2190 if (good == MAX_SHORT) return (TRUE);
2192 /* Reward good haggles, punish bad haggles, notice price */
2193 if (good > ((3 * bad) + (5 + (minprice/50)))) return (TRUE);
2195 /* Return the flag */
2201 * @brief 店主の持つプレイヤーに対する売買の良し悪し経験を記憶する /
2202 * Update the bargain info
2203 * @param price 実際の取引価格
2204 * @param minprice 店主の提示した価格
2208 static void updatebargain(PRICE price, PRICE minprice, int num)
2210 /* Hack -- auto-haggle */
2211 if (!manual_haggle) return;
2213 /* Cheap items are "boring" */
2214 if ((minprice/num) < 10L) return;
2216 /* Count the successful haggles */
2217 if (price == minprice)
2219 /* Just count the good haggles */
2220 if (st_ptr->good_buy < MAX_SHORT)
2226 /* Count the failed haggles */
2229 /* Just count the bad haggles */
2230 if (st_ptr->bad_buy < MAX_SHORT)
2239 * @brief 店の商品リストを再表示する /
2240 * Re-displays a single store entry
2244 static void display_entry(int pos)
2250 char o_name[MAX_NLEN];
2255 o_ptr = &st_ptr->stock[pos];
2257 /* Get the "offset" */
2258 i = (pos % store_bottom);
2260 /* Label it, clear the line --(-- */
2261 (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
2262 prt(out_val, i+6, 0);
2265 if (show_item_graph)
2267 byte a = object_attr(o_ptr);
2268 char c = object_char(o_ptr);
2270 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
2271 if (use_bigtile) cur_col++;
2276 /* Describe an item in the home */
2277 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
2281 /* Leave room for weights, if necessary -DRS- */
2282 if (show_weights) maxwid -= 10;
2284 object_desc(o_name, o_ptr, 0);
2285 o_name[maxwid] = '\0';
2286 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2291 /* Only show the weight of an individual item */
2292 int wgt = o_ptr->weight;
2294 sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt));
2295 put_str(out_val, i+6, 67);
2297 (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10);
2298 put_str(out_val, i+6, 68);
2304 /* Describe an item (fully) in a store */
2307 /* Must leave room for the "price" */
2310 /* Leave room for weights, if necessary -DRS- */
2311 if (show_weights) maxwid -= 7;
2313 /* Describe the object (fully) */
2314 object_desc(o_name, o_ptr, 0);
2315 o_name[maxwid] = '\0';
2316 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2321 /* Only show the weight of an individual item */
2322 int wgt = o_ptr->weight;
2324 sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
2325 put_str(out_val, i+6, 60);
2327 (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
2328 put_str(out_val, i+6, 61);
2333 /* Display a "fixed" cost */
2334 if (o_ptr->ident & (IDENT_FIXED))
2336 /* Extract the "minimum" price */
2337 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2339 /* Actually draw the price (not fixed) */
2341 (void)sprintf(out_val, "%9ld固", (long)x);
2343 (void)sprintf(out_val, "%9ld F", (long)x);
2346 put_str(out_val, i+6, 68);
2349 /* Display a "taxed" cost */
2350 else if (!manual_haggle)
2352 /* Extract the "minimum" price */
2353 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2355 /* Hack -- Apply Sales Tax if needed */
2356 if (!noneedtobargain(x)) x += x / 10;
2358 /* Actually draw the price (with tax) */
2359 (void)sprintf(out_val, "%9ld ", (long)x);
2360 put_str(out_val, i+6, 68);
2363 /* Display a "haggle" cost */
2366 /* Extrect the "maximum" price */
2367 x = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2369 /* Actually draw the price (not fixed) */
2370 (void)sprintf(out_val, "%9ld ", (long)x);
2371 put_str(out_val, i+6, 68);
2378 * @brief 店の商品リストを表示する /
2379 * Displays a store's inventory -RAK-
2382 * All prices are listed as "per individual object". -BEN-
2384 static void display_inventory(void)
2388 /* Display the next 12 items */
2389 for (k = 0; k < store_bottom; k++)
2391 /* Do not display "dead" items */
2392 if (store_top + k >= st_ptr->stock_num) break;
2394 /* Display that line */
2395 display_entry(store_top + k);
2398 /* Erase the extra lines and the "more" prompt */
2399 for (i = k; i < store_bottom + 1; i++) prt("", i + 6, 0);
2401 /* Assume "no current page" */
2403 put_str(" ", 5, 20);
2405 put_str(" ", 5, 20);
2409 /* Visual reminder of "more items" */
2410 if (st_ptr->stock_num > store_bottom)
2412 /* Show "more" reminder (after the last item) */
2414 prt("-続く-", k + 6, 3);
2416 prt("-more-", k + 6, 3);
2420 /* Indicate the "current page" */
2421 /* Trailing spaces are to display (Page xx) and (Page x) */
2423 put_str(format("(%dページ) ", store_top/store_bottom + 1), 5, 20);
2425 put_str(format("(Page %d) ", store_top/store_bottom + 1), 5, 20);
2430 if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM)
2432 k = st_ptr->stock_size;
2434 if (cur_store_num == STORE_HOME && !powerup_home) k /= 10;
2436 put_str(format("アイテム数: %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 27);
2438 put_str(format("Objects: %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 30);
2445 * @brief プレイヤーの所持金を表示する /
2446 * Displays players gold -RAK-
2450 static void store_prt_gold(void)
2455 prt("手持ちのお金: ", 19 + xtra_stock, 53);
2457 prt("Gold Remaining: ", 19 + xtra_stock, 53);
2461 sprintf(out_val, "%9ld", (long)p_ptr->au);
2462 prt(out_val, 19 + xtra_stock, 68);
2466 * @brief 店舗情報全体を表示するメインルーチン /
2467 * Displays store (after clearing screen) -RAK-
2471 static void display_store(void)
2479 /* The "Home" is special */
2480 if (cur_store_num == STORE_HOME)
2482 /* Put the owner name */
2484 put_str("我が家", 3, 31);
2486 put_str("Your Home", 3, 30);
2490 /* Label the item descriptions */
2492 put_str("アイテムの一覧", 5, 4);
2494 put_str("Item Description", 5, 3);
2498 /* If showing weights, show label */
2502 put_str("重さ", 5, 72);
2504 put_str("Weight", 5, 70);
2510 /* The "Home" is special */
2511 else if (cur_store_num == STORE_MUSEUM)
2513 /* Put the owner name */
2515 put_str("博物館", 3, 31);
2517 put_str("Museum", 3, 30);
2521 /* Label the item descriptions */
2523 put_str("アイテムの一覧", 5, 4);
2525 put_str("Item Description", 5, 3);
2529 /* If showing weights, show label */
2533 put_str("重さ", 5, 72);
2535 put_str("Weight", 5, 70);
2544 cptr store_name = (f_name + f_info[cur_store_feat].name);
2545 cptr owner_name = (ot_ptr->owner_name);
2546 cptr race_name = race_info[ot_ptr->owner_race].title;
2548 /* Put the owner name and race */
2549 sprintf(buf, "%s (%s)", owner_name, race_name);
2550 put_str(buf, 3, 10);
2552 /* Show the max price in the store (above prices) */
2553 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
2556 /* Label the item descriptions */
2558 put_str("商品の一覧", 5, 7);
2560 put_str("Item Description", 5, 3);
2564 /* If showing weights, show label */
2568 put_str("重さ", 5, 62);
2570 put_str("Weight", 5, 60);
2575 /* Label the asking price (in stores) */
2577 put_str("価格", 5, 73);
2579 put_str("Price", 5, 72);
2584 /* Display the current gold */
2587 /* Draw in the inventory */
2588 display_inventory();
2594 * @brief 店舗からアイテムを選択する /
2595 * Get the ID of a store item and return its value -RAK-
2596 * @param com_val 選択IDを返す参照ポインタ
2597 * @param pmt メッセージキャプション
2600 * @return 実際に選択したらTRUE、キャンセルしたらFALSE
2602 static int get_stock(COMMAND_CODE *com_val, cptr pmt, int i, int j)
2608 /* Get the item index */
2609 if (repeat_pull(com_val))
2611 /* Verify the item */
2612 if ((*com_val >= i) && (*com_val <= j))
2623 /* Assume failure */
2626 /* Build the prompt */
2628 hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
2630 (void)sprintf(out_val, "(%s:%c-%c, ESCで中断) %s",
2631 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "アイテム" : "商品"),
2634 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
2639 /* Ask until done */
2645 if (!get_com(out_val, &command, FALSE)) break;
2648 if (islower(command))
2650 else if (isupper(command))
2651 k = A2I(tolower(command)) + 26;
2655 /* Legal responses */
2656 if ((k >= i) && (k <= j))
2665 /* Clear the prompt */
2669 if (command == ESCAPE) return (FALSE);
2671 repeat_push(*com_val);
2679 * @brief 店主の不満度を増やし、プレイヤーを締め出す判定と処理を行う /
2680 * Increase the insult counter and get angry if too many -RAK-
2681 * @return プレイヤーを締め出す場合TRUEを返す
2683 static int increase_insults(void)
2685 /* Increase insults */
2686 st_ptr->insult_cur++;
2688 /* Become insulted */
2689 if (st_ptr->insult_cur > ot_ptr->insult_max)
2695 st_ptr->insult_cur = 0;
2696 st_ptr->good_buy = 0;
2697 st_ptr->bad_buy = 0;
2700 st_ptr->store_open = turn + TURNS_PER_TICK*TOWN_DAWN/8 + randint1(TURNS_PER_TICK*TOWN_DAWN/8);
2712 * @brief 店主の不満度を減らす /
2713 * Decrease insults -RAK-
2714 * @return プレイヤーを締め出す場合TRUEを返す
2716 static void decrease_insults(void)
2718 /* Decrease insults */
2719 if (st_ptr->insult_cur) st_ptr->insult_cur--;
2724 * @brief 店主の不満度が増えた場合のみのメッセージを表示する /
2725 * Have insulted while haggling -RAK-
2726 * @return プレイヤーを締め出す場合TRUEを返す
2728 static int haggle_insults(void)
2730 /* Increase insults */
2731 if (increase_insults()) return (TRUE);
2733 /* Display and flush insult */
2742 * Mega-Hack -- Enable "increments"
2744 static bool allow_inc = FALSE;
2747 * Mega-Hack -- Last "increment" during haggling
2749 static s32b last_inc = 0L;
2753 * @brief 交渉価格を確認と認証の是非を行う /
2756 * @param poffer 別途価格提示をした場合の値を返す参照ポインタ
2757 * @param price 現在の交渉価格
2758 * @param final 最終確定価格ならばTRUE
2759 * @return プレイヤーを締め出す場合TRUEを返す
2761 static int get_haggle(cptr pmt, s32b *poffer, PRICE price, int final)
2771 /* Clear old increment if necessary */
2772 if (!allow_inc) last_inc = 0L;
2779 sprintf(buf, "%s [承諾] ", pmt);
2781 sprintf(buf, "%s [accept] ", pmt);
2786 /* Old (negative) increment, and not final */
2787 else if (last_inc < 0)
2790 sprintf(buf, "%s [-$%ld] ", pmt, (long)(ABS(last_inc)));
2792 sprintf(buf, "%s [-%ld] ", pmt, (long)(ABS(last_inc)));
2797 /* Old (positive) increment, and not final */
2798 else if (last_inc > 0)
2801 sprintf(buf, "%s [+$%ld] ", pmt, (long)(ABS(last_inc)));
2803 sprintf(buf, "%s [+%ld] ", pmt, (long)(ABS(last_inc)));
2811 sprintf(buf, "%s ", pmt);
2819 /* Ask until done */
2824 /* Display prompt */
2828 strcpy(out_val, "");
2831 * Ask the user for a response.
2832 * Don't allow to use numpad as cursor key.
2834 res = askfor_aux(out_val, 32, FALSE);
2840 if (!res) return FALSE;
2842 /* Skip leading spaces */
2843 for (p = out_val; *p == ' '; p++) /* loop */;
2845 /* Empty response */
2848 /* Accept current price */
2856 /* Use previous increment */
2857 if (allow_inc && last_inc)
2859 *poffer += last_inc;
2864 /* Normal response */
2867 /* Extract a number */
2870 /* Handle "incremental" number */
2871 if ((*p == '+' || *p == '-'))
2873 /* Allow increments */
2876 /* Use the given "increment" */
2883 /* Handle normal number */
2886 /* Use the given "number" */
2895 msg_print("値がおかしいです。");
2897 msg_print("Invalid response.");
2909 * @brief 店主がプレイヤーからの交渉価格を判断する /
2910 * Receive an offer (from the player)
2912 * @param poffer 店主からの交渉価格を返す参照ポインタ
2913 * @param last_offer 現在の交渉価格
2914 * @param factor 店主の価格基準倍率
2915 * @param price アイテムの実価値
2916 * @param final 最終価格確定ならばTRUE
2917 * @return プレイヤーの価格に対して不服ならばTRUEを返す /
2918 * Return TRUE if offer is NOT okay
2920 static bool receive_offer(cptr pmt, s32b *poffer,
2921 s32b last_offer, int factor,
2922 PRICE price, int final)
2924 /* Haggle till done */
2927 /* Get a haggle (or cancel) */
2928 if (!get_haggle(pmt, poffer, price, final)) return (TRUE);
2930 /* Acceptable offer */
2931 if (((*poffer) * factor) >= (last_offer * factor)) break;
2933 /* Insult, and check for kicked out */
2934 if (haggle_insults()) return (TRUE);
2936 /* Reject offer (correctly) */
2937 (*poffer) = last_offer;
2946 * @brief プレイヤーが購入する時の値切り処理メインルーチン /
2947 * Haggling routine -RAK-
2948 * @param o_ptr オブジェクトの構造体参照ポインタ
2949 * @param price 最終価格を返す参照ポインタ
2950 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
2951 * Return TRUE if purchase is NOT successful
2953 static bool purchase_haggle(object_type *o_ptr, s32b *price)
2955 s32b cur_ask, final_ask;
2956 s32b last_offer, offer;
2958 s32b min_per, max_per;
2959 int flag, loop_flag, noneed;
2960 int annoyed = 0, final = FALSE;
2962 bool cancel = FALSE;
2967 cptr pmt = "Asking";
2977 /* Extract the starting offer and the final offer */
2978 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2979 final_ask = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2981 /* Determine if haggling is necessary */
2982 noneed = noneedtobargain(final_ask);
2984 /* No need to haggle */
2985 if (noneed || !manual_haggle)
2987 /* No need to haggle */
2990 /* Message summary */
2992 msg_print("結局この金額にまとまった。");
2994 msg_print("You eventually agree upon the price.");
3000 /* No haggle option */
3003 /* Message summary */
3005 msg_print("すんなりとこの金額にまとまった。");
3007 msg_print("You quickly agree upon the price.");
3012 /* Apply Sales Tax */
3013 final_ask += final_ask / 10;
3017 cur_ask = final_ask;
3019 /* Go to final offer */
3023 pmt = "Final Offer";
3030 /* Haggle for the whole pile */
3031 cur_ask *= o_ptr->number;
3032 final_ask *= o_ptr->number;
3035 /* Haggle parameters */
3036 min_per = ot_ptr->haggle_per;
3037 max_per = min_per * 3;
3039 /* Mega-Hack -- artificial "last offer" value */
3040 last_offer = object_value(o_ptr) * o_ptr->number;
3041 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
3042 if (last_offer <= 0) last_offer = 1;
3047 /* No incremental haggling yet */
3050 /* Haggle until done */
3051 for (flag = FALSE; !flag; )
3055 while (!flag && loop_flag)
3057 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
3058 put_str(out_val, 1, 0);
3060 cancel = receive_offer("提示する金額? ",
3062 cancel = receive_offer("What do you offer? ",
3065 &offer, last_offer, 1, cur_ask, final);
3071 else if (offer > cur_ask)
3076 else if (offer == cur_ask)
3089 x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
3092 if (haggle_insults())
3098 else if (x1 > max_per)
3101 if (x1 < max_per) x1 = max_per;
3103 x2 = rand_range(x1-2, x1+2);
3104 x3 = ((cur_ask - offer) * x2 / 100L) + 1;
3105 /* don't let the price go up */
3110 if (cur_ask < final_ask)
3113 cur_ask = final_ask;
3117 pmt = "Final Offer";
3123 (void)(increase_insults());
3128 else if (offer >= cur_ask)
3140 (void)sprintf(out_val, "前回の提示金額: $%ld",
3142 (void)sprintf(out_val, "Your last offer: %ld",
3146 put_str(out_val, 1, 39);
3147 say_comment_2(cur_ask, annoyed);
3153 if (cancel) return (TRUE);
3155 /* Update bargaining info */
3156 updatebargain(*price, final_ask, o_ptr->number);
3164 * @brief プレイヤーが売却する時の値切り処理メインルーチン /
3165 * Haggling routine -RAK-
3166 * @param o_ptr オブジェクトの構造体参照ポインタ
3167 * @param price 最終価格を返す参照ポインタ
3168 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
3169 * Return TRUE if purchase is NOT successful
3171 static bool sell_haggle(object_type *o_ptr, s32b *price)
3173 s32b purse, cur_ask, final_ask;
3174 s32b last_offer = 0, offer = 0;
3176 s32b min_per, max_per;
3177 int flag, loop_flag, noneed;
3178 int annoyed = 0, final = FALSE;
3179 bool cancel = FALSE;
3192 /* Obtain the starting offer and the final offer */
3193 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, TRUE);
3194 final_ask = price_item(o_ptr, ot_ptr->min_inflate, TRUE);
3196 /* Determine if haggling is necessary */
3197 noneed = noneedtobargain(final_ask);
3199 /* Get the owner's payout limit */
3200 purse = (s32b)(ot_ptr->max_cost);
3202 /* No need to haggle */
3203 if (noneed || !manual_haggle || (final_ask >= purse))
3205 /* Apply Sales Tax (if needed) */
3206 if (!manual_haggle && !noneed)
3208 final_ask -= final_ask / 10;
3211 /* No reason to haggle */
3212 if (final_ask >= purse)
3215 msg_print("即座にこの金額にまとまった。");
3217 msg_print("You instantly agree upon the price.");
3222 /* Offer full purse */
3226 /* No need to haggle */
3230 msg_print("結局この金額にまとまった。");
3232 msg_print("You eventually agree upon the price.");
3238 /* No haggle option */
3241 /* Message summary */
3243 msg_print("すんなりとこの金額にまとまった。");
3245 msg_print("You quickly agree upon the price.");
3252 cur_ask = final_ask;
3259 pmt = "Final Offer";
3264 /* Haggle for the whole pile */
3265 cur_ask *= o_ptr->number;
3266 final_ask *= o_ptr->number;
3269 /* Display commands */
3271 /* Haggling parameters */
3272 min_per = ot_ptr->haggle_per;
3273 max_per = min_per * 3;
3275 /* Mega-Hack -- artificial "last offer" value */
3276 last_offer = object_value(o_ptr) * o_ptr->number;
3277 last_offer = last_offer * ot_ptr->max_inflate / 100L;
3282 /* No incremental haggling yet */
3286 for (flag = FALSE; !flag; )
3292 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
3293 put_str(out_val, 1, 0);
3295 cancel = receive_offer("提示する価格? ",
3297 cancel = receive_offer("What price do you ask? ",
3300 &offer, last_offer, -1, cur_ask, final);
3306 else if (offer < cur_ask)
3309 /* rejected, reset offer for incremental haggling */
3312 else if (offer == cur_ask)
3323 if (flag || !loop_flag) break;
3328 x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
3331 if (haggle_insults())
3337 else if (x1 > max_per)
3340 if (x1 < max_per) x1 = max_per;
3342 x2 = rand_range(x1-2, x1+2);
3343 x3 = ((offer - cur_ask) * x2 / 100L) + 1;
3344 /* don't let the price go down */
3348 if (cur_ask > final_ask)
3350 cur_ask = final_ask;
3355 pmt = "Final Offer";
3363 /* 追加 $0 で買い取られてしまうのを防止 By FIRST*/
3366 (void)(increase_insults());
3369 else if (offer <= cur_ask)
3380 (void)sprintf(out_val,
3382 "前回の提示価格 $%ld", (long)last_offer);
3384 "Your last bid %ld", (long)last_offer);
3387 put_str(out_val, 1, 39);
3388 say_comment_3(cur_ask, annoyed);
3394 if (cancel) return (TRUE);
3396 /* Update bargaining info */
3397 updatebargain(*price, final_ask, o_ptr->number);
3405 * @brief 店からの購入処理のメインルーチン /
3406 * Buy an item from a store -RAK-
3409 static void store_purchase(void)
3412 COMMAND_CODE item, item_new;
3423 char o_name[MAX_NLEN];
3427 if (cur_store_num == STORE_MUSEUM)
3430 msg_print("博物館から取り出すことはできません。");
3432 msg_print("Museum.");
3438 if (st_ptr->stock_num <= 0)
3440 if (cur_store_num == STORE_HOME)
3442 msg_print("我が家には何も置いてありません。");
3444 msg_print("Your home is empty.");
3449 msg_print("現在商品の在庫を切らしています。");
3451 msg_print("I am currently out of stock.");
3458 /* Find the number of objects on this and following pages */
3459 i = (st_ptr->stock_num - store_top);
3461 /* And then restrict it to the current page */
3462 if (i > store_bottom) i = store_bottom;
3466 /* ブラックマーケットの時は別のメッセージ */
3467 switch( cur_store_num ) {
3469 sprintf(out_val, "どのアイテムを取りますか? ");
3472 sprintf(out_val, "どれ? ");
3475 sprintf(out_val, "どの品物が欲しいんだい? ");
3479 if (cur_store_num == STORE_HOME)
3481 sprintf(out_val, "Which item do you want to take? ");
3485 sprintf(out_val, "Which item are you interested in? ");
3490 /* Get the item number to be bought */
3491 if (!get_stock(&item, out_val, 0, i - 1)) return;
3493 /* Get the actual index */
3494 item = item + store_top;
3496 /* Get the actual item */
3497 o_ptr = &st_ptr->stock[item];
3499 /* Assume the player wants just one of them */
3502 /* Get local object */
3505 /* Get a copy of the object */
3506 object_copy(j_ptr, o_ptr);
3509 * If a rod or wand, allocate total maximum timeouts or charges
3510 * between those purchased and left on the shelf.
3512 reduce_charges(j_ptr, o_ptr->number - amt);
3514 /* Modify quantity */
3515 j_ptr->number = amt;
3517 /* Hack -- require room in pack */
3518 if (!inven_carry_okay(j_ptr))
3521 msg_print("そんなにアイテムを持てない。");
3523 msg_print("You cannot carry that many different items.");
3529 /* Determine the "best" price (per item) */
3530 best = price_item(j_ptr, ot_ptr->min_inflate, FALSE);
3532 /* Find out how many the player wants */
3533 if (o_ptr->number > 1)
3535 /* Hack -- note cost of "fixed" items */
3536 if ((cur_store_num != STORE_HOME) &&
3537 (o_ptr->ident & IDENT_FIXED))
3540 msg_format("一つにつき $%ldです。", (long)(best));
3542 msg_format("That costs %ld gold per item.", (long)(best));
3547 /* Get a quantity */
3548 amt = get_quantity(NULL, o_ptr->number);
3550 /* Allow user abort */
3551 if (amt <= 0) return;
3554 /* Get local object */
3557 /* Get desired object */
3558 object_copy(j_ptr, o_ptr);
3561 * If a rod or wand, allocate total maximum timeouts or charges
3562 * between those purchased and left on the shelf.
3564 reduce_charges(j_ptr, o_ptr->number - amt);
3566 /* Modify quantity */
3567 j_ptr->number = amt;
3569 /* Hack -- require room in pack */
3570 if (!inven_carry_okay(j_ptr))
3573 msg_print("ザックにそのアイテムを入れる隙間がない。");
3575 msg_print("You cannot carry that many items.");
3581 /* Attempt to buy it */
3582 if (cur_store_num != STORE_HOME)
3584 /* Fixed price, quick buy */
3585 if (o_ptr->ident & (IDENT_FIXED))
3590 /* Go directly to the "best" deal */
3591 price = (best * j_ptr->number);
3597 /* Describe the object (fully) */
3598 object_desc(o_name, j_ptr, 0);
3601 msg_format("%s(%c)を購入する。", o_name, I2A(item));
3603 msg_format("Buying %s (%c).", o_name, I2A(item));
3608 /* Haggle for a final price */
3609 choice = purchase_haggle(j_ptr, &price);
3611 /* Hack -- Got kicked out */
3612 if (st_ptr->store_open >= turn) return;
3615 /* Player wants it */
3618 /* Fix the item price (if "correctly" haggled) */
3619 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
3621 /* Player can afford it */
3622 if (p_ptr->au >= price)
3627 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3628 chg_virtue(V_JUSTICE, -1);
3629 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3630 chg_virtue(V_NATURE, -1);
3638 /* Spend the money */
3641 /* Update the display */
3644 /* Hack -- buying an item makes you aware of it */
3645 object_aware(j_ptr);
3647 /* Hack -- clear the "fixed" flag from the item */
3648 j_ptr->ident &= ~(IDENT_FIXED);
3650 /* Describe the transaction */
3651 object_desc(o_name, j_ptr, 0);
3654 msg_format("%sを $%ldで購入しました。", o_name, (long)price);
3656 msg_format("You bought %s for %ld gold.", o_name, (long)price);
3659 strcpy(record_o_name, o_name);
3662 if (record_buy) do_cmd_write_nikki(NIKKI_BUY, 0, o_name);
3663 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3664 if(record_rand_art && o_ptr->art_name)
3665 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
3667 /* Erase the inscription */
3668 j_ptr->inscription = 0;
3670 /* Erase the "feeling" */
3671 j_ptr->feeling = FEEL_NONE;
3672 j_ptr->ident &= ~(IDENT_STORE);
3673 /* Give it to the player */
3674 item_new = inven_carry(j_ptr);
3676 /* Describe the final result */
3677 object_desc(o_name, &inventory[item_new], 0);
3680 msg_format("%s(%c)を手に入れた。", o_name, index_to_label(item_new));
3682 msg_format("You have %s (%c).",
3683 o_name, index_to_label(item_new));
3686 /* Auto-inscription */
3687 autopick_alter_item(item_new, FALSE);
3689 /* Now, reduce the original stack's pval. */
3690 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3692 o_ptr->pval -= j_ptr->pval;
3698 /* Note how many slots the store used to have */
3699 i = st_ptr->stock_num;
3701 /* Remove the bought items from the store */
3702 store_item_increase(item, -amt);
3703 store_item_optimize(item);
3705 /* Store is empty */
3706 if (st_ptr->stock_num == 0)
3709 if (one_in_(STORE_SHUFFLE))
3713 msg_print("店主は引退した。");
3715 msg_print("The shopkeeper retires.");
3719 /* Shuffle the store */
3720 store_shuffle(cur_store_num);
3723 sprintf(buf, "%s (%s)",
3724 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
3725 put_str(buf, 3, 10);
3726 sprintf(buf, "%s (%ld)",
3727 (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
3735 msg_print("店主は新たな在庫を取り出した。");
3737 msg_print("The shopkeeper brings out some new stock.");
3743 for (i = 0; i < 10; i++)
3745 /* Maintain the store */
3746 store_maint(p_ptr->town_num, cur_store_num);
3752 /* Redraw everything */
3753 display_inventory();
3756 /* The item is gone */
3757 else if (st_ptr->stock_num != i)
3759 /* Pick the correct screen */
3760 if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
3762 /* Redraw everything */
3763 display_inventory();
3766 /* Item is still here */
3769 /* Redraw the item */
3770 display_entry(item);
3774 /* Player cannot afford it */
3777 /* Simple message (no insult) */
3779 msg_print("お金が足りません。");
3781 msg_print("You do not have enough gold.");
3788 /* Home is much easier */
3791 bool combined_or_reordered;
3793 /* Distribute charges of wands/rods */
3794 distribute_charges(o_ptr, j_ptr, amt);
3796 /* Give it to the player */
3797 item_new = inven_carry(j_ptr);
3799 /* Describe just the result */
3800 object_desc(o_name, &inventory[item_new], 0);
3803 msg_format("%s(%c)を取った。",
3805 msg_format("You have %s (%c).",
3807 o_name, index_to_label(item_new));
3812 /* Take note if we take the last one */
3813 i = st_ptr->stock_num;
3815 /* Remove the items from the home */
3816 store_item_increase(item, -amt);
3817 store_item_optimize(item);
3819 combined_or_reordered = combine_and_reorder_home(STORE_HOME);
3821 /* Hack -- Item is still here */
3822 if (i == st_ptr->stock_num)
3824 /* Redraw everything */
3825 if (combined_or_reordered) display_inventory();
3827 /* Redraw the item */
3828 else display_entry(item);
3831 /* The item is gone */
3835 if (st_ptr->stock_num == 0) store_top = 0;
3837 /* Nothing left on that screen */
3838 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
3840 /* Redraw everything */
3841 display_inventory();
3843 chg_virtue(V_SACRIFICE, 1);
3847 /* Not kicked out */
3853 * @brief 店からの売却処理のメインルーチン /
3854 * Sell an item to the store (or home)
3857 static void store_sell(void)
3864 PRICE price, value, dummy;
3873 char o_name[MAX_NLEN];
3876 /* Prepare a prompt */
3877 if (cur_store_num == STORE_HOME)
3879 q = "どのアイテムを置きますか? ";
3881 q = "Drop which item? ";
3884 else if (cur_store_num == STORE_MUSEUM)
3886 q = "どのアイテムを寄贈しますか? ";
3888 q = "Give which item? ";
3893 q = "どのアイテムを売りますか? ";
3895 q = "Sell which item? ";
3899 item_tester_no_ryoute = TRUE;
3900 /* Only allow items the store will buy */
3901 item_tester_hook = store_will_buy;
3903 /* 我が家でおかしなメッセージが出るオリジナルのバグを修正 */
3904 if (cur_store_num == STORE_HOME)
3907 s = "置けるアイテムを持っていません。";
3909 s = "You don't have any item to drop.";
3912 else if (cur_store_num == STORE_MUSEUM)
3915 s = "寄贈できるアイテムを持っていません。";
3917 s = "You don't have any item to give.";
3925 s = "You have nothing that I want.";
3929 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
3931 /* Get the item (in the pack) */
3934 o_ptr = &inventory[item];
3937 /* Get the item (on the floor) */
3940 o_ptr = &o_list[0 - item];
3944 /* Hack -- Cannot remove cursed items */
3945 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
3948 msg_print("ふーむ、どうやらそれは呪われているようだね。");
3950 msg_print("Hmmm, it seems to be cursed.");
3958 /* Assume one item */
3961 /* Find out how many the player wants (letter means "all") */
3962 if (o_ptr->number > 1)
3964 /* Get a quantity */
3965 amt = get_quantity(NULL, o_ptr->number);
3967 /* Allow user abort */
3968 if (amt <= 0) return;
3971 /* Get local object */
3974 /* Get a copy of the object */
3975 object_copy(q_ptr, o_ptr);
3977 /* Modify quantity */
3978 q_ptr->number = amt;
3981 * Hack -- If a rod or wand, allocate total maximum
3982 * timeouts or charges to those being sold. -LM-
3984 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3986 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
3989 /* Get a full description */
3990 object_desc(o_name, q_ptr, 0);
3992 /* Remove any inscription, feeling for stores */
3993 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3995 q_ptr->inscription = 0;
3996 q_ptr->feeling = FEEL_NONE;
3999 /* Is there room in the store (or the home?) */
4000 if (!store_check_num(q_ptr))
4002 if (cur_store_num == STORE_HOME)
4004 msg_print("我が家にはもう置く場所がない。");
4006 msg_print("Your home is full.");
4009 else if (cur_store_num == STORE_MUSEUM)
4011 msg_print("博物館はもう満杯だ。");
4013 msg_print("Museum is full.");
4018 msg_print("すいませんが、店にはもう置く場所がありません。");
4020 msg_print("I have not the room in my store to keep it.");
4028 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
4030 /* Describe the transaction */
4032 msg_format("%s(%c)を売却する。", o_name, index_to_label(item));
4034 msg_format("Selling %s (%c).", o_name, index_to_label(item));
4040 choice = sell_haggle(q_ptr, &price);
4043 if (st_ptr->store_open >= turn) return;
4055 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
4056 chg_virtue(V_JUSTICE, -1);
4058 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
4059 chg_virtue(V_NATURE, 1);
4062 /* Get some money */
4065 /* Update the display */
4068 /* Get the "apparent" value */
4069 dummy = object_value(q_ptr) * q_ptr->number;
4072 identify_item(o_ptr);
4074 /* Get local object */
4077 /* Get a copy of the object */
4078 object_copy(q_ptr, o_ptr);
4080 /* Modify quantity */
4081 q_ptr->number = amt;
4083 /* Make it look like to be known */
4084 q_ptr->ident |= IDENT_STORE;
4087 * Hack -- If a rod or wand, let the shopkeeper know just
4088 * how many charges he really paid for. -LM-
4090 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
4092 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
4095 /* Get the "actual" value */
4096 value = object_value(q_ptr) * q_ptr->number;
4098 /* Get the description all over again */
4099 object_desc(o_name, q_ptr, 0);
4101 /* Describe the result (in message buffer) */
4103 msg_format("%sを $%ldで売却しました。", o_name, (long)price);
4105 msg_format("You sold %s for %ld gold.", o_name, (long)price);
4108 if (record_sell) do_cmd_write_nikki(NIKKI_SELL, 0, o_name);
4110 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
4112 /* Analyze the prices (and comment verbally) unless a figurine*/
4113 purchase_analyze(price, value, dummy);
4117 * Hack -- Allocate charges between those wands or rods sold
4118 * and retained, unless all are being sold. -LM-
4120 distribute_charges(o_ptr, q_ptr, amt);
4122 /* Reset timeouts of the sold items */
4125 /* Take the item from the player, describe the result */
4126 inven_item_increase(item, -amt);
4127 inven_item_describe(item);
4129 /* If items remain, auto-inscribe before optimizing */
4130 if (o_ptr->number > 0)
4131 autopick_alter_item(item, FALSE);
4133 inven_item_optimize(item);
4138 /* The store gets that (known) item */
4139 item_pos = store_carry(q_ptr);
4141 /* Re-display if item is now in store */
4144 store_top = (item_pos / store_bottom) * store_bottom;
4145 display_inventory();
4150 /* Player is at museum */
4151 else if (cur_store_num == STORE_MUSEUM)
4153 char o2_name[MAX_NLEN];
4154 object_desc(o2_name, q_ptr, OD_NAME_ONLY);
4156 if (-1 == store_check_num(q_ptr))
4159 msg_print("それと同じ品物は既に博物館にあるようです。");
4161 msg_print("The same object as it is already in the Museum.");
4167 msg_print("博物館に寄贈したものは取り出すことができません!!");
4169 msg_print("You cannot take items which is given to the Museum back!!");
4173 if (!get_check(format("本当に%sを寄贈しますか?", o2_name))) return;
4175 if (!get_check(format("Really give %s to the Museum? ", o2_name))) return;
4179 identify_item(q_ptr);
4180 q_ptr->ident |= IDENT_MENTAL;
4182 /* Distribute charges of wands/rods */
4183 distribute_charges(o_ptr, q_ptr, amt);
4187 msg_format("%sを置いた。(%c)", o_name, index_to_label(item));
4189 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4194 /* Take it from the players inventory */
4195 inven_item_increase(item, -amt);
4196 inven_item_describe(item);
4197 inven_item_optimize(item);
4202 /* Let the home carry it */
4203 item_pos = home_carry(q_ptr);
4205 /* Update store display */
4208 store_top = (item_pos / store_bottom) * store_bottom;
4209 display_inventory();
4212 /* Player is at home */
4215 /* Distribute charges of wands/rods */
4216 distribute_charges(o_ptr, q_ptr, amt);
4220 msg_format("%sを置いた。(%c)", o_name, index_to_label(item));
4222 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4227 /* Take it from the players inventory */
4228 inven_item_increase(item, -amt);
4229 inven_item_describe(item);
4230 inven_item_optimize(item);
4235 /* Let the home carry it */
4236 item_pos = home_carry(q_ptr);
4238 /* Update store display */
4241 store_top = (item_pos / store_bottom) * store_bottom;
4242 display_inventory();
4246 if ((choice == 0) && (item >= INVEN_RARM))
4255 * @brief 店のアイテムを調べるコマンドのメインルーチン /
4256 * Examine an item in a store -JDL-
4259 static void store_examine(void)
4264 char o_name[MAX_NLEN];
4269 if (st_ptr->stock_num <= 0)
4271 if (cur_store_num == STORE_HOME)
4273 msg_print("我が家には何も置いてありません。");
4275 msg_print("Your home is empty.");
4278 else if (cur_store_num == STORE_MUSEUM)
4280 msg_print("博物館には何も置いてありません。");
4282 msg_print("Museum is empty.");
4287 msg_print("現在商品の在庫を切らしています。");
4289 msg_print("I am currently out of stock.");
4296 /* Find the number of objects on this and following pages */
4297 i = (st_ptr->stock_num - store_top);
4299 /* And then restrict it to the current page */
4300 if (i > store_bottom) i = store_bottom;
4304 sprintf(out_val, "どれを調べますか?");
4306 sprintf(out_val, "Which item do you want to examine? ");
4310 /* Get the item number to be examined */
4311 if (!get_stock(&item, out_val, 0, i - 1)) return;
4313 /* Get the actual index */
4314 item = item + store_top;
4316 /* Get the actual item */
4317 o_ptr = &st_ptr->stock[item];
4319 /* Require full knowledge */
4320 if (!(o_ptr->ident & IDENT_MENTAL))
4322 /* This can only happen in the home */
4324 msg_print("このアイテムについて特に知っていることはない。");
4326 msg_print("You have no special knowledge about that item.");
4333 object_desc(o_name, o_ptr, 0);
4337 msg_format("%sを調べている...", o_name);
4339 msg_format("Examining %s...", o_name);
4343 /* Describe it fully */
4344 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL))
4346 msg_print("特に変わったところはないようだ。");
4348 msg_print("You see nothing special.");
4357 * @brief 博物館のアイテムを除去するコマンドのメインルーチン /
4358 * Remove an item from museum (Originally from TOband)
4361 static void museum_remove_object(void)
4366 char o_name[MAX_NLEN];
4370 if (st_ptr->stock_num <= 0)
4373 msg_print("博物館には何も置いてありません。");
4375 msg_print("Museum is empty.");
4381 /* Find the number of objects on this and following pages */
4382 i = st_ptr->stock_num - store_top;
4384 /* And then restrict it to the current page */
4385 if (i > store_bottom) i = store_bottom;
4389 sprintf(out_val, "どのアイテムの展示をやめさせますか?");
4391 sprintf(out_val, "Which item do you want to order to remove? ");
4394 /* Get the item number to be removed */
4395 if (!get_stock(&item, out_val, 0, i - 1)) return;
4397 /* Get the actual index */
4398 item = item + store_top;
4400 /* Get the actual item */
4401 o_ptr = &st_ptr->stock[item];
4404 object_desc(o_name, o_ptr, 0);
4407 msg_print("展示をやめさせたアイテムは二度と見ることはできません!");
4408 if (!get_check(format("本当に%sの展示をやめさせますか?", o_name))) return;
4410 msg_print("You cannot see items which is removed from the Museum!");
4411 if (!get_check(format("Really order to remove %s from the Museum? ", o_name))) return;
4415 msg_format("%sの展示をやめさせた。", o_name);
4417 msg_format("You ordered to remove %s.", o_name);
4420 /* Remove the items from the home */
4421 store_item_increase(item, -o_ptr->number);
4422 store_item_optimize(item);
4424 (void)combine_and_reorder_home(STORE_MUSEUM);
4426 /* The item is gone */
4429 if (st_ptr->stock_num == 0) store_top = 0;
4431 /* Nothing left on that screen */
4432 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
4434 /* Redraw everything */
4435 display_inventory();
4442 * Hack -- set this to leave the store
4444 static bool leave_store = FALSE;
4448 * @brief 店舗処理コマンド選択のメインルーチン /
4449 * Process a command in a store
4453 * Note that we must allow the use of a few "special" commands
4454 * in the stores which are not allowed in the dungeon, and we
4455 * must disable some commands which are allowed in the dungeon
4456 * but not in the stores, to prevent chaos.
4459 static void store_process_command(void)
4461 /* Handle repeating the last command */
4464 if (rogue_like_commands && command_cmd == 'l')
4466 command_cmd = 'x'; /* hack! */
4469 /* Parse the command */
4470 switch (command_cmd)
4480 /* 1 ページ戻るコマンド: 我が家のページ数が多いので重宝するはず By BUG */
4483 if (st_ptr->stock_num <= store_bottom) {
4485 msg_print("これで全部です。");
4487 msg_print("Entire inventory is shown.");
4491 store_top -= store_bottom;
4492 if ( store_top < 0 )
4493 store_top = ((st_ptr->stock_num - 1 )/store_bottom) * store_bottom;
4494 if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) )
4495 if ( store_top >= store_bottom ) store_top = store_bottom;
4496 display_inventory();
4504 if (st_ptr->stock_num <= store_bottom)
4507 msg_print("これで全部です。");
4509 msg_print("Entire inventory is shown.");
4515 store_top += store_bottom;
4517 * 隠しオプション(powerup_home)がセットされていないときは
4518 * 我が家では 2 ページまでしか表示しない
4520 if ((cur_store_num == STORE_HOME) &&
4521 (powerup_home == FALSE) &&
4522 (st_ptr->stock_num >= STORE_INVEN_MAX))
4524 if (store_top >= (STORE_INVEN_MAX - 1))
4531 if (store_top >= st_ptr->stock_num) store_top = 0;
4534 display_inventory();
4547 /* Get (purchase) */
4574 /*** Inventory Commands ***/
4576 /* Wear/wield equipment */
4583 /* Take off equipment */
4590 /* Destroy an item */
4597 /* Equipment list */
4604 /* Inventory list */
4612 /*** Various commands ***/
4614 /* Identify an object */
4621 /* Hack -- toggle windows */
4624 toggle_inven_equip();
4630 /*** Use various objects ***/
4635 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4636 (p_ptr->pclass == CLASS_BERSERKER) ||
4637 (p_ptr->pclass == CLASS_NINJA) ||
4638 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4639 ) do_cmd_mind_browse();
4640 else if (p_ptr->pclass == CLASS_SMITH)
4642 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4643 do_cmd_magic_eater(TRUE, FALSE);
4644 else if (p_ptr->pclass == CLASS_SNIPER)
4645 do_cmd_snipe_browse();
4646 else do_cmd_browse();
4650 /* Inscribe an object */
4657 /* Uninscribe an object */
4660 do_cmd_uninscribe();
4666 /*** Help and Such ***/
4675 /* Identify symbol */
4678 do_cmd_query_symbol();
4682 /* Character description */
4685 p_ptr->town_num = old_town_num;
4686 do_cmd_change_name();
4687 p_ptr->town_num = inner_town_num;
4693 /*** System Commands ***/
4695 /* Hack -- User interface */
4702 /* Single line from a pref file */
4705 p_ptr->town_num = old_town_num;
4707 p_ptr->town_num = inner_town_num;
4711 /* Interact with macros */
4714 p_ptr->town_num = old_town_num;
4716 p_ptr->town_num = inner_town_num;
4720 /* Interact with visuals */
4723 p_ptr->town_num = old_town_num;
4725 p_ptr->town_num = inner_town_num;
4729 /* Interact with colors */
4732 p_ptr->town_num = old_town_num;
4734 p_ptr->town_num = inner_town_num;
4738 /* Interact with options */
4742 (void)combine_and_reorder_home(STORE_HOME);
4748 /*** Misc Commands ***/
4764 /* Repeat level feeling */
4771 /* Show previous message */
4774 do_cmd_message_one();
4778 /* Show previous messages */
4791 /* Check artifacts, uniques etc. */
4798 /* Load "screen dump" */
4801 do_cmd_load_screen();
4805 /* Save "screen dump" */
4808 do_cmd_save_screen();
4812 /* Hack -- Unknown command */
4815 if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
4817 museum_remove_object();
4822 msg_print("そのコマンドは店の中では使えません。");
4824 msg_print("That command does not work in stores.");
4835 * @brief 店舗処理全体のメインルーチン /
4836 * Enter a store, and interact with it. *
4840 * Note that we use the standard "request_command()" function
4841 * to get a command, allowing us to use "command_arg" and all
4842 * command macros and other nifty stuff, but we use the special
4843 * "shopping" argument, to force certain commands to be converted
4844 * into other commands, normally, we convert "p" (pray) and "m"
4845 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
4848 void do_cmd_store(void)
4854 bool need_redraw_store_inv; /* To redraw missiles damage and prices in store */
4858 Term_get_size(&w, &h);
4860 /* Calculate stocks per 1 page */
4861 xtra_stock = MIN(14+26, ((h > 24) ? (h - 24) : 0));
4862 store_bottom = MIN_STOCK + xtra_stock;
4864 /* Access the player grid */
4865 c_ptr = &cave[p_ptr->y][p_ptr->x];
4867 /* Verify a store */
4868 if (!cave_have_flag_grid(c_ptr, FF_STORE))
4871 msg_print("ここには店がありません。");
4873 msg_print("You see no store here.");
4879 /* Extract the store code */
4880 which = f_info[c_ptr->feat].subtype;
4882 old_town_num = p_ptr->town_num;
4883 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
4884 if (dun_level) p_ptr->town_num = NO_TOWN;
4885 inner_town_num = p_ptr->town_num;
4887 /* Hack -- Check the "locked doors" */
4888 if ((town[p_ptr->town_num].store[which].store_open >= turn) ||
4892 msg_print("ドアに鍵がかかっている。");
4894 msg_print("The doors are locked.");
4897 p_ptr->town_num = old_town_num;
4901 /* Calculate the number of store maintainances since the last visit */
4902 maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
4904 /* Maintain the store max. 10 times */
4905 if (maintain_num > 10) maintain_num = 10;
4909 /* Maintain the store */
4910 for (i = 0; i < maintain_num; i++)
4911 store_maint(p_ptr->town_num, which);
4913 /* Save the visit */
4914 town[p_ptr->town_num].store[which].last_visit = turn;
4917 /* Forget the lite */
4920 /* Forget the view */
4924 /* Hack -- Character is in "icky" mode */
4925 character_icky = TRUE;
4928 /* No command argument */
4931 /* No repeated command */
4934 /* No automatic command */
4937 /* Do not expand macros */
4938 get_com_no_macros = TRUE;
4940 /* Save the store number */
4941 cur_store_num = which;
4943 /* Hack -- save the store feature */
4944 cur_store_feat = c_ptr->feat;
4946 /* Save the store and owner pointers */
4947 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
4948 ot_ptr = &owners[cur_store_num][st_ptr->owner];
4951 /* Start at the beginning */
4954 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
4956 /* Display the store */
4960 leave_store = FALSE;
4962 /* Interact with player */
4963 while (!leave_store)
4965 /* Hack -- Clear line 1 */
4969 clear_from(20 + xtra_stock);
4972 /* Basic commands */
4974 prt(" ESC) 建物から出る", 21 + xtra_stock, 0);
4976 prt(" ESC) Exit from Building.", 21 + xtra_stock, 0);
4980 /* Browse if necessary */
4981 if (st_ptr->stock_num > store_bottom)
4984 prt(" -)前ページ", 22 + xtra_stock, 0);
4985 prt(" スペース) 次ページ", 23 + xtra_stock, 0);
4987 prt(" -) Previous page", 22 + xtra_stock, 0);
4988 prt(" SPACE) Next page", 23 + xtra_stock, 0);
4994 if (cur_store_num == STORE_HOME)
4997 prt("g) アイテムを取る", 21 + xtra_stock, 27);
4998 prt("d) アイテムを置く", 22 + xtra_stock, 27);
4999 prt("x) 家のアイテムを調べる", 23 + xtra_stock, 27);
5001 prt("g) Get an item.", 21 + xtra_stock, 27);
5002 prt("d) Drop an item.", 22 + xtra_stock, 27);
5003 prt("x) eXamine an item in the home.", 23 + xtra_stock, 27);
5007 /* Museum commands */
5008 else if (cur_store_num == STORE_MUSEUM)
5011 prt("d) アイテムを置く", 21 + xtra_stock, 27);
5012 prt("r) アイテムの展示をやめる", 22 + xtra_stock, 27);
5013 prt("x) 博物館のアイテムを調べる", 23 + xtra_stock, 27);
5015 prt("d) Drop an item.", 21 + xtra_stock, 27);
5016 prt("r) order to Remove an item.", 22 + xtra_stock, 27);
5017 prt("x) eXamine an item in the museum.", 23 + xtra_stock, 27);
5025 prt("p) 商品を買う", 21 + xtra_stock, 30);
5026 prt("s) アイテムを売る", 22 + xtra_stock, 30);
5027 prt("x) 商品を調べる", 23 + xtra_stock,30);
5029 prt("p) Purchase an item.", 21 + xtra_stock, 30);
5030 prt("s) Sell an item.", 22 + xtra_stock, 30);
5031 prt("x) eXamine an item in the shop", 23 + xtra_stock,30);
5038 prt("i/e) 持ち物/装備の一覧", 21 + xtra_stock, 56);
5040 if (rogue_like_commands)
5042 prt("w/T) 装備する/はずす", 22 + xtra_stock, 56);
5046 prt("w/t) 装備する/はずす", 22 + xtra_stock, 56);
5049 prt("i/e) Inventry/Equipment list", 21 + xtra_stock, 56);
5051 if (rogue_like_commands)
5053 prt("w/T) Wear/Take off equipment", 22 + xtra_stock, 56);
5057 prt("w/t) Wear/Take off equipment", 22 + xtra_stock, 56);
5062 prt("コマンド:", 20 + xtra_stock, 0);
5064 prt("You may: ", 20 + xtra_stock, 0);
5069 request_command(TRUE);
5071 /* Process the command */
5072 store_process_command();
5075 * Hack -- To redraw missiles damage and prices in store
5076 * If player's charisma changes, or if player changes a bow, PU_BONUS is set
5078 need_redraw_store_inv = (p_ptr->update & PU_BONUS) ? TRUE : FALSE;
5080 /* Hack -- Character is still in "icky" mode */
5081 character_icky = TRUE;
5090 if (inventory[INVEN_PACK].k_idx)
5092 INVENTORY_IDX item = INVEN_PACK;
5094 object_type *o_ptr = &inventory[item];
5096 /* Hack -- Flee from the store */
5097 if (cur_store_num != STORE_HOME)
5100 if (cur_store_num == STORE_MUSEUM)
5101 msg_print("ザックからアイテムがあふれそうなので、あわてて博物館から出た...");
5103 msg_print("ザックからアイテムがあふれそうなので、あわてて店から出た...");
5105 if (cur_store_num == STORE_MUSEUM)
5106 msg_print("Your pack is so full that you flee the Museum...");
5108 msg_print("Your pack is so full that you flee the store...");
5116 /* Hack -- Flee from the home */
5117 else if (!store_check_num(o_ptr))
5120 msg_print("ザックからアイテムがあふれそうなので、あわてて家から出た...");
5122 msg_print("Your pack is so full that you flee your home...");
5130 /* Hack -- Drop items into the home */
5138 char o_name[MAX_NLEN];
5141 /* Give a message */
5143 msg_print("ザックからアイテムがあふれてしまった!");
5145 msg_print("Your pack overflows!");
5149 /* Get local object */
5152 /* Grab a copy of the item */
5153 object_copy(q_ptr, o_ptr);
5156 object_desc(o_name, q_ptr, 0);
5159 msg_format("%sが落ちた。(%c)", o_name, index_to_label(item));
5161 msg_format("You drop %s (%c).", o_name, index_to_label(item));
5165 /* Remove it from the players inventory */
5166 inven_item_increase(item, -255);
5167 inven_item_describe(item);
5168 inven_item_optimize(item);
5173 /* Let the home carry it */
5174 item_pos = home_carry(q_ptr);
5176 /* Redraw the home */
5179 store_top = (item_pos / store_bottom) * store_bottom;
5180 display_inventory();
5185 /* Hack -- Redisplay store prices if charisma changes */
5186 /* Hack -- Redraw missiles damage if player changes bow */
5187 if (need_redraw_store_inv) display_inventory();
5189 /* Hack -- get kicked out of the store */
5190 if (st_ptr->store_open >= turn) leave_store = TRUE;
5193 select_floor_music();
5195 p_ptr->town_num = old_town_num;
5198 p_ptr->energy_use = 100;
5201 /* Hack -- Character is no longer in "icky" mode */
5202 character_icky = FALSE;
5205 /* Hack -- Cancel automatic command */
5208 /* Hack -- Cancel "see" mode */
5209 command_see = FALSE;
5211 /* Allow expanding macros */
5212 get_com_no_macros = FALSE;
5214 /* Flush messages */
5218 /* Clear the screen */
5222 /* Update everything */
5223 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
5224 p_ptr->update |= (PU_MONSTERS);
5226 /* Redraw entire screen */
5227 p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5230 p_ptr->redraw |= (PR_MAP);
5232 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5238 * @brief 現在の町の店主を交代させる /
5239 * Shuffle one of the stores.
5240 * @param which 店舗種類のID
5243 void store_shuffle(int which)
5249 if (which == STORE_HOME) return;
5250 if (which == STORE_MUSEUM) return;
5253 /* Save the store index */
5254 cur_store_num = which;
5256 /* Activate that store */
5257 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
5260 /* Pick a new owner */
5263 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5264 if (j == st_ptr->owner) continue;
5265 for (i = 1;i < max_towns; i++)
5267 if (i == p_ptr->town_num) continue;
5268 if (st_ptr->owner == town[i].store[cur_store_num].owner) break;
5270 if (i == max_towns) break;
5273 /* Activate the new owner */
5274 ot_ptr = &owners[cur_store_num][st_ptr->owner];
5277 /* Reset the owner data */
5278 st_ptr->insult_cur = 0;
5279 st_ptr->store_open = 0;
5280 st_ptr->good_buy = 0;
5281 st_ptr->bad_buy = 0;
5284 /* Hack -- discount all the items */
5285 for (i = 0; i < st_ptr->stock_num; i++)
5289 o_ptr = &st_ptr->stock[i];
5291 if (!object_is_artifact(o_ptr))
5293 /* Hack -- Sell all non-artifact old items for "half price" */
5294 o_ptr->discount = 50;
5296 /* Hack -- Items are no longer "fixed price" */
5297 o_ptr->ident &= ~(IDENT_FIXED);
5299 /* Mega-Hack -- Note that the item is "on sale" */
5300 o_ptr->inscription = quark_add(_("売出中", "on sale"));
5307 * @brief 店の品揃えを変化させる /
5308 * Maintain the inventory at the stores.
5309 * @param town_num 町のID
5310 * @param store_num 店舗種類のID
5313 void store_maint(int town_num, int store_num)
5317 cur_store_num = store_num;
5320 if (store_num == STORE_HOME) return;
5321 if (store_num == STORE_MUSEUM) return;
5323 /* Activate that store */
5324 st_ptr = &town[town_num].store[store_num];
5326 /* Activate the owner */
5327 ot_ptr = &owners[store_num][st_ptr->owner];
5329 /* Store keeper forgives the player */
5330 st_ptr->insult_cur = 0;
5332 /* Mega-Hack -- prune the black market */
5333 if (store_num == STORE_BLACK)
5335 /* Destroy crappy black market items */
5336 for (j = st_ptr->stock_num - 1; j >= 0; j--)
5338 object_type *o_ptr = &st_ptr->stock[j];
5340 /* Destroy crappy items */
5341 if (black_market_crap(o_ptr))
5343 /* Destroy the item */
5344 store_item_increase(j, 0 - o_ptr->number);
5345 store_item_optimize(j);
5351 /* Choose the number of slots to keep */
5352 j = st_ptr->stock_num;
5354 /* Sell a few items */
5355 j = j - randint1(STORE_TURNOVER);
5357 /* Never keep more than "STORE_MAX_KEEP" slots */
5358 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
5360 /* Always "keep" at least "STORE_MIN_KEEP" items */
5361 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
5363 /* Hack -- prevent "underflow" */
5366 /* Destroy objects until only "j" slots are left */
5367 while (st_ptr->stock_num > j) store_delete();
5370 /* Choose the number of slots to fill */
5371 j = st_ptr->stock_num;
5373 /* Buy some more items */
5374 j = j + randint1(STORE_TURNOVER);
5376 /* Never keep more than "STORE_MAX_KEEP" slots */
5377 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
5379 /* Always "keep" at least "STORE_MIN_KEEP" items */
5380 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
5382 /* Hack -- prevent "overflow" */
5383 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
5385 /* Acquire some new items */
5386 while (st_ptr->stock_num < j) store_create();
5391 * @brief 店舗情報を初期化する /
5392 * Initialize the stores
5393 * @param town_num 町のID
5394 * @param store_num 店舗種類のID
5397 void store_init(int town_num, int store_num)
5401 cur_store_num = store_num;
5403 /* Activate that store */
5404 st_ptr = &town[town_num].store[store_num];
5412 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5413 for (i = 1;i < max_towns; i++)
5415 if (i == town_num) continue;
5416 if (st_ptr->owner == town[i].store[store_num].owner) break;
5418 if (i == max_towns) break;
5421 /* Activate the new owner */
5422 ot_ptr = &owners[store_num][st_ptr->owner];
5425 /* Initialize the store */
5426 st_ptr->store_open = 0;
5427 st_ptr->insult_cur = 0;
5428 st_ptr->good_buy = 0;
5429 st_ptr->bad_buy = 0;
5431 /* Nothing in stock */
5432 st_ptr->stock_num = 0;
5435 * MEGA-HACK - Last visit to store is
5436 * BEFORE player birth to enable store restocking
5438 st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
5440 /* Clear any old items */
5441 for (k = 0; k < st_ptr->stock_size; k++)
5443 object_wipe(&st_ptr->stock[k]);
5449 * @brief アイテムを町のブラックマーケットに移動させる /
5450 * @param o_ptr 移動させたいオブジェクトの構造体参照ポインタ
5453 void move_to_black_market(object_type *o_ptr)
5456 if (!p_ptr->town_num) return;
5458 st_ptr = &town[p_ptr->town_num].store[STORE_BLACK];
5460 o_ptr->ident |= IDENT_STORE;
5462 (void)store_carry(o_ptr);
5464 object_wipe(o_ptr); /* Don't leave a bogus object behind... */