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)]);
568 chg_virtue(V_HONOUR, -1);
569 chg_virtue(V_JUSTICE, -1);
573 /* Item was cheaper than we thought, and we paid more than necessary */
574 else if ((value < guess) && (price > value))
576 msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
577 chg_virtue(V_JUSTICE, -1);
578 if (one_in_(4)) chg_virtue(V_HONOUR, -1);
582 /* Item was a good bargain, and we got away with it */
583 else if ((value > guess) && (value < (4 * guess)) && (price < value))
585 msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
586 if (one_in_(4)) chg_virtue(V_HONOUR, -1);
587 else if (one_in_(4)) chg_virtue(V_HONOUR, 1);
591 /* Item was a great bargain, and we got away with it */
592 else if ((value > guess) && (price < value))
594 msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
595 if (one_in_(2)) chg_virtue(V_HONOUR, -1);
596 if (one_in_(4)) chg_virtue(V_HONOUR, 1);
597 if (10 * price < value) chg_virtue(V_SACRIFICE, 1);
605 * We store the current "store feat" here so everyone can access it
607 static int cur_store_feat;
611 * Buying and selling adjustments for race combinations.
612 * Entry[owner][player] gives the basic "cost inflation".
614 static byte rgold_adj[MAX_RACES][MAX_RACES] =
616 /*Hum, HfE, Elf, Hal, Gno, Dwa, HfO, HfT, Dun, HiE, Barbarian,
617 HfOg, HGn, HTn, Cyc, Yek, Klc, Kbd, Nbl, DkE, Drc, Mind Flayer,
618 Imp, Glm, Skl, Zombie, Vampire, Spectre, Fairy, Beastman, Ent,
619 Angel, Demon, Kutar */
622 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
623 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
624 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
625 100, 120, 110, 105 },
628 { 110, 100, 100, 105, 110, 120, 125, 130, 110, 100, 110,
629 120, 115, 108, 115, 110, 110, 120, 120, 115, 115, 110,
630 120, 110, 110, 110, 120, 110, 100, 125, 100, 95, 140,
631 110, 115, 110, 110 },
634 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
635 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
636 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
637 110, 110, 105, 110 },
640 { 115, 110, 105, 95, 105, 110, 115, 130, 115, 105, 115,
641 125, 120, 120, 125, 115, 110, 120, 120, 120, 115, 115,
642 120, 110, 120, 120, 130, 110, 110, 130, 110, 95, 140,
643 115, 120, 105, 115 },
646 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
647 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
648 120, 101, 110, 110, 120, 120, 115, 130, 115, 95, 140,
649 115, 110, 110, 115 },
652 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
653 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
654 120, 105, 115, 115, 115, 115, 120, 130, 120, 95, 140,
655 115, 110, 115, 115 },
658 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
659 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
660 115, 125, 120, 120, 115, 120, 125, 115, 125, 95, 140,
661 115, 110, 115, 115 },
664 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
665 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
666 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
667 110, 110, 115, 110 },
670 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
671 120, 120, 105, 120, 115, 105, 115, 120, 110, 105, 105,
672 120, 105, 120, 120, 125, 120, 105, 135, 105, 95, 140,
673 100, 110, 110, 100 },
676 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
677 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
678 125, 115, 120, 120, 125, 120, 100, 125, 100, 95, 140,
679 110, 110, 105, 110 },
681 /* Human / Barbarian (copied from human) */
682 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
683 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
684 115, 105, 125, 125, 130, 125, 115, 120, 115, 95, 140,
685 100, 120, 110, 100 },
687 /* Half-Ogre: theoretical, copied from half-troll */
688 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
689 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
690 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
691 110, 110, 115, 110 },
693 /* Half-Giant: theoretical, copied from half-troll */
694 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
695 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
696 110, 115, 112, 112, 115, 112, 130, 120, 130, 95, 140,
697 110, 110, 115, 110 },
699 /* Half-Titan: theoretical, copied from High_Elf */
700 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
701 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
702 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
703 110, 110, 115, 110 },
705 /* Cyclops: theoretical, copied from half-troll */
706 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
707 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
708 110, 115, 112, 112, 115, 112, 130, 130, 130, 95, 140,
709 110, 110, 115, 110 },
711 /* Yeek: theoretical, copied from Half-Orc */
712 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
713 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
714 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
715 115, 110, 115, 115 },
717 /* Klackon: theoretical, copied from Gnome */
718 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
719 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
720 120, 101, 110, 110, 120, 120, 130, 130, 130, 95, 140,
721 115, 110, 115, 115 },
723 /* Kobold: theoretical, copied from Half-Orc */
724 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
725 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
726 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
727 115, 110, 115, 115 },
729 /* Nibelung: theoretical, copied from Dwarf */
730 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
731 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
732 120, 105, 115, 115, 120, 120, 130, 130, 130, 95, 140,
733 115, 135, 115, 115 },
736 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
737 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
738 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
739 110, 101, 115, 110 },
741 /* Draconian: theoretical, copied from High_Elf */
742 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
743 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
744 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
745 110, 110, 115, 110 },
747 /* Mind Flayer: theoretical, copied from High_Elf */
748 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
749 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
750 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
751 110, 110, 115, 110 },
753 /* Imp: theoretical, copied from High_Elf */
754 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
755 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
756 125, 115, 120, 120, 120, 120, 130, 130, 130, 120, 120,
757 110, 110, 115, 110 },
759 /* Golem: theoretical, copied from High_Elf */
760 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
761 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
762 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
763 110, 110, 115, 110 },
765 /* Skeleton: theoretical, copied from half-orc */
766 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
767 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
768 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
769 115, 110, 125, 115 },
771 /* Zombie: Theoretical, copied from half-orc */
772 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
773 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
774 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
775 115, 110, 125, 115 },
777 /* Vampire: Theoretical, copied from half-orc */
778 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
779 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
780 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
781 115, 110, 125, 115 },
783 /* Spectre: Theoretical, copied from half-orc */
784 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
785 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
786 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
787 115, 110, 125, 115 },
789 /* Sprite: Theoretical, copied from half-orc */
790 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
791 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
792 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
793 115, 110, 105, 115 },
795 /* Beastman: Theoretical, copied from half-orc */
796 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
797 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
798 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
799 115, 110, 115, 115 },
802 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
803 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
804 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
805 110, 110, 105, 110 },
808 { 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
809 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
810 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 160,
814 { 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
815 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
816 140, 140, 140, 140, 140, 140, 140, 140, 140, 160, 120,
817 140, 140, 140, 140 },
820 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
821 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
822 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
823 100, 120, 110, 100 },
826 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
827 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
828 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
829 110, 101, 115, 110 },
832 { 110, 110, 105, 105, 110, 115, 115, 115, 110, 105, 110,
833 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
834 115, 115, 125, 125, 125, 125, 105, 115, 105, 95, 140,
835 110, 115, 100, 110 },
838 { 105, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
839 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
840 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
841 100, 120, 110, 100 },
848 * Determine the price of an item (qty one) in a store.
849 * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
850 * @param greed 店主の強欲度
851 * @param flip TRUEならば店主にとっての買取価格、FALSEなら売出価格を計算
855 * This function takes into account the player's charisma, and the
856 * shop-keepers friendliness, and the shop-keeper's base greed, but
857 * never lets a shop-keeper lose money in a transaction.
858 * The "greed" value should exceed 100 when the player is "buying" the
859 * item, and should be less than 100 when the player is "selling" it.
860 * Hack -- the black market always charges twice as much as it should.
861 * Charisma adjustment runs from 80 to 130
862 * Racial adjustment runs from 95 to 130
863 * Since greed/charisma/racial adjustments are centered at 100, we need
864 * to adjust (by 200) to extract a usable multiplier. Note that the
865 * "greed" value is always something (?).
868 static s32b price_item(object_type *o_ptr, int greed, bool flip)
875 /* Get the value of one of the items */
876 price = object_value(o_ptr);
878 /* Worthless items */
879 if (price <= 0) return (0L);
882 /* Compute the racial factor */
883 factor = rgold_adj[ot_ptr->owner_race][p_ptr->prace];
885 /* Add in the charisma factor */
886 factor += adj_chr_gold[p_ptr->stat_ind[A_CHR]];
892 /* Adjust for greed */
893 adjust = 100 + (300 - (greed + factor));
895 /* Never get "silly" */
896 if (adjust > 100) adjust = 100;
898 /* Mega-Hack -- Black market sucks */
899 if (cur_store_num == STORE_BLACK)
902 /* Compute the final price (with rounding) */
903 /* Hack -- prevent underflow */
904 price = (price * adjust + 50L) / 100L;
907 /* Shop is selling */
910 /* Adjust for greed */
911 adjust = 100 + ((greed + factor) - 300);
913 /* Never get "silly" */
914 if (adjust < 100) adjust = 100;
916 /* Mega-Hack -- Black market sucks */
917 if (cur_store_num == STORE_BLACK)
920 /* Compute the final price (with rounding) */
921 /* Hack -- prevent overflow */
922 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
925 /* Note -- Never become "free" */
926 if (price <= 0L) return (1L);
928 /* Return the price */
934 * @brief 安価な消耗品の販売数を増やし、低確率で割引にする /
935 * Certain "cheap" objects should be created in "piles"
936 * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
940 * Some objects can be sold at a "discount" (in small piles)
943 static void mass_produce(object_type *o_ptr)
946 DISCOUNT_RATE discount = 0;
948 s32b cost = object_value(o_ptr);
951 /* Analyze the type */
954 /* Food, Flasks, and Lites */
959 if (cost <= 5L) size += damroll(3, 5);
960 if (cost <= 20L) size += damroll(3, 5);
961 if (cost <= 50L) size += damroll(2, 2);
968 if (cost <= 60L) size += damroll(3, 5);
969 if (cost <= 240L) size += damroll(1, 5);
970 if (o_ptr->sval == SV_SCROLL_STAR_IDENTIFY) size += damroll(3, 5);
971 if (o_ptr->sval == SV_SCROLL_STAR_REMOVE_CURSE) size += damroll(1, 4);
976 case TV_SORCERY_BOOK:
984 case TV_CRUSADE_BOOK:
986 case TV_HISSATSU_BOOK:
989 if (cost <= 50L) size += damroll(2, 3);
990 if (cost <= 500L) size += damroll(1, 3);
1008 if (object_is_artifact(o_ptr)) break;
1009 if (object_is_ego(o_ptr)) break;
1010 if (cost <= 10L) size += damroll(3, 5);
1011 if (cost <= 100L) size += damroll(3, 5);
1020 if (cost <= 5L) size += damroll(5, 5);
1021 if (cost <= 50L) size += damroll(5, 5);
1022 if (cost <= 500L) size += damroll(5, 5);
1028 if (cost <= 100L) size += damroll(2, 2);
1029 if (cost <= 1000L) size += damroll(2, 2);
1042 * Because many rods (and a few wands and staffs) are useful mainly
1043 * in quantity, the Black Market will occasionally have a bunch of
1050 if ((cur_store_num == STORE_BLACK) && one_in_(3))
1052 if (cost < 1601L) size += damroll(1, 5);
1053 else if (cost < 3201L) size += damroll(1, 3);
1060 /* Pick a discount */
1065 else if (one_in_(25))
1069 else if (one_in_(150))
1073 else if (one_in_(300))
1077 else if (one_in_(500))
1082 if (o_ptr->art_name)
1087 /* Save the discount */
1088 o_ptr->discount = discount;
1090 /* Save the total pile size */
1091 o_ptr->number = size - (size * discount / 100);
1093 /* Ensure that mass-produced rods and wands get the correct pvals. */
1094 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1096 o_ptr->pval *= (PARAMETER_VALUE)o_ptr->number;
1103 * @brief 店舗に並べた品を同一品であるかどうか判定する /
1104 * Determine if a store item can "absorb" another item
1105 * @param o_ptr 判定するオブジェクト構造体の参照ポインタ1
1106 * @param j_ptr 判定するオブジェクト構造体の参照ポインタ2
1107 * @return 同一扱いできるならTRUEを返す
1110 * See "object_similar()" for the same function for the "player"
1113 static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
1117 /* Hack -- Identical items cannot be stacked */
1118 if (o_ptr == j_ptr) return (0);
1120 /* Different objects cannot be stacked */
1121 if (o_ptr->k_idx != j_ptr->k_idx) return (0);
1123 /* Different charges (etc) cannot be stacked, unless wands or rods. */
1124 if ((o_ptr->pval != j_ptr->pval) && (o_ptr->tval != TV_WAND) && (o_ptr->tval != TV_ROD)) return (0);
1126 /* Require many identical values */
1127 if (o_ptr->to_h != j_ptr->to_h) return (0);
1128 if (o_ptr->to_d != j_ptr->to_d) return (0);
1129 if (o_ptr->to_a != j_ptr->to_a) return (0);
1131 /* Require identical "ego-item" names */
1132 if (o_ptr->name2 != j_ptr->name2) return (0);
1134 /* Artifacts don't stack! */
1135 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return (0);
1137 /* Hack -- Identical art_flags! */
1138 for (i = 0; i < TR_FLAG_SIZE; i++)
1139 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return (0);
1141 /* Hack -- Never stack "powerful" items */
1142 if (o_ptr->xtra1 || j_ptr->xtra1) return (0);
1144 /* Hack -- Never stack recharging items */
1145 if (o_ptr->timeout || j_ptr->timeout) return (0);
1147 /* Require many identical values */
1148 if (o_ptr->ac != j_ptr->ac) return (0);
1149 if (o_ptr->dd != j_ptr->dd) return (0);
1150 if (o_ptr->ds != j_ptr->ds) return (0);
1152 /* Hack -- Never stack chests */
1153 if (o_ptr->tval == TV_CHEST) return (0);
1154 if (o_ptr->tval == TV_STATUE) return (0);
1155 if (o_ptr->tval == TV_CAPTURE) return (0);
1157 /* Require matching discounts */
1158 if (o_ptr->discount != j_ptr->discount) return (0);
1160 /* They match, so they must be similar */
1166 * @brief 店舗に並べた品を重ね合わせできるかどうか判定する /
1167 * Allow a store item to absorb another item
1168 * @param o_ptr 判定するオブジェクト構造体の参照ポインタ1
1169 * @param j_ptr 判定するオブジェクト構造体の参照ポインタ2
1170 * @return 重ね合わせできるならTRUEを返す
1173 * See "object_similar()" for the same function for the "player"
1176 static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
1178 int max_num = (o_ptr->tval == TV_ROD) ?
1179 MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99;
1180 int total = o_ptr->number + j_ptr->number;
1181 int diff = (total > max_num) ? total - max_num : 0;
1183 /* Combine quantity, lose excess items */
1184 o_ptr->number = (total > max_num) ? max_num : total;
1186 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
1187 if (o_ptr->tval == TV_ROD)
1189 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1192 /* Hack -- if wands are stacking, combine the charges. -LM- */
1193 if (o_ptr->tval == TV_WAND)
1195 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1201 * @brief 店舗に品を置くスペースがあるかどうかの判定を返す /
1202 * Check to see if the shop will be carrying too many objects -RAK-
1203 * @param o_ptr 店舗に置きたいオブジェクト構造体の参照ポインタ
1204 * @return 置き場がないなら0、重ね合わせできるアイテムがあるなら-1、スペースがあるなら1を返す。
1207 * Note that the shop, just like a player, will not accept things
1208 * it cannot hold. Before, one could "nuke" potions this way.
1209 * Return value is now int:
1211 * -1 : Can be combined to existing slot.
1212 * 1 : Cannot be combined but there are empty spaces.
1215 static int store_check_num(object_type *o_ptr)
1220 /* The "home" acts like the player */
1221 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
1223 bool old_stack_force_notes = stack_force_notes;
1224 bool old_stack_force_costs = stack_force_costs;
1226 if (cur_store_num != STORE_HOME)
1228 stack_force_notes = FALSE;
1229 stack_force_costs = FALSE;
1232 /* Check all the items */
1233 for (i = 0; i < st_ptr->stock_num; i++)
1235 /* Get the existing item */
1236 j_ptr = &st_ptr->stock[i];
1238 /* Can the new object be combined with the old one? */
1239 if (object_similar(j_ptr, o_ptr))
1241 if (cur_store_num != STORE_HOME)
1243 stack_force_notes = old_stack_force_notes;
1244 stack_force_costs = old_stack_force_costs;
1251 if (cur_store_num != STORE_HOME)
1253 stack_force_notes = old_stack_force_notes;
1254 stack_force_costs = old_stack_force_costs;
1258 /* Normal stores do special stuff */
1261 /* Check all the items */
1262 for (i = 0; i < st_ptr->stock_num; i++)
1264 /* Get the existing item */
1265 j_ptr = &st_ptr->stock[i];
1267 /* Can the new object be combined with the old one? */
1268 if (store_object_similar(j_ptr, o_ptr)) return -1;
1272 /* Free space is always usable */
1274 * オプション powerup_home が設定されていると
1277 if ((cur_store_num == STORE_HOME) && ( powerup_home == FALSE )) {
1278 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) {
1283 if (st_ptr->stock_num < st_ptr->stock_size) {
1288 /* But there was no room at the inn... */
1293 * @brief オブジェクトが祝福されているかの判定を返す /
1294 * @param o_ptr 判定したいオブジェクト構造体の参照ポインタ
1295 * @return アイテムが祝福されたアイテムならばTRUEを返す
1297 static bool is_blessed(object_type *o_ptr)
1299 BIT_FLAGS flgs[TR_FLAG_SIZE];
1300 object_flags(o_ptr, flgs);
1301 if (have_flag(flgs, TR_BLESSED)) return (TRUE);
1302 else return (FALSE);
1308 * @brief オブジェクトが所定の店舗で引き取れるかどうかを返す /
1309 * Determine if the current store will purchase the given item
1310 * @param o_ptr 判定したいオブジェクト構造体の参照ポインタ
1311 * @return アイテムが買い取れるならばTRUEを返す
1313 * Note that a shop-keeper must refuse to buy "worthless" items
1315 static bool store_will_buy(object_type *o_ptr)
1317 /* Hack -- The Home is simple */
1318 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) return (TRUE);
1320 /* Switch on the store */
1321 switch (cur_store_num)
1326 /* Analyze the type */
1327 switch (o_ptr->tval)
1330 if (o_ptr->sval != SV_POTION_WATER) return FALSE;
1342 case TV_BOTTLE: /* 'Green', recycling Angband */
1357 /* Analyze the type */
1358 switch (o_ptr->tval)
1379 /* Analyze the type */
1380 switch (o_ptr->tval)
1389 case TV_HISSATSU_BOOK:
1393 if(o_ptr->sval == SV_WIZSTAFF) return (FALSE);
1405 /* Analyze the type */
1406 switch (o_ptr->tval)
1409 case TV_CRUSADE_BOOK:
1419 monster_race *r_ptr = &r_info[o_ptr->pval];
1422 if (!(r_ptr->flags3 & RF3_EVIL))
1425 if (r_ptr->flags3 & RF3_GOOD) break;
1427 /* Accept animals */
1428 if (r_ptr->flags3 & RF3_ANIMAL) break;
1431 if (my_strchr("?!", r_ptr->d_char)) break;
1437 if (is_blessed(o_ptr)) break;
1446 case STORE_ALCHEMIST:
1448 /* Analyze the type */
1449 switch (o_ptr->tval)
1463 /* Analyze the type */
1464 switch (o_ptr->tval)
1466 case TV_SORCERY_BOOK:
1467 case TV_NATURE_BOOK:
1471 case TV_ARCANE_BOOK:
1473 case TV_DAEMON_BOOK:
1487 if(o_ptr->sval == SV_WIZSTAFF) break;
1488 else return (FALSE);
1495 /* Bookstore Shop */
1498 /* Analyze the type */
1499 switch (o_ptr->tval)
1501 case TV_SORCERY_BOOK:
1502 case TV_NATURE_BOOK:
1507 case TV_ARCANE_BOOK:
1509 case TV_DAEMON_BOOK:
1510 case TV_CRUSADE_BOOK:
1521 /* Ignore "worthless" items */
1522 if (object_value(o_ptr) <= 0) return (FALSE);
1530 * @brief 現在の町の指定された店舗のアイテムを整理する /
1531 * Combine and reorder items in store.
1532 * @param store_num 店舗ID
1533 * @return 実際に整理が行われたならばTRUEを返す。
1535 bool combine_and_reorder_home(int store_num)
1539 object_type forge, *o_ptr, *j_ptr;
1540 bool flag = FALSE, combined;
1541 store_type *old_st_ptr = st_ptr;
1542 bool old_stack_force_notes = stack_force_notes;
1543 bool old_stack_force_costs = stack_force_costs;
1545 st_ptr = &town[1].store[store_num];
1546 if (store_num != STORE_HOME)
1548 stack_force_notes = FALSE;
1549 stack_force_costs = FALSE;
1556 /* Combine the items in the home (backwards) */
1557 for (i = st_ptr->stock_num - 1; i > 0; i--)
1559 o_ptr = &st_ptr->stock[i];
1561 /* Skip empty items */
1562 if (!o_ptr->k_idx) continue;
1564 /* Scan the items above that item */
1565 for (j = 0; j < i; j++)
1569 j_ptr = &st_ptr->stock[j];
1571 /* Skip empty items */
1572 if (!j_ptr->k_idx) continue;
1575 * Get maximum number of the stack if these
1576 * are similar, get zero otherwise.
1578 max_num = object_similar_part(j_ptr, o_ptr);
1580 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
1581 if (max_num && j_ptr->number < max_num)
1583 if (o_ptr->number + j_ptr->number <= max_num)
1585 /* Add together the item counts */
1586 object_absorb(j_ptr, o_ptr);
1588 /* One object is gone */
1589 st_ptr->stock_num--;
1591 /* Slide everything down */
1592 for (k = i; k < st_ptr->stock_num; k++)
1594 /* Structure copy */
1595 st_ptr->stock[k] = st_ptr->stock[k + 1];
1598 /* Erase the "final" slot */
1599 object_wipe(&st_ptr->stock[k]);
1603 ITEM_NUMBER old_num = o_ptr->number;
1604 ITEM_NUMBER remain = j_ptr->number + o_ptr->number - max_num;
1606 /* Add together the item counts */
1607 object_absorb(j_ptr, o_ptr);
1609 o_ptr->number = remain;
1611 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1612 if (o_ptr->tval == TV_ROD)
1614 o_ptr->pval = o_ptr->pval * remain / old_num;
1615 o_ptr->timeout = o_ptr->timeout * remain / old_num;
1618 /* Hack -- if wands are stacking, combine the charges. -LM- */
1619 else if (o_ptr->tval == TV_WAND)
1621 o_ptr->pval = o_ptr->pval * remain / old_num;
1637 /* Re-order the items in the home (forwards) */
1638 for (i = 0; i < st_ptr->stock_num; i++)
1640 o_ptr = &st_ptr->stock[i];
1642 /* Skip empty slots */
1643 if (!o_ptr->k_idx) continue;
1645 /* Get the "value" of the item */
1646 o_value = object_value(o_ptr);
1648 /* Scan every occupied slot */
1649 for (j = 0; j < st_ptr->stock_num; j++)
1651 if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
1654 /* Never move down */
1655 if (j >= i) continue;
1661 /* Save a copy of the moving item */
1662 object_copy(j_ptr, &st_ptr->stock[i]);
1664 /* Slide the objects */
1665 for (k = i; k > j; k--)
1667 /* Slide the item */
1668 object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
1671 /* Insert the moving item */
1672 object_copy(&st_ptr->stock[j], j_ptr);
1675 st_ptr = old_st_ptr;
1676 if (store_num != STORE_HOME)
1678 stack_force_notes = old_stack_force_notes;
1679 stack_force_costs = old_stack_force_costs;
1687 * @brief 我が家にオブジェクトを加える /
1688 * Add the item "o_ptr" to the inventory of the "Home"
1689 * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
1693 * In all cases, return the slot (or -1) where the object was placed
1694 * Note that this is a hacked up version of "inven_carry()".
1695 * Also note that it may not correctly "adapt" to "knowledge" bacoming
1696 * known, the player may have to pick stuff up and drop it again.
1699 static int home_carry(object_type *o_ptr)
1705 bool old_stack_force_notes = stack_force_notes;
1706 bool old_stack_force_costs = stack_force_costs;
1708 if (cur_store_num != STORE_HOME)
1710 stack_force_notes = FALSE;
1711 stack_force_costs = FALSE;
1714 /* Check each existing item (try to combine) */
1715 for (slot = 0; slot < st_ptr->stock_num; slot++)
1717 /* Get the existing item */
1718 j_ptr = &st_ptr->stock[slot];
1720 /* The home acts just like the player */
1721 if (object_similar(j_ptr, o_ptr))
1723 /* Save the new number of items */
1724 object_absorb(j_ptr, o_ptr);
1726 if (cur_store_num != STORE_HOME)
1728 stack_force_notes = old_stack_force_notes;
1729 stack_force_costs = old_stack_force_costs;
1737 if (cur_store_num != STORE_HOME)
1739 stack_force_notes = old_stack_force_notes;
1740 stack_force_costs = old_stack_force_costs;
1745 * 隠し機能: オプション powerup_home が設定されていると
1749 if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE)) {
1750 if (st_ptr->stock_num >= st_ptr->stock_size) {
1755 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10)) {
1761 /* Determine the "value" of the item */
1762 value = object_value(o_ptr);
1764 /* Check existing slots to see if we must "slide" */
1765 for (slot = 0; slot < st_ptr->stock_num; slot++)
1767 if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
1770 /* Slide the others up */
1771 for (i = st_ptr->stock_num; i > slot; i--)
1773 st_ptr->stock[i] = st_ptr->stock[i-1];
1776 /* More stuff now */
1777 st_ptr->stock_num++;
1779 /* Insert the new item */
1780 st_ptr->stock[slot] = *o_ptr;
1782 chg_virtue(V_SACRIFICE, -1);
1784 (void)combine_and_reorder_home(cur_store_num);
1786 /* Return the location */
1792 * @brief 店舗にオブジェクトを加える /
1793 * Add the item "o_ptr" to a real stores inventory.
1794 * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
1798 * In all cases, return the slot (or -1) where the object was placed
1799 * Note that this is a hacked up version of "inven_carry()".
1800 * Also note that it may not correctly "adapt" to "knowledge" bacoming
1801 * known, the player may have to pick stuff up and drop it again.
1804 static int store_carry(object_type *o_ptr)
1807 s32b value, j_value;
1811 /* Evaluate the object */
1812 value = object_value(o_ptr);
1814 /* Cursed/Worthless items "disappear" when sold */
1815 if (value <= 0) return (-1);
1817 /* All store items are fully *identified* */
1818 o_ptr->ident |= IDENT_MENTAL;
1820 /* Erase the inscription */
1821 o_ptr->inscription = 0;
1823 /* Erase the "feeling" */
1824 o_ptr->feeling = FEEL_NONE;
1826 /* Check each existing item (try to combine) */
1827 for (slot = 0; slot < st_ptr->stock_num; slot++)
1829 /* Get the existing item */
1830 j_ptr = &st_ptr->stock[slot];
1832 /* Can the existing items be incremented? */
1833 if (store_object_similar(j_ptr, o_ptr))
1835 /* Hack -- extra items disappear */
1836 store_object_absorb(j_ptr, o_ptr);
1844 if (st_ptr->stock_num >= st_ptr->stock_size) return (-1);
1847 /* Check existing slots to see if we must "slide" */
1848 for (slot = 0; slot < st_ptr->stock_num; slot++)
1851 j_ptr = &st_ptr->stock[slot];
1853 /* Objects sort by decreasing type */
1854 if (o_ptr->tval > j_ptr->tval) break;
1855 if (o_ptr->tval < j_ptr->tval) continue;
1857 /* Objects sort by increasing sval */
1858 if (o_ptr->sval < j_ptr->sval) break;
1859 if (o_ptr->sval > j_ptr->sval) continue;
1862 * Hack: otherwise identical rods sort by
1863 * increasing recharge time --dsb
1865 if (o_ptr->tval == TV_ROD)
1867 if (o_ptr->pval < j_ptr->pval) break;
1868 if (o_ptr->pval > j_ptr->pval) continue;
1871 /* Evaluate that slot */
1872 j_value = object_value(j_ptr);
1874 /* Objects sort by decreasing value */
1875 if (value > j_value) break;
1876 if (value < j_value) continue;
1879 /* Slide the others up */
1880 for (i = st_ptr->stock_num; i > slot; i--)
1882 st_ptr->stock[i] = st_ptr->stock[i-1];
1885 /* More stuff now */
1886 st_ptr->stock_num++;
1888 /* Insert the new item */
1889 st_ptr->stock[slot] = *o_ptr;
1891 /* Return the location */
1897 * @brief 店舗のオブジェクト数を増やす /
1898 * Add the item "o_ptr" to a real stores inventory.
1899 * @param item 増やしたいアイテムのID
1904 * Increase, by a given amount, the number of a certain item
1905 * in a certain store. This can result in zero items.
1907 * @todo numは本来ITEM_NUMBER型にしたい。
1909 static void store_item_increase(INVENTORY_IDX item, int num)
1914 o_ptr = &st_ptr->stock[item];
1916 /* Verify the number */
1917 cnt = o_ptr->number + num;
1918 if (cnt > 255) cnt = 255;
1919 else if (cnt < 0) cnt = 0;
1920 num = cnt - o_ptr->number;
1922 /* Save the new number */
1923 o_ptr->number += (ITEM_NUMBER)num;
1928 * @brief 店舗のオブジェクト数を削除する /
1929 * Remove a slot if it is empty
1930 * @param item 削除したいアイテムのID
1933 static void store_item_optimize(INVENTORY_IDX item)
1938 o_ptr = &st_ptr->stock[item];
1941 if (!o_ptr->k_idx) return;
1943 /* Must have no items */
1944 if (o_ptr->number) return;
1947 st_ptr->stock_num--;
1949 /* Slide everyone */
1950 for (j = item; j < st_ptr->stock_num; j++)
1952 st_ptr->stock[j] = st_ptr->stock[j + 1];
1955 /* Nuke the final slot */
1956 object_wipe(&st_ptr->stock[j]);
1960 * @brief ブラックマーケット用の無価値品の排除判定 /
1961 * This function will keep 'crap' out of the black market.
1962 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1963 * @return ブラックマーケットにとって無価値な品ならばTRUEを返す
1966 * Crap is defined as any item that is "available" elsewhere
1967 * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com>
1970 static bool black_market_crap(object_type *o_ptr)
1974 /* Ego items are never crap */
1975 if (object_is_ego(o_ptr)) return (FALSE);
1977 /* Good items are never crap */
1978 if (o_ptr->to_a > 0) return (FALSE);
1979 if (o_ptr->to_h > 0) return (FALSE);
1980 if (o_ptr->to_d > 0) return (FALSE);
1982 /* Check all stores */
1983 for (i = 0; i < MAX_STORES; i++)
1985 if (i == STORE_HOME) continue;
1986 if (i == STORE_MUSEUM) continue;
1988 /* Check every item in the store */
1989 for (j = 0; j < town[p_ptr->town_num].store[i].stock_num; j++)
1991 object_type *j_ptr = &town[p_ptr->town_num].store[i].stock[j];
1993 /* Duplicate item "type", assume crappy */
1994 if (o_ptr->k_idx == j_ptr->k_idx) return (TRUE);
2004 * @brief 店舗の品揃え変化のためにアイテムを削除する /
2005 * Attempt to delete (some of) a random item from the store
2009 * Hack -- we attempt to "maintain" piles of items when possible.
2012 static void store_delete(void)
2017 /* Pick a random slot */
2018 what = (INVENTORY_IDX)randint0(st_ptr->stock_num);
2020 /* Determine how many items are here */
2021 num = st_ptr->stock[what].number;
2023 /* Hack -- sometimes, only destroy half the items */
2024 if (randint0(100) < 50) num = (num + 1) / 2;
2026 /* Hack -- sometimes, only destroy a single item */
2027 if (randint0(100) < 50) num = 1;
2029 /* Hack -- decrement the maximum timeouts and total charges of rods and wands. -LM- */
2030 if ((st_ptr->stock[what].tval == TV_ROD) || (st_ptr->stock[what].tval == TV_WAND))
2032 st_ptr->stock[what].pval -= num * st_ptr->stock[what].pval / st_ptr->stock[what].number;
2035 /* Actually destroy (part of) the item */
2036 store_item_increase(what, -num);
2037 store_item_optimize(what);
2042 * @brief 店舗の品揃え変化のためにアイテムを追加する /
2043 * Creates a random item and gives it to a store
2047 * This algorithm needs to be rethought. A lot.
2048 * Currently, "normal" stores use a pre-built array.
2049 * Note -- the "level" given to "obj_get_num()" is a "favored"
2050 * level, that is, there is a much higher chance of getting
2051 * items with a level approaching that of the given level...
2052 * Should we check for "permission" to have the given item?
2055 static void store_create(void)
2065 /* Paranoia -- no room left */
2066 if (st_ptr->stock_num >= st_ptr->stock_size) return;
2069 /* Hack -- consider up to four items */
2070 for (tries = 0; tries < 4; tries++)
2073 if (cur_store_num == STORE_BLACK)
2075 /* Pick a level for object/magic */
2076 level = 25 + randint0(25);
2078 /* Random item (usually of given level) */
2079 i = get_obj_num(level);
2081 /* Handle failure */
2088 /* Hack -- Pick an item to sell */
2089 i = st_ptr->table[randint0(st_ptr->table_num)];
2091 /* Hack -- fake level for apply_magic() */
2092 level = rand_range(1, STORE_OBJ_LEVEL);
2097 /* Create a new object of the chosen kind */
2098 object_prep(q_ptr, i);
2100 /* Apply some "low-level" magic (no artifacts) */
2101 apply_magic(q_ptr, level, AM_NO_FIXED_ART);
2103 /* Require valid object */
2104 if (!store_will_buy(q_ptr)) continue;
2106 /* Hack -- Charge lite's */
2107 if (q_ptr->tval == TV_LITE)
2109 if (q_ptr->sval == SV_LITE_TORCH) q_ptr->xtra4 = FUEL_TORCH / 2;
2110 if (q_ptr->sval == SV_LITE_LANTERN) q_ptr->xtra4 = FUEL_LAMP / 2;
2114 /* The item is "known" */
2115 object_known(q_ptr);
2117 /* Mark it storebought */
2118 q_ptr->ident |= IDENT_STORE;
2120 /* Mega-Hack -- no chests in stores */
2121 if (q_ptr->tval == TV_CHEST) continue;
2123 /* Prune the black market */
2124 if (cur_store_num == STORE_BLACK)
2126 /* Hack -- No "crappy" items */
2127 if (black_market_crap(q_ptr)) continue;
2129 /* Hack -- No "cheap" items */
2130 if (object_value(q_ptr) < 10) continue;
2132 /* No "worthless" items */
2133 /* if (object_value(q_ptr) <= 0) continue; */
2136 /* Prune normal stores */
2139 /* No "worthless" items */
2140 if (object_value(q_ptr) <= 0) continue;
2144 /* Mass produce and/or Apply discount */
2145 mass_produce(q_ptr);
2147 /* Attempt to carry the (known) item */
2148 (void)store_carry(q_ptr);
2150 /* Definitely done */
2157 * @brief 店舗の割引対象外にするかどうかを判定 /
2158 * Eliminate need to bargain if player has haggled well in the past
2159 * @param minprice アイテムの最低販売価格
2160 * @return 割引を禁止するならTRUEを返す。
2162 static bool noneedtobargain(PRICE minprice)
2164 s32b good = st_ptr->good_buy;
2165 s32b bad = st_ptr->bad_buy;
2167 /* Cheap items are "boring" */
2168 if (minprice < 10L) return (TRUE);
2170 /* Perfect haggling */
2171 if (good == MAX_SHORT) return (TRUE);
2173 /* Reward good haggles, punish bad haggles, notice price */
2174 if (good > ((3 * bad) + (5 + (minprice/50)))) return (TRUE);
2176 /* Return the flag */
2182 * @brief 店主の持つプレイヤーに対する売買の良し悪し経験を記憶する /
2183 * Update the bargain info
2184 * @param price 実際の取引価格
2185 * @param minprice 店主の提示した価格
2189 static void updatebargain(PRICE price, PRICE minprice, int num)
2191 /* Hack -- auto-haggle */
2192 if (!manual_haggle) return;
2194 /* Cheap items are "boring" */
2195 if ((minprice/num) < 10L) return;
2197 /* Count the successful haggles */
2198 if (price == minprice)
2200 /* Just count the good haggles */
2201 if (st_ptr->good_buy < MAX_SHORT)
2207 /* Count the failed haggles */
2210 /* Just count the bad haggles */
2211 if (st_ptr->bad_buy < MAX_SHORT)
2220 * @brief 店の商品リストを再表示する /
2221 * Re-displays a single store entry
2225 static void display_entry(int pos)
2231 char o_name[MAX_NLEN];
2236 o_ptr = &st_ptr->stock[pos];
2238 /* Get the "offset" */
2239 i = (pos % store_bottom);
2241 /* Label it, clear the line --(-- */
2242 (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
2243 prt(out_val, i+6, 0);
2246 if (show_item_graph)
2248 byte a = object_attr(o_ptr);
2249 char c = object_char(o_ptr);
2251 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
2252 if (use_bigtile) cur_col++;
2257 /* Describe an item in the home */
2258 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
2262 /* Leave room for weights, if necessary -DRS- */
2263 if (show_weights) maxwid -= 10;
2265 object_desc(o_name, o_ptr, 0);
2266 o_name[maxwid] = '\0';
2267 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2272 /* Only show the weight of an individual item */
2273 int wgt = o_ptr->weight;
2275 sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt));
2276 put_str(out_val, i+6, 67);
2278 (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10);
2279 put_str(out_val, i+6, 68);
2285 /* Describe an item (fully) in a store */
2288 /* Must leave room for the "price" */
2291 /* Leave room for weights, if necessary -DRS- */
2292 if (show_weights) maxwid -= 7;
2294 /* Describe the object (fully) */
2295 object_desc(o_name, o_ptr, 0);
2296 o_name[maxwid] = '\0';
2297 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2302 /* Only show the weight of an individual item */
2303 int wgt = o_ptr->weight;
2305 sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
2306 put_str(out_val, i+6, 60);
2308 (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
2309 put_str(out_val, i+6, 61);
2314 /* Display a "fixed" cost */
2315 if (o_ptr->ident & (IDENT_FIXED))
2317 /* Extract the "minimum" price */
2318 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2320 /* Actually draw the price (not fixed) */
2322 (void)sprintf(out_val, "%9ld固", (long)x);
2324 (void)sprintf(out_val, "%9ld F", (long)x);
2327 put_str(out_val, i+6, 68);
2330 /* Display a "taxed" cost */
2331 else if (!manual_haggle)
2333 /* Extract the "minimum" price */
2334 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2336 /* Hack -- Apply Sales Tax if needed */
2337 if (!noneedtobargain(x)) x += x / 10;
2339 /* Actually draw the price (with tax) */
2340 (void)sprintf(out_val, "%9ld ", (long)x);
2341 put_str(out_val, i+6, 68);
2344 /* Display a "haggle" cost */
2347 /* Extrect the "maximum" price */
2348 x = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2350 /* Actually draw the price (not fixed) */
2351 (void)sprintf(out_val, "%9ld ", (long)x);
2352 put_str(out_val, i+6, 68);
2359 * @brief 店の商品リストを表示する /
2360 * Displays a store's inventory -RAK-
2363 * All prices are listed as "per individual object". -BEN-
2365 static void display_inventory(void)
2369 /* Display the next 12 items */
2370 for (k = 0; k < store_bottom; k++)
2372 /* Do not display "dead" items */
2373 if (store_top + k >= st_ptr->stock_num) break;
2375 /* Display that line */
2376 display_entry(store_top + k);
2379 /* Erase the extra lines and the "more" prompt */
2380 for (i = k; i < store_bottom + 1; i++) prt("", i + 6, 0);
2382 /* Assume "no current page" */
2384 put_str(" ", 5, 20);
2386 put_str(" ", 5, 20);
2390 /* Visual reminder of "more items" */
2391 if (st_ptr->stock_num > store_bottom)
2393 /* Show "more" reminder (after the last item) */
2395 prt("-続く-", k + 6, 3);
2397 prt("-more-", k + 6, 3);
2401 /* Indicate the "current page" */
2402 /* Trailing spaces are to display (Page xx) and (Page x) */
2404 put_str(format("(%dページ) ", store_top/store_bottom + 1), 5, 20);
2406 put_str(format("(Page %d) ", store_top/store_bottom + 1), 5, 20);
2411 if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM)
2413 k = st_ptr->stock_size;
2415 if (cur_store_num == STORE_HOME && !powerup_home) k /= 10;
2417 put_str(format("アイテム数: %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 27);
2419 put_str(format("Objects: %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 30);
2426 * @brief プレイヤーの所持金を表示する /
2427 * Displays players gold -RAK-
2431 static void store_prt_gold(void)
2436 prt("手持ちのお金: ", 19 + xtra_stock, 53);
2438 prt("Gold Remaining: ", 19 + xtra_stock, 53);
2442 sprintf(out_val, "%9ld", (long)p_ptr->au);
2443 prt(out_val, 19 + xtra_stock, 68);
2447 * @brief 店舗情報全体を表示するメインルーチン /
2448 * Displays store (after clearing screen) -RAK-
2452 static void display_store(void)
2460 /* The "Home" is special */
2461 if (cur_store_num == STORE_HOME)
2463 /* Put the owner name */
2465 put_str("我が家", 3, 31);
2467 put_str("Your Home", 3, 30);
2471 /* Label the item descriptions */
2473 put_str("アイテムの一覧", 5, 4);
2475 put_str("Item Description", 5, 3);
2479 /* If showing weights, show label */
2483 put_str("重さ", 5, 72);
2485 put_str("Weight", 5, 70);
2491 /* The "Home" is special */
2492 else if (cur_store_num == STORE_MUSEUM)
2494 /* Put the owner name */
2496 put_str("博物館", 3, 31);
2498 put_str("Museum", 3, 30);
2502 /* Label the item descriptions */
2504 put_str("アイテムの一覧", 5, 4);
2506 put_str("Item Description", 5, 3);
2510 /* If showing weights, show label */
2514 put_str("重さ", 5, 72);
2516 put_str("Weight", 5, 70);
2525 cptr store_name = (f_name + f_info[cur_store_feat].name);
2526 cptr owner_name = (ot_ptr->owner_name);
2527 cptr race_name = race_info[ot_ptr->owner_race].title;
2529 /* Put the owner name and race */
2530 sprintf(buf, "%s (%s)", owner_name, race_name);
2531 put_str(buf, 3, 10);
2533 /* Show the max price in the store (above prices) */
2534 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
2537 /* Label the item descriptions */
2539 put_str("商品の一覧", 5, 7);
2541 put_str("Item Description", 5, 3);
2545 /* If showing weights, show label */
2549 put_str("重さ", 5, 62);
2551 put_str("Weight", 5, 60);
2556 /* Label the asking price (in stores) */
2558 put_str("価格", 5, 73);
2560 put_str("Price", 5, 72);
2565 /* Display the current gold */
2568 /* Draw in the inventory */
2569 display_inventory();
2575 * @brief 店舗からアイテムを選択する /
2576 * Get the ID of a store item and return its value -RAK-
2577 * @param com_val 選択IDを返す参照ポインタ
2578 * @param pmt メッセージキャプション
2581 * @return 実際に選択したらTRUE、キャンセルしたらFALSE
2583 static int get_stock(COMMAND_CODE *com_val, cptr pmt, int i, int j)
2589 /* Get the item index */
2590 if (repeat_pull(com_val))
2592 /* Verify the item */
2593 if ((*com_val >= i) && (*com_val <= j))
2604 /* Assume failure */
2607 /* Build the prompt */
2609 hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
2611 (void)sprintf(out_val, "(%s:%c-%c, ESCで中断) %s",
2612 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "アイテム" : "商品"),
2615 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
2620 /* Ask until done */
2626 if (!get_com(out_val, &command, FALSE)) break;
2629 if (islower(command))
2631 else if (isupper(command))
2632 k = A2I(tolower(command)) + 26;
2636 /* Legal responses */
2637 if ((k >= i) && (k <= j))
2646 /* Clear the prompt */
2650 if (command == ESCAPE) return (FALSE);
2652 repeat_push(*com_val);
2660 * @brief 店主の不満度を増やし、プレイヤーを締め出す判定と処理を行う /
2661 * Increase the insult counter and get angry if too many -RAK-
2662 * @return プレイヤーを締め出す場合TRUEを返す
2664 static int increase_insults(void)
2666 /* Increase insults */
2667 st_ptr->insult_cur++;
2669 /* Become insulted */
2670 if (st_ptr->insult_cur > ot_ptr->insult_max)
2676 st_ptr->insult_cur = 0;
2677 st_ptr->good_buy = 0;
2678 st_ptr->bad_buy = 0;
2681 st_ptr->store_open = turn + TURNS_PER_TICK*TOWN_DAWN/8 + randint1(TURNS_PER_TICK*TOWN_DAWN/8);
2693 * @brief 店主の不満度を減らす /
2694 * Decrease insults -RAK-
2695 * @return プレイヤーを締め出す場合TRUEを返す
2697 static void decrease_insults(void)
2699 /* Decrease insults */
2700 if (st_ptr->insult_cur) st_ptr->insult_cur--;
2705 * @brief 店主の不満度が増えた場合のみのメッセージを表示する /
2706 * Have insulted while haggling -RAK-
2707 * @return プレイヤーを締め出す場合TRUEを返す
2709 static int haggle_insults(void)
2711 /* Increase insults */
2712 if (increase_insults()) return (TRUE);
2714 /* Display and flush insult */
2723 * Mega-Hack -- Enable "increments"
2725 static bool allow_inc = FALSE;
2728 * Mega-Hack -- Last "increment" during haggling
2730 static s32b last_inc = 0L;
2734 * @brief 交渉価格を確認と認証の是非を行う /
2737 * @param poffer 別途価格提示をした場合の値を返す参照ポインタ
2738 * @param price 現在の交渉価格
2739 * @param final 最終確定価格ならばTRUE
2740 * @return プレイヤーを締め出す場合TRUEを返す
2742 static int get_haggle(cptr pmt, s32b *poffer, PRICE price, int final)
2752 /* Clear old increment if necessary */
2753 if (!allow_inc) last_inc = 0L;
2760 sprintf(buf, "%s [承諾] ", pmt);
2762 sprintf(buf, "%s [accept] ", pmt);
2767 /* Old (negative) increment, and not final */
2768 else if (last_inc < 0)
2771 sprintf(buf, "%s [-$%ld] ", pmt, (long)(ABS(last_inc)));
2773 sprintf(buf, "%s [-%ld] ", pmt, (long)(ABS(last_inc)));
2778 /* Old (positive) increment, and not final */
2779 else if (last_inc > 0)
2782 sprintf(buf, "%s [+$%ld] ", pmt, (long)(ABS(last_inc)));
2784 sprintf(buf, "%s [+%ld] ", pmt, (long)(ABS(last_inc)));
2792 sprintf(buf, "%s ", pmt);
2800 /* Ask until done */
2805 /* Display prompt */
2809 strcpy(out_val, "");
2812 * Ask the user for a response.
2813 * Don't allow to use numpad as cursor key.
2815 res = askfor_aux(out_val, 32, FALSE);
2821 if (!res) return FALSE;
2823 /* Skip leading spaces */
2824 for (p = out_val; *p == ' '; p++) /* loop */;
2826 /* Empty response */
2829 /* Accept current price */
2837 /* Use previous increment */
2838 if (allow_inc && last_inc)
2840 *poffer += last_inc;
2845 /* Normal response */
2848 /* Extract a number */
2851 /* Handle "incremental" number */
2852 if ((*p == '+' || *p == '-'))
2854 /* Allow increments */
2857 /* Use the given "increment" */
2864 /* Handle normal number */
2867 /* Use the given "number" */
2876 msg_print("値がおかしいです。");
2878 msg_print("Invalid response.");
2890 * @brief 店主がプレイヤーからの交渉価格を判断する /
2891 * Receive an offer (from the player)
2893 * @param poffer 店主からの交渉価格を返す参照ポインタ
2894 * @param last_offer 現在の交渉価格
2895 * @param factor 店主の価格基準倍率
2896 * @param price アイテムの実価値
2897 * @param final 最終価格確定ならばTRUE
2898 * @return プレイヤーの価格に対して不服ならばTRUEを返す /
2899 * Return TRUE if offer is NOT okay
2901 static bool receive_offer(cptr pmt, s32b *poffer,
2902 s32b last_offer, int factor,
2903 PRICE price, int final)
2905 /* Haggle till done */
2908 /* Get a haggle (or cancel) */
2909 if (!get_haggle(pmt, poffer, price, final)) return (TRUE);
2911 /* Acceptable offer */
2912 if (((*poffer) * factor) >= (last_offer * factor)) break;
2914 /* Insult, and check for kicked out */
2915 if (haggle_insults()) return (TRUE);
2917 /* Reject offer (correctly) */
2918 (*poffer) = last_offer;
2927 * @brief プレイヤーが購入する時の値切り処理メインルーチン /
2928 * Haggling routine -RAK-
2929 * @param o_ptr オブジェクトの構造体参照ポインタ
2930 * @param price 最終価格を返す参照ポインタ
2931 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
2932 * Return TRUE if purchase is NOT successful
2934 static bool purchase_haggle(object_type *o_ptr, s32b *price)
2936 s32b cur_ask, final_ask;
2937 s32b last_offer, offer;
2939 s32b min_per, max_per;
2940 int flag, loop_flag, noneed;
2941 int annoyed = 0, final = FALSE;
2943 bool cancel = FALSE;
2948 cptr pmt = "Asking";
2958 /* Extract the starting offer and the final offer */
2959 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2960 final_ask = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2962 /* Determine if haggling is necessary */
2963 noneed = noneedtobargain(final_ask);
2965 /* No need to haggle */
2966 if (noneed || !manual_haggle)
2968 /* No need to haggle */
2971 /* Message summary */
2973 msg_print("結局この金額にまとまった。");
2975 msg_print("You eventually agree upon the price.");
2981 /* No haggle option */
2984 /* Message summary */
2986 msg_print("すんなりとこの金額にまとまった。");
2988 msg_print("You quickly agree upon the price.");
2993 /* Apply Sales Tax */
2994 final_ask += final_ask / 10;
2998 cur_ask = final_ask;
3000 /* Go to final offer */
3004 pmt = "Final Offer";
3011 /* Haggle for the whole pile */
3012 cur_ask *= o_ptr->number;
3013 final_ask *= o_ptr->number;
3016 /* Haggle parameters */
3017 min_per = ot_ptr->haggle_per;
3018 max_per = min_per * 3;
3020 /* Mega-Hack -- artificial "last offer" value */
3021 last_offer = object_value(o_ptr) * o_ptr->number;
3022 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
3023 if (last_offer <= 0) last_offer = 1;
3028 /* No incremental haggling yet */
3031 /* Haggle until done */
3032 for (flag = FALSE; !flag; )
3036 while (!flag && loop_flag)
3038 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
3039 put_str(out_val, 1, 0);
3041 cancel = receive_offer("提示する金額? ",
3043 cancel = receive_offer("What do you offer? ",
3046 &offer, last_offer, 1, cur_ask, final);
3052 else if (offer > cur_ask)
3057 else if (offer == cur_ask)
3070 x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
3073 if (haggle_insults())
3079 else if (x1 > max_per)
3082 if (x1 < max_per) x1 = max_per;
3084 x2 = rand_range(x1-2, x1+2);
3085 x3 = ((cur_ask - offer) * x2 / 100L) + 1;
3086 /* don't let the price go up */
3091 if (cur_ask < final_ask)
3094 cur_ask = final_ask;
3098 pmt = "Final Offer";
3104 (void)(increase_insults());
3109 else if (offer >= cur_ask)
3121 (void)sprintf(out_val, "前回の提示金額: $%ld",
3123 (void)sprintf(out_val, "Your last offer: %ld",
3127 put_str(out_val, 1, 39);
3128 say_comment_2(cur_ask, annoyed);
3134 if (cancel) return (TRUE);
3136 /* Update bargaining info */
3137 updatebargain(*price, final_ask, o_ptr->number);
3145 * @brief プレイヤーが売却する時の値切り処理メインルーチン /
3146 * Haggling routine -RAK-
3147 * @param o_ptr オブジェクトの構造体参照ポインタ
3148 * @param price 最終価格を返す参照ポインタ
3149 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
3150 * Return TRUE if purchase is NOT successful
3152 static bool sell_haggle(object_type *o_ptr, s32b *price)
3154 s32b purse, cur_ask, final_ask;
3155 s32b last_offer = 0, offer = 0;
3157 s32b min_per, max_per;
3158 int flag, loop_flag, noneed;
3159 int annoyed = 0, final = FALSE;
3160 bool cancel = FALSE;
3173 /* Obtain the starting offer and the final offer */
3174 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, TRUE);
3175 final_ask = price_item(o_ptr, ot_ptr->min_inflate, TRUE);
3177 /* Determine if haggling is necessary */
3178 noneed = noneedtobargain(final_ask);
3180 /* Get the owner's payout limit */
3181 purse = (s32b)(ot_ptr->max_cost);
3183 /* No need to haggle */
3184 if (noneed || !manual_haggle || (final_ask >= purse))
3186 /* Apply Sales Tax (if needed) */
3187 if (!manual_haggle && !noneed)
3189 final_ask -= final_ask / 10;
3192 /* No reason to haggle */
3193 if (final_ask >= purse)
3196 msg_print("即座にこの金額にまとまった。");
3198 msg_print("You instantly agree upon the price.");
3203 /* Offer full purse */
3207 /* No need to haggle */
3211 msg_print("結局この金額にまとまった。");
3213 msg_print("You eventually agree upon the price.");
3219 /* No haggle option */
3222 /* Message summary */
3224 msg_print("すんなりとこの金額にまとまった。");
3226 msg_print("You quickly agree upon the price.");
3233 cur_ask = final_ask;
3240 pmt = "Final Offer";
3245 /* Haggle for the whole pile */
3246 cur_ask *= o_ptr->number;
3247 final_ask *= o_ptr->number;
3250 /* Display commands */
3252 /* Haggling parameters */
3253 min_per = ot_ptr->haggle_per;
3254 max_per = min_per * 3;
3256 /* Mega-Hack -- artificial "last offer" value */
3257 last_offer = object_value(o_ptr) * o_ptr->number;
3258 last_offer = last_offer * ot_ptr->max_inflate / 100L;
3263 /* No incremental haggling yet */
3267 for (flag = FALSE; !flag; )
3273 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
3274 put_str(out_val, 1, 0);
3276 cancel = receive_offer("提示する価格? ",
3278 cancel = receive_offer("What price do you ask? ",
3281 &offer, last_offer, -1, cur_ask, final);
3287 else if (offer < cur_ask)
3290 /* rejected, reset offer for incremental haggling */
3293 else if (offer == cur_ask)
3304 if (flag || !loop_flag) break;
3309 x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
3312 if (haggle_insults())
3318 else if (x1 > max_per)
3321 if (x1 < max_per) x1 = max_per;
3323 x2 = rand_range(x1-2, x1+2);
3324 x3 = ((offer - cur_ask) * x2 / 100L) + 1;
3325 /* don't let the price go down */
3329 if (cur_ask > final_ask)
3331 cur_ask = final_ask;
3336 pmt = "Final Offer";
3344 /* 追加 $0 で買い取られてしまうのを防止 By FIRST*/
3347 (void)(increase_insults());
3350 else if (offer <= cur_ask)
3361 (void)sprintf(out_val,
3363 "前回の提示価格 $%ld", (long)last_offer);
3365 "Your last bid %ld", (long)last_offer);
3368 put_str(out_val, 1, 39);
3369 say_comment_3(cur_ask, annoyed);
3375 if (cancel) return (TRUE);
3377 /* Update bargaining info */
3378 updatebargain(*price, final_ask, o_ptr->number);
3386 * @brief 店からの購入処理のメインルーチン /
3387 * Buy an item from a store -RAK-
3390 static void store_purchase(void)
3393 COMMAND_CODE item, item_new;
3404 char o_name[MAX_NLEN];
3408 if (cur_store_num == STORE_MUSEUM)
3411 msg_print("博物館から取り出すことはできません。");
3413 msg_print("Museum.");
3419 if (st_ptr->stock_num <= 0)
3421 if (cur_store_num == STORE_HOME)
3423 msg_print("我が家には何も置いてありません。");
3425 msg_print("Your home is empty.");
3430 msg_print("現在商品の在庫を切らしています。");
3432 msg_print("I am currently out of stock.");
3439 /* Find the number of objects on this and following pages */
3440 i = (st_ptr->stock_num - store_top);
3442 /* And then restrict it to the current page */
3443 if (i > store_bottom) i = store_bottom;
3447 /* ブラックマーケットの時は別のメッセージ */
3448 switch( cur_store_num ) {
3450 sprintf(out_val, "どのアイテムを取りますか? ");
3453 sprintf(out_val, "どれ? ");
3456 sprintf(out_val, "どの品物が欲しいんだい? ");
3460 if (cur_store_num == STORE_HOME)
3462 sprintf(out_val, "Which item do you want to take? ");
3466 sprintf(out_val, "Which item are you interested in? ");
3471 /* Get the item number to be bought */
3472 if (!get_stock(&item, out_val, 0, i - 1)) return;
3474 /* Get the actual index */
3475 item = item + store_top;
3477 /* Get the actual item */
3478 o_ptr = &st_ptr->stock[item];
3480 /* Assume the player wants just one of them */
3484 /* Get a copy of the object */
3485 object_copy(j_ptr, o_ptr);
3488 * If a rod or wand, allocate total maximum timeouts or charges
3489 * between those purchased and left on the shelf.
3491 reduce_charges(j_ptr, o_ptr->number - amt);
3493 /* Modify quantity */
3494 j_ptr->number = amt;
3496 /* Hack -- require room in pack */
3497 if (!inven_carry_okay(j_ptr))
3500 msg_print("そんなにアイテムを持てない。");
3502 msg_print("You cannot carry that many different items.");
3508 /* Determine the "best" price (per item) */
3509 best = price_item(j_ptr, ot_ptr->min_inflate, FALSE);
3511 /* Find out how many the player wants */
3512 if (o_ptr->number > 1)
3514 /* Hack -- note cost of "fixed" items */
3515 if ((cur_store_num != STORE_HOME) &&
3516 (o_ptr->ident & IDENT_FIXED))
3519 msg_format("一つにつき $%ldです。", (long)(best));
3521 msg_format("That costs %ld gold per item.", (long)(best));
3526 /* Get a quantity */
3527 amt = get_quantity(NULL, o_ptr->number);
3529 /* Allow user abort */
3530 if (amt <= 0) return;
3534 /* Get desired object */
3535 object_copy(j_ptr, o_ptr);
3538 * If a rod or wand, allocate total maximum timeouts or charges
3539 * between those purchased and left on the shelf.
3541 reduce_charges(j_ptr, o_ptr->number - amt);
3543 /* Modify quantity */
3544 j_ptr->number = amt;
3546 /* Hack -- require room in pack */
3547 if (!inven_carry_okay(j_ptr))
3550 msg_print("ザックにそのアイテムを入れる隙間がない。");
3552 msg_print("You cannot carry that many items.");
3558 /* Attempt to buy it */
3559 if (cur_store_num != STORE_HOME)
3561 /* Fixed price, quick buy */
3562 if (o_ptr->ident & (IDENT_FIXED))
3567 /* Go directly to the "best" deal */
3568 price = (best * j_ptr->number);
3574 /* Describe the object (fully) */
3575 object_desc(o_name, j_ptr, 0);
3578 msg_format("%s(%c)を購入する。", o_name, I2A(item));
3580 msg_format("Buying %s (%c).", o_name, I2A(item));
3585 /* Haggle for a final price */
3586 choice = purchase_haggle(j_ptr, &price);
3588 /* Hack -- Got kicked out */
3589 if (st_ptr->store_open >= turn) return;
3592 /* Player wants it */
3595 /* Fix the item price (if "correctly" haggled) */
3596 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
3598 /* Player can afford it */
3599 if (p_ptr->au >= price)
3604 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3605 chg_virtue(V_JUSTICE, -1);
3606 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3607 chg_virtue(V_NATURE, -1);
3615 /* Spend the money */
3618 /* Update the display */
3621 /* Hack -- buying an item makes you aware of it */
3622 object_aware(j_ptr);
3624 /* Hack -- clear the "fixed" flag from the item */
3625 j_ptr->ident &= ~(IDENT_FIXED);
3627 /* Describe the transaction */
3628 object_desc(o_name, j_ptr, 0);
3631 msg_format("%sを $%ldで購入しました。", o_name, (long)price);
3633 msg_format("You bought %s for %ld gold.", o_name, (long)price);
3636 strcpy(record_o_name, o_name);
3639 if (record_buy) do_cmd_write_nikki(NIKKI_BUY, 0, o_name);
3640 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3641 if(record_rand_art && o_ptr->art_name)
3642 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
3644 /* Erase the inscription */
3645 j_ptr->inscription = 0;
3647 /* Erase the "feeling" */
3648 j_ptr->feeling = FEEL_NONE;
3649 j_ptr->ident &= ~(IDENT_STORE);
3650 /* Give it to the player */
3651 item_new = inven_carry(j_ptr);
3653 /* Describe the final result */
3654 object_desc(o_name, &inventory[item_new], 0);
3657 msg_format("%s(%c)を手に入れた。", o_name, index_to_label(item_new));
3659 msg_format("You have %s (%c).",
3660 o_name, index_to_label(item_new));
3663 /* Auto-inscription */
3664 autopick_alter_item(item_new, FALSE);
3666 /* Now, reduce the original stack's pval. */
3667 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3669 o_ptr->pval -= j_ptr->pval;
3673 /* Note how many slots the store used to have */
3674 i = st_ptr->stock_num;
3676 /* Remove the bought items from the store */
3677 store_item_increase(item, -amt);
3678 store_item_optimize(item);
3680 /* Store is empty */
3681 if (st_ptr->stock_num == 0)
3684 if (one_in_(STORE_SHUFFLE))
3688 msg_print("店主は引退した。");
3690 msg_print("The shopkeeper retires.");
3694 /* Shuffle the store */
3695 store_shuffle(cur_store_num);
3698 sprintf(buf, "%s (%s)",
3699 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
3700 put_str(buf, 3, 10);
3701 sprintf(buf, "%s (%ld)",
3702 (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
3710 msg_print("店主は新たな在庫を取り出した。");
3712 msg_print("The shopkeeper brings out some new stock.");
3718 for (i = 0; i < 10; i++)
3720 /* Maintain the store */
3721 store_maint(p_ptr->town_num, cur_store_num);
3727 /* Redraw everything */
3728 display_inventory();
3731 /* The item is gone */
3732 else if (st_ptr->stock_num != i)
3734 /* Pick the correct screen */
3735 if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
3737 /* Redraw everything */
3738 display_inventory();
3741 /* Item is still here */
3744 /* Redraw the item */
3745 display_entry(item);
3749 /* Player cannot afford it */
3752 /* Simple message (no insult) */
3754 msg_print("お金が足りません。");
3756 msg_print("You do not have enough gold.");
3763 /* Home is much easier */
3766 bool combined_or_reordered;
3768 /* Distribute charges of wands/rods */
3769 distribute_charges(o_ptr, j_ptr, amt);
3771 /* Give it to the player */
3772 item_new = inven_carry(j_ptr);
3774 /* Describe just the result */
3775 object_desc(o_name, &inventory[item_new], 0);
3778 msg_format("%s(%c)を取った。",
3780 msg_format("You have %s (%c).",
3782 o_name, index_to_label(item_new));
3785 /* Take note if we take the last one */
3786 i = st_ptr->stock_num;
3788 /* Remove the items from the home */
3789 store_item_increase(item, -amt);
3790 store_item_optimize(item);
3792 combined_or_reordered = combine_and_reorder_home(STORE_HOME);
3794 /* Hack -- Item is still here */
3795 if (i == st_ptr->stock_num)
3797 /* Redraw everything */
3798 if (combined_or_reordered) display_inventory();
3800 /* Redraw the item */
3801 else display_entry(item);
3804 /* The item is gone */
3808 if (st_ptr->stock_num == 0) store_top = 0;
3810 /* Nothing left on that screen */
3811 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
3813 /* Redraw everything */
3814 display_inventory();
3816 chg_virtue(V_SACRIFICE, 1);
3820 /* Not kicked out */
3826 * @brief 店からの売却処理のメインルーチン /
3827 * Sell an item to the store (or home)
3830 static void store_sell(void)
3837 PRICE price, value, dummy;
3846 char o_name[MAX_NLEN];
3849 /* Prepare a prompt */
3850 if (cur_store_num == STORE_HOME)
3852 q = "どのアイテムを置きますか? ";
3854 q = "Drop which item? ";
3857 else if (cur_store_num == STORE_MUSEUM)
3859 q = "どのアイテムを寄贈しますか? ";
3861 q = "Give which item? ";
3866 q = "どのアイテムを売りますか? ";
3868 q = "Sell which item? ";
3872 item_tester_no_ryoute = TRUE;
3873 /* Only allow items the store will buy */
3874 item_tester_hook = store_will_buy;
3876 /* 我が家でおかしなメッセージが出るオリジナルのバグを修正 */
3877 if (cur_store_num == STORE_HOME)
3880 s = "置けるアイテムを持っていません。";
3882 s = "You don't have any item to drop.";
3885 else if (cur_store_num == STORE_MUSEUM)
3888 s = "寄贈できるアイテムを持っていません。";
3890 s = "You don't have any item to give.";
3898 s = "You have nothing that I want.";
3902 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
3904 /* Get the item (in the pack) */
3907 o_ptr = &inventory[item];
3910 /* Get the item (on the floor) */
3913 o_ptr = &o_list[0 - item];
3917 /* Hack -- Cannot remove cursed items */
3918 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
3921 msg_print("ふーむ、どうやらそれは呪われているようだね。");
3923 msg_print("Hmmm, it seems to be cursed.");
3931 /* Assume one item */
3934 /* Find out how many the player wants (letter means "all") */
3935 if (o_ptr->number > 1)
3937 /* Get a quantity */
3938 amt = get_quantity(NULL, o_ptr->number);
3940 /* Allow user abort */
3941 if (amt <= 0) return;
3945 /* Get a copy of the object */
3946 object_copy(q_ptr, o_ptr);
3948 /* Modify quantity */
3949 q_ptr->number = amt;
3952 * Hack -- If a rod or wand, allocate total maximum
3953 * timeouts or charges to those being sold. -LM-
3955 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3957 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
3960 /* Get a full description */
3961 object_desc(o_name, q_ptr, 0);
3963 /* Remove any inscription, feeling for stores */
3964 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3966 q_ptr->inscription = 0;
3967 q_ptr->feeling = FEEL_NONE;
3970 /* Is there room in the store (or the home?) */
3971 if (!store_check_num(q_ptr))
3973 if (cur_store_num == STORE_HOME)
3975 msg_print("我が家にはもう置く場所がない。");
3977 msg_print("Your home is full.");
3980 else if (cur_store_num == STORE_MUSEUM)
3982 msg_print("博物館はもう満杯だ。");
3984 msg_print("Museum is full.");
3989 msg_print("すいませんが、店にはもう置く場所がありません。");
3991 msg_print("I have not the room in my store to keep it.");
3999 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
4001 /* Describe the transaction */
4003 msg_format("%s(%c)を売却する。", o_name, index_to_label(item));
4005 msg_format("Selling %s (%c).", o_name, index_to_label(item));
4011 choice = sell_haggle(q_ptr, &price);
4014 if (st_ptr->store_open >= turn) return;
4026 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
4027 chg_virtue(V_JUSTICE, -1);
4029 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
4030 chg_virtue(V_NATURE, 1);
4033 /* Get some money */
4036 /* Update the display */
4039 /* Get the "apparent" value */
4040 dummy = object_value(q_ptr) * q_ptr->number;
4043 identify_item(o_ptr);
4046 /* Get a copy of the object */
4047 object_copy(q_ptr, o_ptr);
4049 /* Modify quantity */
4050 q_ptr->number = amt;
4052 /* Make it look like to be known */
4053 q_ptr->ident |= IDENT_STORE;
4056 * Hack -- If a rod or wand, let the shopkeeper know just
4057 * how many charges he really paid for. -LM-
4059 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
4061 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
4064 /* Get the "actual" value */
4065 value = object_value(q_ptr) * q_ptr->number;
4067 /* Get the description all over again */
4068 object_desc(o_name, q_ptr, 0);
4070 /* Describe the result (in message buffer) */
4072 msg_format("%sを $%ldで売却しました。", o_name, (long)price);
4074 msg_format("You sold %s for %ld gold.", o_name, (long)price);
4077 if (record_sell) do_cmd_write_nikki(NIKKI_SELL, 0, o_name);
4079 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
4081 /* Analyze the prices (and comment verbally) unless a figurine*/
4082 purchase_analyze(price, value, dummy);
4086 * Hack -- Allocate charges between those wands or rods sold
4087 * and retained, unless all are being sold. -LM-
4089 distribute_charges(o_ptr, q_ptr, amt);
4091 /* Reset timeouts of the sold items */
4094 /* Take the item from the player, describe the result */
4095 inven_item_increase(item, -amt);
4096 inven_item_describe(item);
4098 /* If items remain, auto-inscribe before optimizing */
4099 if (o_ptr->number > 0)
4100 autopick_alter_item(item, FALSE);
4102 inven_item_optimize(item);
4105 /* The store gets that (known) item */
4106 item_pos = store_carry(q_ptr);
4108 /* Re-display if item is now in store */
4111 store_top = (item_pos / store_bottom) * store_bottom;
4112 display_inventory();
4117 /* Player is at museum */
4118 else if (cur_store_num == STORE_MUSEUM)
4120 char o2_name[MAX_NLEN];
4121 object_desc(o2_name, q_ptr, OD_NAME_ONLY);
4123 if (-1 == store_check_num(q_ptr))
4126 msg_print("それと同じ品物は既に博物館にあるようです。");
4128 msg_print("The same object as it is already in the Museum.");
4134 msg_print("博物館に寄贈したものは取り出すことができません!!");
4136 msg_print("You cannot take items which is given to the Museum back!!");
4140 if (!get_check(format("本当に%sを寄贈しますか?", o2_name))) return;
4142 if (!get_check(format("Really give %s to the Museum? ", o2_name))) return;
4146 identify_item(q_ptr);
4147 q_ptr->ident |= IDENT_MENTAL;
4149 /* Distribute charges of wands/rods */
4150 distribute_charges(o_ptr, q_ptr, amt);
4152 msg_format("%sを置いた。(%c)", o_name, index_to_label(item));
4154 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4159 /* Take it from the players inventory */
4160 inven_item_increase(item, -amt);
4161 inven_item_describe(item);
4162 inven_item_optimize(item);
4165 /* Let the home carry it */
4166 item_pos = home_carry(q_ptr);
4168 /* Update store display */
4171 store_top = (item_pos / store_bottom) * store_bottom;
4172 display_inventory();
4175 /* Player is at home */
4178 /* Distribute charges of wands/rods */
4179 distribute_charges(o_ptr, q_ptr, amt);
4181 msg_format("%sを置いた。(%c)", o_name, index_to_label(item));
4183 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4188 /* Take it from the players inventory */
4189 inven_item_increase(item, -amt);
4190 inven_item_describe(item);
4191 inven_item_optimize(item);
4194 /* Let the home carry it */
4195 item_pos = home_carry(q_ptr);
4197 /* Update store display */
4200 store_top = (item_pos / store_bottom) * store_bottom;
4201 display_inventory();
4205 if ((choice == 0) && (item >= INVEN_RARM))
4214 * @brief 店のアイテムを調べるコマンドのメインルーチン /
4215 * Examine an item in a store -JDL-
4218 static void store_examine(void)
4223 char o_name[MAX_NLEN];
4227 if (st_ptr->stock_num <= 0)
4229 if (cur_store_num == STORE_HOME)
4230 msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
4231 else if (cur_store_num == STORE_MUSEUM)
4232 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
4234 msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
4238 /* Find the number of objects on this and following pages */
4239 i = (st_ptr->stock_num - store_top);
4241 /* And then restrict it to the current page */
4242 if (i > store_bottom) i = store_bottom;
4245 sprintf(out_val, _("どれを調べますか?", "Which item do you want to examine? "));
4247 /* Get the item number to be examined */
4248 if (!get_stock(&item, out_val, 0, i - 1)) return;
4250 /* Get the actual index */
4251 item = item + store_top;
4253 /* Get the actual item */
4254 o_ptr = &st_ptr->stock[item];
4256 /* Require full knowledge */
4257 if (!(o_ptr->ident & IDENT_MENTAL))
4259 /* This can only happen in the home */
4260 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
4264 object_desc(o_name, o_ptr, 0);
4265 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
4267 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL))
4268 msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
4275 * @brief 博物館のアイテムを除去するコマンドのメインルーチン /
4276 * Remove an item from museum (Originally from TOband)
4279 static void museum_remove_object(void)
4284 char o_name[MAX_NLEN];
4288 if (st_ptr->stock_num <= 0)
4290 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
4294 /* Find the number of objects on this and following pages */
4295 i = st_ptr->stock_num - store_top;
4297 /* And then restrict it to the current page */
4298 if (i > store_bottom) i = store_bottom;
4301 sprintf(out_val, _("どのアイテムの展示をやめさせますか?", "Which item do you want to order to remove? "));
4303 /* Get the item number to be removed */
4304 if (!get_stock(&item, out_val, 0, i - 1)) return;
4306 /* Get the actual index */
4307 item = item + store_top;
4309 /* Get the actual item */
4310 o_ptr = &st_ptr->stock[item];
4312 object_desc(o_name, o_ptr, 0);
4314 msg_print(_("展示をやめさせたアイテムは二度と見ることはできません!", "You cannot see items which is removed from the Museum!"));
4315 if (!get_check(format(_("本当に%sの展示をやめさせますか?", "Really order to remove %s from the Museum? "), o_name))) return;
4317 msg_format(_("%sの展示をやめさせた。", "You ordered to remove %s."), o_name);
4319 /* Remove the items from the home */
4320 store_item_increase(item, -o_ptr->number);
4321 store_item_optimize(item);
4323 (void)combine_and_reorder_home(STORE_MUSEUM);
4325 /* The item is gone */
4328 if (st_ptr->stock_num == 0) store_top = 0;
4330 /* Nothing left on that screen */
4331 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
4333 /* Redraw everything */
4334 display_inventory();
4341 * Hack -- set this to leave the store
4343 static bool leave_store = FALSE;
4347 * @brief 店舗処理コマンド選択のメインルーチン /
4348 * Process a command in a store
4352 * Note that we must allow the use of a few "special" commands
4353 * in the stores which are not allowed in the dungeon, and we
4354 * must disable some commands which are allowed in the dungeon
4355 * but not in the stores, to prevent chaos.
4358 static void store_process_command(void)
4360 /* Handle repeating the last command */
4363 if (rogue_like_commands && command_cmd == 'l')
4365 command_cmd = 'x'; /* hack! */
4368 /* Parse the command */
4369 switch (command_cmd)
4379 /* 1 ページ戻るコマンド: 我が家のページ数が多いので重宝するはず By BUG */
4382 if (st_ptr->stock_num <= store_bottom) {
4383 msg_print(_("これで全部です。", "Entire inventory is shown."));
4386 store_top -= store_bottom;
4387 if ( store_top < 0 )
4388 store_top = ((st_ptr->stock_num - 1 )/store_bottom) * store_bottom;
4389 if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) )
4390 if ( store_top >= store_bottom ) store_top = store_bottom;
4391 display_inventory();
4399 if (st_ptr->stock_num <= store_bottom)
4401 msg_print(_("これで全部です。", "Entire inventory is shown."));
4405 store_top += store_bottom;
4407 * 隠しオプション(powerup_home)がセットされていないときは
4408 * 我が家では 2 ページまでしか表示しない
4410 if ((cur_store_num == STORE_HOME) &&
4411 (powerup_home == FALSE) &&
4412 (st_ptr->stock_num >= STORE_INVEN_MAX))
4414 if (store_top >= (STORE_INVEN_MAX - 1))
4421 if (store_top >= st_ptr->stock_num) store_top = 0;
4424 display_inventory();
4436 /* Get (purchase) */
4463 /*** Inventory Commands ***/
4465 /* Wear/wield equipment */
4472 /* Take off equipment */
4479 /* Destroy an item */
4486 /* Equipment list */
4493 /* Inventory list */
4501 /*** Various commands ***/
4503 /* Identify an object */
4510 /* Hack -- toggle windows */
4513 toggle_inven_equip();
4517 /*** Use various objects ***/
4522 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4523 (p_ptr->pclass == CLASS_BERSERKER) ||
4524 (p_ptr->pclass == CLASS_NINJA) ||
4525 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4526 ) do_cmd_mind_browse();
4527 else if (p_ptr->pclass == CLASS_SMITH)
4529 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4530 do_cmd_magic_eater(TRUE, FALSE);
4531 else if (p_ptr->pclass == CLASS_SNIPER)
4532 do_cmd_snipe_browse();
4533 else do_cmd_browse();
4537 /* Inscribe an object */
4544 /* Uninscribe an object */
4547 do_cmd_uninscribe();
4553 /*** Help and Such ***/
4562 /* Identify symbol */
4565 do_cmd_query_symbol();
4569 /* Character description */
4572 p_ptr->town_num = old_town_num;
4573 do_cmd_change_name();
4574 p_ptr->town_num = inner_town_num;
4580 /*** System Commands ***/
4582 /* Hack -- User interface */
4589 /* Single line from a pref file */
4592 p_ptr->town_num = old_town_num;
4594 p_ptr->town_num = inner_town_num;
4598 /* Interact with macros */
4601 p_ptr->town_num = old_town_num;
4603 p_ptr->town_num = inner_town_num;
4607 /* Interact with visuals */
4610 p_ptr->town_num = old_town_num;
4612 p_ptr->town_num = inner_town_num;
4616 /* Interact with colors */
4619 p_ptr->town_num = old_town_num;
4621 p_ptr->town_num = inner_town_num;
4625 /* Interact with options */
4629 (void)combine_and_reorder_home(STORE_HOME);
4635 /*** Misc Commands ***/
4651 /* Repeat level feeling */
4658 /* Show previous message */
4661 do_cmd_message_one();
4665 /* Show previous messages */
4678 /* Check artifacts, uniques etc. */
4685 /* Load "screen dump" */
4688 do_cmd_load_screen();
4692 /* Save "screen dump" */
4695 do_cmd_save_screen();
4699 /* Hack -- Unknown command */
4702 if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
4704 museum_remove_object();
4708 msg_print(_("そのコマンドは店の中では使えません。", "That command does not work in stores."));
4717 * @brief 店舗処理全体のメインルーチン /
4718 * Enter a store, and interact with it. *
4722 * Note that we use the standard "request_command()" function
4723 * to get a command, allowing us to use "command_arg" and all
4724 * command macros and other nifty stuff, but we use the special
4725 * "shopping" argument, to force certain commands to be converted
4726 * into other commands, normally, we convert "p" (pray) and "m"
4727 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
4730 void do_cmd_store(void)
4736 bool need_redraw_store_inv; /* To redraw missiles damage and prices in store */
4740 Term_get_size(&w, &h);
4742 /* Calculate stocks per 1 page */
4743 xtra_stock = MIN(14+26, ((h > 24) ? (h - 24) : 0));
4744 store_bottom = MIN_STOCK + xtra_stock;
4746 /* Access the player grid */
4747 c_ptr = &cave[p_ptr->y][p_ptr->x];
4749 /* Verify a store */
4750 if (!cave_have_flag_grid(c_ptr, FF_STORE))
4752 msg_print(_("ここには店がありません。", "You see no store here."));
4756 /* Extract the store code */
4757 which = f_info[c_ptr->feat].subtype;
4759 old_town_num = p_ptr->town_num;
4760 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
4761 if (dun_level) p_ptr->town_num = NO_TOWN;
4762 inner_town_num = p_ptr->town_num;
4764 /* Hack -- Check the "locked doors" */
4765 if ((town[p_ptr->town_num].store[which].store_open >= turn) ||
4768 msg_print(_("ドアに鍵がかかっている。", "The doors are locked."));
4769 p_ptr->town_num = old_town_num;
4773 /* Calculate the number of store maintainances since the last visit */
4774 maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
4776 /* Maintain the store max. 10 times */
4777 if (maintain_num > 10) maintain_num = 10;
4781 /* Maintain the store */
4782 for (i = 0; i < maintain_num; i++)
4783 store_maint(p_ptr->town_num, which);
4785 /* Save the visit */
4786 town[p_ptr->town_num].store[which].last_visit = turn;
4789 /* Forget the lite */
4792 /* Forget the view */
4796 /* Hack -- Character is in "icky" mode */
4797 character_icky = TRUE;
4800 /* No command argument */
4803 /* No repeated command */
4806 /* No automatic command */
4809 /* Do not expand macros */
4810 get_com_no_macros = TRUE;
4812 /* Save the store number */
4813 cur_store_num = which;
4815 /* Hack -- save the store feature */
4816 cur_store_feat = c_ptr->feat;
4818 /* Save the store and owner pointers */
4819 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
4820 ot_ptr = &owners[cur_store_num][st_ptr->owner];
4823 /* Start at the beginning */
4826 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
4828 /* Display the store */
4832 leave_store = FALSE;
4834 /* Interact with player */
4835 while (!leave_store)
4837 /* Hack -- Clear line 1 */
4841 clear_from(20 + xtra_stock);
4844 /* Basic commands */
4846 prt(" ESC) 建物から出る", 21 + xtra_stock, 0);
4848 prt(" ESC) Exit from Building.", 21 + xtra_stock, 0);
4852 /* Browse if necessary */
4853 if (st_ptr->stock_num > store_bottom)
4856 prt(" -)前ページ", 22 + xtra_stock, 0);
4857 prt(" スペース) 次ページ", 23 + xtra_stock, 0);
4859 prt(" -) Previous page", 22 + xtra_stock, 0);
4860 prt(" SPACE) Next page", 23 + xtra_stock, 0);
4866 if (cur_store_num == STORE_HOME)
4869 prt("g) アイテムを取る", 21 + xtra_stock, 27);
4870 prt("d) アイテムを置く", 22 + xtra_stock, 27);
4871 prt("x) 家のアイテムを調べる", 23 + xtra_stock, 27);
4873 prt("g) Get an item.", 21 + xtra_stock, 27);
4874 prt("d) Drop an item.", 22 + xtra_stock, 27);
4875 prt("x) eXamine an item in the home.", 23 + xtra_stock, 27);
4879 /* Museum commands */
4880 else if (cur_store_num == STORE_MUSEUM)
4883 prt("d) アイテムを置く", 21 + xtra_stock, 27);
4884 prt("r) アイテムの展示をやめる", 22 + xtra_stock, 27);
4885 prt("x) 博物館のアイテムを調べる", 23 + xtra_stock, 27);
4887 prt("d) Drop an item.", 21 + xtra_stock, 27);
4888 prt("r) order to Remove an item.", 22 + xtra_stock, 27);
4889 prt("x) eXamine an item in the museum.", 23 + xtra_stock, 27);
4897 prt("p) 商品を買う", 21 + xtra_stock, 30);
4898 prt("s) アイテムを売る", 22 + xtra_stock, 30);
4899 prt("x) 商品を調べる", 23 + xtra_stock,30);
4901 prt("p) Purchase an item.", 21 + xtra_stock, 30);
4902 prt("s) Sell an item.", 22 + xtra_stock, 30);
4903 prt("x) eXamine an item in the shop", 23 + xtra_stock,30);
4910 prt("i/e) 持ち物/装備の一覧", 21 + xtra_stock, 56);
4912 if (rogue_like_commands)
4914 prt("w/T) 装備する/はずす", 22 + xtra_stock, 56);
4918 prt("w/t) 装備する/はずす", 22 + xtra_stock, 56);
4921 prt("i/e) Inventry/Equipment list", 21 + xtra_stock, 56);
4923 if (rogue_like_commands)
4925 prt("w/T) Wear/Take off equipment", 22 + xtra_stock, 56);
4929 prt("w/t) Wear/Take off equipment", 22 + xtra_stock, 56);
4933 prt(_("コマンド:", "You may: "), 20 + xtra_stock, 0);
4936 request_command(TRUE);
4938 /* Process the command */
4939 store_process_command();
4942 * Hack -- To redraw missiles damage and prices in store
4943 * If player's charisma changes, or if player changes a bow, PU_BONUS is set
4945 need_redraw_store_inv = (p_ptr->update & PU_BONUS) ? TRUE : FALSE;
4947 /* Hack -- Character is still in "icky" mode */
4948 character_icky = TRUE;
4954 if (inventory[INVEN_PACK].k_idx)
4956 INVENTORY_IDX item = INVEN_PACK;
4958 object_type *o_ptr = &inventory[item];
4960 /* Hack -- Flee from the store */
4961 if (cur_store_num != STORE_HOME)
4964 if (cur_store_num == STORE_MUSEUM)
4965 msg_print("ザックからアイテムがあふれそうなので、あわてて博物館から出た...");
4967 msg_print("ザックからアイテムがあふれそうなので、あわてて店から出た...");
4969 if (cur_store_num == STORE_MUSEUM)
4970 msg_print("Your pack is so full that you flee the Museum...");
4972 msg_print("Your pack is so full that you flee the store...");
4980 /* Hack -- Flee from the home */
4981 else if (!store_check_num(o_ptr))
4984 msg_print("ザックからアイテムがあふれそうなので、あわてて家から出た...");
4986 msg_print("Your pack is so full that you flee your home...");
4994 /* Hack -- Drop items into the home */
5002 char o_name[MAX_NLEN];
5005 /* Give a message */
5007 msg_print("ザックからアイテムがあふれてしまった!");
5009 msg_print("Your pack overflows!");
5014 /* Grab a copy of the item */
5015 object_copy(q_ptr, o_ptr);
5018 object_desc(o_name, q_ptr, 0);
5021 msg_format("%sが落ちた。(%c)", o_name, index_to_label(item));
5023 msg_format("You drop %s (%c).", o_name, index_to_label(item));
5027 /* Remove it from the players inventory */
5028 inven_item_increase(item, -255);
5029 inven_item_describe(item);
5030 inven_item_optimize(item);
5033 /* Let the home carry it */
5034 item_pos = home_carry(q_ptr);
5036 /* Redraw the home */
5039 store_top = (item_pos / store_bottom) * store_bottom;
5040 display_inventory();
5045 /* Hack -- Redisplay store prices if charisma changes */
5046 /* Hack -- Redraw missiles damage if player changes bow */
5047 if (need_redraw_store_inv) display_inventory();
5049 /* Hack -- get kicked out of the store */
5050 if (st_ptr->store_open >= turn) leave_store = TRUE;
5053 select_floor_music();
5055 p_ptr->town_num = old_town_num;
5058 p_ptr->energy_use = 100;
5061 /* Hack -- Character is no longer in "icky" mode */
5062 character_icky = FALSE;
5065 /* Hack -- Cancel automatic command */
5068 /* Hack -- Cancel "see" mode */
5069 command_see = FALSE;
5071 /* Allow expanding macros */
5072 get_com_no_macros = FALSE;
5074 /* Flush messages */
5078 /* Clear the screen */
5082 /* Update everything */
5083 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
5084 p_ptr->update |= (PU_MONSTERS);
5086 /* Redraw entire screen */
5087 p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5089 p_ptr->redraw |= (PR_MAP);
5091 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5097 * @brief 現在の町の店主を交代させる /
5098 * Shuffle one of the stores.
5099 * @param which 店舗種類のID
5102 void store_shuffle(int which)
5108 if (which == STORE_HOME) return;
5109 if (which == STORE_MUSEUM) return;
5112 /* Save the store index */
5113 cur_store_num = which;
5115 /* Activate that store */
5116 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
5119 /* Pick a new owner */
5122 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5123 if (j == st_ptr->owner) continue;
5124 for (i = 1;i < max_towns; i++)
5126 if (i == p_ptr->town_num) continue;
5127 if (st_ptr->owner == town[i].store[cur_store_num].owner) break;
5129 if (i == max_towns) break;
5132 /* Activate the new owner */
5133 ot_ptr = &owners[cur_store_num][st_ptr->owner];
5136 /* Reset the owner data */
5137 st_ptr->insult_cur = 0;
5138 st_ptr->store_open = 0;
5139 st_ptr->good_buy = 0;
5140 st_ptr->bad_buy = 0;
5143 /* Hack -- discount all the items */
5144 for (i = 0; i < st_ptr->stock_num; i++)
5148 o_ptr = &st_ptr->stock[i];
5150 if (!object_is_artifact(o_ptr))
5152 /* Hack -- Sell all non-artifact old items for "half price" */
5153 o_ptr->discount = 50;
5155 /* Hack -- Items are no longer "fixed price" */
5156 o_ptr->ident &= ~(IDENT_FIXED);
5158 /* Mega-Hack -- Note that the item is "on sale" */
5159 o_ptr->inscription = quark_add(_("売出中", "on sale"));
5166 * @brief 店の品揃えを変化させる /
5167 * Maintain the inventory at the stores.
5168 * @param town_num 町のID
5169 * @param store_num 店舗種類のID
5172 void store_maint(int town_num, int store_num)
5176 cur_store_num = store_num;
5179 if (store_num == STORE_HOME) return;
5180 if (store_num == STORE_MUSEUM) return;
5182 /* Activate that store */
5183 st_ptr = &town[town_num].store[store_num];
5185 /* Activate the owner */
5186 ot_ptr = &owners[store_num][st_ptr->owner];
5188 /* Store keeper forgives the player */
5189 st_ptr->insult_cur = 0;
5191 /* Mega-Hack -- prune the black market */
5192 if (store_num == STORE_BLACK)
5194 /* Destroy crappy black market items */
5195 for (j = st_ptr->stock_num - 1; j >= 0; j--)
5197 object_type *o_ptr = &st_ptr->stock[j];
5199 /* Destroy crappy items */
5200 if (black_market_crap(o_ptr))
5202 /* Destroy the item */
5203 store_item_increase(j, 0 - o_ptr->number);
5204 store_item_optimize(j);
5210 /* Choose the number of slots to keep */
5211 j = st_ptr->stock_num;
5213 /* Sell a few items */
5214 j = j - randint1(STORE_TURNOVER);
5216 /* Never keep more than "STORE_MAX_KEEP" slots */
5217 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
5219 /* Always "keep" at least "STORE_MIN_KEEP" items */
5220 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
5222 /* Hack -- prevent "underflow" */
5225 /* Destroy objects until only "j" slots are left */
5226 while (st_ptr->stock_num > j) store_delete();
5229 /* Choose the number of slots to fill */
5230 j = st_ptr->stock_num;
5232 /* Buy some more items */
5233 j = j + randint1(STORE_TURNOVER);
5235 /* Never keep more than "STORE_MAX_KEEP" slots */
5236 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
5238 /* Always "keep" at least "STORE_MIN_KEEP" items */
5239 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
5241 /* Hack -- prevent "overflow" */
5242 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
5244 /* Acquire some new items */
5245 while (st_ptr->stock_num < j) store_create();
5250 * @brief 店舗情報を初期化する /
5251 * Initialize the stores
5252 * @param town_num 町のID
5253 * @param store_num 店舗種類のID
5256 void store_init(int town_num, int store_num)
5260 cur_store_num = store_num;
5262 /* Activate that store */
5263 st_ptr = &town[town_num].store[store_num];
5271 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5272 for (i = 1;i < max_towns; i++)
5274 if (i == town_num) continue;
5275 if (st_ptr->owner == town[i].store[store_num].owner) break;
5277 if (i == max_towns) break;
5280 /* Activate the new owner */
5281 ot_ptr = &owners[store_num][st_ptr->owner];
5284 /* Initialize the store */
5285 st_ptr->store_open = 0;
5286 st_ptr->insult_cur = 0;
5287 st_ptr->good_buy = 0;
5288 st_ptr->bad_buy = 0;
5290 /* Nothing in stock */
5291 st_ptr->stock_num = 0;
5294 * MEGA-HACK - Last visit to store is
5295 * BEFORE player birth to enable store restocking
5297 st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
5299 /* Clear any old items */
5300 for (k = 0; k < st_ptr->stock_size; k++)
5302 object_wipe(&st_ptr->stock[k]);
5308 * @brief アイテムを町のブラックマーケットに移動させる /
5309 * @param o_ptr 移動させたいオブジェクトの構造体参照ポインタ
5312 void move_to_black_market(object_type *o_ptr)
5315 if (!p_ptr->town_num) return;
5317 st_ptr = &town[p_ptr->town_num].store[STORE_BLACK];
5319 o_ptr->ident |= IDENT_STORE;
5321 (void)store_carry(o_ptr);
5323 object_wipe(o_ptr); /* Don't leave a bogus object behind... */