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"
21 static int cur_store_num = 0;
22 static int store_top = 0;
23 static int store_bottom = 0;
24 static int xtra_stock = 0;
25 static store_type *st_ptr = NULL;
26 static const owner_type *ot_ptr = NULL;
27 static s16b old_town_num = 0;
28 static s16b inner_town_num = 0;
29 #define RUMOR_CHANCE 8
31 #define MAX_COMMENT_1 6
33 static cptr comment_1[MAX_COMMENT_1] =
54 /*! ブラックマーケット追加メッセージ(承諾) */
55 static cptr comment_1_B[MAX_COMMENT_1] = {
64 #define MAX_COMMENT_2A 2
66 static cptr comment_2a[MAX_COMMENT_2A] =
69 "私の忍耐力を試しているのかい? $%s が最後だ。",
70 "我慢にも限度があるぞ。 $%s が最後だ。"
72 "You try my patience. %s is final.",
73 "My patience grows thin. %s is final."
78 #define MAX_COMMENT_2B 12
80 static cptr comment_2b[MAX_COMMENT_2B] =
83 " $%s ぐらいは出さなきゃダメだよ。",
86 "何て奴だ! $%s 以下はあり得ないぞ。",
87 "それじゃ少なすぎる! $%s は欲しいところだ。",
88 "バカにしている! $%s はもらわないと。",
90 "おいおい! $%s を考えてくれないか?",
91 "1000匹のオークのノミに苦しめられるがいい! $%s だ。",
92 "お前の大切なものに災いあれ! $%s でどうだ。",
93 "モルゴスに賞味されるがいい!本当は $%s なんだろう?",
94 "お前の母親はオーガか! $%s は出すつもりなんだろ?"
96 "I can take no less than %s gold pieces.",
97 "I will accept no less than %s gold pieces.",
98 "Ha! No less than %s gold pieces.",
99 "You knave! No less than %s gold pieces.",
100 "That's a pittance! I want %s gold pieces.",
101 "That's an insult! I want %s gold pieces.",
102 "As if! How about %s gold pieces?",
103 "My arse! How about %s gold pieces?",
104 "May the fleas of 1000 orcs molest you! Try %s gold pieces.",
105 "May your most favourite parts go moldy! Try %s gold pieces.",
106 "May Morgoth find you tasty! Perhaps %s gold pieces?",
107 "Your mother was an Ogre! Perhaps %s gold pieces?"
113 /*! ブラックマーケット用追加メッセージ(売るとき) */
114 static cptr comment_2b_B[MAX_COMMENT_2B] = {
115 "いくら俺様がお人好しとはいえ $%s が限界だね。嫌なら帰りな。",
116 "金がないのかい、あんた?まずは家に帰って $%s 揃えてきな。",
117 "物の価値が分からん奴だな。これは $%s が普通なんだよ。",
118 "俺の付けた値段に文句があるのか? $%s が限界だ。",
119 "ひょっとして新手の冗談かい? $%s 持ってないなら帰りな。",
120 "うちは他の店とは違うんだよ。$%s ぐらいは出しな。",
121 "買う気がないなら帰りな。 $%s だと言っているんだ。",
122 "話にならないね。 $%s くらい持っているんだろ?",
123 "は?なんだそりゃ? $%s の間違いか、ひょっとして?",
124 "出口はあっちだよ。それとも $%s 出せるのかい、あんたに。",
125 "命知らずな奴だな。 $%s 出せば今日の所は勘弁してやるよ。",
126 "うちの店は貧乏人お断りだ。 $%s ぐらい出せないのかい?"
129 #define MAX_COMMENT_3A 2
131 static cptr comment_3a[MAX_COMMENT_3A] =
134 "私の忍耐力を試しているのかい? $%s が最後だ。",
135 "我慢にも限度があるぞ。 $%s が最後だ。"
137 "You try my patience. %s is final.",
138 "My patience grows thin. %s is final."
144 #define MAX_COMMENT_3B 12
146 static cptr comment_3b[MAX_COMMENT_3B] =
149 "本音を言うと $%s でいいんだろ?",
151 " $%s ぐらいなら出してもいいが。",
152 " $%s 以上払うなんて考えられないね。",
153 "まあ落ちついて。 $%s でどうだい?",
154 "そのガラクタなら $%s で引き取るよ。",
155 "それじゃ高すぎる! $%s がいいとこだろ。",
156 "どうせいらないんだろ! $%s でいいだろ?",
157 "だめだめ! $%s がずっとお似合いだよ。",
158 "バカにしている! $%s がせいぜいだ。",
159 " $%s なら嬉しいところだがなあ。",
160 " $%s 、それ以上はビタ一文出さないよ!"
162 "Perhaps %s gold pieces?",
163 "How about %s gold pieces?",
164 "I will pay no more than %s gold pieces.",
165 "I can afford no more than %s gold pieces.",
166 "Be reasonable. How about %s gold pieces?",
167 "I'll buy it as scrap for %s gold pieces.",
168 "That is too much! How about %s gold pieces?",
169 "That looks war surplus! Say %s gold pieces?",
170 "Never! %s is more like it.",
171 "That's an insult! %s is more like it.",
172 "%s gold pieces and be thankful for it!",
173 "%s gold pieces and not a copper more!"
179 /*! ブラックマーケット用追加メッセージ(買い取り) */
180 static cptr comment_3b_B[MAX_COMMENT_3B] = {
181 " $%s ってところだね。そのどうしようもないガラクタは。",
182 "この俺が $%s って言っているんだから、その通りにした方が身のためだぞ。",
183 "俺の優しさに甘えるのもいい加減にしておけ。 $%s だ。",
184 "その品なら $%s で売ってくれているがね、常識ある紳士はみんな。",
185 "こりゃまた、がめつい奴だな。いくら俺が温厚とはいえ $%s が限界だ。",
186 " $%s だ。別に俺はそんなガラクタ欲しくはないんだから。",
187 "俺の鑑定額が気に入らないのか? $%s 、嫌なら帰りな。",
188 " $%s で引き取ってやるよ。喜んで受け取りな、貧乏人。",
189 "物の価値が分からん奴は始末におえんな。それは $%s なんだよ。",
190 "そんなに金が欲しいのか、あんた? $%s で満足できんのか?",
191 "入る店間違えてんじゃないのか? $%s で嫌なら他をあたってくれ。",
192 "俺の言い値にケチをつける奴がいるとは! その度胸に免じて $%s だ。"
195 #define MAX_COMMENT_4A 4
197 static cptr comment_4a[MAX_COMMENT_4A] =
200 "もうたくさんだ!何度も私をわずらわせないでくれ!",
201 "うがー!一日の我慢の限度を超えている!",
202 "もういい!時間の無駄以外のなにものでもない!",
203 "もうやってられないよ!顔も見たくない!"
205 "Enough! You have abused me once too often!",
206 "Arghhh! I have had enough abuse for one day!",
207 "That does it! You shall waste my time no more!",
208 "This is getting nowhere! I'm going to Londis!"
214 /*! ブラックマーケット用追加メッセージ(怒りの頂点) */
215 static cptr comment_4a_B[MAX_COMMENT_4A] = {
216 "なめやがって!温厚な俺様でも限界があるってことを知れ!",
217 "俺をここまで怒らせて...命があるだけでもありがたいと思え!",
218 "ふざけてるのか!冷やかしなら相手を見てからにしろ!",
219 "いいかげんにしろ!今度こんなまねしたらただじゃおかねえぞ!"
222 #define MAX_COMMENT_4B 4
224 static cptr comment_4b[MAX_COMMENT_4B] =
233 "Get out of my sight!",
234 "Begone, you scoundrel!",
241 /*! ブラックマーケット用追加メッセージ(追い出し) */
242 static cptr comment_4b_B[MAX_COMMENT_4B] = {
249 #define MAX_COMMENT_5 8
251 static cptr comment_5[MAX_COMMENT_5] =
265 "You will have to do better than that!",
266 "Do you wish to do business or not?",
267 "You've got to be kidding!",
268 "You'd better be kidding!",
269 "You try my patience.",
270 "Hmmm, nice weather we're having."
276 /*! ブラックマーケット用追加メッセージ(怒り) */
277 static cptr comment_5_B[MAX_COMMENT_5] = {
288 #define MAX_COMMENT_6 4
290 static cptr comment_6[MAX_COMMENT_6] =
298 "I must have heard you wrong.",
299 "I'm sorry, I missed that.",
300 "I'm sorry, what was that?",
301 "Sorry, what was that again?"
309 * @brief 取引成功時の店主のメッセージ処理 /
313 static void say_comment_1(void)
316 /* ブラックマーケットのときは別のメッセージを出す */
317 if ( cur_store_num == STORE_BLACK ) {
318 msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
321 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
324 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
328 if (one_in_(RUMOR_CHANCE))
331 msg_print("店主は耳うちした:");
333 msg_print("The shopkeeper whispers something into your ear:");
341 * @brief プレイヤーがアイテムを買う時の価格代案メッセージ処理 /
342 * Continue haggling (player is buying)
343 * @param value 店主の提示価格
344 * @param annoyed 店主のいらつき度
347 static void say_comment_2(PRICE value, int annoyed)
351 /* Prepare a string to insert */
352 sprintf(tmp_val, "%ld", (long)value);
357 /* Formatted message */
358 msg_format(comment_2a[randint0(MAX_COMMENT_2A)], tmp_val);
364 /* Formatted message */
366 /* ブラックマーケットの時は別のメッセージを出す */
367 if ( cur_store_num == STORE_BLACK ){
368 msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val);
371 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
374 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
382 * @brief プレイヤーがアイテムを売る時の価格代案メッセージ処理 /
383 * Continue haggling (player is selling)
384 * @param value 店主の提示価格
385 * @param annoyed 店主のいらつき度
388 static void say_comment_3(PRICE value, int annoyed)
392 /* Prepare a string to insert */
393 sprintf(tmp_val, "%ld", (long)value);
398 /* Formatted message */
399 msg_format(comment_3a[randint0(MAX_COMMENT_3A)], tmp_val);
405 /* Formatted message */
407 /* ブラックマーケットの時は別のメッセージを出す */
408 if ( cur_store_num == STORE_BLACK ){
409 msg_format(comment_3b_B[randint0(MAX_COMMENT_3B)], tmp_val);
412 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
415 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
423 * @brief 店主がプレイヤーを追い出す時のメッセージ処理 /
424 * Kick 'da bum out. -RAK-
427 static void say_comment_4(void)
430 /* ブラックマーケットの時は別のメッセージを出す */
431 if ( cur_store_num == STORE_BLACK ){
432 msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
433 msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
436 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
437 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
440 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
441 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
448 * @brief 店主がプレイヤーに取り合わない時のメッセージ処理 /
449 * You are insulting me
452 static void say_comment_5(void)
455 /* ブラックマーケットの時は別のメッセージを出す */
456 if ( cur_store_num == STORE_BLACK ){
457 msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
460 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
463 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
470 * @brief 店主がプレイヤーの提示を理解できなかった時のメッセージ処理 /
471 * That makes no sense.
474 static void say_comment_6(void)
476 msg_print(comment_6[randint0(MAX_COMMENT_6)]);
480 #define MAX_COMMENT_7A 4
482 static cptr comment_7a[MAX_COMMENT_7A] =
487 "誰かがむせび泣く声が聞こえる...。",
492 "You hear someone sobbing...",
493 "The shopkeeper howls in agony!"
498 #define MAX_COMMENT_7B 4
500 static cptr comment_7b[MAX_COMMENT_7B] =
510 "The shopkeeper curses at you.",
511 "The shopkeeper glares at you."
516 #define MAX_COMMENT_7C 4
518 static cptr comment_7c[MAX_COMMENT_7C] =
527 "You've made my day!",
528 "The shopkeeper giggles.",
529 "The shopkeeper laughs loudly."
534 #define MAX_COMMENT_7D 4
536 static cptr comment_7d[MAX_COMMENT_7D] =
540 "こんなおいしい思いをしたら、真面目に働けなくなるなぁ。",
545 "I think I'll retire!",
546 "The shopkeeper jumps for joy.",
547 "The shopkeeper smiles gleefully."
554 * @brief 店主が交渉を終えた際の反応を返す処理 /
555 * Let a shop-keeper React to a purchase
556 * @param price アイテムの取引額
557 * @param value アイテムの実際価値
558 * @param guess 店主が当初予想していた価値
561 * We paid "price", it was worth "value", and we thought it was worth "guess"
563 static void purchase_analyze(PRICE price, PRICE value, PRICE guess)
565 /* Item was worthless, but we bought it */
566 if ((value <= 0) && (price > value))
568 msg_print(comment_7a[randint0(MAX_COMMENT_7A)]);
569 chg_virtue(V_HONOUR, -1);
570 chg_virtue(V_JUSTICE, -1);
574 /* Item was cheaper than we thought, and we paid more than necessary */
575 else if ((value < guess) && (price > value))
577 msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
578 chg_virtue(V_JUSTICE, -1);
579 if (one_in_(4)) chg_virtue(V_HONOUR, -1);
583 /* Item was a good bargain, and we got away with it */
584 else if ((value > guess) && (value < (4 * guess)) && (price < value))
586 msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
587 if (one_in_(4)) chg_virtue(V_HONOUR, -1);
588 else if (one_in_(4)) chg_virtue(V_HONOUR, 1);
592 /* Item was a great bargain, and we got away with it */
593 else if ((value > guess) && (price < value))
595 msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
596 if (one_in_(2)) chg_virtue(V_HONOUR, -1);
597 if (one_in_(4)) chg_virtue(V_HONOUR, 1);
598 if (10 * price < value) chg_virtue(V_SACRIFICE, 1);
606 * We store the current "store feat" here so everyone can access it
608 static int cur_store_feat;
612 * Buying and selling adjustments for race combinations.
613 * Entry[owner][player] gives the basic "cost inflation".
615 static byte rgold_adj[MAX_RACES][MAX_RACES] =
617 /*Hum, HfE, Elf, Hal, Gno, Dwa, HfO, HfT, Dun, HiE, Barbarian,
618 HfOg, HGn, HTn, Cyc, Yek, Klc, Kbd, Nbl, DkE, Drc, Mind Flayer,
619 Imp, Glm, Skl, Zombie, Vampire, Spectre, Fairy, Beastman, Ent,
620 Angel, Demon, Kutar */
623 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
624 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
625 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
626 100, 120, 110, 105 },
629 { 110, 100, 100, 105, 110, 120, 125, 130, 110, 100, 110,
630 120, 115, 108, 115, 110, 110, 120, 120, 115, 115, 110,
631 120, 110, 110, 110, 120, 110, 100, 125, 100, 95, 140,
632 110, 115, 110, 110 },
635 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
636 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
637 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
638 110, 110, 105, 110 },
641 { 115, 110, 105, 95, 105, 110, 115, 130, 115, 105, 115,
642 125, 120, 120, 125, 115, 110, 120, 120, 120, 115, 115,
643 120, 110, 120, 120, 130, 110, 110, 130, 110, 95, 140,
644 115, 120, 105, 115 },
647 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
648 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
649 120, 101, 110, 110, 120, 120, 115, 130, 115, 95, 140,
650 115, 110, 110, 115 },
653 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
654 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
655 120, 105, 115, 115, 115, 115, 120, 130, 120, 95, 140,
656 115, 110, 115, 115 },
659 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
660 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
661 115, 125, 120, 120, 115, 120, 125, 115, 125, 95, 140,
662 115, 110, 115, 115 },
665 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
666 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
667 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
668 110, 110, 115, 110 },
671 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
672 120, 120, 105, 120, 115, 105, 115, 120, 110, 105, 105,
673 120, 105, 120, 120, 125, 120, 105, 135, 105, 95, 140,
674 100, 110, 110, 100 },
677 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
678 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
679 125, 115, 120, 120, 125, 120, 100, 125, 100, 95, 140,
680 110, 110, 105, 110 },
682 /* Human / Barbarian (copied from human) */
683 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
684 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
685 115, 105, 125, 125, 130, 125, 115, 120, 115, 95, 140,
686 100, 120, 110, 100 },
688 /* Half-Ogre: theoretical, copied from half-troll */
689 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
690 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
691 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
692 110, 110, 115, 110 },
694 /* Half-Giant: theoretical, copied from half-troll */
695 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
696 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
697 110, 115, 112, 112, 115, 112, 130, 120, 130, 95, 140,
698 110, 110, 115, 110 },
700 /* Half-Titan: theoretical, copied from High_Elf */
701 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
702 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
703 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
704 110, 110, 115, 110 },
706 /* Cyclops: theoretical, copied from half-troll */
707 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
708 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
709 110, 115, 112, 112, 115, 112, 130, 130, 130, 95, 140,
710 110, 110, 115, 110 },
712 /* Yeek: theoretical, copied from Half-Orc */
713 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
714 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
715 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
716 115, 110, 115, 115 },
718 /* Klackon: theoretical, copied from Gnome */
719 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
720 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
721 120, 101, 110, 110, 120, 120, 130, 130, 130, 95, 140,
722 115, 110, 115, 115 },
724 /* Kobold: theoretical, copied from Half-Orc */
725 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
726 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
727 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
728 115, 110, 115, 115 },
730 /* Nibelung: theoretical, copied from Dwarf */
731 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
732 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
733 120, 105, 115, 115, 120, 120, 130, 130, 130, 95, 140,
734 115, 135, 115, 115 },
737 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
738 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
739 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
740 110, 101, 115, 110 },
742 /* Draconian: theoretical, copied from High_Elf */
743 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
744 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
745 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
746 110, 110, 115, 110 },
748 /* Mind Flayer: theoretical, copied from High_Elf */
749 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
750 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
751 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
752 110, 110, 115, 110 },
754 /* Imp: theoretical, copied from High_Elf */
755 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
756 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
757 125, 115, 120, 120, 120, 120, 130, 130, 130, 120, 120,
758 110, 110, 115, 110 },
760 /* Golem: theoretical, copied from High_Elf */
761 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
762 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
763 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
764 110, 110, 115, 110 },
766 /* Skeleton: theoretical, copied from half-orc */
767 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
768 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
769 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
770 115, 110, 125, 115 },
772 /* Zombie: Theoretical, copied from half-orc */
773 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
774 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
775 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
776 115, 110, 125, 115 },
778 /* Vampire: Theoretical, copied from half-orc */
779 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
780 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
781 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
782 115, 110, 125, 115 },
784 /* Spectre: Theoretical, copied from half-orc */
785 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
786 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
787 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
788 115, 110, 125, 115 },
790 /* Sprite: Theoretical, copied from half-orc */
791 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
792 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
793 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
794 115, 110, 105, 115 },
796 /* Beastman: Theoretical, copied from half-orc */
797 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
798 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
799 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
800 115, 110, 115, 115 },
803 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
804 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
805 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
806 110, 110, 105, 110 },
809 { 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
810 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
811 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 160,
815 { 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
816 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
817 140, 140, 140, 140, 140, 140, 140, 140, 140, 160, 120,
818 140, 140, 140, 140 },
821 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
822 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
823 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
824 100, 120, 110, 100 },
827 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
828 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
829 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
830 110, 101, 115, 110 },
833 { 110, 110, 105, 105, 110, 115, 115, 115, 110, 105, 110,
834 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
835 115, 115, 125, 125, 125, 125, 105, 115, 105, 95, 140,
836 110, 115, 100, 110 },
839 { 105, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
840 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
841 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
842 100, 120, 110, 100 },
849 * Determine the price of an item (qty one) in a store.
850 * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
851 * @param greed 店主の強欲度
852 * @param flip TRUEならば店主にとっての買取価格、FALSEなら売出価格を計算
856 * This function takes into account the player's charisma, and the
857 * shop-keepers friendliness, and the shop-keeper's base greed, but
858 * never lets a shop-keeper lose money in a transaction.
859 * The "greed" value should exceed 100 when the player is "buying" the
860 * item, and should be less than 100 when the player is "selling" it.
861 * Hack -- the black market always charges twice as much as it should.
862 * Charisma adjustment runs from 80 to 130
863 * Racial adjustment runs from 95 to 130
864 * Since greed/charisma/racial adjustments are centered at 100, we need
865 * to adjust (by 200) to extract a usable multiplier. Note that the
866 * "greed" value is always something (?).
869 static s32b price_item(object_type *o_ptr, int greed, bool flip)
876 /* Get the value of one of the items */
877 price = object_value(o_ptr);
879 /* Worthless items */
880 if (price <= 0) return (0L);
883 /* Compute the racial factor */
884 factor = rgold_adj[ot_ptr->owner_race][p_ptr->prace];
886 /* Add in the charisma factor */
887 factor += adj_chr_gold[p_ptr->stat_ind[A_CHR]];
893 /* Adjust for greed */
894 adjust = 100 + (300 - (greed + factor));
896 /* Never get "silly" */
897 if (adjust > 100) adjust = 100;
899 /* Mega-Hack -- Black market sucks */
900 if (cur_store_num == STORE_BLACK)
903 /* Compute the final price (with rounding) */
904 /* Hack -- prevent underflow */
905 price = (price * adjust + 50L) / 100L;
908 /* Shop is selling */
911 /* Adjust for greed */
912 adjust = 100 + ((greed + factor) - 300);
914 /* Never get "silly" */
915 if (adjust < 100) adjust = 100;
917 /* Mega-Hack -- Black market sucks */
918 if (cur_store_num == STORE_BLACK)
921 /* Compute the final price (with rounding) */
922 /* Hack -- prevent overflow */
923 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
926 /* Note -- Never become "free" */
927 if (price <= 0L) return (1L);
929 /* Return the price */
935 * @brief 安価な消耗品の販売数を増やし、低確率で割引にする /
936 * Certain "cheap" objects should be created in "piles"
937 * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
941 * Some objects can be sold at a "discount" (in small piles)
944 static void mass_produce(object_type *o_ptr)
947 DISCOUNT_RATE discount = 0;
949 s32b cost = object_value(o_ptr);
952 /* Analyze the type */
955 /* Food, Flasks, and Lites */
960 if (cost <= 5L) size += damroll(3, 5);
961 if (cost <= 20L) size += damroll(3, 5);
962 if (cost <= 50L) size += damroll(2, 2);
969 if (cost <= 60L) size += damroll(3, 5);
970 if (cost <= 240L) size += damroll(1, 5);
971 if (o_ptr->sval == SV_SCROLL_STAR_IDENTIFY) size += damroll(3, 5);
972 if (o_ptr->sval == SV_SCROLL_STAR_REMOVE_CURSE) size += damroll(1, 4);
977 case TV_SORCERY_BOOK:
985 case TV_CRUSADE_BOOK:
987 case TV_HISSATSU_BOOK:
990 if (cost <= 50L) size += damroll(2, 3);
991 if (cost <= 500L) size += damroll(1, 3);
1009 if (object_is_artifact(o_ptr)) break;
1010 if (object_is_ego(o_ptr)) break;
1011 if (cost <= 10L) size += damroll(3, 5);
1012 if (cost <= 100L) size += damroll(3, 5);
1021 if (cost <= 5L) size += damroll(5, 5);
1022 if (cost <= 50L) size += damroll(5, 5);
1023 if (cost <= 500L) size += damroll(5, 5);
1029 if (cost <= 100L) size += damroll(2, 2);
1030 if (cost <= 1000L) size += damroll(2, 2);
1043 * Because many rods (and a few wands and staffs) are useful mainly
1044 * in quantity, the Black Market will occasionally have a bunch of
1051 if ((cur_store_num == STORE_BLACK) && one_in_(3))
1053 if (cost < 1601L) size += damroll(1, 5);
1054 else if (cost < 3201L) size += damroll(1, 3);
1061 /* Pick a discount */
1066 else if (one_in_(25))
1070 else if (one_in_(150))
1074 else if (one_in_(300))
1078 else if (one_in_(500))
1083 if (o_ptr->art_name)
1088 /* Save the discount */
1089 o_ptr->discount = discount;
1091 /* Save the total pile size */
1092 o_ptr->number = size - (size * discount / 100);
1094 /* Ensure that mass-produced rods and wands get the correct pvals. */
1095 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1097 o_ptr->pval *= (PARAMETER_VALUE)o_ptr->number;
1104 * @brief 店舗に並べた品を同一品であるかどうか判定する /
1105 * Determine if a store item can "absorb" another item
1106 * @param o_ptr 判定するオブジェクト構造体の参照ポインタ1
1107 * @param j_ptr 判定するオブジェクト構造体の参照ポインタ2
1108 * @return 同一扱いできるならTRUEを返す
1111 * See "object_similar()" for the same function for the "player"
1114 static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
1118 /* Hack -- Identical items cannot be stacked */
1119 if (o_ptr == j_ptr) return (0);
1121 /* Different objects cannot be stacked */
1122 if (o_ptr->k_idx != j_ptr->k_idx) return (0);
1124 /* Different charges (etc) cannot be stacked, unless wands or rods. */
1125 if ((o_ptr->pval != j_ptr->pval) && (o_ptr->tval != TV_WAND) && (o_ptr->tval != TV_ROD)) return (0);
1127 /* Require many identical values */
1128 if (o_ptr->to_h != j_ptr->to_h) return (0);
1129 if (o_ptr->to_d != j_ptr->to_d) return (0);
1130 if (o_ptr->to_a != j_ptr->to_a) return (0);
1132 /* Require identical "ego-item" names */
1133 if (o_ptr->name2 != j_ptr->name2) return (0);
1135 /* Artifacts don't stack! */
1136 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return (0);
1138 /* Hack -- Identical art_flags! */
1139 for (i = 0; i < TR_FLAG_SIZE; i++)
1140 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return (0);
1142 /* Hack -- Never stack "powerful" items */
1143 if (o_ptr->xtra1 || j_ptr->xtra1) return (0);
1145 /* Hack -- Never stack recharging items */
1146 if (o_ptr->timeout || j_ptr->timeout) return (0);
1148 /* Require many identical values */
1149 if (o_ptr->ac != j_ptr->ac) return (0);
1150 if (o_ptr->dd != j_ptr->dd) return (0);
1151 if (o_ptr->ds != j_ptr->ds) return (0);
1153 /* Hack -- Never stack chests */
1154 if (o_ptr->tval == TV_CHEST) return (0);
1155 if (o_ptr->tval == TV_STATUE) return (0);
1156 if (o_ptr->tval == TV_CAPTURE) return (0);
1158 /* Require matching discounts */
1159 if (o_ptr->discount != j_ptr->discount) return (0);
1161 /* They match, so they must be similar */
1167 * @brief 店舗に並べた品を重ね合わせできるかどうか判定する /
1168 * Allow a store item to absorb another item
1169 * @param o_ptr 判定するオブジェクト構造体の参照ポインタ1
1170 * @param j_ptr 判定するオブジェクト構造体の参照ポインタ2
1171 * @return 重ね合わせできるならTRUEを返す
1174 * See "object_similar()" for the same function for the "player"
1177 static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
1179 int max_num = (o_ptr->tval == TV_ROD) ?
1180 MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99;
1181 int total = o_ptr->number + j_ptr->number;
1182 int diff = (total > max_num) ? total - max_num : 0;
1184 /* Combine quantity, lose excess items */
1185 o_ptr->number = (total > max_num) ? max_num : total;
1187 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
1188 if (o_ptr->tval == TV_ROD)
1190 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1193 /* Hack -- if wands are stacking, combine the charges. -LM- */
1194 if (o_ptr->tval == TV_WAND)
1196 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1202 * @brief 店舗に品を置くスペースがあるかどうかの判定を返す /
1203 * Check to see if the shop will be carrying too many objects -RAK-
1204 * @param o_ptr 店舗に置きたいオブジェクト構造体の参照ポインタ
1205 * @return 置き場がないなら0、重ね合わせできるアイテムがあるなら-1、スペースがあるなら1を返す。
1208 * Note that the shop, just like a player, will not accept things
1209 * it cannot hold. Before, one could "nuke" potions this way.
1210 * Return value is now int:
1212 * -1 : Can be combined to existing slot.
1213 * 1 : Cannot be combined but there are empty spaces.
1216 static int store_check_num(object_type *o_ptr)
1221 /* The "home" acts like the player */
1222 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
1224 bool old_stack_force_notes = stack_force_notes;
1225 bool old_stack_force_costs = stack_force_costs;
1227 if (cur_store_num != STORE_HOME)
1229 stack_force_notes = FALSE;
1230 stack_force_costs = FALSE;
1233 /* Check all the items */
1234 for (i = 0; i < st_ptr->stock_num; i++)
1236 /* Get the existing item */
1237 j_ptr = &st_ptr->stock[i];
1239 /* Can the new object be combined with the old one? */
1240 if (object_similar(j_ptr, o_ptr))
1242 if (cur_store_num != STORE_HOME)
1244 stack_force_notes = old_stack_force_notes;
1245 stack_force_costs = old_stack_force_costs;
1252 if (cur_store_num != STORE_HOME)
1254 stack_force_notes = old_stack_force_notes;
1255 stack_force_costs = old_stack_force_costs;
1259 /* Normal stores do special stuff */
1262 /* Check all the items */
1263 for (i = 0; i < st_ptr->stock_num; i++)
1265 /* Get the existing item */
1266 j_ptr = &st_ptr->stock[i];
1268 /* Can the new object be combined with the old one? */
1269 if (store_object_similar(j_ptr, o_ptr)) return -1;
1273 /* Free space is always usable */
1275 * オプション powerup_home が設定されていると
1278 if ((cur_store_num == STORE_HOME) && ( powerup_home == FALSE )) {
1279 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) {
1284 if (st_ptr->stock_num < st_ptr->stock_size) {
1289 /* But there was no room at the inn... */
1294 * @brief オブジェクトが祝福されているかの判定を返す /
1295 * @param o_ptr 判定したいオブジェクト構造体の参照ポインタ
1296 * @return アイテムが祝福されたアイテムならばTRUEを返す
1298 static bool is_blessed(object_type *o_ptr)
1300 BIT_FLAGS flgs[TR_FLAG_SIZE];
1301 object_flags(o_ptr, flgs);
1302 if (have_flag(flgs, TR_BLESSED)) return (TRUE);
1303 else return (FALSE);
1309 * @brief オブジェクトが所定の店舗で引き取れるかどうかを返す /
1310 * Determine if the current store will purchase the given item
1311 * @param o_ptr 判定したいオブジェクト構造体の参照ポインタ
1312 * @return アイテムが買い取れるならばTRUEを返す
1314 * Note that a shop-keeper must refuse to buy "worthless" items
1316 static bool store_will_buy(object_type *o_ptr)
1318 /* Hack -- The Home is simple */
1319 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) return (TRUE);
1321 /* Switch on the store */
1322 switch (cur_store_num)
1327 /* Analyze the type */
1328 switch (o_ptr->tval)
1331 if (o_ptr->sval != SV_POTION_WATER) return FALSE;
1343 case TV_BOTTLE: /* 'Green', recycling Angband */
1358 /* Analyze the type */
1359 switch (o_ptr->tval)
1380 /* Analyze the type */
1381 switch (o_ptr->tval)
1390 case TV_HISSATSU_BOOK:
1394 if(o_ptr->sval == SV_WIZSTAFF) return (FALSE);
1406 /* Analyze the type */
1407 switch (o_ptr->tval)
1410 case TV_CRUSADE_BOOK:
1420 monster_race *r_ptr = &r_info[o_ptr->pval];
1423 if (!(r_ptr->flags3 & RF3_EVIL))
1426 if (r_ptr->flags3 & RF3_GOOD) break;
1428 /* Accept animals */
1429 if (r_ptr->flags3 & RF3_ANIMAL) break;
1432 if (my_strchr("?!", r_ptr->d_char)) break;
1438 if (is_blessed(o_ptr)) break;
1447 case STORE_ALCHEMIST:
1449 /* Analyze the type */
1450 switch (o_ptr->tval)
1464 /* Analyze the type */
1465 switch (o_ptr->tval)
1467 case TV_SORCERY_BOOK:
1468 case TV_NATURE_BOOK:
1472 case TV_ARCANE_BOOK:
1474 case TV_DAEMON_BOOK:
1488 if(o_ptr->sval == SV_WIZSTAFF) break;
1489 else return (FALSE);
1496 /* Bookstore Shop */
1499 /* Analyze the type */
1500 switch (o_ptr->tval)
1502 case TV_SORCERY_BOOK:
1503 case TV_NATURE_BOOK:
1508 case TV_ARCANE_BOOK:
1510 case TV_DAEMON_BOOK:
1511 case TV_CRUSADE_BOOK:
1522 /* Ignore "worthless" items */
1523 if (object_value(o_ptr) <= 0) return (FALSE);
1531 * @brief 現在の町の指定された店舗のアイテムを整理する /
1532 * Combine and reorder items in store.
1533 * @param store_num 店舗ID
1534 * @return 実際に整理が行われたならばTRUEを返す。
1536 bool combine_and_reorder_home(int store_num)
1540 object_type forge, *o_ptr, *j_ptr;
1541 bool flag = FALSE, combined;
1542 store_type *old_st_ptr = st_ptr;
1543 bool old_stack_force_notes = stack_force_notes;
1544 bool old_stack_force_costs = stack_force_costs;
1546 st_ptr = &town[1].store[store_num];
1547 if (store_num != STORE_HOME)
1549 stack_force_notes = FALSE;
1550 stack_force_costs = FALSE;
1557 /* Combine the items in the home (backwards) */
1558 for (i = st_ptr->stock_num - 1; i > 0; i--)
1560 o_ptr = &st_ptr->stock[i];
1562 /* Skip empty items */
1563 if (!o_ptr->k_idx) continue;
1565 /* Scan the items above that item */
1566 for (j = 0; j < i; j++)
1570 j_ptr = &st_ptr->stock[j];
1572 /* Skip empty items */
1573 if (!j_ptr->k_idx) continue;
1576 * Get maximum number of the stack if these
1577 * are similar, get zero otherwise.
1579 max_num = object_similar_part(j_ptr, o_ptr);
1581 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
1582 if (max_num && j_ptr->number < max_num)
1584 if (o_ptr->number + j_ptr->number <= max_num)
1586 /* Add together the item counts */
1587 object_absorb(j_ptr, o_ptr);
1589 /* One object is gone */
1590 st_ptr->stock_num--;
1592 /* Slide everything down */
1593 for (k = i; k < st_ptr->stock_num; k++)
1595 /* Structure copy */
1596 st_ptr->stock[k] = st_ptr->stock[k + 1];
1599 /* Erase the "final" slot */
1600 object_wipe(&st_ptr->stock[k]);
1604 ITEM_NUMBER old_num = o_ptr->number;
1605 ITEM_NUMBER remain = j_ptr->number + o_ptr->number - max_num;
1607 /* Add together the item counts */
1608 object_absorb(j_ptr, o_ptr);
1610 o_ptr->number = remain;
1612 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1613 if (o_ptr->tval == TV_ROD)
1615 o_ptr->pval = o_ptr->pval * remain / old_num;
1616 o_ptr->timeout = o_ptr->timeout * remain / old_num;
1619 /* Hack -- if wands are stacking, combine the charges. -LM- */
1620 else if (o_ptr->tval == TV_WAND)
1622 o_ptr->pval = o_ptr->pval * remain / old_num;
1638 /* Re-order the items in the home (forwards) */
1639 for (i = 0; i < st_ptr->stock_num; i++)
1641 o_ptr = &st_ptr->stock[i];
1643 /* Skip empty slots */
1644 if (!o_ptr->k_idx) continue;
1646 /* Get the "value" of the item */
1647 o_value = object_value(o_ptr);
1649 /* Scan every occupied slot */
1650 for (j = 0; j < st_ptr->stock_num; j++)
1652 if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
1655 /* Never move down */
1656 if (j >= i) continue;
1662 /* Save a copy of the moving item */
1663 object_copy(j_ptr, &st_ptr->stock[i]);
1665 /* Slide the objects */
1666 for (k = i; k > j; k--)
1668 /* Slide the item */
1669 object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
1672 /* Insert the moving item */
1673 object_copy(&st_ptr->stock[j], j_ptr);
1676 st_ptr = old_st_ptr;
1677 if (store_num != STORE_HOME)
1679 stack_force_notes = old_stack_force_notes;
1680 stack_force_costs = old_stack_force_costs;
1688 * @brief 我が家にオブジェクトを加える /
1689 * Add the item "o_ptr" to the inventory of the "Home"
1690 * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
1694 * In all cases, return the slot (or -1) where the object was placed
1695 * Note that this is a hacked up version of "inven_carry()".
1696 * Also note that it may not correctly "adapt" to "knowledge" bacoming
1697 * known, the player may have to pick stuff up and drop it again.
1700 static int home_carry(object_type *o_ptr)
1706 bool old_stack_force_notes = stack_force_notes;
1707 bool old_stack_force_costs = stack_force_costs;
1709 if (cur_store_num != STORE_HOME)
1711 stack_force_notes = FALSE;
1712 stack_force_costs = FALSE;
1715 /* Check each existing item (try to combine) */
1716 for (slot = 0; slot < st_ptr->stock_num; slot++)
1718 /* Get the existing item */
1719 j_ptr = &st_ptr->stock[slot];
1721 /* The home acts just like the player */
1722 if (object_similar(j_ptr, o_ptr))
1724 /* Save the new number of items */
1725 object_absorb(j_ptr, o_ptr);
1727 if (cur_store_num != STORE_HOME)
1729 stack_force_notes = old_stack_force_notes;
1730 stack_force_costs = old_stack_force_costs;
1738 if (cur_store_num != STORE_HOME)
1740 stack_force_notes = old_stack_force_notes;
1741 stack_force_costs = old_stack_force_costs;
1746 * 隠し機能: オプション powerup_home が設定されていると
1750 if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE)) {
1751 if (st_ptr->stock_num >= st_ptr->stock_size) {
1756 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10)) {
1762 /* Determine the "value" of the item */
1763 value = object_value(o_ptr);
1765 /* Check existing slots to see if we must "slide" */
1766 for (slot = 0; slot < st_ptr->stock_num; slot++)
1768 if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
1771 /* Slide the others up */
1772 for (i = st_ptr->stock_num; i > slot; i--)
1774 st_ptr->stock[i] = st_ptr->stock[i-1];
1777 /* More stuff now */
1778 st_ptr->stock_num++;
1780 /* Insert the new item */
1781 st_ptr->stock[slot] = *o_ptr;
1783 chg_virtue(V_SACRIFICE, -1);
1785 (void)combine_and_reorder_home(cur_store_num);
1787 /* Return the location */
1793 * @brief 店舗にオブジェクトを加える /
1794 * Add the item "o_ptr" to a real stores inventory.
1795 * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
1799 * In all cases, return the slot (or -1) where the object was placed
1800 * Note that this is a hacked up version of "inven_carry()".
1801 * Also note that it may not correctly "adapt" to "knowledge" bacoming
1802 * known, the player may have to pick stuff up and drop it again.
1805 static int store_carry(object_type *o_ptr)
1808 s32b value, j_value;
1812 /* Evaluate the object */
1813 value = object_value(o_ptr);
1815 /* Cursed/Worthless items "disappear" when sold */
1816 if (value <= 0) return (-1);
1818 /* All store items are fully *identified* */
1819 o_ptr->ident |= IDENT_MENTAL;
1821 /* Erase the inscription */
1822 o_ptr->inscription = 0;
1824 /* Erase the "feeling" */
1825 o_ptr->feeling = FEEL_NONE;
1827 /* Check each existing item (try to combine) */
1828 for (slot = 0; slot < st_ptr->stock_num; slot++)
1830 /* Get the existing item */
1831 j_ptr = &st_ptr->stock[slot];
1833 /* Can the existing items be incremented? */
1834 if (store_object_similar(j_ptr, o_ptr))
1836 /* Hack -- extra items disappear */
1837 store_object_absorb(j_ptr, o_ptr);
1845 if (st_ptr->stock_num >= st_ptr->stock_size) return (-1);
1848 /* Check existing slots to see if we must "slide" */
1849 for (slot = 0; slot < st_ptr->stock_num; slot++)
1852 j_ptr = &st_ptr->stock[slot];
1854 /* Objects sort by decreasing type */
1855 if (o_ptr->tval > j_ptr->tval) break;
1856 if (o_ptr->tval < j_ptr->tval) continue;
1858 /* Objects sort by increasing sval */
1859 if (o_ptr->sval < j_ptr->sval) break;
1860 if (o_ptr->sval > j_ptr->sval) continue;
1863 * Hack: otherwise identical rods sort by
1864 * increasing recharge time --dsb
1866 if (o_ptr->tval == TV_ROD)
1868 if (o_ptr->pval < j_ptr->pval) break;
1869 if (o_ptr->pval > j_ptr->pval) continue;
1872 /* Evaluate that slot */
1873 j_value = object_value(j_ptr);
1875 /* Objects sort by decreasing value */
1876 if (value > j_value) break;
1877 if (value < j_value) continue;
1880 /* Slide the others up */
1881 for (i = st_ptr->stock_num; i > slot; i--)
1883 st_ptr->stock[i] = st_ptr->stock[i-1];
1886 /* More stuff now */
1887 st_ptr->stock_num++;
1889 /* Insert the new item */
1890 st_ptr->stock[slot] = *o_ptr;
1892 /* Return the location */
1898 * @brief 店舗のオブジェクト数を増やす /
1899 * Add the item "o_ptr" to a real stores inventory.
1900 * @param item 増やしたいアイテムのID
1905 * Increase, by a given amount, the number of a certain item
1906 * in a certain store. This can result in zero items.
1908 * @todo numは本来ITEM_NUMBER型にしたい。
1910 static void store_item_increase(INVENTORY_IDX item, int num)
1915 o_ptr = &st_ptr->stock[item];
1917 /* Verify the number */
1918 cnt = o_ptr->number + num;
1919 if (cnt > 255) cnt = 255;
1920 else if (cnt < 0) cnt = 0;
1921 num = cnt - o_ptr->number;
1923 /* Save the new number */
1924 o_ptr->number += (ITEM_NUMBER)num;
1929 * @brief 店舗のオブジェクト数を削除する /
1930 * Remove a slot if it is empty
1931 * @param item 削除したいアイテムのID
1934 static void store_item_optimize(INVENTORY_IDX item)
1939 o_ptr = &st_ptr->stock[item];
1942 if (!o_ptr->k_idx) return;
1944 /* Must have no items */
1945 if (o_ptr->number) return;
1948 st_ptr->stock_num--;
1950 /* Slide everyone */
1951 for (j = item; j < st_ptr->stock_num; j++)
1953 st_ptr->stock[j] = st_ptr->stock[j + 1];
1956 /* Nuke the final slot */
1957 object_wipe(&st_ptr->stock[j]);
1961 * @brief ブラックマーケット用の無価値品の排除判定 /
1962 * This function will keep 'crap' out of the black market.
1963 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1964 * @return ブラックマーケットにとって無価値な品ならばTRUEを返す
1967 * Crap is defined as any item that is "available" elsewhere
1968 * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com>
1971 static bool black_market_crap(object_type *o_ptr)
1975 /* Ego items are never crap */
1976 if (object_is_ego(o_ptr)) return (FALSE);
1978 /* Good items are never crap */
1979 if (o_ptr->to_a > 0) return (FALSE);
1980 if (o_ptr->to_h > 0) return (FALSE);
1981 if (o_ptr->to_d > 0) return (FALSE);
1983 /* Check all stores */
1984 for (i = 0; i < MAX_STORES; i++)
1986 if (i == STORE_HOME) continue;
1987 if (i == STORE_MUSEUM) continue;
1989 /* Check every item in the store */
1990 for (j = 0; j < town[p_ptr->town_num].store[i].stock_num; j++)
1992 object_type *j_ptr = &town[p_ptr->town_num].store[i].stock[j];
1994 /* Duplicate item "type", assume crappy */
1995 if (o_ptr->k_idx == j_ptr->k_idx) return (TRUE);
2005 * @brief 店舗の品揃え変化のためにアイテムを削除する /
2006 * Attempt to delete (some of) a random item from the store
2010 * Hack -- we attempt to "maintain" piles of items when possible.
2013 static void store_delete(void)
2018 /* Pick a random slot */
2019 what = (INVENTORY_IDX)randint0(st_ptr->stock_num);
2021 /* Determine how many items are here */
2022 num = st_ptr->stock[what].number;
2024 /* Hack -- sometimes, only destroy half the items */
2025 if (randint0(100) < 50) num = (num + 1) / 2;
2027 /* Hack -- sometimes, only destroy a single item */
2028 if (randint0(100) < 50) num = 1;
2030 /* Hack -- decrement the maximum timeouts and total charges of rods and wands. -LM- */
2031 if ((st_ptr->stock[what].tval == TV_ROD) || (st_ptr->stock[what].tval == TV_WAND))
2033 st_ptr->stock[what].pval -= num * st_ptr->stock[what].pval / st_ptr->stock[what].number;
2036 /* Actually destroy (part of) the item */
2037 store_item_increase(what, -num);
2038 store_item_optimize(what);
2043 * @brief 店舗の品揃え変化のためにアイテムを追加する /
2044 * Creates a random item and gives it to a store
2048 * This algorithm needs to be rethought. A lot.
2049 * Currently, "normal" stores use a pre-built array.
2050 * Note -- the "level" given to "obj_get_num()" is a "favored"
2051 * level, that is, there is a much higher chance of getting
2052 * items with a level approaching that of the given level...
2053 * Should we check for "permission" to have the given item?
2056 static void store_create(void)
2066 /* Paranoia -- no room left */
2067 if (st_ptr->stock_num >= st_ptr->stock_size) return;
2070 /* Hack -- consider up to four items */
2071 for (tries = 0; tries < 4; tries++)
2074 if (cur_store_num == STORE_BLACK)
2076 /* Pick a level for object/magic */
2077 level = 25 + randint0(25);
2079 /* Random item (usually of given level) */
2080 i = get_obj_num(level);
2082 /* Handle failure */
2089 /* Hack -- Pick an item to sell */
2090 i = st_ptr->table[randint0(st_ptr->table_num)];
2092 /* Hack -- fake level for apply_magic() */
2093 level = rand_range(1, STORE_OBJ_LEVEL);
2098 /* Create a new object of the chosen kind */
2099 object_prep(q_ptr, i);
2101 /* Apply some "low-level" magic (no artifacts) */
2102 apply_magic(q_ptr, level, AM_NO_FIXED_ART);
2104 /* Require valid object */
2105 if (!store_will_buy(q_ptr)) continue;
2107 /* Hack -- Charge lite's */
2108 if (q_ptr->tval == TV_LITE)
2110 if (q_ptr->sval == SV_LITE_TORCH) q_ptr->xtra4 = FUEL_TORCH / 2;
2111 if (q_ptr->sval == SV_LITE_LANTERN) q_ptr->xtra4 = FUEL_LAMP / 2;
2115 /* The item is "known" */
2116 object_known(q_ptr);
2118 /* Mark it storebought */
2119 q_ptr->ident |= IDENT_STORE;
2121 /* Mega-Hack -- no chests in stores */
2122 if (q_ptr->tval == TV_CHEST) continue;
2124 /* Prune the black market */
2125 if (cur_store_num == STORE_BLACK)
2127 /* Hack -- No "crappy" items */
2128 if (black_market_crap(q_ptr)) continue;
2130 /* Hack -- No "cheap" items */
2131 if (object_value(q_ptr) < 10) continue;
2133 /* No "worthless" items */
2134 /* if (object_value(q_ptr) <= 0) continue; */
2137 /* Prune normal stores */
2140 /* No "worthless" items */
2141 if (object_value(q_ptr) <= 0) continue;
2145 /* Mass produce and/or Apply discount */
2146 mass_produce(q_ptr);
2148 /* Attempt to carry the (known) item */
2149 (void)store_carry(q_ptr);
2151 /* Definitely done */
2158 * @brief 店舗の割引対象外にするかどうかを判定 /
2159 * Eliminate need to bargain if player has haggled well in the past
2160 * @param minprice アイテムの最低販売価格
2161 * @return 割引を禁止するならTRUEを返す。
2163 static bool noneedtobargain(PRICE minprice)
2165 s32b good = st_ptr->good_buy;
2166 s32b bad = st_ptr->bad_buy;
2168 /* Cheap items are "boring" */
2169 if (minprice < 10L) return (TRUE);
2171 /* Perfect haggling */
2172 if (good == MAX_SHORT) return (TRUE);
2174 /* Reward good haggles, punish bad haggles, notice price */
2175 if (good > ((3 * bad) + (5 + (minprice/50)))) return (TRUE);
2177 /* Return the flag */
2183 * @brief 店主の持つプレイヤーに対する売買の良し悪し経験を記憶する /
2184 * Update the bargain info
2185 * @param price 実際の取引価格
2186 * @param minprice 店主の提示した価格
2190 static void updatebargain(PRICE price, PRICE minprice, int num)
2192 /* Hack -- auto-haggle */
2193 if (!manual_haggle) return;
2195 /* Cheap items are "boring" */
2196 if ((minprice/num) < 10L) return;
2198 /* Count the successful haggles */
2199 if (price == minprice)
2201 /* Just count the good haggles */
2202 if (st_ptr->good_buy < MAX_SHORT)
2208 /* Count the failed haggles */
2211 /* Just count the bad haggles */
2212 if (st_ptr->bad_buy < MAX_SHORT)
2221 * @brief 店の商品リストを再表示する /
2222 * Re-displays a single store entry
2226 static void display_entry(int pos)
2232 char o_name[MAX_NLEN];
2237 o_ptr = &st_ptr->stock[pos];
2239 /* Get the "offset" */
2240 i = (pos % store_bottom);
2242 /* Label it, clear the line --(-- */
2243 (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
2244 prt(out_val, i+6, 0);
2247 if (show_item_graph)
2249 byte a = object_attr(o_ptr);
2250 char c = object_char(o_ptr);
2252 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
2253 if (use_bigtile) cur_col++;
2258 /* Describe an item in the home */
2259 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
2263 /* Leave room for weights, if necessary -DRS- */
2264 if (show_weights) maxwid -= 10;
2266 object_desc(o_name, o_ptr, 0);
2267 o_name[maxwid] = '\0';
2268 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2273 /* Only show the weight of an individual item */
2274 int wgt = o_ptr->weight;
2276 sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt));
2277 put_str(out_val, i+6, 67);
2279 (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10);
2280 put_str(out_val, i+6, 68);
2286 /* Describe an item (fully) in a store */
2289 /* Must leave room for the "price" */
2292 /* Leave room for weights, if necessary -DRS- */
2293 if (show_weights) maxwid -= 7;
2295 /* Describe the object (fully) */
2296 object_desc(o_name, o_ptr, 0);
2297 o_name[maxwid] = '\0';
2298 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2303 /* Only show the weight of an individual item */
2304 int wgt = o_ptr->weight;
2306 sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
2307 put_str(out_val, i+6, 60);
2309 (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
2310 put_str(out_val, i+6, 61);
2315 /* Display a "fixed" cost */
2316 if (o_ptr->ident & (IDENT_FIXED))
2318 /* Extract the "minimum" price */
2319 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2321 /* Actually draw the price (not fixed) */
2323 (void)sprintf(out_val, "%9ld固", (long)x);
2325 (void)sprintf(out_val, "%9ld F", (long)x);
2328 put_str(out_val, i+6, 68);
2331 /* Display a "taxed" cost */
2332 else if (!manual_haggle)
2334 /* Extract the "minimum" price */
2335 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2337 /* Hack -- Apply Sales Tax if needed */
2338 if (!noneedtobargain(x)) x += x / 10;
2340 /* Actually draw the price (with tax) */
2341 (void)sprintf(out_val, "%9ld ", (long)x);
2342 put_str(out_val, i+6, 68);
2345 /* Display a "haggle" cost */
2348 /* Extrect the "maximum" price */
2349 x = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2351 /* Actually draw the price (not fixed) */
2352 (void)sprintf(out_val, "%9ld ", (long)x);
2353 put_str(out_val, i+6, 68);
2360 * @brief 店の商品リストを表示する /
2361 * Displays a store's inventory -RAK-
2364 * All prices are listed as "per individual object". -BEN-
2366 static void display_inventory(void)
2370 /* Display the next 12 items */
2371 for (k = 0; k < store_bottom; k++)
2373 /* Do not display "dead" items */
2374 if (store_top + k >= st_ptr->stock_num) break;
2376 /* Display that line */
2377 display_entry(store_top + k);
2380 /* Erase the extra lines and the "more" prompt */
2381 for (i = k; i < store_bottom + 1; i++) prt("", i + 6, 0);
2383 /* Assume "no current page" */
2385 put_str(" ", 5, 20);
2387 put_str(" ", 5, 20);
2391 /* Visual reminder of "more items" */
2392 if (st_ptr->stock_num > store_bottom)
2394 /* Show "more" reminder (after the last item) */
2396 prt("-続く-", k + 6, 3);
2398 prt("-more-", k + 6, 3);
2402 /* Indicate the "current page" */
2403 /* Trailing spaces are to display (Page xx) and (Page x) */
2405 put_str(format("(%dページ) ", store_top/store_bottom + 1), 5, 20);
2407 put_str(format("(Page %d) ", store_top/store_bottom + 1), 5, 20);
2412 if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM)
2414 k = st_ptr->stock_size;
2416 if (cur_store_num == STORE_HOME && !powerup_home) k /= 10;
2418 put_str(format("アイテム数: %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 27);
2420 put_str(format("Objects: %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 30);
2427 * @brief プレイヤーの所持金を表示する /
2428 * Displays players gold -RAK-
2432 static void store_prt_gold(void)
2437 prt("手持ちのお金: ", 19 + xtra_stock, 53);
2439 prt("Gold Remaining: ", 19 + xtra_stock, 53);
2443 sprintf(out_val, "%9ld", (long)p_ptr->au);
2444 prt(out_val, 19 + xtra_stock, 68);
2448 * @brief 店舗情報全体を表示するメインルーチン /
2449 * Displays store (after clearing screen) -RAK-
2453 static void display_store(void)
2459 /* The "Home" is special */
2460 if (cur_store_num == STORE_HOME)
2462 /* Put the owner name */
2464 put_str("我が家", 3, 31);
2466 put_str("Your Home", 3, 30);
2470 /* Label the item descriptions */
2472 put_str("アイテムの一覧", 5, 4);
2474 put_str("Item Description", 5, 3);
2478 /* If showing weights, show label */
2482 put_str("重さ", 5, 72);
2484 put_str("Weight", 5, 70);
2490 /* The "Home" is special */
2491 else if (cur_store_num == STORE_MUSEUM)
2493 /* Put the owner name */
2495 put_str("博物館", 3, 31);
2497 put_str("Museum", 3, 30);
2501 /* Label the item descriptions */
2503 put_str("アイテムの一覧", 5, 4);
2505 put_str("Item Description", 5, 3);
2509 /* If showing weights, show label */
2513 put_str("重さ", 5, 72);
2515 put_str("Weight", 5, 70);
2524 cptr store_name = (f_name + f_info[cur_store_feat].name);
2525 cptr owner_name = (ot_ptr->owner_name);
2526 cptr race_name = race_info[ot_ptr->owner_race].title;
2528 /* Put the owner name and race */
2529 sprintf(buf, "%s (%s)", owner_name, race_name);
2530 put_str(buf, 3, 10);
2532 /* Show the max price in the store (above prices) */
2533 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
2536 /* Label the item descriptions */
2538 put_str("商品の一覧", 5, 7);
2540 put_str("Item Description", 5, 3);
2544 /* If showing weights, show label */
2548 put_str("重さ", 5, 62);
2550 put_str("Weight", 5, 60);
2555 /* Label the asking price (in stores) */
2557 put_str("価格", 5, 73);
2559 put_str("Price", 5, 72);
2564 /* Display the current gold */
2567 /* Draw in the inventory */
2568 display_inventory();
2574 * @brief 店舗からアイテムを選択する /
2575 * Get the ID of a store item and return its value -RAK-
2576 * @param com_val 選択IDを返す参照ポインタ
2577 * @param pmt メッセージキャプション
2580 * @return 実際に選択したらTRUE、キャンセルしたらFALSE
2582 static int get_stock(COMMAND_CODE *com_val, cptr pmt, int i, int j)
2588 /* Get the item index */
2589 if (repeat_pull(com_val))
2591 /* Verify the item */
2592 if ((*com_val >= i) && (*com_val <= j))
2603 /* Assume failure */
2606 /* Build the prompt */
2608 hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
2610 (void)sprintf(out_val, "(%s:%c-%c, ESCで中断) %s",
2611 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "アイテム" : "商品"),
2614 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
2619 /* Ask until done */
2625 if (!get_com(out_val, &command, FALSE)) break;
2628 if (islower(command))
2630 else if (isupper(command))
2631 k = A2I(tolower(command)) + 26;
2635 /* Legal responses */
2636 if ((k >= i) && (k <= j))
2645 /* Clear the prompt */
2649 if (command == ESCAPE) return (FALSE);
2651 repeat_push(*com_val);
2659 * @brief 店主の不満度を増やし、プレイヤーを締め出す判定と処理を行う /
2660 * Increase the insult counter and get angry if too many -RAK-
2661 * @return プレイヤーを締め出す場合TRUEを返す
2663 static int increase_insults(void)
2665 /* Increase insults */
2666 st_ptr->insult_cur++;
2668 /* Become insulted */
2669 if (st_ptr->insult_cur > ot_ptr->insult_max)
2675 st_ptr->insult_cur = 0;
2676 st_ptr->good_buy = 0;
2677 st_ptr->bad_buy = 0;
2680 st_ptr->store_open = turn + TURNS_PER_TICK*TOWN_DAWN/8 + randint1(TURNS_PER_TICK*TOWN_DAWN/8);
2692 * @brief 店主の不満度を減らす /
2693 * Decrease insults -RAK-
2694 * @return プレイヤーを締め出す場合TRUEを返す
2696 static void decrease_insults(void)
2698 /* Decrease insults */
2699 if (st_ptr->insult_cur) st_ptr->insult_cur--;
2704 * @brief 店主の不満度が増えた場合のみのメッセージを表示する /
2705 * Have insulted while haggling -RAK-
2706 * @return プレイヤーを締め出す場合TRUEを返す
2708 static int haggle_insults(void)
2710 /* Increase insults */
2711 if (increase_insults()) return (TRUE);
2713 /* Display and flush insult */
2722 * Mega-Hack -- Enable "increments"
2724 static bool allow_inc = FALSE;
2727 * Mega-Hack -- Last "increment" during haggling
2729 static s32b last_inc = 0L;
2733 * @brief 交渉価格を確認と認証の是非を行う /
2736 * @param poffer 別途価格提示をした場合の値を返す参照ポインタ
2737 * @param price 現在の交渉価格
2738 * @param final 最終確定価格ならばTRUE
2739 * @return プレイヤーを締め出す場合TRUEを返す
2741 static int get_haggle(cptr pmt, s32b *poffer, PRICE price, int final)
2751 /* Clear old increment if necessary */
2752 if (!allow_inc) last_inc = 0L;
2759 sprintf(buf, "%s [承諾] ", pmt);
2761 sprintf(buf, "%s [accept] ", pmt);
2766 /* Old (negative) increment, and not final */
2767 else if (last_inc < 0)
2770 sprintf(buf, "%s [-$%ld] ", pmt, (long)(ABS(last_inc)));
2772 sprintf(buf, "%s [-%ld] ", pmt, (long)(ABS(last_inc)));
2777 /* Old (positive) increment, and not final */
2778 else if (last_inc > 0)
2781 sprintf(buf, "%s [+$%ld] ", pmt, (long)(ABS(last_inc)));
2783 sprintf(buf, "%s [+%ld] ", pmt, (long)(ABS(last_inc)));
2791 sprintf(buf, "%s ", pmt);
2799 /* Ask until done */
2804 /* Display prompt */
2808 strcpy(out_val, "");
2811 * Ask the user for a response.
2812 * Don't allow to use numpad as cursor key.
2814 res = askfor_aux(out_val, 32, FALSE);
2820 if (!res) return FALSE;
2822 /* Skip leading spaces */
2823 for (p = out_val; *p == ' '; p++) /* loop */;
2825 /* Empty response */
2828 /* Accept current price */
2836 /* Use previous increment */
2837 if (allow_inc && last_inc)
2839 *poffer += last_inc;
2844 /* Normal response */
2847 /* Extract a number */
2850 /* Handle "incremental" number */
2851 if ((*p == '+' || *p == '-'))
2853 /* Allow increments */
2856 /* Use the given "increment" */
2863 /* Handle normal number */
2866 /* Use the given "number" */
2875 msg_print("値がおかしいです。");
2877 msg_print("Invalid response.");
2889 * @brief 店主がプレイヤーからの交渉価格を判断する /
2890 * Receive an offer (from the player)
2892 * @param poffer 店主からの交渉価格を返す参照ポインタ
2893 * @param last_offer 現在の交渉価格
2894 * @param factor 店主の価格基準倍率
2895 * @param price アイテムの実価値
2896 * @param final 最終価格確定ならばTRUE
2897 * @return プレイヤーの価格に対して不服ならばTRUEを返す /
2898 * Return TRUE if offer is NOT okay
2900 static bool receive_offer(cptr pmt, s32b *poffer,
2901 s32b last_offer, int factor,
2902 PRICE price, int final)
2904 /* Haggle till done */
2907 /* Get a haggle (or cancel) */
2908 if (!get_haggle(pmt, poffer, price, final)) return (TRUE);
2910 /* Acceptable offer */
2911 if (((*poffer) * factor) >= (last_offer * factor)) break;
2913 /* Insult, and check for kicked out */
2914 if (haggle_insults()) return (TRUE);
2916 /* Reject offer (correctly) */
2917 (*poffer) = last_offer;
2926 * @brief プレイヤーが購入する時の値切り処理メインルーチン /
2927 * Haggling routine -RAK-
2928 * @param o_ptr オブジェクトの構造体参照ポインタ
2929 * @param price 最終価格を返す参照ポインタ
2930 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
2931 * Return TRUE if purchase is NOT successful
2933 static bool purchase_haggle(object_type *o_ptr, s32b *price)
2935 s32b cur_ask, final_ask;
2936 s32b last_offer, offer;
2938 s32b min_per, max_per;
2939 int flag, loop_flag, noneed;
2940 int annoyed = 0, final = FALSE;
2942 bool cancel = FALSE;
2947 cptr pmt = "Asking";
2957 /* Extract the starting offer and the final offer */
2958 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2959 final_ask = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2961 /* Determine if haggling is necessary */
2962 noneed = noneedtobargain(final_ask);
2964 /* No need to haggle */
2965 if (noneed || !manual_haggle)
2967 /* No need to haggle */
2970 /* Message summary */
2972 msg_print("結局この金額にまとまった。");
2974 msg_print("You eventually agree upon the price.");
2980 /* No haggle option */
2983 /* Message summary */
2985 msg_print("すんなりとこの金額にまとまった。");
2987 msg_print("You quickly agree upon the price.");
2992 /* Apply Sales Tax */
2993 final_ask += final_ask / 10;
2997 cur_ask = final_ask;
2999 /* Go to final offer */
3003 pmt = "Final Offer";
3010 /* Haggle for the whole pile */
3011 cur_ask *= o_ptr->number;
3012 final_ask *= o_ptr->number;
3015 /* Haggle parameters */
3016 min_per = ot_ptr->haggle_per;
3017 max_per = min_per * 3;
3019 /* Mega-Hack -- artificial "last offer" value */
3020 last_offer = object_value(o_ptr) * o_ptr->number;
3021 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
3022 if (last_offer <= 0) last_offer = 1;
3027 /* No incremental haggling yet */
3030 /* Haggle until done */
3031 for (flag = FALSE; !flag; )
3035 while (!flag && loop_flag)
3037 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
3038 put_str(out_val, 1, 0);
3040 cancel = receive_offer("提示する金額? ",
3042 cancel = receive_offer("What do you offer? ",
3045 &offer, last_offer, 1, cur_ask, final);
3051 else if (offer > cur_ask)
3056 else if (offer == cur_ask)
3069 x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
3072 if (haggle_insults())
3078 else if (x1 > max_per)
3081 if (x1 < max_per) x1 = max_per;
3083 x2 = rand_range(x1-2, x1+2);
3084 x3 = ((cur_ask - offer) * x2 / 100L) + 1;
3085 /* don't let the price go up */
3090 if (cur_ask < final_ask)
3093 cur_ask = final_ask;
3097 pmt = "Final Offer";
3103 (void)(increase_insults());
3108 else if (offer >= cur_ask)
3120 (void)sprintf(out_val, "前回の提示金額: $%ld",
3122 (void)sprintf(out_val, "Your last offer: %ld",
3126 put_str(out_val, 1, 39);
3127 say_comment_2(cur_ask, annoyed);
3133 if (cancel) return (TRUE);
3135 /* Update bargaining info */
3136 updatebargain(*price, final_ask, o_ptr->number);
3144 * @brief プレイヤーが売却する時の値切り処理メインルーチン /
3145 * Haggling routine -RAK-
3146 * @param o_ptr オブジェクトの構造体参照ポインタ
3147 * @param price 最終価格を返す参照ポインタ
3148 * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
3149 * Return TRUE if purchase is NOT successful
3151 static bool sell_haggle(object_type *o_ptr, s32b *price)
3153 s32b purse, cur_ask, final_ask;
3154 s32b last_offer = 0, offer = 0;
3156 s32b min_per, max_per;
3157 int flag, loop_flag, noneed;
3158 int annoyed = 0, final = FALSE;
3159 bool cancel = FALSE;
3172 /* Obtain the starting offer and the final offer */
3173 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, TRUE);
3174 final_ask = price_item(o_ptr, ot_ptr->min_inflate, TRUE);
3176 /* Determine if haggling is necessary */
3177 noneed = noneedtobargain(final_ask);
3179 /* Get the owner's payout limit */
3180 purse = (s32b)(ot_ptr->max_cost);
3182 /* No need to haggle */
3183 if (noneed || !manual_haggle || (final_ask >= purse))
3185 /* Apply Sales Tax (if needed) */
3186 if (!manual_haggle && !noneed)
3188 final_ask -= final_ask / 10;
3191 /* No reason to haggle */
3192 if (final_ask >= purse)
3195 msg_print("即座にこの金額にまとまった。");
3197 msg_print("You instantly agree upon the price.");
3202 /* Offer full purse */
3206 /* No need to haggle */
3210 msg_print("結局この金額にまとまった。");
3212 msg_print("You eventually agree upon the price.");
3218 /* No haggle option */
3221 /* Message summary */
3223 msg_print("すんなりとこの金額にまとまった。");
3225 msg_print("You quickly agree upon the price.");
3232 cur_ask = final_ask;
3239 pmt = "Final Offer";
3244 /* Haggle for the whole pile */
3245 cur_ask *= o_ptr->number;
3246 final_ask *= o_ptr->number;
3249 /* Display commands */
3251 /* Haggling parameters */
3252 min_per = ot_ptr->haggle_per;
3253 max_per = min_per * 3;
3255 /* Mega-Hack -- artificial "last offer" value */
3256 last_offer = object_value(o_ptr) * o_ptr->number;
3257 last_offer = last_offer * ot_ptr->max_inflate / 100L;
3262 /* No incremental haggling yet */
3266 for (flag = FALSE; !flag; )
3272 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
3273 put_str(out_val, 1, 0);
3275 cancel = receive_offer("提示する価格? ",
3277 cancel = receive_offer("What price do you ask? ",
3280 &offer, last_offer, -1, cur_ask, final);
3286 else if (offer < cur_ask)
3289 /* rejected, reset offer for incremental haggling */
3292 else if (offer == cur_ask)
3303 if (flag || !loop_flag) break;
3308 x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
3311 if (haggle_insults())
3317 else if (x1 > max_per)
3320 if (x1 < max_per) x1 = max_per;
3322 x2 = rand_range(x1-2, x1+2);
3323 x3 = ((offer - cur_ask) * x2 / 100L) + 1;
3324 /* don't let the price go down */
3328 if (cur_ask > final_ask)
3330 cur_ask = final_ask;
3335 pmt = "Final Offer";
3343 /* 追加 $0 で買い取られてしまうのを防止 By FIRST*/
3346 (void)(increase_insults());
3349 else if (offer <= cur_ask)
3360 (void)sprintf(out_val,
3362 "前回の提示価格 $%ld", (long)last_offer);
3364 "Your last bid %ld", (long)last_offer);
3367 put_str(out_val, 1, 39);
3368 say_comment_3(cur_ask, annoyed);
3374 if (cancel) return (TRUE);
3376 /* Update bargaining info */
3377 updatebargain(*price, final_ask, o_ptr->number);
3385 * @brief 店からの購入処理のメインルーチン /
3386 * Buy an item from a store -RAK-
3389 static void store_purchase(void)
3392 COMMAND_CODE item, item_new;
3403 char o_name[MAX_NLEN];
3407 if (cur_store_num == STORE_MUSEUM)
3410 msg_print("博物館から取り出すことはできません。");
3412 msg_print("Museum.");
3418 if (st_ptr->stock_num <= 0)
3420 if (cur_store_num == STORE_HOME)
3422 msg_print("我が家には何も置いてありません。");
3424 msg_print("Your home is empty.");
3429 msg_print("現在商品の在庫を切らしています。");
3431 msg_print("I am currently out of stock.");
3438 /* Find the number of objects on this and following pages */
3439 i = (st_ptr->stock_num - store_top);
3441 /* And then restrict it to the current page */
3442 if (i > store_bottom) i = store_bottom;
3446 /* ブラックマーケットの時は別のメッセージ */
3447 switch( cur_store_num ) {
3449 sprintf(out_val, "どのアイテムを取りますか? ");
3452 sprintf(out_val, "どれ? ");
3455 sprintf(out_val, "どの品物が欲しいんだい? ");
3459 if (cur_store_num == STORE_HOME)
3461 sprintf(out_val, "Which item do you want to take? ");
3465 sprintf(out_val, "Which item are you interested in? ");
3470 /* Get the item number to be bought */
3471 if (!get_stock(&item, out_val, 0, i - 1)) return;
3473 /* Get the actual index */
3474 item = item + store_top;
3476 /* Get the actual item */
3477 o_ptr = &st_ptr->stock[item];
3479 /* Assume the player wants just one of them */
3483 /* Get a copy of the object */
3484 object_copy(j_ptr, o_ptr);
3487 * If a rod or wand, allocate total maximum timeouts or charges
3488 * between those purchased and left on the shelf.
3490 reduce_charges(j_ptr, o_ptr->number - amt);
3492 /* Modify quantity */
3493 j_ptr->number = amt;
3495 /* Hack -- require room in pack */
3496 if (!inven_carry_okay(j_ptr))
3499 msg_print("そんなにアイテムを持てない。");
3501 msg_print("You cannot carry that many different items.");
3507 /* Determine the "best" price (per item) */
3508 best = price_item(j_ptr, ot_ptr->min_inflate, FALSE);
3510 /* Find out how many the player wants */
3511 if (o_ptr->number > 1)
3513 /* Hack -- note cost of "fixed" items */
3514 if ((cur_store_num != STORE_HOME) &&
3515 (o_ptr->ident & IDENT_FIXED))
3518 msg_format("一つにつき $%ldです。", (long)(best));
3520 msg_format("That costs %ld gold per item.", (long)(best));
3525 /* Get a quantity */
3526 amt = get_quantity(NULL, o_ptr->number);
3528 /* Allow user abort */
3529 if (amt <= 0) return;
3533 /* Get desired object */
3534 object_copy(j_ptr, o_ptr);
3537 * If a rod or wand, allocate total maximum timeouts or charges
3538 * between those purchased and left on the shelf.
3540 reduce_charges(j_ptr, o_ptr->number - amt);
3542 /* Modify quantity */
3543 j_ptr->number = amt;
3545 /* Hack -- require room in pack */
3546 if (!inven_carry_okay(j_ptr))
3549 msg_print("ザックにそのアイテムを入れる隙間がない。");
3551 msg_print("You cannot carry that many items.");
3557 /* Attempt to buy it */
3558 if (cur_store_num != STORE_HOME)
3560 /* Fixed price, quick buy */
3561 if (o_ptr->ident & (IDENT_FIXED))
3566 /* Go directly to the "best" deal */
3567 price = (best * j_ptr->number);
3573 /* Describe the object (fully) */
3574 object_desc(o_name, j_ptr, 0);
3577 msg_format("%s(%c)を購入する。", o_name, I2A(item));
3579 msg_format("Buying %s (%c).", o_name, I2A(item));
3584 /* Haggle for a final price */
3585 choice = purchase_haggle(j_ptr, &price);
3587 /* Hack -- Got kicked out */
3588 if (st_ptr->store_open >= turn) return;
3591 /* Player wants it */
3594 /* Fix the item price (if "correctly" haggled) */
3595 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
3597 /* Player can afford it */
3598 if (p_ptr->au >= price)
3603 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3604 chg_virtue(V_JUSTICE, -1);
3605 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3606 chg_virtue(V_NATURE, -1);
3614 /* Spend the money */
3617 /* Update the display */
3620 /* Hack -- buying an item makes you aware of it */
3621 object_aware(j_ptr);
3623 /* Hack -- clear the "fixed" flag from the item */
3624 j_ptr->ident &= ~(IDENT_FIXED);
3626 /* Describe the transaction */
3627 object_desc(o_name, j_ptr, 0);
3630 msg_format("%sを $%ldで購入しました。", o_name, (long)price);
3632 msg_format("You bought %s for %ld gold.", o_name, (long)price);
3635 strcpy(record_o_name, o_name);
3638 if (record_buy) do_cmd_write_nikki(NIKKI_BUY, 0, o_name);
3639 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3640 if(record_rand_art && o_ptr->art_name)
3641 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
3643 /* Erase the inscription */
3644 j_ptr->inscription = 0;
3646 /* Erase the "feeling" */
3647 j_ptr->feeling = FEEL_NONE;
3648 j_ptr->ident &= ~(IDENT_STORE);
3649 /* Give it to the player */
3650 item_new = inven_carry(j_ptr);
3652 /* Describe the final result */
3653 object_desc(o_name, &inventory[item_new], 0);
3656 msg_format("%s(%c)を手に入れた。", o_name, index_to_label(item_new));
3658 msg_format("You have %s (%c).",
3659 o_name, index_to_label(item_new));
3662 /* Auto-inscription */
3663 autopick_alter_item(item_new, FALSE);
3665 /* Now, reduce the original stack's pval. */
3666 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3668 o_ptr->pval -= j_ptr->pval;
3672 /* Note how many slots the store used to have */
3673 i = st_ptr->stock_num;
3675 /* Remove the bought items from the store */
3676 store_item_increase(item, -amt);
3677 store_item_optimize(item);
3679 /* Store is empty */
3680 if (st_ptr->stock_num == 0)
3683 if (one_in_(STORE_SHUFFLE))
3687 msg_print("店主は引退した。");
3689 msg_print("The shopkeeper retires.");
3693 /* Shuffle the store */
3694 store_shuffle(cur_store_num);
3697 sprintf(buf, "%s (%s)",
3698 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
3699 put_str(buf, 3, 10);
3700 sprintf(buf, "%s (%ld)",
3701 (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
3709 msg_print("店主は新たな在庫を取り出した。");
3711 msg_print("The shopkeeper brings out some new stock.");
3717 for (i = 0; i < 10; i++)
3719 /* Maintain the store */
3720 store_maint(p_ptr->town_num, cur_store_num);
3725 display_inventory();
3728 /* The item is gone */
3729 else if (st_ptr->stock_num != i)
3731 /* Pick the correct screen */
3732 if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
3733 display_inventory();
3736 /* Item is still here */
3739 /* Redraw the item */
3740 display_entry(item);
3744 /* Player cannot afford it */
3747 /* Simple message (no insult) */
3749 msg_print("お金が足りません。");
3751 msg_print("You do not have enough gold.");
3758 /* Home is much easier */
3761 bool combined_or_reordered;
3763 /* Distribute charges of wands/rods */
3764 distribute_charges(o_ptr, j_ptr, amt);
3766 /* Give it to the player */
3767 item_new = inven_carry(j_ptr);
3769 /* Describe just the result */
3770 object_desc(o_name, &inventory[item_new], 0);
3773 msg_format("%s(%c)を取った。",
3775 msg_format("You have %s (%c).",
3777 o_name, index_to_label(item_new));
3780 /* Take note if we take the last one */
3781 i = st_ptr->stock_num;
3783 /* Remove the items from the home */
3784 store_item_increase(item, -amt);
3785 store_item_optimize(item);
3787 combined_or_reordered = combine_and_reorder_home(STORE_HOME);
3789 /* Hack -- Item is still here */
3790 if (i == st_ptr->stock_num)
3792 if (combined_or_reordered) display_inventory();
3794 /* Redraw the item */
3795 else display_entry(item);
3798 /* The item is gone */
3802 if (st_ptr->stock_num == 0) store_top = 0;
3804 /* Nothing left on that screen */
3805 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
3806 display_inventory();
3808 chg_virtue(V_SACRIFICE, 1);
3812 /* Not kicked out */
3818 * @brief 店からの売却処理のメインルーチン /
3819 * Sell an item to the store (or home)
3822 static void store_sell(void)
3829 PRICE price, value, dummy;
3838 char o_name[MAX_NLEN];
3841 /* Prepare a prompt */
3842 if (cur_store_num == STORE_HOME)
3844 q = "どのアイテムを置きますか? ";
3846 q = "Drop which item? ";
3849 else if (cur_store_num == STORE_MUSEUM)
3851 q = "どのアイテムを寄贈しますか? ";
3853 q = "Give which item? ";
3858 q = "どのアイテムを売りますか? ";
3860 q = "Sell which item? ";
3864 item_tester_no_ryoute = TRUE;
3865 /* Only allow items the store will buy */
3866 item_tester_hook = store_will_buy;
3868 /* 我が家でおかしなメッセージが出るオリジナルのバグを修正 */
3869 if (cur_store_num == STORE_HOME)
3872 s = "置けるアイテムを持っていません。";
3874 s = "You don't have any item to drop.";
3877 else if (cur_store_num == STORE_MUSEUM)
3880 s = "寄贈できるアイテムを持っていません。";
3882 s = "You don't have any item to give.";
3890 s = "You have nothing that I want.";
3894 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
3896 /* Get the item (in the pack) */
3899 o_ptr = &inventory[item];
3902 /* Get the item (on the floor) */
3905 o_ptr = &o_list[0 - item];
3909 /* Hack -- Cannot remove cursed items */
3910 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
3913 msg_print("ふーむ、どうやらそれは呪われているようだね。");
3915 msg_print("Hmmm, it seems to be cursed.");
3923 /* Assume one item */
3926 /* Find out how many the player wants (letter means "all") */
3927 if (o_ptr->number > 1)
3929 /* Get a quantity */
3930 amt = get_quantity(NULL, o_ptr->number);
3932 /* Allow user abort */
3933 if (amt <= 0) return;
3937 /* Get a copy of the object */
3938 object_copy(q_ptr, o_ptr);
3940 /* Modify quantity */
3941 q_ptr->number = amt;
3944 * Hack -- If a rod or wand, allocate total maximum
3945 * timeouts or charges to those being sold. -LM-
3947 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3949 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
3952 /* Get a full description */
3953 object_desc(o_name, q_ptr, 0);
3955 /* Remove any inscription, feeling for stores */
3956 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3958 q_ptr->inscription = 0;
3959 q_ptr->feeling = FEEL_NONE;
3962 /* Is there room in the store (or the home?) */
3963 if (!store_check_num(q_ptr))
3965 if (cur_store_num == STORE_HOME)
3967 msg_print("我が家にはもう置く場所がない。");
3969 msg_print("Your home is full.");
3972 else if (cur_store_num == STORE_MUSEUM)
3974 msg_print("博物館はもう満杯だ。");
3976 msg_print("Museum is full.");
3981 msg_print("すいませんが、店にはもう置く場所がありません。");
3983 msg_print("I have not the room in my store to keep it.");
3991 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3993 /* Describe the transaction */
3995 msg_format("%s(%c)を売却する。", o_name, index_to_label(item));
3997 msg_format("Selling %s (%c).", o_name, index_to_label(item));
4003 choice = sell_haggle(q_ptr, &price);
4006 if (st_ptr->store_open >= turn) return;
4018 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
4019 chg_virtue(V_JUSTICE, -1);
4021 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
4022 chg_virtue(V_NATURE, 1);
4025 /* Get some money */
4028 /* Update the display */
4031 /* Get the "apparent" value */
4032 dummy = object_value(q_ptr) * q_ptr->number;
4035 identify_item(o_ptr);
4038 /* Get a copy of the object */
4039 object_copy(q_ptr, o_ptr);
4041 /* Modify quantity */
4042 q_ptr->number = amt;
4044 /* Make it look like to be known */
4045 q_ptr->ident |= IDENT_STORE;
4048 * Hack -- If a rod or wand, let the shopkeeper know just
4049 * how many charges he really paid for. -LM-
4051 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
4053 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
4056 /* Get the "actual" value */
4057 value = object_value(q_ptr) * q_ptr->number;
4059 /* Get the description all over again */
4060 object_desc(o_name, q_ptr, 0);
4062 /* Describe the result (in message buffer) */
4064 msg_format("%sを $%ldで売却しました。", o_name, (long)price);
4066 msg_format("You sold %s for %ld gold.", o_name, (long)price);
4069 if (record_sell) do_cmd_write_nikki(NIKKI_SELL, 0, o_name);
4071 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
4073 /* Analyze the prices (and comment verbally) unless a figurine*/
4074 purchase_analyze(price, value, dummy);
4078 * Hack -- Allocate charges between those wands or rods sold
4079 * and retained, unless all are being sold. -LM-
4081 distribute_charges(o_ptr, q_ptr, amt);
4083 /* Reset timeouts of the sold items */
4086 /* Take the item from the player, describe the result */
4087 inven_item_increase(item, -amt);
4088 inven_item_describe(item);
4090 /* If items remain, auto-inscribe before optimizing */
4091 if (o_ptr->number > 0)
4092 autopick_alter_item(item, FALSE);
4094 inven_item_optimize(item);
4097 /* The store gets that (known) item */
4098 item_pos = store_carry(q_ptr);
4100 /* Re-display if item is now in store */
4103 store_top = (item_pos / store_bottom) * store_bottom;
4104 display_inventory();
4109 /* Player is at museum */
4110 else if (cur_store_num == STORE_MUSEUM)
4112 char o2_name[MAX_NLEN];
4113 object_desc(o2_name, q_ptr, OD_NAME_ONLY);
4115 if (-1 == store_check_num(q_ptr))
4118 msg_print("それと同じ品物は既に博物館にあるようです。");
4120 msg_print("The same object as it is already in the Museum.");
4126 msg_print("博物館に寄贈したものは取り出すことができません!!");
4128 msg_print("You cannot take items which is given to the Museum back!!");
4132 if (!get_check(format("本当に%sを寄贈しますか?", o2_name))) return;
4134 if (!get_check(format("Really give %s to the Museum? ", o2_name))) return;
4138 identify_item(q_ptr);
4139 q_ptr->ident |= IDENT_MENTAL;
4141 /* Distribute charges of wands/rods */
4142 distribute_charges(o_ptr, q_ptr, amt);
4144 msg_format("%sを置いた。(%c)", o_name, index_to_label(item));
4146 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4151 /* Take it from the players inventory */
4152 inven_item_increase(item, -amt);
4153 inven_item_describe(item);
4154 inven_item_optimize(item);
4157 /* Let the home carry it */
4158 item_pos = home_carry(q_ptr);
4160 /* Update store display */
4163 store_top = (item_pos / store_bottom) * store_bottom;
4164 display_inventory();
4167 /* Player is at home */
4170 /* Distribute charges of wands/rods */
4171 distribute_charges(o_ptr, q_ptr, amt);
4173 msg_format("%sを置いた。(%c)", o_name, index_to_label(item));
4175 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4180 /* Take it from the players inventory */
4181 inven_item_increase(item, -amt);
4182 inven_item_describe(item);
4183 inven_item_optimize(item);
4186 /* Let the home carry it */
4187 item_pos = home_carry(q_ptr);
4189 /* Update store display */
4192 store_top = (item_pos / store_bottom) * store_bottom;
4193 display_inventory();
4197 if ((choice == 0) && (item >= INVEN_RARM))
4206 * @brief 店のアイテムを調べるコマンドのメインルーチン /
4207 * Examine an item in a store -JDL-
4210 static void store_examine(void)
4215 char o_name[MAX_NLEN];
4219 if (st_ptr->stock_num <= 0)
4221 if (cur_store_num == STORE_HOME)
4222 msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
4223 else if (cur_store_num == STORE_MUSEUM)
4224 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
4226 msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
4230 /* Find the number of objects on this and following pages */
4231 i = (st_ptr->stock_num - store_top);
4233 /* And then restrict it to the current page */
4234 if (i > store_bottom) i = store_bottom;
4237 sprintf(out_val, _("どれを調べますか?", "Which item do you want to examine? "));
4239 /* Get the item number to be examined */
4240 if (!get_stock(&item, out_val, 0, i - 1)) return;
4242 /* Get the actual index */
4243 item = item + store_top;
4245 /* Get the actual item */
4246 o_ptr = &st_ptr->stock[item];
4248 /* Require full knowledge */
4249 if (!(o_ptr->ident & IDENT_MENTAL))
4251 /* This can only happen in the home */
4252 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
4256 object_desc(o_name, o_ptr, 0);
4257 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
4259 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL))
4260 msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
4267 * @brief 博物館のアイテムを除去するコマンドのメインルーチン /
4268 * Remove an item from museum (Originally from TOband)
4271 static void museum_remove_object(void)
4276 char o_name[MAX_NLEN];
4280 if (st_ptr->stock_num <= 0)
4282 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
4286 /* Find the number of objects on this and following pages */
4287 i = st_ptr->stock_num - store_top;
4289 /* And then restrict it to the current page */
4290 if (i > store_bottom) i = store_bottom;
4293 sprintf(out_val, _("どのアイテムの展示をやめさせますか?", "Which item do you want to order to remove? "));
4295 /* Get the item number to be removed */
4296 if (!get_stock(&item, out_val, 0, i - 1)) return;
4298 /* Get the actual index */
4299 item = item + store_top;
4301 /* Get the actual item */
4302 o_ptr = &st_ptr->stock[item];
4304 object_desc(o_name, o_ptr, 0);
4306 msg_print(_("展示をやめさせたアイテムは二度と見ることはできません!", "You cannot see items which is removed from the Museum!"));
4307 if (!get_check(format(_("本当に%sの展示をやめさせますか?", "Really order to remove %s from the Museum? "), o_name))) return;
4309 msg_format(_("%sの展示をやめさせた。", "You ordered to remove %s."), o_name);
4311 /* Remove the items from the home */
4312 store_item_increase(item, -o_ptr->number);
4313 store_item_optimize(item);
4315 (void)combine_and_reorder_home(STORE_MUSEUM);
4317 /* The item is gone */
4320 if (st_ptr->stock_num == 0) store_top = 0;
4322 /* Nothing left on that screen */
4323 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
4324 display_inventory();
4331 * Hack -- set this to leave the store
4333 static bool leave_store = FALSE;
4337 * @brief 店舗処理コマンド選択のメインルーチン /
4338 * Process a command in a store
4342 * Note that we must allow the use of a few "special" commands
4343 * in the stores which are not allowed in the dungeon, and we
4344 * must disable some commands which are allowed in the dungeon
4345 * but not in the stores, to prevent chaos.
4348 static void store_process_command(void)
4350 /* Handle repeating the last command */
4353 if (rogue_like_commands && command_cmd == 'l')
4355 command_cmd = 'x'; /* hack! */
4358 /* Parse the command */
4359 switch (command_cmd)
4369 /* 1 ページ戻るコマンド: 我が家のページ数が多いので重宝するはず By BUG */
4372 if (st_ptr->stock_num <= store_bottom) {
4373 msg_print(_("これで全部です。", "Entire inventory is shown."));
4376 store_top -= store_bottom;
4377 if ( store_top < 0 )
4378 store_top = ((st_ptr->stock_num - 1 )/store_bottom) * store_bottom;
4379 if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) )
4380 if ( store_top >= store_bottom ) store_top = store_bottom;
4381 display_inventory();
4389 if (st_ptr->stock_num <= store_bottom)
4391 msg_print(_("これで全部です。", "Entire inventory is shown."));
4395 store_top += store_bottom;
4397 * 隠しオプション(powerup_home)がセットされていないときは
4398 * 我が家では 2 ページまでしか表示しない
4400 if ((cur_store_num == STORE_HOME) &&
4401 (powerup_home == FALSE) &&
4402 (st_ptr->stock_num >= STORE_INVEN_MAX))
4404 if (store_top >= (STORE_INVEN_MAX - 1))
4411 if (store_top >= st_ptr->stock_num) store_top = 0;
4414 display_inventory();
4426 /* Get (purchase) */
4453 /*** Inventory Commands ***/
4455 /* Wear/wield equipment */
4462 /* Take off equipment */
4469 /* Destroy an item */
4476 /* Equipment list */
4483 /* Inventory list */
4491 /*** Various commands ***/
4493 /* Identify an object */
4500 /* Hack -- toggle windows */
4503 toggle_inven_equip();
4507 /*** Use various objects ***/
4512 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4513 (p_ptr->pclass == CLASS_BERSERKER) ||
4514 (p_ptr->pclass == CLASS_NINJA) ||
4515 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4516 ) do_cmd_mind_browse();
4517 else if (p_ptr->pclass == CLASS_SMITH)
4519 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4520 do_cmd_magic_eater(TRUE, FALSE);
4521 else if (p_ptr->pclass == CLASS_SNIPER)
4522 do_cmd_snipe_browse();
4523 else do_cmd_browse();
4527 /* Inscribe an object */
4534 /* Uninscribe an object */
4537 do_cmd_uninscribe();
4543 /*** Help and Such ***/
4552 /* Identify symbol */
4555 do_cmd_query_symbol();
4559 /* Character description */
4562 p_ptr->town_num = old_town_num;
4563 do_cmd_change_name();
4564 p_ptr->town_num = inner_town_num;
4570 /*** System Commands ***/
4572 /* Hack -- User interface */
4579 /* Single line from a pref file */
4582 p_ptr->town_num = old_town_num;
4584 p_ptr->town_num = inner_town_num;
4588 /* Interact with macros */
4591 p_ptr->town_num = old_town_num;
4593 p_ptr->town_num = inner_town_num;
4597 /* Interact with visuals */
4600 p_ptr->town_num = old_town_num;
4602 p_ptr->town_num = inner_town_num;
4606 /* Interact with colors */
4609 p_ptr->town_num = old_town_num;
4611 p_ptr->town_num = inner_town_num;
4615 /* Interact with options */
4619 (void)combine_and_reorder_home(STORE_HOME);
4625 /*** Misc Commands ***/
4641 /* Repeat level feeling */
4648 /* Show previous message */
4651 do_cmd_message_one();
4655 /* Show previous messages */
4668 /* Check artifacts, uniques etc. */
4675 /* Load "screen dump" */
4678 do_cmd_load_screen();
4682 /* Save "screen dump" */
4685 do_cmd_save_screen();
4689 /* Hack -- Unknown command */
4692 if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
4694 museum_remove_object();
4698 msg_print(_("そのコマンドは店の中では使えません。", "That command does not work in stores."));
4707 * @brief 店舗処理全体のメインルーチン /
4708 * Enter a store, and interact with it. *
4712 * Note that we use the standard "request_command()" function
4713 * to get a command, allowing us to use "command_arg" and all
4714 * command macros and other nifty stuff, but we use the special
4715 * "shopping" argument, to force certain commands to be converted
4716 * into other commands, normally, we convert "p" (pray) and "m"
4717 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
4720 void do_cmd_store(void)
4726 bool need_redraw_store_inv; /* To redraw missiles damage and prices in store */
4730 Term_get_size(&w, &h);
4732 /* Calculate stocks per 1 page */
4733 xtra_stock = MIN(14+26, ((h > 24) ? (h - 24) : 0));
4734 store_bottom = MIN_STOCK + xtra_stock;
4736 /* Access the player grid */
4737 c_ptr = &cave[p_ptr->y][p_ptr->x];
4739 /* Verify a store */
4740 if (!cave_have_flag_grid(c_ptr, FF_STORE))
4742 msg_print(_("ここには店がありません。", "You see no store here."));
4746 /* Extract the store code */
4747 which = f_info[c_ptr->feat].subtype;
4749 old_town_num = p_ptr->town_num;
4750 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
4751 if (dun_level) p_ptr->town_num = NO_TOWN;
4752 inner_town_num = p_ptr->town_num;
4754 /* Hack -- Check the "locked doors" */
4755 if ((town[p_ptr->town_num].store[which].store_open >= turn) ||
4758 msg_print(_("ドアに鍵がかかっている。", "The doors are locked."));
4759 p_ptr->town_num = old_town_num;
4763 /* Calculate the number of store maintainances since the last visit */
4764 maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
4766 /* Maintain the store max. 10 times */
4767 if (maintain_num > 10) maintain_num = 10;
4771 /* Maintain the store */
4772 for (i = 0; i < maintain_num; i++)
4773 store_maint(p_ptr->town_num, which);
4775 /* Save the visit */
4776 town[p_ptr->town_num].store[which].last_visit = turn;
4779 /* Forget the lite */
4782 /* Forget the view */
4786 /* Hack -- Character is in "icky" mode */
4787 character_icky = TRUE;
4790 /* No command argument */
4793 /* No repeated command */
4796 /* No automatic command */
4799 /* Do not expand macros */
4800 get_com_no_macros = TRUE;
4802 /* Save the store number */
4803 cur_store_num = which;
4805 /* Hack -- save the store feature */
4806 cur_store_feat = c_ptr->feat;
4808 /* Save the store and owner pointers */
4809 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
4810 ot_ptr = &owners[cur_store_num][st_ptr->owner];
4813 /* Start at the beginning */
4816 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
4818 /* Display the store */
4822 leave_store = FALSE;
4824 /* Interact with player */
4825 while (!leave_store)
4827 /* Hack -- Clear line 1 */
4831 clear_from(20 + xtra_stock);
4834 /* Basic commands */
4836 prt(" ESC) 建物から出る", 21 + xtra_stock, 0);
4838 prt(" ESC) Exit from Building.", 21 + xtra_stock, 0);
4842 /* Browse if necessary */
4843 if (st_ptr->stock_num > store_bottom)
4846 prt(" -)前ページ", 22 + xtra_stock, 0);
4847 prt(" スペース) 次ページ", 23 + xtra_stock, 0);
4849 prt(" -) Previous page", 22 + xtra_stock, 0);
4850 prt(" SPACE) Next page", 23 + xtra_stock, 0);
4856 if (cur_store_num == STORE_HOME)
4859 prt("g) アイテムを取る", 21 + xtra_stock, 27);
4860 prt("d) アイテムを置く", 22 + xtra_stock, 27);
4861 prt("x) 家のアイテムを調べる", 23 + xtra_stock, 27);
4863 prt("g) Get an item.", 21 + xtra_stock, 27);
4864 prt("d) Drop an item.", 22 + xtra_stock, 27);
4865 prt("x) eXamine an item in the home.", 23 + xtra_stock, 27);
4869 /* Museum commands */
4870 else if (cur_store_num == STORE_MUSEUM)
4873 prt("d) アイテムを置く", 21 + xtra_stock, 27);
4874 prt("r) アイテムの展示をやめる", 22 + xtra_stock, 27);
4875 prt("x) 博物館のアイテムを調べる", 23 + xtra_stock, 27);
4877 prt("d) Drop an item.", 21 + xtra_stock, 27);
4878 prt("r) order to Remove an item.", 22 + xtra_stock, 27);
4879 prt("x) eXamine an item in the museum.", 23 + xtra_stock, 27);
4887 prt("p) 商品を買う", 21 + xtra_stock, 30);
4888 prt("s) アイテムを売る", 22 + xtra_stock, 30);
4889 prt("x) 商品を調べる", 23 + xtra_stock,30);
4891 prt("p) Purchase an item.", 21 + xtra_stock, 30);
4892 prt("s) Sell an item.", 22 + xtra_stock, 30);
4893 prt("x) eXamine an item in the shop", 23 + xtra_stock,30);
4900 prt("i/e) 持ち物/装備の一覧", 21 + xtra_stock, 56);
4902 if (rogue_like_commands)
4904 prt("w/T) 装備する/はずす", 22 + xtra_stock, 56);
4908 prt("w/t) 装備する/はずす", 22 + xtra_stock, 56);
4911 prt("i/e) Inventry/Equipment list", 21 + xtra_stock, 56);
4913 if (rogue_like_commands)
4915 prt("w/T) Wear/Take off equipment", 22 + xtra_stock, 56);
4919 prt("w/t) Wear/Take off equipment", 22 + xtra_stock, 56);
4923 prt(_("コマンド:", "You may: "), 20 + xtra_stock, 0);
4926 request_command(TRUE);
4928 /* Process the command */
4929 store_process_command();
4932 * Hack -- To redraw missiles damage and prices in store
4933 * If player's charisma changes, or if player changes a bow, PU_BONUS is set
4935 need_redraw_store_inv = (p_ptr->update & PU_BONUS) ? TRUE : FALSE;
4937 /* Hack -- Character is still in "icky" mode */
4938 character_icky = TRUE;
4943 if (inventory[INVEN_PACK].k_idx)
4945 INVENTORY_IDX item = INVEN_PACK;
4947 object_type *o_ptr = &inventory[item];
4949 /* Hack -- Flee from the store */
4950 if (cur_store_num != STORE_HOME)
4953 if (cur_store_num == STORE_MUSEUM)
4954 msg_print("ザックからアイテムがあふれそうなので、あわてて博物館から出た...");
4956 msg_print("ザックからアイテムがあふれそうなので、あわてて店から出た...");
4958 if (cur_store_num == STORE_MUSEUM)
4959 msg_print("Your pack is so full that you flee the Museum...");
4961 msg_print("Your pack is so full that you flee the store...");
4969 /* Hack -- Flee from the home */
4970 else if (!store_check_num(o_ptr))
4973 msg_print("ザックからアイテムがあふれそうなので、あわてて家から出た...");
4975 msg_print("Your pack is so full that you flee your home...");
4983 /* Hack -- Drop items into the home */
4991 char o_name[MAX_NLEN];
4994 /* Give a message */
4996 msg_print("ザックからアイテムがあふれてしまった!");
4998 msg_print("Your pack overflows!");
5003 /* Grab a copy of the item */
5004 object_copy(q_ptr, o_ptr);
5007 object_desc(o_name, q_ptr, 0);
5010 msg_format("%sが落ちた。(%c)", o_name, index_to_label(item));
5012 msg_format("You drop %s (%c).", o_name, index_to_label(item));
5016 /* Remove it from the players inventory */
5017 inven_item_increase(item, -255);
5018 inven_item_describe(item);
5019 inven_item_optimize(item);
5022 /* Let the home carry it */
5023 item_pos = home_carry(q_ptr);
5025 /* Redraw the home */
5028 store_top = (item_pos / store_bottom) * store_bottom;
5029 display_inventory();
5034 /* Hack -- Redisplay store prices if charisma changes */
5035 /* Hack -- Redraw missiles damage if player changes bow */
5036 if (need_redraw_store_inv) display_inventory();
5038 /* Hack -- get kicked out of the store */
5039 if (st_ptr->store_open >= turn) leave_store = TRUE;
5042 select_floor_music();
5044 p_ptr->town_num = old_town_num;
5047 p_ptr->energy_use = 100;
5050 /* Hack -- Character is no longer in "icky" mode */
5051 character_icky = FALSE;
5054 /* Hack -- Cancel automatic command */
5057 /* Hack -- Cancel "see" mode */
5058 command_see = FALSE;
5060 /* Allow expanding macros */
5061 get_com_no_macros = FALSE;
5066 /* Update everything */
5067 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
5068 p_ptr->update |= (PU_MONSTERS);
5070 /* Redraw entire screen */
5071 p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5072 p_ptr->redraw |= (PR_MAP);
5073 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5079 * @brief 現在の町の店主を交代させる /
5080 * Shuffle one of the stores.
5081 * @param which 店舗種類のID
5084 void store_shuffle(int which)
5090 if (which == STORE_HOME) return;
5091 if (which == STORE_MUSEUM) return;
5094 /* Save the store index */
5095 cur_store_num = which;
5097 /* Activate that store */
5098 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
5101 /* Pick a new owner */
5104 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5105 if (j == st_ptr->owner) continue;
5106 for (i = 1;i < max_towns; i++)
5108 if (i == p_ptr->town_num) continue;
5109 if (st_ptr->owner == town[i].store[cur_store_num].owner) break;
5111 if (i == max_towns) break;
5114 /* Activate the new owner */
5115 ot_ptr = &owners[cur_store_num][st_ptr->owner];
5118 /* Reset the owner data */
5119 st_ptr->insult_cur = 0;
5120 st_ptr->store_open = 0;
5121 st_ptr->good_buy = 0;
5122 st_ptr->bad_buy = 0;
5125 /* Hack -- discount all the items */
5126 for (i = 0; i < st_ptr->stock_num; i++)
5130 o_ptr = &st_ptr->stock[i];
5132 if (!object_is_artifact(o_ptr))
5134 /* Hack -- Sell all non-artifact old items for "half price" */
5135 o_ptr->discount = 50;
5137 /* Hack -- Items are no longer "fixed price" */
5138 o_ptr->ident &= ~(IDENT_FIXED);
5140 /* Mega-Hack -- Note that the item is "on sale" */
5141 o_ptr->inscription = quark_add(_("売出中", "on sale"));
5148 * @brief 店の品揃えを変化させる /
5149 * Maintain the inventory at the stores.
5150 * @param town_num 町のID
5151 * @param store_num 店舗種類のID
5154 void store_maint(int town_num, int store_num)
5158 cur_store_num = store_num;
5161 if (store_num == STORE_HOME) return;
5162 if (store_num == STORE_MUSEUM) return;
5164 /* Activate that store */
5165 st_ptr = &town[town_num].store[store_num];
5167 /* Activate the owner */
5168 ot_ptr = &owners[store_num][st_ptr->owner];
5170 /* Store keeper forgives the player */
5171 st_ptr->insult_cur = 0;
5173 /* Mega-Hack -- prune the black market */
5174 if (store_num == STORE_BLACK)
5176 /* Destroy crappy black market items */
5177 for (j = st_ptr->stock_num - 1; j >= 0; j--)
5179 object_type *o_ptr = &st_ptr->stock[j];
5181 /* Destroy crappy items */
5182 if (black_market_crap(o_ptr))
5184 /* Destroy the item */
5185 store_item_increase(j, 0 - o_ptr->number);
5186 store_item_optimize(j);
5192 /* Choose the number of slots to keep */
5193 j = st_ptr->stock_num;
5195 /* Sell a few items */
5196 j = j - randint1(STORE_TURNOVER);
5198 /* Never keep more than "STORE_MAX_KEEP" slots */
5199 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
5201 /* Always "keep" at least "STORE_MIN_KEEP" items */
5202 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
5204 /* Hack -- prevent "underflow" */
5207 /* Destroy objects until only "j" slots are left */
5208 while (st_ptr->stock_num > j) store_delete();
5211 /* Choose the number of slots to fill */
5212 j = st_ptr->stock_num;
5214 /* Buy some more items */
5215 j = j + randint1(STORE_TURNOVER);
5217 /* Never keep more than "STORE_MAX_KEEP" slots */
5218 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
5220 /* Always "keep" at least "STORE_MIN_KEEP" items */
5221 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
5223 /* Hack -- prevent "overflow" */
5224 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
5226 /* Acquire some new items */
5227 while (st_ptr->stock_num < j) store_create();
5232 * @brief 店舗情報を初期化する /
5233 * Initialize the stores
5234 * @param town_num 町のID
5235 * @param store_num 店舗種類のID
5238 void store_init(int town_num, int store_num)
5242 cur_store_num = store_num;
5244 /* Activate that store */
5245 st_ptr = &town[town_num].store[store_num];
5253 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5254 for (i = 1;i < max_towns; i++)
5256 if (i == town_num) continue;
5257 if (st_ptr->owner == town[i].store[store_num].owner) break;
5259 if (i == max_towns) break;
5262 /* Activate the new owner */
5263 ot_ptr = &owners[store_num][st_ptr->owner];
5266 /* Initialize the store */
5267 st_ptr->store_open = 0;
5268 st_ptr->insult_cur = 0;
5269 st_ptr->good_buy = 0;
5270 st_ptr->bad_buy = 0;
5272 /* Nothing in stock */
5273 st_ptr->stock_num = 0;
5276 * MEGA-HACK - Last visit to store is
5277 * BEFORE player birth to enable store restocking
5279 st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
5281 /* Clear any old items */
5282 for (k = 0; k < st_ptr->stock_size; k++)
5284 object_wipe(&st_ptr->stock[k]);
5290 * @brief アイテムを町のブラックマーケットに移動させる /
5291 * @param o_ptr 移動させたいオブジェクトの構造体参照ポインタ
5294 void move_to_black_market(object_type *o_ptr)
5297 if (!p_ptr->town_num) return;
5299 st_ptr = &town[p_ptr->town_num].store[STORE_BLACK];
5301 o_ptr->ident |= IDENT_STORE;
5303 (void)store_carry(o_ptr);
5305 object_wipe(o_ptr); /* Don't leave a bogus object behind... */