OSDN Git Service

90df83429f1ef83ad51a360c333acbbd485712e0
[hengband/hengband.git] / src / store.c
1 /*!
2  * @file store.c
3  * @brief 店の処理 / Store commands
4  * @date 2014/02/02
5  * @author
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.
11  */
12
13 #include "angband.h"
14 #include "cmd-item.h"
15 #include "cmd-zapwand.h"
16 #include "cmd-magiceat.h"
17 #include "store.h"
18 #include "avatar.h"
19
20 #define MIN_STOCK 12
21
22  /*!
23   * @brief 闘技場のモンスターID及び報酬アイテムテーブル /
24   * Store owners (exactly four "possible" owners per store, chosen randomly)
25   * @details
26   * <pre>
27   * { name, purse, max greed, min greed, haggle_per, tolerance, race, unused }
28   *
29   * Lifted extra shopkeepers from CthAngband (don't you just love open source
30   * development? ;-)). Since this gave less than 32 unique names for some
31   * shops, those have their first x names copied to reach 32.
32   *
33   * For the weapon and armour shops, several owners have a limit of 5k.
34   *
35   * I want to do 50k owners, but the purse is currently s16b. Perhaps
36   * we should just store 1/10th of the purse?
37   * </pre>
38   */
39 const owner_type owners[MAX_STORES][MAX_OWNERS] =
40 {
41         {
42                 /* General store - 32 unique names */
43                 /*
44                   Raistlin は dragonlance の powerful wizard 。
45                   Rincewind the Chicken は Terry Pratchett の Discworld の登場人物 上記のパロディ?、
46                   { "憶病者ラストリン",       200,    175,  108,   4,  12,  RACE_HUMAN},
47                   { "Raistlin the Chicken",       200,    175, 108,  4, 12, RACE_HUMAN},
48                 */
49
50 #ifdef JP
51                 { "フレンドリーなビルボ",       200,    170,  108,   5,  15,  RACE_HOBBIT},
52                 { "憶病者リンスウィンド",       200,    175,  108,   4,  12,  RACE_HUMAN},
53                 { "背の低いサルタン",             300,    170,  107,   5,  15,  RACE_GNOME},
54                 { "ハンサムなライア=エル",      300,    165,  107,   6,  18,  RACE_ELF},
55                 { "親切なファリルマウエン",         250,    170, 108,  5, 15, RACE_HOBBIT},
56                 { "臆病者ヴォワラン",       500,    175, 108,  4, 12, RACE_HUMAN},
57                 { "チビのエラシュナク",          750,    170, 107,  5, 15, RACE_BEASTMAN},
58                 { "ハンサムなグラッグ",        1000,    165, 107,  6, 18, RACE_HALF_TITAN},
59                 { "ケチなフォロビア",         250,    170, 108,  5, 15, RACE_HUMAN},
60                 { "馬鹿のエリス",       500,    175, 108,  4, 12, RACE_HUMAN},
61                 { "腹ペコのフィルバート",          750,    170, 107,  5, 15, RACE_VAMPIRE},
62                 { "スナーグル・サシグア",        1000,    165, 107,  6, 18, RACE_MIND_FLAYER},
63                 { "長死きエロワーズ",         250,    170, 108,  5, 15, RACE_SPECTRE},
64                 { "ノロマのフンディ",       500,    175, 108,  4, 12, RACE_ZOMBIE},
65                 { "グランサス",          750,    170, 107,  5, 15, RACE_SKELETON},
66                 { "丁寧なロラックス",        1000,    165, 107,  6, 18, RACE_VAMPIRE},
67                 { "ブッチ",         250,    170, 108,  5, 15, RACE_HALF_ORC},
68                 { "美しきエルベレス",       500,    175, 108,  4, 12, RACE_HIGH_ELF},
69                 { "こそこそサーレス",          750,    170, 107,  5, 15, RACE_GNOME},
70                 { "ナーロック",        1000,    165, 107,  6, 18, RACE_DWARF},
71                 { "チビのヘイネッカ",         250,    170, 108,  5, 15, RACE_GNOME},
72                 { "きちがいロワラン",       500,    175, 108,  4, 12, RACE_HALF_GIANT},
73                 { "毒息のウート",          750,    170, 107,  5, 15, RACE_DRACONIAN},
74                 { "でぶっちょアラァカ",        1000,    165, 107,  6, 18, RACE_DRACONIAN},
75                 { "低能なプーゴー",         250,    170, 108,  5, 15, RACE_BEASTMAN},
76                 { "フェロールフィリアン",       500,    175, 108,  4, 12, RACE_ELF},
77                 { "年寄りマロカ",          750,    170, 107,  5, 15, RACE_GNOME},
78                 { "勇敢なサシン",        1000,    165, 107,  6, 18, RACE_HALF_GIANT},
79                 { "田舎者アビエマール",         250,    170, 108,  5, 15, RACE_HUMAN},
80                 { "貧乏なハーク",       500,    175, 108,  4, 12, RACE_HALF_ORC},
81                 { "みじめなソアリン",          750,    170, 107,  5, 15, RACE_ZOMBIE},
82                 { "質素なメルラ",        1000,    165, 107,  6, 18, RACE_ELF},
83 #else
84                 { "Bilbo the Friendly",         200,    170, 108,  5, 15, RACE_HOBBIT},
85                 { "Rincewind the Chicken",       200,    175, 108,  4, 12, RACE_HUMAN},
86                 { "Sultan the Midget",          300,    170, 107,  5, 15, RACE_GNOME},
87                 { "Lyar-el the Comely",         300,    165, 107,  6, 18, RACE_ELF},
88                 { "Falilmawen the Friendly",         250,    170, 108,  5, 15, RACE_HOBBIT},
89                 { "Voirin the Cowardly",       500,    175, 108,  4, 12, RACE_HUMAN},
90                 { "Erashnak the Midget",          750,    170, 107,  5, 15, RACE_BEASTMAN},
91                 { "Grug the Comely",        1000,    165, 107,  6, 18, RACE_HALF_TITAN},
92                 { "Forovir the Cheap",         250,    170, 108,  5, 15, RACE_HUMAN},
93                 { "Ellis the Fool",       500,    175, 108,  4, 12, RACE_HUMAN},
94                 { "Filbert the Hungry",          750,    170, 107,  5, 15, RACE_VAMPIRE},
95                 { "Fthnargl Psathiggua",        1000,    165, 107,  6, 18, RACE_MIND_FLAYER},
96                 { "Eloise Long-Dead",         250,    170, 108,  5, 15, RACE_SPECTRE},
97                 { "Fundi the Slow",       500,    175, 108,  4, 12, RACE_ZOMBIE},
98                 { "Granthus",          750,    170, 107,  5, 15, RACE_SKELETON},
99                 { "Lorax the Suave",        1000,    165, 107,  6, 18, RACE_VAMPIRE},
100                 { "Butch",         250,    170, 108,  5, 15, RACE_HALF_ORC},
101                 { "Elbereth the Beautiful",       500,    175, 108,  4, 12, RACE_HIGH_ELF},
102                 { "Sarleth the Sneaky",          750,    170, 107,  5, 15, RACE_GNOME},
103                 { "Narlock",        1000,    165, 107,  6, 18, RACE_DWARF},
104                 { "Haneka the Small",         250,    170, 108,  5, 15, RACE_GNOME},
105                 { "Loirin the Mad",       500,    175, 108,  4, 12, RACE_HALF_GIANT},
106                 { "Wuto Poisonbreath",          750,    170, 107,  5, 15, RACE_DRACONIAN},
107                 { "Araaka the Rotund",        1000,    165, 107,  6, 18, RACE_DRACONIAN},
108                 { "Poogor the Dumb",         250,    170, 108,  5, 15, RACE_BEASTMAN},
109                 { "Felorfiliand",       500,    175, 108,  4, 12, RACE_ELF},
110                 { "Maroka the Aged",          750,    170, 107,  5, 15, RACE_GNOME},
111                 { "Sasin the Bold",        1000,    165, 107,  6, 18, RACE_HALF_GIANT},
112                 { "Abiemar the Peasant",         250,    170, 108,  5, 15, RACE_HUMAN},
113                 { "Hurk the Poor",       500,    175, 108,  4, 12, RACE_HALF_ORC},
114                 { "Soalin the Wretched",          750,    170, 107,  5, 15, RACE_ZOMBIE},
115                 { "Merulla the Humble",        1000,    165, 107,  6, 18, RACE_ELF},
116 #endif
117         },
118         {
119                 /* Armoury - 28 unique names */
120 #ifdef JP
121                 { "醜悪コン=ダー",      5000,   210,  115,   5,   7,  RACE_HALF_ORC},
122                 { "頑固者ダーグ=ロウ",  10000,  190,  111,   4,   9,  RACE_HUMAN},
123                 { "賢者デカド",                 25000,  200,  112,   4,  10,  RACE_DUNADAN},
124                 { "鍛冶屋のウィーランド",   30000,  200,  112,   4,   5,  RACE_DWARF},
125                 { "醜悪コン=ダー",           10000,   210, 115,  5,  7, RACE_HALF_ORC},
126                 { "頑固者ダーグ=ロウ",          15000,  190, 111,  4,  9, RACE_HUMAN},
127                 { "ハンサムなデカド",            25000,  200, 112,  4, 10, RACE_AMBERITE},
128                 { "エロー・ドラゴンスケイル",          30000,  200, 112,  4,  5, RACE_ELF},
129                 { "デリカトス",           10000,   210, 115,  5,  7, RACE_SPRITE},
130                 { "巨大なグルース",          15000,  190, 111,  4,  9, RACE_HALF_GIANT},
131                 { "アニムス",            25000,  200, 112,  4, 10, RACE_GOLEM},
132                 { "マルヴァス",          30000,  200, 112,  4,  5, RACE_HALF_TITAN},
133                 { "セラクシス",           10000,   210, 115,  5,  7, RACE_ZOMBIE},
134                 { "デス・チル",          5000,  190, 111,  4,  9, RACE_SPECTRE},
135                 { "微かなドリオス",            25000,  200, 112,  4, 10, RACE_SPECTRE},
136                 { "冷たいバスリック",          30000,  200, 112,  4,  5, RACE_VAMPIRE},
137                 { "冷酷ヴェンジェラ",           10000,   210, 115,  5,  7, RACE_HALF_TROLL},
138                 { "強者ウィラナ",          15000,  190, 111,  4,  9, RACE_HUMAN},
139                 { "ヨジョ二世",            25000,  200, 112,  4, 10, RACE_DWARF},
140                 { "優しいラナラー",          30000,  200, 112,  4,  5, RACE_AMBERITE},
141                 { "不浄のホルバグ",           5000,   210, 115,  5,  7, RACE_HALF_ORC},
142                 { "テレパスのエレレン",          15000,  190, 111,  4,  9, RACE_DARK_ELF},
143                 { "イスドリリアス",            25000,  200, 112,  4, 10, RACE_SPRITE},
144                 { "一つ目ヴェグナー",          5000,  200, 112,  4,  5, RACE_CYCLOPS},
145                 { "混沌のロディッシュ",           10000,   210, 115,  5,  7, RACE_BEASTMAN},
146                 { "剣豪ヘジン",          15000,  190, 111,  4,  9, RACE_NIBELUNG},
147                 { "ずる屋のエルベレリス",           10000,  200, 112,  4, 10, RACE_DARK_ELF},
148                 { "インプのザサス",          30000,  200, 112,  4,  5, RACE_IMP},
149                 { "醜悪コン=ダー",           5000,   210, 115,  5,  7, RACE_HALF_ORC},
150                 { "頑固者ダーグ=ロウ",          10000,  190, 111,  4,  9, RACE_HUMAN},
151                 { "ハンサムなデカド",            25000,  200, 112,  4, 10, RACE_AMBERITE},
152                 { "鍛冶屋のウィーランド",          30000,  200, 112,  4,  5, RACE_DWARF},
153 #else
154                 { "Kon-Dar the Ugly",           5000,   210, 115,  5,  7, RACE_HALF_ORC},
155                 { "Darg-Low the Grim",          10000,  190, 111,  4,  9, RACE_HUMAN},
156                 { "Decado the Handsome",            25000,  200, 112,  4, 10, RACE_DUNADAN},
157                 { "Wieland the Smith",          30000,  200, 112,  4,  5, RACE_DWARF},
158                 { "Kon-Dar the Ugly",           10000,   210, 115,  5,  7, RACE_HALF_ORC},
159                 { "Darg-Low the Grim",          15000,  190, 111,  4,  9, RACE_HUMAN},
160                 { "Decado the Handsome",            25000,  200, 112,  4, 10, RACE_AMBERITE},
161                 { "Elo Dragonscale",          30000,  200, 112,  4,  5, RACE_ELF},
162                 { "Delicatus",           10000,   210, 115,  5,  7, RACE_SPRITE},
163                 { "Gruce the Huge",          15000,  190, 111,  4,  9, RACE_HALF_GIANT},
164                 { "Animus",            25000,  200, 112,  4, 10, RACE_GOLEM},
165                 { "Malvus",          30000,  200, 112,  4,  5, RACE_HALF_TITAN},
166                 { "Selaxis",           10000,   210, 115,  5,  7, RACE_ZOMBIE},
167                 { "Deathchill",          5000,  190, 111,  4,  9, RACE_SPECTRE},
168                 { "Drios the Faint",            25000,  200, 112,  4, 10, RACE_SPECTRE},
169                 { "Bathric the Cold",          30000,  200, 112,  4,  5, RACE_VAMPIRE},
170                 { "Vengella the Cruel",           10000,   210, 115,  5,  7, RACE_HALF_TROLL},
171                 { "Wyrana the Mighty",          15000,  190, 111,  4,  9, RACE_HUMAN},
172                 { "Yojo II",            25000,  200, 112,  4, 10, RACE_DWARF},
173                 { "Ranalar the Sweet",          30000,  200, 112,  4,  5, RACE_AMBERITE},
174                 { "Horbag the Unclean",           5000,   210, 115,  5,  7, RACE_HALF_ORC},
175                 { "Elelen the Telepath",          15000,  190, 111,  4,  9, RACE_DARK_ELF},
176                 { "Isedrelias",            25000,  200, 112,  4, 10, RACE_SPRITE},
177                 { "Vegnar One-eye",          5000,  200, 112,  4,  5, RACE_CYCLOPS},
178                 { "Rodish the Chaotic",           10000,   210, 115,  5,  7, RACE_BEASTMAN},
179                 { "Hesin Swordmaster",          15000,  190, 111,  4,  9, RACE_NIBELUNG},
180                 { "Elvererith the Cheat",           10000,  200, 112,  4, 10, RACE_DARK_ELF},
181                 { "Zzathath the Imp",          30000,  200, 112,  4,  5, RACE_IMP},
182                 { "Kon-Dar the Ugly",           5000,   210, 115,  5,  7, RACE_HALF_ORC},
183                 { "Darg-Low the Grim",          10000,  190, 111,  4,  9, RACE_HUMAN},
184                 { "Decado the Handsome",            25000,  200, 112,  4, 10, RACE_AMBERITE},
185                 { "Wieland the Smith",          30000,  200, 112,  4,  5, RACE_DWARF},
186 #endif
187         },
188
189         {
190                 /* Weapon Smith - 28 unique names */
191 #ifdef JP
192                 { "残忍なるアーノルド",        5000,   210,  115,   6,   6,  RACE_HALF_TROLL},
193                 { "獣殺しのアーンダル", 10000,  185,  110,   5,   9,  RACE_HALF_ELF},
194                 { "獣マスターのエディー", 25000,  190,  115,   5,   7,  RACE_HOBBIT},
195                 { "竜殺しのオグライン", 30000,  195,  112,   4,   8,  RACE_DWARF},
196                 { "熟練者ドリュー",      10000,   210, 115,  6,  6, RACE_HUMAN},
197                 { "龍の子オラックス",        15000,  185, 110,  5,  9, RACE_DRACONIAN},
198                 { "病気持ちのアンスラックス",         25000,  190, 115,  5,  7, RACE_BEASTMAN},
199                 { "頑丈者アルコス",       30000,  195, 112,  4,  8, RACE_DWARF},
200                 { "腐れ者のサリアス",      5000,   210, 115,  6,  6, RACE_ZOMBIE},
201                 { "晒し骨のトゥエシク",        15000,  185, 110,  5,  9, RACE_SKELETON},
202                 { "ビリオス",         25000,  190, 115,  5,  7, RACE_BEASTMAN},
203                 { "ファスガル",       30000,  195, 112,  4,  8, RACE_ZOMBIE},
204                 { "パラディンのエレフリス",      10000,   210, 115,  6,  6, RACE_BARBARIAN},
205                 { "キ'トリッ'ク",        15000,  185, 110,  5,  9, RACE_KLACKON},
206                 { "蜘蛛の友ドゥロカス",         25000,  190, 115,  5,  7, RACE_DARK_ELF},
207                 { "巨人殺しのフングス",       30000,  195, 112,  4,  8, RACE_DWARF},
208                 { "デランサ",      10000,   210, 115,  6,  6, RACE_ELF},
209                 { "レンジャーのソルビスタニ",        15000,  185, 110,  5,  9, RACE_HALF_ELF},
210                 { "ノロマのゾリル",         25000,  190, 115,  5,  7, RACE_GOLEM},
211                 { "イーオン・フラックス",       20000,  195, 112,  4,  8, RACE_HALF_ELF},
212                 { "強者ナドック",      10000,   210, 115,  6,  6, RACE_HOBBIT},
213                 { "弱虫エラモグ",        15000,  185, 110,  5,  9, RACE_KOBOLD},
214                 { "公正なエオウィリス",         25000,  190, 115,  5,  7, RACE_VAMPIRE},
215                 { "バルログ殺しのヒュイモグ",       30000,  195, 112,  4,  8, RACE_HALF_ORC},
216                 { "冷酷ピーダス",      5000,   210, 115,  6,  6, RACE_HUMAN},
217                 { "ヴァモグ スレイヤー",        15000,  185, 110,  5,  9, RACE_HALF_OGRE},
218                 { "性悪フーシュナク",         25000,  190, 115,  5,  7, RACE_BEASTMAN},
219                 { "舞闘バレン",       30000,  195, 112,  4,  8, RACE_BARBARIAN},
220                 { "残忍なるアーノルド",      5000,   210, 115,  6,  6, RACE_BARBARIAN},
221                 { "獣殺しのアーンダル",        10000,  185, 110,  5,  9, RACE_HALF_ELF},
222                 { "ビーストマスター・エディー",         25000,  190, 115,  5,  7, RACE_HALF_ORC},
223                 { "竜殺しのオグライン",       30000,  195, 112,  4,  8, RACE_DWARF},
224 #else
225                 { "Arnold the Beastly",      5000,   210, 115,  6,  6, RACE_BARBARIAN},
226                 { "Arndal Beast-Slayer",        10000,  185, 110,  5,  9, RACE_HALF_ELF},
227                 { "Eddie Beast-Master",         25000,  190, 115,  5,  7, RACE_HALF_ORC},
228                 { "Oglign Dragon-Slayer",       30000,  195, 112,  4,  8, RACE_DWARF},
229                 { "Drew the Skilled",      10000,   210, 115,  6,  6, RACE_HUMAN},
230                 { "Orrax Dragonson",        15000,  185, 110,  5,  9, RACE_DRACONIAN},
231                 { "Anthrax Disease-Carrier",         25000,  190, 115,  5,  7, RACE_BEASTMAN},
232                 { "Arkhoth the Stout",       30000,  195, 112,  4,  8, RACE_DWARF},
233                 { "Sarlyas the Rotten",      5000,   210, 115,  6,  6, RACE_ZOMBIE},
234                 { "Tuethic Bare-Bones",        15000,  185, 110,  5,  9, RACE_SKELETON},
235                 { "Bilious",         25000,  190, 115,  5,  7, RACE_BEASTMAN},
236                 { "Fasgul",       30000,  195, 112,  4,  8, RACE_ZOMBIE},
237                 { "Ellefris the Paladin",      10000,   210, 115,  6,  6, RACE_BARBARIAN},
238                 { "K'trrik'k",        15000,  185, 110,  5,  9, RACE_KLACKON},
239                 { "Drocus Spiderfriend",         25000,  190, 115,  5,  7, RACE_DARK_ELF},
240                 { "Fungus Giant-Slayer",       30000,  195, 112,  4,  8, RACE_DWARF},
241                 { "Delantha",      10000,   210, 115,  6,  6, RACE_ELF},
242                 { "Solvistani the Ranger",        15000,  185, 110,  5,  9, RACE_HALF_ELF},
243                 { "Xoril the Slow",         25000,  190, 115,  5,  7, RACE_GOLEM},
244                 { "Aeon Flux",       20000,  195, 112,  4,  8, RACE_HALF_ELF},
245                 { "Nadoc the Strong",      10000,   210, 115,  6,  6, RACE_HOBBIT},
246                 { "Eramog the Weak",        15000,  185, 110,  5,  9, RACE_KOBOLD},
247                 { "Eowilith the Fair",         25000,  190, 115,  5,  7, RACE_VAMPIRE},
248                 { "Huimog Balrog-Slayer",       30000,  195, 112,  4,  8, RACE_HALF_ORC},
249                 { "Peadus the Cruel",      5000,   210, 115,  6,  6, RACE_HUMAN},
250                 { "Vamog Slayer",        15000,  185, 110,  5,  9, RACE_HALF_OGRE},
251                 { "Hooshnak the Vicious",         25000,  190, 115,  5,  7, RACE_BEASTMAN},
252                 { "Balenn War-Dancer",       30000,  195, 112,  4,  8, RACE_BARBARIAN},
253                 { "Arnold the Beastly",      5000,   210, 115,  6,  6, RACE_BARBARIAN},
254                 { "Arndal Beast-Slayer",        10000,  185, 110,  5,  9, RACE_HALF_ELF},
255                 { "Eddie Beast-Master",         25000,  190, 115,  5,  7, RACE_HALF_ORC},
256                 { "Oglign Dragon-Slayer",       30000,  195, 112,  4,  8, RACE_DWARF},
257 #endif
258         },
259         {
260                 /* Temple - 22 unique names */
261 #ifdef JP
262                 { "質素なルードヴィヒ",         5000,   175,  109,   6,  15,  RACE_HUMAN},
263                 { "パラディンのガンナー",       10000,  185,  110,   5,  23,  RACE_HUMAN},
264                 { "選ばれしトリン",                     25000,  180,  107,   6,  20,  RACE_ELF},
265                 { "賢明なるサラストロ",                     30000,  185,  109,   5,  15,  RACE_DWARF},
266                 { "パーシヴァル卿",           25000,  180, 107,  6, 20, RACE_HIGH_ELF},
267                 { "神聖なるアセナス",          30000,  185, 109,  5, 15, RACE_HUMAN},
268                 { "マッキノン",         10000,   175, 109,  6, 15, RACE_HUMAN},
269                 { "謹み婦人",         15000,  185, 110,  5, 23, RACE_HIGH_ELF},
270                 { "ドルイドのハシュニック",           25000,  180, 107,  6, 20, RACE_HOBBIT},
271                 { "フィナク",          30000,  185, 109,  5, 15, RACE_YEEK},
272                 { "クリキック",         10000,   175, 109,  6, 15, RACE_KLACKON},
273                 { "荒くれ者モリヴァル",         15000,  185, 110,  5, 23, RACE_ELF},
274                 { "暗きホシャック",           25000,  180, 107,  6, 20, RACE_IMP},
275                 { "賢者アタール",          30000,  185, 109,  5, 15, RACE_HUMAN},
276                 { "清きイベニッド",         10000,   175, 109,  6, 15, RACE_HUMAN},
277                 { "エリディシュ",         15000,  185, 110,  5, 23, RACE_HALF_TROLL},
278                 { "呪術師ヴルドゥシュ",           25000,  180, 107,  6, 20, RACE_HALF_OGRE},
279                 { "狂戦士ハオブ",          30000,  185, 109,  5, 15, RACE_BARBARIAN},
280                 { "若きプルーグディシュ",         10000,   175, 109,  6, 15, RACE_HALF_OGRE},
281                 { "きちがいラムワイズ",         15000,  185, 110,  5, 23, RACE_YEEK},
282                 { "有徳者ムワート",           25000,  180, 107,  6, 20, RACE_KOBOLD},
283                 { "弱虫ダードバード",          30000,  185, 109,  5, 15, RACE_SPECTRE},
284                 { "質素なルードヴィヒ",         5000,   175,  109,   6,  15,  RACE_HUMAN},
285                 { "パラディンのガンナー",       10000,  185,  110,   5,  23,  RACE_HUMAN},
286                 { "選ばれしトリン",                     25000,  180,  107,   6,  20,  RACE_ELF},
287                 { "賢明なるサラストロ",                     30000,  185,  109,   5,  15,  RACE_DWARF},
288                 { "パーシヴァル卿",           25000,  180, 107,  6, 20, RACE_HIGH_ELF},
289                 { "神聖なるアセナス",          30000,  185, 109,  5, 15, RACE_HUMAN},
290                 { "マッキノン",         10000,   175, 109,  6, 15, RACE_HUMAN},
291                 { "謹み婦人",         15000,  185, 110,  5, 23, RACE_HIGH_ELF},
292                 { "ドルイドのハシュニック",           25000,  180, 107,  6, 20, RACE_HOBBIT},
293                 { "フィナク",          30000,  185, 109,  5, 15, RACE_YEEK},
294 #else
295                 { "Ludwig the Humble",          5000,   175, 109,  6, 15, RACE_DWARF},
296                 { "Gunnar the Paladin",         10000,  185, 110,  5, 23, RACE_HALF_TROLL},
297                 { "Torin the Chosen",           25000,  180, 107,  6, 20, RACE_HIGH_ELF},
298                 { "Sarastro the Wise",          30000,  185, 109,  5, 15, RACE_HUMAN},
299                 { "Sir Parsival the Pure",           25000,  180, 107,  6, 20, RACE_HIGH_ELF},
300                 { "Asenath the Holy",          30000,  185, 109,  5, 15, RACE_HUMAN},
301                 { "McKinnon",         10000,   175, 109,  6, 15, RACE_HUMAN},
302                 { "Mistress Chastity",         15000,  185, 110,  5, 23, RACE_HIGH_ELF},
303                 { "Hashnik the Druid",           25000,  180, 107,  6, 20, RACE_HOBBIT},
304                 { "Finak",          30000,  185, 109,  5, 15, RACE_YEEK},
305                 { "Krikkik",         10000,   175, 109,  6, 15, RACE_KLACKON},
306                 { "Morival the Wild",         15000,  185, 110,  5, 23, RACE_ELF},
307                 { "Hoshak the Dark",           25000,  180, 107,  6, 20, RACE_IMP},
308                 { "Atal the Wise",          30000,  185, 109,  5, 15, RACE_HUMAN},
309                 { "Ibenidd the Chaste",         10000,   175, 109,  6, 15, RACE_HUMAN},
310                 { "Eridish",         15000,  185, 110,  5, 23, RACE_HALF_TROLL},
311                 { "Vrudush the Shaman",           25000,  180, 107,  6, 20, RACE_HALF_OGRE},
312                 { "Haob the Berserker",          30000,  185, 109,  5, 15, RACE_BARBARIAN},
313                 { "Proogdish the Youthfull",         10000,   175, 109,  6, 15, RACE_HALF_OGRE},
314                 { "Lumwise the Mad",         15000,  185, 110,  5, 23, RACE_YEEK},
315                 { "Muirt the Virtuous",           25000,  180, 107,  6, 20, RACE_KOBOLD},
316                 { "Dardobard the Weak",          30000,  185, 109,  5, 15, RACE_SPECTRE},
317                 { "Ludwig the Humble",          5000,   175, 109,  6, 15, RACE_DWARF},
318                 { "Gunnar the Paladin",         10000,  185, 110,  5, 23, RACE_HALF_TROLL},
319                 { "Torin the Chosen",           25000,  180, 107,  6, 20, RACE_HIGH_ELF},
320                 { "Sarastro the Wise",          30000,  185, 109,  5, 15, RACE_HUMAN},
321                 { "Sir Parsival the Pure",           25000,  180, 107,  6, 20, RACE_HIGH_ELF},
322                 { "Asenath the Holy",          30000,  185, 109,  5, 15, RACE_HUMAN},
323                 { "McKinnon",         10000,   175, 109,  6, 15, RACE_HUMAN},
324                 { "Mistress Chastity",         15000,  185, 110,  5, 23, RACE_HIGH_ELF},
325                 { "Hashnik the Druid",           25000,  180, 107,  6, 20, RACE_HOBBIT},
326                 { "Finak",          30000,  185, 109,  5, 15, RACE_YEEK},
327 #endif
328         },
329         {
330                 /* Alchemist - 26 unique names */
331 #ifdef JP
332                 { "化学者マウザー",             10000,  190,  111,   5,   8,  RACE_HALF_ELF},
333                 { "カオスのウィズル",   10000,  190,  110,   6,   8,  RACE_HOBBIT},
334                 { "強欲ミダス",              15000,  200,  116,   6,   9,  RACE_GNOME},
335                 { "貧弱ジャ=ファー",                   15000,  220,  111,   4,   9,  RACE_ELF},/*FIRST*/
336                 { "カカルラカカル",           15000,  200, 116,  6,  9, RACE_KLACKON},
337                 { "錬金術師ジャル=エス",       15000,  220, 111,  4,  9, RACE_ELF},
338                 { "用心深いファネラス",         10000,  190, 111,  5,  8, RACE_DWARF},
339                 { "キチガイのルンシー",         10000,  190, 110,  6,  8, RACE_HUMAN},
340                 { "グランブルワース",           15000,  200, 116,  6,  9, RACE_GNOME},
341                 { "フリッター",       15000,  220, 111,  4,  9, RACE_SPRITE},
342                 { "ザリルス",         10000,  190, 111,  5,  8, RACE_HUMAN},
343                 { "古きエグバート",         10000,  190, 110,  6,  8, RACE_DWARF},
344                 { "誇り高きヴァリンドラ",           15000,  200, 116,  6,  9, RACE_HIGH_ELF},
345                 { "錬金術師タエン",       15000,  220, 111,  4,  9, RACE_HUMAN},
346                 { "巧言カイド",         10000,  190, 111,  5,  8, RACE_VAMPIRE},
347                 { "暗きフリア",         10000,  190, 110,  6,  8, RACE_NIBELUNG},
348                 { "質素なドムリ",           15000,  200, 116,  6,  9, RACE_DWARF},
349                 { "魔の子ヤァジュッカ",       15000,  220, 111,  4,  9, RACE_IMP},
350                 { "薬草師ジェララルドール",         10000,  190, 111,  5,  8, RACE_HIGH_ELF},
351                 { "賢者オレラルダン",         10000,  190, 110,  6,  8, RACE_BARBARIAN},
352                 { "デモニシストのフゾグロ",           15000,  200, 116,  6,  9, RACE_IMP},
353                 { "錬金術師ドゥリアシュ",       15000,  220, 111,  4,  9, RACE_HALF_ORC},
354                 { "強者ネリア",         10000,  190, 111,  5,  8, RACE_CYCLOPS},
355                 { "辛口リグナス",         10000,  190, 110,  6,  8, RACE_HALF_ORC},
356                 { "ティルバ",           15000,  200, 116,  6,  9, RACE_HOBBIT},
357                 { "金持ちミリルドリック",       15000,  220, 111,  4,  9, RACE_HUMAN},
358
359                 { "科学者マウザー",         10000,  190, 111,  5,  8, RACE_HALF_ELF},
360                 { "カオスのウィズル",         10000,  190, 110,  6,  8, RACE_HOBBIT},
361                 { "強欲ミダス",           15000,  200, 116,  6,  9, RACE_GNOME},
362                 { "錬金術師ジャ=ファー",       15000,  220, 111,  4,  9, RACE_ELF},
363                 { "カカルラカカル",           15000,  200, 116,  6,  9, RACE_KLACKON},
364                 { "錬金術師ジャル=エス",       15000,  220, 111,  4,  9, RACE_ELF},
365 #else
366                 { "Mauser the Chemist",         10000,  190, 111,  5,  8, RACE_HALF_ELF},
367                 { "Wizzle the Chaotic",         10000,  190, 110,  6,  8, RACE_HOBBIT},
368                 { "Midas the Greedy",           15000,  200, 116,  6,  9, RACE_GNOME},
369                 { "Ja-Far the Alchemist",       15000,  220, 111,  4,  9, RACE_ELF},
370                 { "Kakalrakakal",           15000,  200, 116,  6,  9, RACE_KLACKON},
371                 { "Jal-Eth the Alchemist",       15000,  220, 111,  4,  9, RACE_ELF},
372                 { "Fanelath the Cautious",         10000,  190, 111,  5,  8, RACE_DWARF},
373                 { "Runcie the Insane",         10000,  190, 110,  6,  8, RACE_HUMAN},
374                 { "Grumbleworth",           15000,  200, 116,  6,  9, RACE_GNOME},
375                 { "Flitter",       15000,  220, 111,  4,  9, RACE_SPRITE},
376                 { "Xarillus",         10000,  190, 111,  5,  8, RACE_HUMAN},
377                 { "Egbert the Old",         10000,  190, 110,  6,  8, RACE_DWARF},
378                 { "Valindra the Proud",           15000,  200, 116,  6,  9, RACE_HIGH_ELF},
379                 { "Taen the Alchemist",       15000,  220, 111,  4,  9, RACE_HUMAN},
380                 { "Cayd the Sweet",         10000,  190, 111,  5,  8, RACE_VAMPIRE},
381                 { "Fulir the Dark",         10000,  190, 110,  6,  8, RACE_NIBELUNG},
382                 { "Domli the Humble",           15000,  200, 116,  6,  9, RACE_DWARF},
383                 { "Yaarjukka Demonspawn",       15000,  220, 111,  4,  9, RACE_IMP},
384                 { "Gelaraldor the Herbmaster",         10000,  190, 111,  5,  8, RACE_HIGH_ELF},
385                 { "Olelaldan the Wise",         10000,  190, 110,  6,  8, RACE_BARBARIAN},
386                 { "Fthoglo the Demonicist",           15000,  200, 116,  6,  9, RACE_IMP},
387                 { "Dridash the Alchemist",       15000,  220, 111,  4,  9, RACE_HALF_ORC},
388                 { "Nelir the Strong",         10000,  190, 111,  5,  8, RACE_CYCLOPS},
389                 { "Lignus the Pungent",         10000,  190, 110,  6,  8, RACE_HALF_ORC},
390                 { "Tilba",           15000,  200, 116,  6,  9, RACE_HOBBIT},
391                 { "Myrildric the Wealthy",       15000,  220, 111,  4,  9, RACE_HUMAN},
392
393                 { "Mauser the Chemist",         10000,  190, 111,  5,  8, RACE_HALF_ELF},
394                 { "Wizzle the Chaotic",         10000,  190, 110,  6,  8, RACE_HOBBIT},
395                 { "Midas the Greedy",           15000,  200, 116,  6,  9, RACE_GNOME},
396                 { "Ja-Far the Alchemist",       15000,  220, 111,  4,  9, RACE_ELF},
397                 { "Kakalrakakal",           15000,  200, 116,  6,  9, RACE_KLACKON},
398                 { "Jal-Eth the Alchemist",       15000,  220, 111,  4,  9, RACE_ELF},
399 #endif
400         },
401
402         {
403                 /* Magic Shop - 23 unique names */
404 #ifdef JP
405                 { "ソーサラーのロ=パン",       20000,  200,  110,   7,   8,  RACE_HALF_ELF},
406                 { "偉大なるブガービイ",         20000,  215,  113,   6,  10,  RACE_GNOME},
407                 { "イェンダーの魔法使い",     30000,  200,  110,   7,  10,  RACE_HUMAN},
408                 { "死霊使いリャク",30000,      175,  110,   5,  11,  RACE_HIGH_ELF},
409                 { "魔術師スキドゥニー",        15000,  200, 110,  7,  8, RACE_HALF_ELF},
410                 { "幻術師キリア",       30000,  200, 110,  7, 10, RACE_HUMAN},
411                 { "死霊術師ニッキ",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
412                 { "ソロストラン",        15000,  200, 110,  7,  8, RACE_SPRITE},
413                 { "烏賊口アチシェ",         20000,  215, 113,  6, 10, RACE_MIND_FLAYER},
414                 { "貴族のカザ",       30000,  200, 110,  7, 10, RACE_HIGH_ELF},
415                 { "暗きファジル",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
416                 { "偉大なるケルドーン",        15000,  200, 110,  7,  8, RACE_DWARF},
417                 { "フィランスロプス",         20000,  215, 113,  6, 10, RACE_HOBBIT},
418                 { "魔女のアグナー",       30000,  200, 110,  7, 10, RACE_HUMAN},
419                 { "死霊術師ビュリアンス",       30000,  175, 110,  5, 11, RACE_BEASTMAN},
420                 { "ハイメイジのヴイラク",        15000,  200, 110,  7,  8, RACE_BEASTMAN},
421                 { "知恵者マディッシュ",         20000,  215, 113,  6, 10, RACE_BEASTMAN},
422                 { "ファレブリンボール",       30000,  200, 110,  7, 10, RACE_HIGH_ELF},
423                 { "陰険フェリル=ガンド",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
424                 { "呪術師サレゴード",        15000,  200, 110,  7,  8, RACE_BARBARIAN},
425                 { "神秘家クトゥアロス",         20000,  215, 113,  6, 10, RACE_MIND_FLAYER},
426                 { "幻術師イベリ",       30000,  200, 110,  7, 10, RACE_SKELETON},
427                 { "死霊術師ヘトー",       30000,  175, 110,  5, 11, RACE_YEEK},
428                 { "魔術師ロ=パン",        20000,  200, 110,  7,  8, RACE_HALF_ELF},
429                 { "偉大なるブガービイ",         20000,  215, 113,  6, 10, RACE_GNOME},
430                 { "イェンダーの魔法使い",       30000,  200, 110,  7, 10, RACE_HUMAN},
431                 { "死霊術師リャク",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
432                 { "魔術師スキドゥニー",        15000,  200, 110,  7,  8, RACE_HALF_ELF},
433                 { "幻術師キリア",       30000,  200, 110,  7, 10, RACE_HUMAN},
434                 { "死霊術師ニッキ",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
435                 { "ソロストラン",        15000,  200, 110,  7,  8, RACE_SPRITE},
436                 { "烏賊口アチシェ",         20000,  215, 113,  6, 10, RACE_MIND_FLAYER},
437 #else
438                 { "Lo Pan the Sorcerer",        20000,  200, 110,  7,  8, RACE_HALF_ELF},
439                 { "Buggerby the Great",         20000,  215, 113,  6, 10, RACE_GNOME},
440                 { "The Wizard of Yendor",       30000,  200, 110,  7, 10, RACE_HUMAN},
441                 { "Rjak the Necromancer",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
442                 { "Skidney the Sorcerer",        15000,  200, 110,  7,  8, RACE_HALF_ELF},
443                 { "Kyria the Illusionist",       30000,  200, 110,  7, 10, RACE_HUMAN},
444                 { "Nikki the Necromancer",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
445                 { "Solostoran",        15000,  200, 110,  7,  8, RACE_SPRITE},
446                 { "Achshe the Tentacled",         20000,  215, 113,  6, 10, RACE_MIND_FLAYER},
447                 { "Kaza the Noble",       30000,  200, 110,  7, 10, RACE_HIGH_ELF},
448                 { "Fazzil the Dark",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
449                 { "Keldorn the Grand",        15000,  200, 110,  7,  8, RACE_DWARF},
450                 { "Philanthropus",         20000,  215, 113,  6, 10, RACE_HOBBIT},
451                 { "Agnar the Enchantress",       30000,  200, 110,  7, 10, RACE_HUMAN},
452                 { "Buliance the Necromancer",       30000,  175, 110,  5, 11, RACE_BEASTMAN},
453                 { "Vuirak the High-Mage",        15000,  200, 110,  7,  8, RACE_BEASTMAN},
454                 { "Madish the Smart",         20000,  215, 113,  6, 10, RACE_BEASTMAN},
455                 { "Falebrimbor",       30000,  200, 110,  7, 10, RACE_HIGH_ELF},
456                 { "Felil-Gand the Subtle",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
457                 { "Thalegord the Shaman",        15000,  200, 110,  7,  8, RACE_BARBARIAN},
458                 { "Cthoaloth the Mystic",         20000,  215, 113,  6, 10, RACE_MIND_FLAYER},
459                 { "Ibeli the Illusionist",       30000,  200, 110,  7, 10, RACE_SKELETON},
460                 { "Heto the Necromancer",       30000,  175, 110,  5, 11, RACE_YEEK},
461                 { "Lo Pan the Sorcerer",        20000,  200, 110,  7,  8, RACE_HALF_ELF},
462                 { "Buggerby the Great",         20000,  215, 113,  6, 10, RACE_GNOME},
463                 { "The Wizard of Yendor",       30000,  200, 110,  7, 10, RACE_HUMAN},
464                 { "Rjak the Necromancer",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
465                 { "Skidney the Sorcerer",        15000,  200, 110,  7,  8, RACE_HALF_ELF},
466                 { "Kyria the Illusionist",       30000,  200, 110,  7, 10, RACE_HUMAN},
467                 { "Nikki the Necromancer",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
468                 { "Solostoran",        15000,  200, 110,  7,  8, RACE_SPRITE},
469                 { "Achshe the Tentacled",         20000,  215, 113,  6, 10, RACE_MIND_FLAYER},
470 #endif
471         },
472         {
473                 /* Black Market - 32 unique names */
474 #ifdef JP
475                 { "ガリー=ギガズ",            20000,  250,  150,  10,   5,  RACE_HALF_TROLL},
476                 { "ゴブリンのヒストーア",       20000,  250,  150,  10,   5,  RACE_HALF_ORC},
477                 { "フェレンギ人クアーク",           30000,  250,  150,  10,   5,  RACE_HUMAN},
478                 { "公正なる(?)トッピ",                     30000,  250,  150,  10,   5,  RACE_ELF},
479                 { "死人ヴァッサ",             20000,  250, 150, 10,  5, RACE_ZOMBIE},
480                 { "裏切り者カイン",          20000,  250, 150, 10,  5, RACE_VAMPIRE},
481                 { "ブボニカス",          30000,  250, 150, 10,  5, RACE_BEASTMAN},
482                 { "コープスライト",           30000,  250, 150, 10,  5, RACE_SPECTRE},
483                 { "血に飢えしパリッシュ",                 20000,  250, 150, 10,  5, RACE_VAMPIRE},
484                 { "ヴァイル",          20000,  250, 150, 10,  5, RACE_SKELETON},
485                 { "信頼のプレンティス",          30000,  250, 150, 10,  5, RACE_SKELETON},
486                 { "人間殺しのグリエラ",           30000,  250, 150, 10,  5, RACE_IMP},
487                 { "エンジェル",                 20000,  250, 150, 10,  5, RACE_VAMPIRE},
488                 { "水膨れフロツァム",          20000,  250, 150, 10,  5, RACE_ZOMBIE},
489                 { "ニーヴァル",          30000,  250, 150, 10,  5, RACE_VAMPIRE},
490                 { "明るいアナスタシア",           30000,  250, 150, 10,  5, RACE_SPECTRE},
491                 { "死霊術師チャリティー", 20000,  250, 150, 10,  5, RACE_DARK_ELF},
492                 { "ボクサーのプグナシオス",          20000,  250, 150, 10,  5, RACE_HALF_ORC},
493                 { "幸運なフットソア",          30000,  250, 150, 10,  5, RACE_BEASTMAN},
494                 { "光指のシドリア",           30000,  250, 150, 10,  5, RACE_HUMAN},
495                 { "手品師リアソー",                 20000,  250, 150, 10,  5, RACE_HOBBIT},
496                 { "やりくり上手のジャナッカ",          20000,  250, 150, 10,  5, RACE_GNOME},
497                 { "悪党シーナ",          30000,  250, 150, 10,  5, RACE_GNOME},
498                 { "大爪アルニッキ",           30000,  250, 150, 10,  5, RACE_DRACONIAN},
499                 { "貧乏チャエアンド",                 20000,  250, 150, 10,  5, RACE_HUMAN},
500                 { "山賊アファードーフ",          20000,  250, 150, 10,  5, RACE_BARBARIAN},
501                 { "強欲ラザクスル",          30000,  250, 150, 10,  5, RACE_MIND_FLAYER},
502                 { "ファラレウィン",           30000,  250, 150, 10,  5, RACE_SPRITE},
503                 { "しわしわヴォスール",                 20000,  250, 150, 10,  5, RACE_NIBELUNG},
504                 { "ハンサムなアラオード",          20000,  250, 150, 10,  5, RACE_AMBERITE},
505                 { "負け犬セラドフリド",          30000,  250, 150, 10,  5, RACE_HUMAN},
506                 { "片足のエルーロ",           30000,  250, 150, 10,  5, RACE_HALF_OGRE},
507 #else
508                 { "Gary Gygaz",                 20000,  250, 150, 10,  5, RACE_HALF_TROLL},
509                 { "Histor the Goblin",          20000,  250, 150, 10,  5, RACE_HALF_ORC},
510                 { "Quark the Ferengi",          30000,  250, 150, 10,  5, RACE_DWARF},
511                 { "Topi the Fair(?)",           30000,  250, 150, 10,  5, RACE_HUMAN},
512                 { "Vhassa the Dead",             20000,  250, 150, 10,  5, RACE_ZOMBIE},
513                 { "Kyn the Treacherous",          20000,  250, 150, 10,  5, RACE_VAMPIRE},
514                 { "Bubonicus",          30000,  250, 150, 10,  5, RACE_BEASTMAN},
515                 { "Corpselight",           30000,  250, 150, 10,  5, RACE_SPECTRE},
516                 { "Parrish the Bloodthirsty",                 20000,  250, 150, 10,  5, RACE_VAMPIRE},
517                 { "Vile",          20000,  250, 150, 10,  5, RACE_SKELETON},
518                 { "Prentice the Trusted",          30000,  250, 150, 10,  5, RACE_SKELETON},
519                 { "Griella Humanslayer",           30000,  250, 150, 10,  5, RACE_IMP},
520                 { "Angel",                 20000,  250, 150, 10,  5, RACE_VAMPIRE},
521                 { "Flotsam the Bloated",          20000,  250, 150, 10,  5, RACE_ZOMBIE},
522                 { "Nieval",          30000,  250, 150, 10,  5, RACE_VAMPIRE},
523                 { "Anastasia the Luminous",           30000,  250, 150, 10,  5, RACE_SPECTRE},
524                 { "Charity the Necromancer", 20000,  250, 150, 10,  5, RACE_DARK_ELF},
525                 { "Pugnacious the Pugilist",          20000,  250, 150, 10,  5, RACE_HALF_ORC},
526                 { "Footsore the Lucky",          30000,  250, 150, 10,  5, RACE_BEASTMAN},
527                 { "Sidria Lighfingered",           30000,  250, 150, 10,  5, RACE_HUMAN},
528                 { "Riatho the Juggler",                 20000,  250, 150, 10,  5, RACE_HOBBIT},
529                 { "Janaaka the Shifty",          20000,  250, 150, 10,  5, RACE_GNOME},
530                 { "Cina the Rogue",          30000,  250, 150, 10,  5, RACE_GNOME},
531                 { "Arunikki Greatclaw",           30000,  250, 150, 10,  5, RACE_DRACONIAN},
532                 { "Chaeand the Poor",                 20000,  250, 150, 10,  5, RACE_HUMAN},
533                 { "Afardorf the Brigand",          20000,  250, 150, 10,  5, RACE_BARBARIAN},
534                 { "Lathaxl the Greedy",          30000,  250, 150, 10,  5, RACE_MIND_FLAYER},
535                 { "Falarewyn",           30000,  250, 150, 10,  5, RACE_SPRITE},
536                 { "Vosur the Wrinkled",                 20000,  250, 150, 10,  5, RACE_NIBELUNG},
537                 { "Araord the Handsome",          20000,  250, 150, 10,  5, RACE_AMBERITE},
538                 { "Theradfrid the Loser",          30000,  250, 150, 10,  5, RACE_HUMAN},
539                 { "One-Legged Eroolo",           30000,  250, 150, 10,  5, RACE_HALF_OGRE},
540 #endif
541         },
542         {
543                 /* Home */
544 #ifdef JP
545                 { "我が家",                          0,      100, 100,  0, 99, 99},
546                 { "我が家",                          0,      100, 100,  0, 99, 99},
547                 { "我が家",                          0,      100, 100,  0, 99, 99},
548                 { "我が家",                          0,      100, 100,  0, 99, 99},
549                 { "我が家",                          0,      100, 100,  0, 99, 99},
550                 { "我が家",                          0,      100, 100,  0, 99, 99},
551                 { "我が家",                          0,      100, 100,  0, 99, 99},
552                 { "我が家",                          0,      100, 100,  0, 99, 99},
553                 { "我が家",                          0,      100, 100,  0, 99, 99},
554                 { "我が家",                          0,      100, 100,  0, 99, 99},
555                 { "我が家",                          0,      100, 100,  0, 99, 99},
556                 { "我が家",                          0,      100, 100,  0, 99, 99},
557                 { "我が家",                          0,      100, 100,  0, 99, 99},
558                 { "我が家",                          0,      100, 100,  0, 99, 99},
559                 { "我が家",                          0,      100, 100,  0, 99, 99},
560                 { "我が家",                          0,      100, 100,  0, 99, 99},
561                 { "我が家",                          0,      100, 100,  0, 99, 99},
562                 { "我が家",                          0,      100, 100,  0, 99, 99},
563                 { "我が家",                          0,      100, 100,  0, 99, 99},
564                 { "我が家",                          0,      100, 100,  0, 99, 99},
565                 { "我が家",                          0,      100, 100,  0, 99, 99},
566                 { "我が家",                          0,      100, 100,  0, 99, 99},
567                 { "我が家",                          0,      100, 100,  0, 99, 99},
568                 { "我が家",                          0,      100, 100,  0, 99, 99},
569                 { "我が家",                          0,      100, 100,  0, 99, 99},
570                 { "我が家",                          0,      100, 100,  0, 99, 99},
571                 { "我が家",                          0,      100, 100,  0, 99, 99},
572                 { "我が家",                          0,      100, 100,  0, 99, 99},
573                 { "我が家",                          0,      100, 100,  0, 99, 99},
574                 { "我が家",                          0,      100, 100,  0, 99, 99},
575                 { "我が家",                          0,      100, 100,  0, 99, 99},
576                 { "我が家",                          0,      100, 100,  0, 99, 99},
577 #else
578                 { "Your home",                          0,      100, 100,  0, 99, 99},
579                 { "Your home",                          0,      100, 100,  0, 99, 99},
580                 { "Your home",                          0,      100, 100,  0, 99, 99},
581                 { "Your home",                          0,      100, 100,  0, 99, 99},
582                 { "Your home",                          0,      100, 100,  0, 99, 99},
583                 { "Your home",                          0,      100, 100,  0, 99, 99},
584                 { "Your home",                          0,      100, 100,  0, 99, 99},
585                 { "Your home",                          0,      100, 100,  0, 99, 99},
586                 { "Your home",                          0,      100, 100,  0, 99, 99},
587                 { "Your home",                          0,      100, 100,  0, 99, 99},
588                 { "Your home",                          0,      100, 100,  0, 99, 99},
589                 { "Your home",                          0,      100, 100,  0, 99, 99},
590                 { "Your home",                          0,      100, 100,  0, 99, 99},
591                 { "Your home",                          0,      100, 100,  0, 99, 99},
592                 { "Your home",                          0,      100, 100,  0, 99, 99},
593                 { "Your home",                          0,      100, 100,  0, 99, 99},
594                 { "Your home",                          0,      100, 100,  0, 99, 99},
595                 { "Your home",                          0,      100, 100,  0, 99, 99},
596                 { "Your home",                          0,      100, 100,  0, 99, 99},
597                 { "Your home",                          0,      100, 100,  0, 99, 99},
598                 { "Your home",                          0,      100, 100,  0, 99, 99},
599                 { "Your home",                          0,      100, 100,  0, 99, 99},
600                 { "Your home",                          0,      100, 100,  0, 99, 99},
601                 { "Your home",                          0,      100, 100,  0, 99, 99},
602                 { "Your home",                          0,      100, 100,  0, 99, 99},
603                 { "Your home",                          0,      100, 100,  0, 99, 99},
604                 { "Your home",                          0,      100, 100,  0, 99, 99},
605                 { "Your home",                          0,      100, 100,  0, 99, 99},
606                 { "Your home",                          0,      100, 100,  0, 99, 99},
607                 { "Your home",                          0,      100, 100,  0, 99, 99},
608                 { "Your home",                          0,      100, 100,  0, 99, 99},
609                 { "Your home",                          0,      100, 100,  0, 99, 99},
610 #endif
611
612         },
613
614         {
615                 /* Bookstore - 21 unique names */
616 #ifdef JP
617                 { "強欲ドラフ", 10000, 175, 108, 4, 12, RACE_HUMAN},
618                 { "賢者オドナー", 15000, 120, 105, 6, 16, RACE_HIGH_ELF},
619                 { "中立のガンダー", 25000, 120, 110, 7, 19, RACE_DARK_ELF},
620                 { "忍耐の人ロ=シャ", 30000, 140, 105, 6, 12, RACE_ELF},
621                 { "ランドルフ・カーター", 15000, 175, 108, 4, 12, RACE_HUMAN},
622                 { "隼のサライ", 15000, 175, 108, 4, 12, RACE_HUMAN},
623                 { "千里眼ボドリル", 20000, 120, 105, 6, 16, RACE_HIGH_ELF},
624                 { "沈黙のヴェオロイン", 25000, 120, 110, 7, 19, RACE_ZOMBIE},
625                 { "学者のヴァンシラス", 30000, 140, 105, 6, 12, RACE_MIND_FLAYER},
626                 { "物書きオセイン", 15000, 175, 108, 4, 12, RACE_SKELETON},
627                 { "本の虫オルヴァー", 20000, 120, 105, 6, 16, RACE_VAMPIRE},
628                 { "浅井墓男", 25000, 120, 110, 7, 19, RACE_ZOMBIE},
629                 { "デスマスク", 30000, 140, 105, 6, 12, RACE_ZOMBIE},
630                 { "学者のアスーヌ", 15000, 175, 108, 4, 12, RACE_MIND_FLAYER},
631                 { "死人のプリランド", 20000, 120, 105, 6, 16, RACE_ZOMBIE},
632                 { "鉄のロナール", 25000, 120, 110, 7, 19, RACE_GOLEM},
633 #else
634                 { "Dolaf the Greedy", 10000, 175, 108, 4, 12, RACE_HUMAN},
635                 { "Odnar the Sage", 15000, 120, 105, 6, 16, RACE_HIGH_ELF},
636                 { "Gandar the Neutral", 25000, 120, 110, 7, 19, RACE_DARK_ELF},
637                 { "Ro-sha the Patient", 30000, 140, 105, 6, 12, RACE_ELF},
638                 { "Randolph Carter", 15000, 175, 108, 4, 12, RACE_HUMAN},
639                 { "Sarai the Swift", 15000, 175, 108, 4, 12, RACE_HUMAN},
640                 { "Bodril the Seer", 20000, 120, 105, 6, 16, RACE_HIGH_ELF},
641                 { "Veloin the Quiet", 25000, 120, 110, 7, 19, RACE_ZOMBIE},
642                 { "Vanthylas the Learned", 30000, 140, 105, 6, 12, RACE_MIND_FLAYER},
643                 { "Ossein the Literate", 15000, 175, 108, 4, 12, RACE_SKELETON},
644                 { "Olvar Bookworm", 20000, 120, 105, 6, 16, RACE_VAMPIRE},
645                 { "Shallowgrave", 25000, 120, 110, 7, 19, RACE_ZOMBIE},
646                 { "Death Mask", 30000, 140, 105, 6, 12, RACE_ZOMBIE},
647                 { "Asuunu the Learned", 15000, 175, 108, 4, 12, RACE_MIND_FLAYER},
648                 { "Prirand the Dead", 20000, 120, 105, 6, 16, RACE_ZOMBIE},
649                 { "Ronar the Iron", 25000, 120, 110, 7, 19, RACE_GOLEM},
650 #endif
651 #ifdef JP
652                 { "ガリル=ガミル", 30000, 140, 105, 6, 12, RACE_ELF},
653                 { "本食いローバグ", 15000, 175, 108, 4, 12, RACE_KOBOLD},
654                 { "キリアリキーク", 20000, 120, 105, 6, 16, RACE_KLACKON},
655                 { "静かなるリリン", 25000, 120, 110, 7, 19, RACE_DWARF},
656                 { "王者イサング", 30000, 140, 105, 6, 12, RACE_HIGH_ELF},
657                 { "強欲ドラフ", 10000, 175, 108, 4, 12, RACE_HUMAN},
658                 { "賢者オドナー", 15000, 120, 105, 6, 16, RACE_HIGH_ELF},
659                 { "中立のガンダー", 25000, 120, 110, 7, 19, RACE_DARK_ELF},
660                 { "忍耐の人ロ=シャ", 30000, 140, 105, 6, 12, RACE_ELF},
661                 { "ランドルフ・カーター", 15000, 175, 108, 4, 12, RACE_HUMAN},
662                 { "隼サライ", 15000, 175, 108, 4, 12, RACE_HUMAN},
663                 { "千里眼ボドリル", 20000, 120, 105, 6, 16, RACE_HIGH_ELF},
664                 { "沈黙のヴェオロイン", 25000, 120, 110, 7, 19, RACE_ZOMBIE},
665                 { "学者のヴァンシラス", 30000, 140, 105, 6, 12, RACE_MIND_FLAYER},
666                 { "物書きオセイン", 15000, 175, 108, 4, 12, RACE_SKELETON},
667                 { "本の虫オルヴァー", 20000, 120, 105, 6, 16, RACE_VAMPIRE},
668 #else
669                 { "Galil-Gamir", 30000, 140, 105, 6, 12, RACE_ELF},
670                 { "Rorbag Book-Eater", 15000, 175, 108, 4, 12, RACE_KOBOLD},
671                 { "Kiriarikirk", 20000, 120, 105, 6, 16, RACE_KLACKON},
672                 { "Rilin the Quiet", 25000, 120, 110, 7, 19, RACE_DWARF},
673                 { "Isung the Lord", 30000, 140, 105, 6, 12, RACE_HIGH_ELF},
674                 { "Dolaf the Greedy", 10000, 175, 108, 4, 12, RACE_HUMAN},
675                 { "Odnar the Sage", 15000, 120, 105, 6, 16, RACE_HIGH_ELF},
676                 { "Gandar the Neutral", 25000, 120, 110, 7, 19, RACE_DARK_ELF},
677                 { "Ro-sha the Patient", 30000, 140, 105, 6, 12, RACE_ELF},
678                 { "Randolph Carter", 15000, 175, 108, 4, 12, RACE_HUMAN},
679                 { "Sarai the Swift", 15000, 175, 108, 4, 12, RACE_HUMAN},
680                 { "Bodril the Seer", 20000, 120, 105, 6, 16, RACE_HIGH_ELF},
681                 { "Veloin the Quiet", 25000, 120, 110, 7, 19, RACE_ZOMBIE},
682                 { "Vanthylas the Learned", 30000, 140, 105, 6, 12, RACE_MIND_FLAYER},
683                 { "Ossein the Literate", 15000, 175, 108, 4, 12, RACE_SKELETON},
684                 { "Olvar Bookworm", 20000, 120, 105, 6, 16, RACE_VAMPIRE},
685 #endif
686         },
687
688         {
689                 /* Museum */
690 #ifdef JP
691                 { "博物館",                          0,      100, 100,  0, 99, 99},
692                 { "博物館",                          0,      100, 100,  0, 99, 99},
693                 { "博物館",                          0,      100, 100,  0, 99, 99},
694                 { "博物館",                          0,      100, 100,  0, 99, 99},
695                 { "博物館",                          0,      100, 100,  0, 99, 99},
696                 { "博物館",                          0,      100, 100,  0, 99, 99},
697                 { "博物館",                          0,      100, 100,  0, 99, 99},
698                 { "博物館",                          0,      100, 100,  0, 99, 99},
699                 { "博物館",                          0,      100, 100,  0, 99, 99},
700                 { "博物館",                          0,      100, 100,  0, 99, 99},
701                 { "博物館",                          0,      100, 100,  0, 99, 99},
702                 { "博物館",                          0,      100, 100,  0, 99, 99},
703                 { "博物館",                          0,      100, 100,  0, 99, 99},
704                 { "博物館",                          0,      100, 100,  0, 99, 99},
705                 { "博物館",                          0,      100, 100,  0, 99, 99},
706                 { "博物館",                          0,      100, 100,  0, 99, 99},
707                 { "博物館",                          0,      100, 100,  0, 99, 99},
708                 { "博物館",                          0,      100, 100,  0, 99, 99},
709                 { "博物館",                          0,      100, 100,  0, 99, 99},
710                 { "博物館",                          0,      100, 100,  0, 99, 99},
711                 { "博物館",                          0,      100, 100,  0, 99, 99},
712                 { "博物館",                          0,      100, 100,  0, 99, 99},
713                 { "博物館",                          0,      100, 100,  0, 99, 99},
714                 { "博物館",                          0,      100, 100,  0, 99, 99},
715                 { "博物館",                          0,      100, 100,  0, 99, 99},
716                 { "博物館",                          0,      100, 100,  0, 99, 99},
717                 { "博物館",                          0,      100, 100,  0, 99, 99},
718                 { "博物館",                          0,      100, 100,  0, 99, 99},
719                 { "博物館",                          0,      100, 100,  0, 99, 99},
720                 { "博物館",                          0,      100, 100,  0, 99, 99},
721                 { "博物館",                          0,      100, 100,  0, 99, 99},
722                 { "博物館",                          0,      100, 100,  0, 99, 99},
723 #else
724                 { "Museum",                          0,      100, 100,  0, 99, 99},
725                 { "Museum",                          0,      100, 100,  0, 99, 99},
726                 { "Museum",                          0,      100, 100,  0, 99, 99},
727                 { "Museum",                          0,      100, 100,  0, 99, 99},
728                 { "Museum",                          0,      100, 100,  0, 99, 99},
729                 { "Museum",                          0,      100, 100,  0, 99, 99},
730                 { "Museum",                          0,      100, 100,  0, 99, 99},
731                 { "Museum",                          0,      100, 100,  0, 99, 99},
732                 { "Museum",                          0,      100, 100,  0, 99, 99},
733                 { "Museum",                          0,      100, 100,  0, 99, 99},
734                 { "Museum",                          0,      100, 100,  0, 99, 99},
735                 { "Museum",                          0,      100, 100,  0, 99, 99},
736                 { "Museum",                          0,      100, 100,  0, 99, 99},
737                 { "Museum",                          0,      100, 100,  0, 99, 99},
738                 { "Museum",                          0,      100, 100,  0, 99, 99},
739                 { "Museum",                          0,      100, 100,  0, 99, 99},
740                 { "Museum",                          0,      100, 100,  0, 99, 99},
741                 { "Museum",                          0,      100, 100,  0, 99, 99},
742                 { "Museum",                          0,      100, 100,  0, 99, 99},
743                 { "Museum",                          0,      100, 100,  0, 99, 99},
744                 { "Museum",                          0,      100, 100,  0, 99, 99},
745                 { "Museum",                          0,      100, 100,  0, 99, 99},
746                 { "Museum",                          0,      100, 100,  0, 99, 99},
747                 { "Museum",                          0,      100, 100,  0, 99, 99},
748                 { "Museum",                          0,      100, 100,  0, 99, 99},
749                 { "Museum",                          0,      100, 100,  0, 99, 99},
750                 { "Museum",                          0,      100, 100,  0, 99, 99},
751                 { "Museum",                          0,      100, 100,  0, 99, 99},
752                 { "Museum",                          0,      100, 100,  0, 99, 99},
753                 { "Museum",                          0,      100, 100,  0, 99, 99},
754                 { "Museum",                          0,      100, 100,  0, 99, 99},
755                 { "Museum",                          0,      100, 100,  0, 99, 99},
756 #endif
757
758         },
759
760 };
761
762 static int cur_store_num = 0;
763 static int store_top = 0;
764 static int store_bottom = 0;
765 static int xtra_stock = 0;
766 static store_type *st_ptr = NULL;
767 static const owner_type *ot_ptr = NULL;
768 static s16b old_town_num = 0;
769 static s16b inner_town_num = 0;
770 #define RUMOR_CHANCE 8
771
772 #define MAX_COMMENT_1   6
773
774 static concptr comment_1[MAX_COMMENT_1] =
775 {
776 #ifdef JP
777         "オーケーだ。",
778         "結構だ。",
779         "そうしよう!",
780         "賛成だ!",
781         "よし!",
782         "わかった!"
783 #else
784         "Okay.",
785         "Fine.",
786         "Accepted!",
787         "Agreed!",
788         "Done!",
789         "Taken!"
790 #endif
791
792 };
793
794 #ifdef JP
795 /*! ブラックマーケット追加メッセージ(承諾) */
796 static concptr comment_1_B[MAX_COMMENT_1] = {
797         "まあ、それでいいや。",
798         "今日はそれで勘弁してやる。",
799         "分かったよ。",
800         "しょうがない。",
801         "それで我慢するよ。",
802         "こんなもんだろう。"
803 };
804 #endif
805 #define MAX_COMMENT_2A  2
806
807 static concptr comment_2a[MAX_COMMENT_2A] =
808 {
809 #ifdef JP
810         "私の忍耐力を試しているのかい? $%s が最後だ。",
811         "我慢にも限度があるぞ。 $%s が最後だ。"
812 #else
813         "You try my patience.  %s is final.",
814         "My patience grows thin.  %s is final."
815 #endif
816
817 };
818
819 #define MAX_COMMENT_2B  12
820
821 static concptr comment_2b[MAX_COMMENT_2B] =
822 {
823 #ifdef JP
824         " $%s ぐらいは出さなきゃダメだよ。",
825         " $%s なら受け取ってもいいが。",
826         "ハ! $%s 以下はないね。",
827         "何て奴だ! $%s 以下はあり得ないぞ。",
828         "それじゃ少なすぎる! $%s は欲しいところだ。",
829         "バカにしている! $%s はもらわないと。",
830         "嘘だろう! $%s でどうだい?",
831         "おいおい! $%s を考えてくれないか?",
832         "1000匹のオークのノミに苦しめられるがいい! $%s だ。",
833         "お前の大切なものに災いあれ! $%s でどうだ。",
834         "モルゴスに賞味されるがいい!本当は $%s なんだろう?",
835         "お前の母親はオーガか! $%s は出すつもりなんだろ?"
836 #else
837         "I can take no less than %s gold pieces.",
838         "I will accept no less than %s gold pieces.",
839         "Ha!  No less than %s gold pieces.",
840         "You knave!  No less than %s gold pieces.",
841         "That's a pittance!  I want %s gold pieces.",
842         "That's an insult!  I want %s gold pieces.",
843         "As if!  How about %s gold pieces?",
844         "My arse!  How about %s gold pieces?",
845         "May the fleas of 1000 orcs molest you!  Try %s gold pieces.",
846         "May your most favourite parts go moldy!  Try %s gold pieces.",
847         "May Morgoth find you tasty!  Perhaps %s gold pieces?",
848         "Your mother was an Ogre!  Perhaps %s gold pieces?"
849 #endif
850
851 };
852
853 #ifdef JP
854 /*! ブラックマーケット用追加メッセージ(売るとき) */
855 static concptr comment_2b_B[MAX_COMMENT_2B] = {
856         "いくら俺様がお人好しとはいえ $%s が限界だね。嫌なら帰りな。",
857         "金がないのかい、あんた?まずは家に帰って $%s 揃えてきな。",
858         "物の価値が分からん奴だな。これは $%s が普通なんだよ。",
859         "俺の付けた値段に文句があるのか? $%s が限界だ。",
860         "ひょっとして新手の冗談かい? $%s 持ってないなら帰りな。",
861         "うちは他の店とは違うんだよ。$%s ぐらいは出しな。",
862         "買う気がないなら帰りな。 $%s だと言っているんだ。",
863         "話にならないね。 $%s くらい持っているんだろ?",
864         "は?なんだそりゃ? $%s の間違いか、ひょっとして?",
865         "出口はあっちだよ。それとも $%s 出せるのかい、あんたに。",
866         "命知らずな奴だな。 $%s 出せば今日の所は勘弁してやるよ。",
867         "うちの店は貧乏人お断りだ。 $%s ぐらい出せないのかい?"
868 };
869 #endif
870 #define MAX_COMMENT_3A  2
871
872 static concptr comment_3a[MAX_COMMENT_3A] =
873 {
874 #ifdef JP
875         "私の忍耐力を試しているのかい? $%s が最後だ。",
876         "我慢にも限度があるぞ。 $%s が最後だ。"
877 #else
878         "You try my patience.  %s is final.",
879         "My patience grows thin.  %s is final."
880 #endif
881
882 };
883
884
885 #define MAX_COMMENT_3B  12
886
887 static concptr comment_3b[MAX_COMMENT_3B] =
888 {
889 #ifdef JP
890         "本音を言うと $%s でいいんだろ?",
891         " $%s でどうだい?",
892         " $%s ぐらいなら出してもいいが。",
893         " $%s 以上払うなんて考えられないね。",
894         "まあ落ちついて。 $%s でどうだい?",
895         "そのガラクタなら $%s で引き取るよ。",
896         "それじゃ高すぎる! $%s がいいとこだろ。",
897         "どうせいらないんだろ! $%s でいいだろ?",
898         "だめだめ! $%s がずっとお似合いだよ。",
899         "バカにしている! $%s がせいぜいだ。",
900         " $%s なら嬉しいところだがなあ。",
901         " $%s 、それ以上はビタ一文出さないよ!"
902 #else
903         "Perhaps %s gold pieces?",
904         "How about %s gold pieces?",
905         "I will pay no more than %s gold pieces.",
906         "I can afford no more than %s gold pieces.",
907         "Be reasonable.  How about %s gold pieces?",
908         "I'll buy it as scrap for %s gold pieces.",
909         "That is too much!  How about %s gold pieces?",
910         "That looks war surplus!  Say %s gold pieces?",
911         "Never!  %s is more like it.",
912         "That's an insult!  %s is more like it.",
913         "%s gold pieces and be thankful for it!",
914         "%s gold pieces and not a copper more!"
915 #endif
916
917 };
918
919 #ifdef JP
920 /*! ブラックマーケット用追加メッセージ(買い取り) */
921 static concptr comment_3b_B[MAX_COMMENT_3B] = {
922         " $%s ってところだね。そのどうしようもないガラクタは。",
923         "この俺が $%s って言っているんだから、その通りにした方が身のためだぞ。",
924         "俺の優しさに甘えるのもいい加減にしておけ。 $%s だ。",
925         "その品なら $%s で売ってくれているがね、常識ある紳士はみんな。",
926         "こりゃまた、がめつい奴だな。いくら俺が温厚とはいえ $%s が限界だ。",
927         " $%s だ。別に俺はそんなガラクタ欲しくはないんだから。",
928         "俺の鑑定額が気に入らないのか? $%s 、嫌なら帰りな。",
929         " $%s で引き取ってやるよ。喜んで受け取りな、貧乏人。",
930         "物の価値が分からん奴は始末におえんな。それは $%s なんだよ。",
931         "そんなに金が欲しいのか、あんた? $%s で満足できんのか?",
932         "入る店間違えてんじゃないのか? $%s で嫌なら他をあたってくれ。",
933         "俺の言い値にケチをつける奴がいるとは! その度胸に免じて $%s だ。"
934 };
935 #endif
936 #define MAX_COMMENT_4A  4
937
938 static concptr comment_4a[MAX_COMMENT_4A] =
939 {
940 #ifdef JP
941         "もうたくさんだ!何度も私をわずらわせないでくれ!",
942         "うがー!一日の我慢の限度を超えている!",
943         "もういい!時間の無駄以外のなにものでもない!",
944         "もうやってられないよ!顔も見たくない!"
945 #else
946         "Enough!  You have abused me once too often!",
947         "Arghhh!  I have had enough abuse for one day!",
948         "That does it!  You shall waste my time no more!",
949         "This is getting nowhere!  I'm going to Londis!"
950 #endif
951
952 };
953
954 #ifdef JP
955 /*! ブラックマーケット用追加メッセージ(怒りの頂点) */
956 static concptr comment_4a_B[MAX_COMMENT_4A] = {
957         "なめやがって!温厚な俺様でも限界があるってことを知れ!",
958         "俺をここまで怒らせて...命があるだけでもありがたいと思え!",
959         "ふざけてるのか!冷やかしなら相手を見てからにしろ!",
960         "いいかげんにしろ!今度こんなまねしたらただじゃおかねえぞ!"
961 };
962 #endif
963 #define MAX_COMMENT_4B  4
964
965 static concptr comment_4b[MAX_COMMENT_4B] =
966 {
967 #ifdef JP
968         "店から出て行け!",
969         "俺の前から消え失せろ!",
970         "どっかに行っちまえ!",
971         "出ろ、出ろ、出て行け!"
972 #else
973         "Leave my store!",
974         "Get out of my sight!",
975         "Begone, you scoundrel!",
976         "Out, out, out!"
977 #endif
978
979 };
980
981 #ifdef JP
982 /*! ブラックマーケット用追加メッセージ(追い出し) */
983 static concptr comment_4b_B[MAX_COMMENT_4B] = {
984         "二度とうちに来るんじゃねえ!!",
985         "とっとと、どっかへ失せろ!!",
986         "今すぐ消え失せろ!!",
987         "出ていけ!出ていけ!!"
988 };
989 #endif
990 #define MAX_COMMENT_5   8
991
992 static concptr comment_5[MAX_COMMENT_5] =
993 {
994 #ifdef JP
995         "考え直してくれ。",
996         "そりゃおかしい!",
997         "もっと真面目に言ってくれ!",
998         "交渉する気があるのかい?",
999         "冷やかしに来たのか!",
1000         "悪い冗談だ!",
1001         "我慢くらべかい。",
1002         "ふーむ、良い天気だ。"
1003 #else
1004         "Try again.",
1005         "Ridiculous!",
1006         "You will have to do better than that!",
1007         "Do you wish to do business or not?",
1008         "You've got to be kidding!",
1009         "You'd better be kidding!",
1010         "You try my patience.",
1011         "Hmmm, nice weather we're having."
1012 #endif
1013
1014 };
1015
1016 #ifdef JP
1017 /*! ブラックマーケット用追加メッセージ(怒り) */
1018 static concptr comment_5_B[MAX_COMMENT_5] = {
1019         "時間の無駄だな、これは。",
1020         "厄介なお客様だな!",
1021         "話して分かる相手じゃなさそうだ。",
1022         "痛い目にあいたいらしいな!",
1023         "なんて強欲な奴だ!",
1024         "話にならん輩だ!",
1025         "どうしようもない貧乏人だ!",
1026         "喧嘩を売っているのか?"
1027 };
1028 #endif
1029 #define MAX_COMMENT_6   4
1030
1031 static concptr comment_6[MAX_COMMENT_6] =
1032 {
1033 #ifdef JP
1034         "どうやら聞き間違えたらしい。",
1035         "失礼、よく聞こえなかったよ。",
1036         "すまない、何だって?",
1037         "悪い、もう一度言ってくれる?"
1038 #else
1039         "I must have heard you wrong.",
1040         "I'm sorry, I missed that.",
1041         "I'm sorry, what was that?",
1042         "Sorry, what was that again?"
1043 #endif
1044
1045 };
1046
1047 /*** Initialize others ***/
1048
1049 /*!
1050  * 店舗で販売するオブジェクトを定義する / Hack -- Objects sold in the stores -- by tval/sval pair.
1051  */
1052 byte store_table[MAX_STORES][STORE_CHOICES][2] =
1053 {
1054         {
1055                 /* General Store */
1056
1057                 { TV_FOOD, SV_FOOD_RATION },
1058                 { TV_FOOD, SV_FOOD_RATION },
1059                 { TV_FOOD, SV_FOOD_RATION },
1060                 { TV_FOOD, SV_FOOD_RATION },
1061
1062                 { TV_FOOD, SV_FOOD_RATION },
1063                 { TV_FOOD, SV_FOOD_BISCUIT },
1064                 { TV_FOOD, SV_FOOD_JERKY },
1065                 { TV_FOOD, SV_FOOD_JERKY },
1066
1067                 { TV_FOOD, SV_FOOD_PINT_OF_WINE },
1068                 { TV_FOOD, SV_FOOD_PINT_OF_ALE },
1069                 { TV_LITE, SV_LITE_TORCH },
1070                 { TV_LITE, SV_LITE_TORCH },
1071
1072                 { TV_LITE, SV_LITE_TORCH },
1073                 { TV_LITE, SV_LITE_TORCH },
1074                 { TV_LITE, SV_LITE_LANTERN },
1075                 { TV_LITE, SV_LITE_LANTERN },
1076
1077                 { TV_FLASK, 0 },
1078                 { TV_FLASK, 0 },
1079                 { TV_FLASK, 0 },
1080                 { TV_FLASK, 0 },
1081
1082                 { TV_FLASK, 0 },
1083                 { TV_FLASK, 0 },
1084                 { TV_SPIKE, 0 },
1085                 { TV_SPIKE, 0 },
1086
1087                 { TV_SHOT, SV_AMMO_NORMAL },
1088                 { TV_ARROW, SV_AMMO_NORMAL },
1089                 { TV_BOLT, SV_AMMO_NORMAL },
1090                 { TV_DIGGING, SV_SHOVEL },
1091
1092                 { TV_DIGGING, SV_PICK },
1093                 { TV_CLOAK, SV_CLOAK },
1094                 { TV_CLOAK, SV_CLOAK },
1095                 { TV_CLOAK, SV_FUR_CLOAK },
1096
1097                 { TV_FOOD, SV_FOOD_RATION },
1098                 { TV_FOOD, SV_FOOD_RATION },
1099                 { TV_FOOD, SV_FOOD_RATION },
1100                 { TV_FOOD, SV_FOOD_RATION },
1101
1102                 { TV_POTION, SV_POTION_WATER },
1103                 { TV_POTION, SV_POTION_WATER },
1104                 { TV_LITE, SV_LITE_LANTERN },
1105                 { TV_LITE, SV_LITE_LANTERN },
1106
1107                 { TV_FOOD, SV_FOOD_WAYBREAD },
1108                 { TV_FOOD, SV_FOOD_WAYBREAD },
1109                 { TV_CAPTURE, 0 },
1110                 { TV_FIGURINE, 0 },
1111
1112                 { TV_SHOT, SV_AMMO_NORMAL },
1113                 { TV_ARROW, SV_AMMO_NORMAL },
1114                 { TV_BOLT, SV_AMMO_NORMAL },
1115                 { TV_DIGGING, SV_SHOVEL }
1116         },
1117
1118         {
1119                 /* Armoury */
1120
1121                 { TV_BOOTS, SV_PAIR_OF_SOFT_LEATHER_BOOTS },
1122                 { TV_BOOTS, SV_PAIR_OF_SOFT_LEATHER_BOOTS },
1123                 { TV_BOOTS, SV_PAIR_OF_HARD_LEATHER_BOOTS },
1124                 { TV_BOOTS, SV_PAIR_OF_HARD_LEATHER_BOOTS },
1125
1126                 { TV_HELM, SV_HARD_LEATHER_CAP },
1127                 { TV_HELM, SV_HARD_LEATHER_CAP },
1128                 { TV_HELM, SV_METAL_CAP },
1129                 { TV_HELM, SV_IRON_HELM },
1130
1131                 { TV_SOFT_ARMOR, SV_ROBE },
1132                 { TV_SOFT_ARMOR, SV_ROBE },
1133                 { TV_SOFT_ARMOR, SV_SOFT_LEATHER_ARMOR },
1134                 { TV_SOFT_ARMOR, SV_SOFT_LEATHER_ARMOR },
1135
1136                 { TV_SOFT_ARMOR, SV_HARD_LEATHER_ARMOR },
1137                 { TV_SOFT_ARMOR, SV_HARD_LEATHER_ARMOR },
1138                 { TV_SOFT_ARMOR, SV_HARD_STUDDED_LEATHER },
1139                 { TV_SOFT_ARMOR, SV_HARD_STUDDED_LEATHER },
1140
1141                 { TV_SOFT_ARMOR, SV_RHINO_HIDE_ARMOR },
1142                 { TV_SOFT_ARMOR, SV_LEATHER_SCALE_MAIL },
1143                 { TV_HARD_ARMOR, SV_METAL_SCALE_MAIL },
1144                 { TV_HARD_ARMOR, SV_CHAIN_MAIL },
1145
1146                 { TV_HARD_ARMOR, SV_DOUBLE_RING_MAIL },
1147                 { TV_HARD_ARMOR, SV_AUGMENTED_CHAIN_MAIL },
1148                 { TV_HARD_ARMOR, SV_BAR_CHAIN_MAIL },
1149                 { TV_HARD_ARMOR, SV_DOUBLE_CHAIN_MAIL },
1150
1151                 { TV_HARD_ARMOR, SV_METAL_BRIGANDINE_ARMOUR },
1152                 { TV_HARD_ARMOR, SV_SPLINT_MAIL },
1153                 { TV_GLOVES, SV_SET_OF_LEATHER_GLOVES },
1154                 { TV_GLOVES, SV_SET_OF_LEATHER_GLOVES },
1155
1156                 { TV_GLOVES, SV_SET_OF_GAUNTLETS },
1157                 { TV_SHIELD, SV_SMALL_LEATHER_SHIELD },
1158                 { TV_SHIELD, SV_LARGE_LEATHER_SHIELD },
1159                 { TV_SHIELD, SV_SMALL_METAL_SHIELD },
1160
1161                 { TV_BOOTS, SV_PAIR_OF_HARD_LEATHER_BOOTS },
1162                 { TV_BOOTS, SV_PAIR_OF_HARD_LEATHER_BOOTS },
1163                 { TV_HELM, SV_HARD_LEATHER_CAP },
1164                 { TV_HELM, SV_HARD_LEATHER_CAP },
1165
1166                 { TV_SOFT_ARMOR, SV_ROBE },
1167                 { TV_SOFT_ARMOR, SV_SOFT_LEATHER_ARMOR },
1168                 { TV_SOFT_ARMOR, SV_SOFT_LEATHER_ARMOR },
1169                 { TV_SOFT_ARMOR, SV_HARD_LEATHER_ARMOR },
1170
1171                 { TV_SOFT_ARMOR, SV_LEATHER_JACK },
1172                 { TV_HARD_ARMOR, SV_METAL_SCALE_MAIL },
1173                 { TV_HARD_ARMOR, SV_CHAIN_MAIL },
1174                 { TV_HARD_ARMOR, SV_CHAIN_MAIL },
1175
1176                 { TV_GLOVES, SV_SET_OF_LEATHER_GLOVES },
1177                 { TV_GLOVES, SV_SET_OF_GAUNTLETS },
1178                 { TV_SHIELD, SV_SMALL_LEATHER_SHIELD },
1179                 { TV_SHIELD, SV_SMALL_LEATHER_SHIELD }
1180         },
1181
1182         {
1183                 /* Weaponsmith */
1184
1185                 { TV_SWORD, SV_DAGGER },
1186                 { TV_SWORD, SV_MAIN_GAUCHE },
1187                 { TV_SWORD, SV_RAPIER },
1188                 { TV_SWORD, SV_SMALL_SWORD },
1189
1190                 { TV_SWORD, SV_SHORT_SWORD },
1191                 { TV_SWORD, SV_SABRE },
1192                 { TV_SWORD, SV_CUTLASS },
1193                 { TV_SWORD, SV_TULWAR },
1194
1195                 { TV_SWORD, SV_BROAD_SWORD },
1196                 { TV_SWORD, SV_LONG_SWORD },
1197                 { TV_SWORD, SV_SCIMITAR },
1198                 { TV_SWORD, SV_KATANA },
1199
1200                 { TV_SWORD, SV_BASTARD_SWORD },
1201                 { TV_POLEARM, SV_SPEAR },
1202                 { TV_POLEARM, SV_AWL_PIKE },
1203                 { TV_POLEARM, SV_TRIDENT },
1204
1205                 { TV_POLEARM, SV_PIKE },
1206                 { TV_POLEARM, SV_BEAKED_AXE },
1207                 { TV_POLEARM, SV_BROAD_AXE },
1208                 { TV_POLEARM, SV_LANCE },
1209
1210                 { TV_POLEARM, SV_BATTLE_AXE },
1211                 { TV_POLEARM, SV_HATCHET },
1212                 { TV_BOW, SV_SLING },
1213                 { TV_BOW, SV_SHORT_BOW },
1214
1215                 { TV_BOW, SV_LIGHT_XBOW },
1216                 { TV_SHOT, SV_AMMO_NORMAL },
1217                 { TV_SHOT, SV_AMMO_NORMAL },
1218                 { TV_ARROW, SV_AMMO_NORMAL },
1219
1220                 { TV_ARROW, SV_AMMO_NORMAL },
1221                 { TV_BOLT, SV_AMMO_NORMAL },
1222                 { TV_BOLT, SV_AMMO_NORMAL },
1223                 { TV_BOW, SV_LIGHT_XBOW },
1224
1225                 { TV_ARROW, SV_AMMO_NORMAL },
1226                 { TV_BOLT, SV_AMMO_NORMAL },
1227                 { TV_BOW, SV_SHORT_BOW },
1228                 { TV_BOW, SV_LIGHT_XBOW },
1229
1230                 { TV_SWORD, SV_DAGGER },
1231                 { TV_SWORD, SV_TANTO },
1232                 { TV_SWORD, SV_RAPIER },
1233                 { TV_SWORD, SV_SMALL_SWORD },
1234
1235                 { TV_SWORD, SV_SHORT_SWORD },
1236                 { TV_SWORD, SV_LONG_SWORD },
1237                 { TV_SWORD, SV_SCIMITAR },
1238                 { TV_SWORD, SV_BROAD_SWORD },
1239
1240                 { TV_HISSATSU_BOOK, 0 },
1241                 { TV_HISSATSU_BOOK, 0 },
1242                 { TV_HISSATSU_BOOK, 1 },
1243                 { TV_HISSATSU_BOOK, 1 },
1244         },
1245
1246         {
1247                 /* Temple */
1248
1249                 { TV_HAFTED, SV_NUNCHAKU },
1250                 { TV_HAFTED, SV_QUARTERSTAFF },
1251                 { TV_HAFTED, SV_MACE },
1252                 { TV_HAFTED, SV_BO_STAFF },
1253
1254                 { TV_HAFTED, SV_WAR_HAMMER },
1255                 { TV_HAFTED, SV_WAR_HAMMER },
1256                 { TV_HAFTED, SV_MORNING_STAR },
1257                 { TV_HAFTED, SV_FLAIL },
1258
1259                 { TV_HAFTED, SV_LEAD_FILLED_MACE },
1260                 { TV_SCROLL, SV_SCROLL_REMOVE_CURSE },
1261                 { TV_SCROLL, SV_SCROLL_BLESSING },
1262                 { TV_SCROLL, SV_SCROLL_HOLY_CHANT },
1263
1264                 { TV_POTION, SV_POTION_HEROISM },
1265                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1266                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1267                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1268
1269                 { TV_POTION, SV_POTION_CURE_LIGHT },
1270                 { TV_POTION, SV_POTION_CURE_SERIOUS },
1271                 { TV_POTION, SV_POTION_CURE_SERIOUS },
1272                 { TV_POTION, SV_POTION_CURE_CRITICAL },
1273
1274                 { TV_POTION, SV_POTION_CURE_CRITICAL },
1275                 { TV_POTION, SV_POTION_RESTORE_EXP },
1276                 { TV_POTION, SV_POTION_RESTORE_EXP },
1277                 { TV_POTION, SV_POTION_RESTORE_EXP },
1278
1279                 { TV_LIFE_BOOK, 0 },
1280                 { TV_LIFE_BOOK, 0 },
1281                 { TV_LIFE_BOOK, 1 },
1282                 { TV_LIFE_BOOK, 1 },
1283
1284                 { TV_CRUSADE_BOOK, 0 },
1285                 { TV_CRUSADE_BOOK, 0 },
1286                 { TV_CRUSADE_BOOK, 1 },
1287                 { TV_CRUSADE_BOOK, 1 },
1288
1289                 { TV_HAFTED, SV_WHIP },
1290                 { TV_HAFTED, SV_MACE },
1291                 { TV_HAFTED, SV_BALL_AND_CHAIN },
1292                 { TV_HAFTED, SV_WAR_HAMMER },
1293
1294                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1295                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1296                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1297                 { TV_POTION, SV_POTION_CURE_CRITICAL },
1298
1299                 { TV_POTION, SV_POTION_CURE_CRITICAL },
1300                 { TV_POTION, SV_POTION_RESTORE_EXP },
1301
1302                 { TV_FIGURINE, 0 },
1303                 { TV_STATUE, SV_ANY },
1304
1305                 { TV_SCROLL, SV_SCROLL_REMOVE_CURSE },
1306                 { TV_SCROLL, SV_SCROLL_REMOVE_CURSE },
1307                 { TV_SCROLL, SV_SCROLL_STAR_REMOVE_CURSE },
1308                 { TV_SCROLL, SV_SCROLL_STAR_REMOVE_CURSE }
1309         },
1310
1311         {
1312                 /* Alchemy shop */
1313
1314                 { TV_SCROLL, SV_SCROLL_ENCHANT_WEAPON_TO_HIT },
1315                 { TV_SCROLL, SV_SCROLL_ENCHANT_WEAPON_TO_DAM },
1316                 { TV_SCROLL, SV_SCROLL_ENCHANT_ARMOR },
1317                 { TV_SCROLL, SV_SCROLL_IDENTIFY },
1318
1319                 { TV_SCROLL, SV_SCROLL_IDENTIFY },
1320                 { TV_SCROLL, SV_SCROLL_IDENTIFY },
1321                 { TV_SCROLL, SV_SCROLL_IDENTIFY },
1322                 { TV_SCROLL, SV_SCROLL_LIGHT },
1323
1324                 { TV_SCROLL, SV_SCROLL_PHASE_DOOR },
1325                 { TV_SCROLL, SV_SCROLL_PHASE_DOOR },
1326                 { TV_SCROLL, SV_SCROLL_TELEPORT },
1327                 { TV_SCROLL, SV_SCROLL_MONSTER_CONFUSION },
1328
1329                 { TV_SCROLL, SV_SCROLL_MAPPING },
1330                 { TV_SCROLL, SV_SCROLL_DETECT_GOLD },
1331                 { TV_SCROLL, SV_SCROLL_DETECT_ITEM },
1332                 { TV_SCROLL, SV_SCROLL_DETECT_TRAP },
1333
1334                 { TV_SCROLL, SV_SCROLL_DETECT_INVIS },
1335                 { TV_SCROLL, SV_SCROLL_RECHARGING },
1336                 { TV_SCROLL, SV_SCROLL_TELEPORT },
1337                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1338
1339                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1340                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1341                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1342                 { TV_SCROLL, SV_SCROLL_TELEPORT },
1343
1344                 { TV_SCROLL, SV_SCROLL_TELEPORT },
1345                 { TV_POTION, SV_POTION_RES_STR },
1346                 { TV_POTION, SV_POTION_RES_INT },
1347                 { TV_POTION, SV_POTION_RES_WIS },
1348
1349                 { TV_POTION, SV_POTION_RES_DEX },
1350                 { TV_POTION, SV_POTION_RES_CON },
1351                 { TV_POTION, SV_POTION_RES_CHR },
1352                 { TV_SCROLL, SV_SCROLL_IDENTIFY },
1353
1354                 { TV_SCROLL, SV_SCROLL_IDENTIFY },
1355                 { TV_SCROLL, SV_SCROLL_STAR_IDENTIFY },  /* Yep, occasionally! */
1356                 { TV_SCROLL, SV_SCROLL_STAR_IDENTIFY },
1357                 { TV_SCROLL, SV_SCROLL_LIGHT },
1358
1359                 { TV_POTION, SV_POTION_RES_STR },
1360                 { TV_POTION, SV_POTION_RES_INT },
1361                 { TV_POTION, SV_POTION_RES_WIS },
1362                 { TV_POTION, SV_POTION_RES_DEX },
1363
1364                 { TV_POTION, SV_POTION_RES_CON },
1365                 { TV_POTION, SV_POTION_RES_CHR },
1366                 { TV_SCROLL, SV_SCROLL_ENCHANT_ARMOR },
1367                 { TV_SCROLL, SV_SCROLL_ENCHANT_ARMOR },
1368
1369                 { TV_SCROLL, SV_SCROLL_RECHARGING },
1370                 { TV_SCROLL, SV_SCROLL_PHASE_DOOR },
1371                 { TV_SCROLL, SV_SCROLL_ENCHANT_WEAPON_TO_HIT },
1372                 { TV_SCROLL, SV_SCROLL_ENCHANT_WEAPON_TO_DAM },
1373
1374         },
1375
1376         {
1377                 /* Magic-User store */
1378
1379                 { TV_RING, SV_RING_PROTECTION },
1380                 { TV_RING, SV_RING_LEVITATION_FALL },
1381                 { TV_RING, SV_RING_PROTECTION },
1382                 { TV_RING, SV_RING_RESIST_FIRE },
1383
1384                 { TV_RING, SV_RING_RESIST_COLD },
1385                 { TV_AMULET, SV_AMULET_CHARISMA },
1386                 { TV_RING, SV_RING_WARNING },
1387                 { TV_AMULET, SV_AMULET_RESIST_ACID },
1388
1389                 { TV_AMULET, SV_AMULET_SEARCHING },
1390                 { TV_WAND, SV_WAND_SLOW_MONSTER },
1391                 { TV_WAND, SV_WAND_CONFUSE_MONSTER },
1392                 { TV_WAND, SV_WAND_SLEEP_MONSTER },
1393
1394                 { TV_WAND, SV_WAND_MAGIC_MISSILE },
1395                 { TV_WAND, SV_WAND_STINKING_CLOUD },
1396                 { TV_WAND, SV_WAND_WONDER },
1397                 { TV_WAND, SV_WAND_DISARMING },
1398
1399                 { TV_STAFF, SV_STAFF_LITE },
1400                 { TV_STAFF, SV_STAFF_MAPPING },
1401                 { TV_STAFF, SV_STAFF_DETECT_TRAP },
1402                 { TV_STAFF, SV_STAFF_DETECT_DOOR },
1403
1404                 { TV_STAFF, SV_STAFF_DETECT_GOLD },
1405                 { TV_STAFF, SV_STAFF_DETECT_ITEM },
1406                 { TV_STAFF, SV_STAFF_DETECT_INVIS },
1407                 { TV_STAFF, SV_STAFF_DETECT_EVIL },
1408
1409                 { TV_STAFF, SV_STAFF_TELEPORTATION },
1410                 { TV_STAFF, SV_STAFF_TELEPORTATION },
1411                 { TV_STAFF, SV_STAFF_TELEPORTATION },
1412                 { TV_STAFF, SV_STAFF_TELEPORTATION },
1413
1414                 { TV_STAFF, SV_STAFF_IDENTIFY },
1415                 { TV_STAFF, SV_STAFF_IDENTIFY },
1416                 { TV_STAFF, SV_STAFF_IDENTIFY },
1417
1418                 { TV_STAFF, SV_STAFF_IDENTIFY },
1419                 { TV_STAFF, SV_STAFF_REMOVE_CURSE },
1420                 { TV_STAFF, SV_STAFF_CURE_LIGHT },
1421                 { TV_STAFF, SV_STAFF_PROBING },
1422
1423                 { TV_FIGURINE, 0 },
1424
1425                 { TV_SORCERY_BOOK, 0 },
1426                 { TV_SORCERY_BOOK, 0 },
1427                 { TV_SORCERY_BOOK, 1 },
1428                 { TV_SORCERY_BOOK, 1 },
1429
1430                 { TV_ARCANE_BOOK, 0 },
1431                 { TV_ARCANE_BOOK, 0 },
1432                 { TV_ARCANE_BOOK, 1 },
1433                 { TV_ARCANE_BOOK, 1 },
1434
1435                 { TV_ARCANE_BOOK, 2 },
1436                 { TV_ARCANE_BOOK, 2 },
1437                 { TV_ARCANE_BOOK, 3 },
1438                 { TV_ARCANE_BOOK, 3 },
1439
1440         },
1441
1442         {
1443                 /* Black Market (unused) */
1444                 { 0, 0 },
1445                 { 0, 0 },
1446                 { 0, 0 },
1447                 { 0, 0 },
1448                 { 0, 0 },
1449                 { 0, 0 },
1450                 { 0, 0 },
1451                 { 0, 0 },
1452                 { 0, 0 },
1453                 { 0, 0 },
1454                 { 0, 0 },
1455                 { 0, 0 },
1456                 { 0, 0 },
1457                 { 0, 0 },
1458                 { 0, 0 },
1459                 { 0, 0 },
1460                 { 0, 0 },
1461                 { 0, 0 },
1462                 { 0, 0 },
1463                 { 0, 0 },
1464                 { 0, 0 },
1465                 { 0, 0 },
1466                 { 0, 0 },
1467                 { 0, 0 },
1468                 { 0, 0 },
1469                 { 0, 0 },
1470                 { 0, 0 },
1471                 { 0, 0 },
1472                 { 0, 0 },
1473                 { 0, 0 },
1474                 { 0, 0 },
1475                 { 0, 0 }
1476         },
1477
1478         {
1479                 /* Home (unused) */
1480                 { 0, 0 },
1481                 { 0, 0 },
1482                 { 0, 0 },
1483                 { 0, 0 },
1484                 { 0, 0 },
1485                 { 0, 0 },
1486                 { 0, 0 },
1487                 { 0, 0 },
1488                 { 0, 0 },
1489                 { 0, 0 },
1490                 { 0, 0 },
1491                 { 0, 0 },
1492                 { 0, 0 },
1493                 { 0, 0 },
1494                 { 0, 0 },
1495                 { 0, 0 },
1496                 { 0, 0 },
1497                 { 0, 0 },
1498                 { 0, 0 },
1499                 { 0, 0 },
1500                 { 0, 0 },
1501                 { 0, 0 },
1502                 { 0, 0 },
1503                 { 0, 0 },
1504                 { 0, 0 },
1505                 { 0, 0 },
1506                 { 0, 0 },
1507                 { 0, 0 },
1508                 { 0, 0 },
1509                 { 0, 0 },
1510                 { 0, 0 },
1511                 { 0, 0 }
1512         },
1513
1514         {
1515                 /* Bookstore */
1516                 { TV_SORCERY_BOOK, 0 },
1517                 { TV_SORCERY_BOOK, 0 },
1518                 { TV_SORCERY_BOOK, 1 },
1519                 { TV_SORCERY_BOOK, 1 },
1520
1521                 { TV_NATURE_BOOK, 0 },
1522                 { TV_NATURE_BOOK, 0 },
1523                 { TV_NATURE_BOOK, 1 },
1524                 { TV_NATURE_BOOK, 1 },
1525
1526                 { TV_CHAOS_BOOK, 0 },
1527                 { TV_CHAOS_BOOK, 0 },
1528                 { TV_CHAOS_BOOK, 1 },
1529                 { TV_CHAOS_BOOK, 1 },
1530
1531                 { TV_DEATH_BOOK, 0 },
1532                 { TV_DEATH_BOOK, 0 },
1533                 { TV_DEATH_BOOK, 1 },
1534                 { TV_DEATH_BOOK, 1 },
1535
1536                 { TV_TRUMP_BOOK, 0 },           /* +16 */
1537                 { TV_TRUMP_BOOK, 0 },
1538                 { TV_TRUMP_BOOK, 1 },
1539                 { TV_TRUMP_BOOK, 1 },
1540
1541                 { TV_ARCANE_BOOK, 0 },
1542                 { TV_ARCANE_BOOK, 1 },
1543                 { TV_ARCANE_BOOK, 2 },
1544                 { TV_ARCANE_BOOK, 3 },
1545
1546                 { TV_CRAFT_BOOK, 0 },
1547                 { TV_CRAFT_BOOK, 0 },
1548                 { TV_CRAFT_BOOK, 1 },
1549                 { TV_CRAFT_BOOK, 1 },
1550
1551                 { TV_DAEMON_BOOK, 0 },
1552                 { TV_DAEMON_BOOK, 0 },
1553                 { TV_DAEMON_BOOK, 1 },
1554                 { TV_DAEMON_BOOK, 1 },
1555
1556                 { TV_MUSIC_BOOK, 0 },
1557                 { TV_MUSIC_BOOK, 0 },
1558                 { TV_MUSIC_BOOK, 1 },
1559                 { TV_MUSIC_BOOK, 1 },
1560
1561                 { TV_HEX_BOOK, 0 },
1562                 { TV_HEX_BOOK, 0 },
1563                 { TV_HEX_BOOK, 1 },
1564                 { TV_HEX_BOOK, 1 },
1565         },
1566
1567         {
1568                 /* Museum (unused) */
1569                 { 0, 0 },
1570                 { 0, 0 },
1571                 { 0, 0 },
1572                 { 0, 0 },
1573                 { 0, 0 },
1574                 { 0, 0 },
1575                 { 0, 0 },
1576                 { 0, 0 },
1577                 { 0, 0 },
1578                 { 0, 0 },
1579                 { 0, 0 },
1580                 { 0, 0 },
1581                 { 0, 0 },
1582                 { 0, 0 },
1583                 { 0, 0 },
1584                 { 0, 0 },
1585                 { 0, 0 },
1586                 { 0, 0 },
1587                 { 0, 0 },
1588                 { 0, 0 },
1589                 { 0, 0 },
1590                 { 0, 0 },
1591                 { 0, 0 },
1592                 { 0, 0 },
1593                 { 0, 0 },
1594                 { 0, 0 },
1595                 { 0, 0 },
1596                 { 0, 0 },
1597                 { 0, 0 },
1598                 { 0, 0 },
1599                 { 0, 0 },
1600                 { 0, 0 }
1601         }
1602 };
1603
1604
1605
1606 /*!
1607  * @brief 取引成功時の店主のメッセージ処理 /
1608  * Successful haggle.
1609  * @return なし
1610  */
1611 static void say_comment_1(void)
1612 {
1613 #ifdef JP
1614         /* ブラックマーケットのときは別のメッセージを出す */
1615         if ( cur_store_num == STORE_BLACK ) {
1616                 msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
1617         }
1618         else{
1619                 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
1620         }
1621 #else
1622         msg_print(comment_1[randint0(MAX_COMMENT_1)]);
1623 #endif
1624
1625
1626         if (one_in_(RUMOR_CHANCE))
1627         {
1628 #ifdef JP
1629                 msg_print("店主は耳うちした:");
1630 #else
1631                 msg_print("The shopkeeper whispers something into your ear:");
1632 #endif
1633                 display_rumor(TRUE);
1634         }
1635 }
1636
1637
1638 /*!
1639  * @brief プレイヤーがアイテムを買う時の価格代案メッセージ処理 /
1640  * Continue haggling (player is buying)
1641  * @param value 店主の提示価格
1642  * @param annoyed 店主のいらつき度
1643  * @return なし
1644  */
1645 static void say_comment_2(PRICE value, int annoyed)
1646 {
1647         char    tmp_val[80];
1648
1649         /* Prepare a string to insert */
1650         sprintf(tmp_val, "%ld", (long)value);
1651
1652         /* Final offer */
1653         if (annoyed > 0)
1654         {
1655                 /* Formatted message */
1656                 msg_format(comment_2a[randint0(MAX_COMMENT_2A)], tmp_val);
1657         }
1658
1659         /* Normal offer */
1660         else
1661         {
1662                 /* Formatted message */
1663 #ifdef JP
1664                 /* ブラックマーケットの時は別のメッセージを出す */
1665                 if ( cur_store_num == STORE_BLACK ){
1666                         msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val);
1667                 }
1668                 else{
1669                 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
1670         }
1671 #else
1672                 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
1673 #endif
1674
1675         }
1676 }
1677
1678
1679 /*!
1680  * @brief プレイヤーがアイテムを売る時の価格代案メッセージ処理 /
1681  * Continue haggling (player is selling)
1682  * @param value 店主の提示価格
1683  * @param annoyed 店主のいらつき度
1684  * @return なし
1685  */
1686 static void say_comment_3(PRICE value, int annoyed)
1687 {
1688         char    tmp_val[80];
1689
1690         /* Prepare a string to insert */
1691         sprintf(tmp_val, "%ld", (long)value);
1692
1693         /* Final offer */
1694         if (annoyed > 0)
1695         {
1696                 /* Formatted message */
1697                 msg_format(comment_3a[randint0(MAX_COMMENT_3A)], tmp_val);
1698         }
1699
1700         /* Normal offer */
1701         else
1702         {
1703                 /* Formatted message */
1704 #ifdef JP
1705                 /* ブラックマーケットの時は別のメッセージを出す */
1706                 if ( cur_store_num == STORE_BLACK ){
1707                         msg_format(comment_3b_B[randint0(MAX_COMMENT_3B)], tmp_val);
1708                 }
1709                 else{
1710                 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
1711         }
1712 #else
1713                 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
1714 #endif
1715
1716         }
1717 }
1718
1719
1720 /*!
1721  * @brief 店主がプレイヤーを追い出す時のメッセージ処理 /
1722  * Kick 'da bum out.                                    -RAK-
1723  * @return なし
1724  */
1725 static void say_comment_4(void)
1726 {
1727 #ifdef JP
1728         /* ブラックマーケットの時は別のメッセージを出す */
1729         if ( cur_store_num == STORE_BLACK ){
1730                 msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
1731                 msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
1732         }
1733         else{
1734                 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
1735                 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
1736         }
1737 #else
1738         msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
1739         msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
1740 #endif
1741
1742 }
1743
1744
1745 /*!
1746  * @brief 店主がプレイヤーに取り合わない時のメッセージ処理 /
1747  * You are insulting me
1748  * @return なし
1749  */
1750 static void say_comment_5(void)
1751 {
1752 #ifdef JP
1753         /* ブラックマーケットの時は別のメッセージを出す */
1754         if ( cur_store_num == STORE_BLACK ){
1755                 msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
1756         }
1757         else{
1758                 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
1759         }
1760 #else
1761         msg_print(comment_5[randint0(MAX_COMMENT_5)]);
1762 #endif
1763
1764 }
1765
1766
1767 /*!
1768  * @brief 店主がプレイヤーの提示を理解できなかった時のメッセージ処理 /
1769  * That makes no sense.
1770  * @return なし
1771  */
1772 static void say_comment_6(void)
1773 {
1774         msg_print(comment_6[randint0(MAX_COMMENT_6)]);
1775 }
1776
1777
1778 #define MAX_COMMENT_7A  4
1779
1780 static concptr comment_7a[MAX_COMMENT_7A] =
1781 {
1782 #ifdef JP
1783         "うわああぁぁ!",
1784         "なんてこった!",
1785         "誰かがむせび泣く声が聞こえる...。",
1786         "店主が悔しげにわめいている!"
1787 #else
1788         "Arrgghh!",
1789         "You bastard!",
1790         "You hear someone sobbing...",
1791         "The shopkeeper howls in agony!"
1792 #endif
1793
1794 };
1795
1796 #define MAX_COMMENT_7B  4
1797
1798 static concptr comment_7b[MAX_COMMENT_7B] =
1799 {
1800 #ifdef JP
1801         "くそう!",
1802         "この悪魔め!",
1803         "店主が恨めしそうに見ている。",
1804         "店主が睨んでいる。"
1805 #else
1806         "Damn!",
1807         "You fiend!",
1808         "The shopkeeper curses at you.",
1809         "The shopkeeper glares at you."
1810 #endif
1811
1812 };
1813
1814 #define MAX_COMMENT_7C  4
1815
1816 static concptr comment_7c[MAX_COMMENT_7C] =
1817 {
1818 #ifdef JP
1819         "すばらしい!",
1820         "君が天使に見えるよ!",
1821         "店主がクスクス笑っている。",
1822         "店主が大声で笑っている。"
1823 #else
1824         "Cool!",
1825         "You've made my day!",
1826         "The shopkeeper giggles.",
1827         "The shopkeeper laughs loudly."
1828 #endif
1829
1830 };
1831
1832 #define MAX_COMMENT_7D  4
1833
1834 static concptr comment_7d[MAX_COMMENT_7D] =
1835 {
1836 #ifdef JP
1837         "やっほぅ!",
1838         "こんなおいしい思いをしたら、真面目に働けなくなるなぁ。",
1839         "店主は嬉しくて跳ね回っている。",
1840         "店主は満面に笑みをたたえている。"
1841 #else
1842         "Yipee!",
1843         "I think I'll retire!",
1844         "The shopkeeper jumps for joy.",
1845         "The shopkeeper smiles gleefully."
1846 #endif
1847
1848 };
1849
1850
1851 /*!
1852  * @brief 店主が交渉を終えた際の反応を返す処理 /
1853  * Let a shop-keeper React to a purchase
1854  * @param price アイテムの取引額
1855  * @param value アイテムの実際価値
1856  * @param guess 店主が当初予想していた価値
1857  * @return なし
1858  * @details 
1859  * We paid "price", it was worth "value", and we thought it was worth "guess"
1860  */
1861 static void purchase_analyze(PRICE price, PRICE value, PRICE guess)
1862 {
1863         /* Item was worthless, but we bought it */
1864         if ((value <= 0) && (price > value))
1865         {
1866                 msg_print(comment_7a[randint0(MAX_COMMENT_7A)]);
1867                 chg_virtue(V_HONOUR, -1);
1868                 chg_virtue(V_JUSTICE, -1);
1869                 sound(SOUND_STORE1);
1870         }
1871
1872         /* Item was cheaper than we thought, and we paid more than necessary */
1873         else if ((value < guess) && (price > value))
1874         {
1875                 msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
1876                 chg_virtue(V_JUSTICE, -1);
1877                 if (one_in_(4)) chg_virtue(V_HONOUR, -1);
1878                 sound(SOUND_STORE2);
1879         }
1880
1881         /* Item was a good bargain, and we got away with it */
1882         else if ((value > guess) && (value < (4 * guess)) && (price < value))
1883         {
1884                 msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
1885                 if (one_in_(4)) chg_virtue(V_HONOUR, -1);
1886                 else if (one_in_(4)) chg_virtue(V_HONOUR, 1);
1887                 sound(SOUND_STORE3);
1888         }
1889
1890         /* Item was a great bargain, and we got away with it */
1891         else if ((value > guess) && (price < value))
1892         {
1893                 msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
1894                 if (one_in_(2)) chg_virtue(V_HONOUR, -1);
1895                 if (one_in_(4)) chg_virtue(V_HONOUR, 1);
1896                 if (10 * price < value) chg_virtue(V_SACRIFICE, 1);
1897                 sound(SOUND_STORE4);
1898         }
1899 }
1900
1901
1902
1903 /*
1904  * We store the current "store feat" here so everyone can access it
1905  */
1906 static int cur_store_feat;
1907
1908
1909 /*
1910  * Buying and selling adjustments for race combinations.
1911  * Entry[owner][player] gives the basic "cost inflation".
1912  */
1913 static byte rgold_adj[MAX_RACES][MAX_RACES] =
1914 {
1915         /*Hum, HfE, Elf,  Hal, Gno, Dwa, HfO, HfT, Dun, HiE, Barbarian,
1916          HfOg, HGn, HTn, Cyc, Yek, Klc, Kbd, Nbl, DkE, Drc, Mind Flayer,
1917          Imp,  Glm, Skl, Zombie, Vampire, Spectre, Fairy, Beastman, Ent,
1918          Angel, Demon, Kutar */
1919
1920         /* Human */
1921         { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
1922           124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
1923           115, 105, 125, 125, 125, 125, 105, 120, 105,  95, 140,
1924           100, 120, 110, 105 },
1925
1926         /* Half-Elf */
1927         { 110, 100, 100, 105, 110, 120, 125, 130, 110, 100, 110,
1928           120, 115, 108, 115, 110, 110, 120, 120, 115, 115, 110,
1929           120, 110, 110, 110, 120, 110, 100, 125, 100,  95, 140,
1930           110, 115, 110, 110 },
1931
1932         /* Elf */
1933         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
1934           120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
1935           120, 115, 110, 110, 120, 110, 100, 125, 100,  95, 140,
1936           110, 110, 105, 110 },
1937
1938         /* Halfling */
1939         { 115, 110, 105,  95, 105, 110, 115, 130, 115, 105, 115,
1940           125, 120, 120, 125, 115, 110, 120, 120, 120, 115, 115,
1941           120, 110, 120, 120, 130, 110, 110, 130, 110,  95, 140,
1942           115, 120, 105, 115 },
1943
1944         /* Gnome */
1945         { 115, 115, 110, 105,  95, 110, 115, 130, 115, 110, 115,
1946           120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
1947           120, 101, 110, 110, 120, 120, 115, 130, 115,  95, 140,
1948           115, 110, 110, 115 },
1949
1950         /* Dwarf */
1951         { 115, 120, 120, 110, 110,  95, 125, 135, 115, 120, 115,
1952           125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
1953           120, 105, 115, 115, 115, 115, 120, 130, 120,  95, 140,
1954           115, 110, 115, 115 },
1955
1956         /* Half-Orc */
1957         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
1958           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
1959           115, 125, 120, 120, 115, 120, 125, 115, 125,  95, 140,
1960           115, 110, 115, 115 },
1961
1962         /* Half-Troll */
1963         { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
1964           110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
1965           110, 115, 112, 112, 115, 112, 120, 110, 120,  95, 140,
1966           110, 110, 115, 110 },
1967
1968         /* Amberite */
1969         { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
1970           120, 120, 105, 120, 115, 105, 115, 120, 110, 105, 105,
1971           120, 105, 120, 120, 125, 120, 105, 135, 105,  95, 140,
1972           100, 110, 110, 100 },
1973
1974         /* High_Elf */
1975         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
1976           125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
1977           125, 115, 120, 120, 125, 120, 100, 125, 100,  95, 140,
1978           110, 110, 105, 110 },
1979
1980         /* Human / Barbarian (copied from human) */
1981         { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
1982           124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
1983           115, 105, 125, 125, 130, 125, 115, 120, 115,  95, 140,
1984           100, 120, 110, 100 },
1985
1986         /* Half-Ogre: theoretical, copied from half-troll */
1987         { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
1988           110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
1989           110, 115, 112, 112, 115, 112, 120, 110, 120,  95, 140,
1990           110, 110, 115, 110 },
1991
1992         /* Half-Giant: theoretical, copied from half-troll */
1993         { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
1994           110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
1995           110, 115, 112, 112, 115, 112, 130, 120, 130,  95, 140,
1996           110, 110, 115, 110 },
1997
1998         /* Half-Titan: theoretical, copied from High_Elf */
1999         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
2000           125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
2001           125, 115, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2002           110, 110, 115, 110 },
2003
2004         /* Cyclops: theoretical, copied from half-troll */
2005         { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
2006           110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
2007           110, 115, 112, 112, 115, 112, 130, 130, 130,  95, 140,
2008           110, 110, 115, 110 },
2009
2010         /* Yeek: theoretical, copied from Half-Orc */
2011         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2012           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2013           115, 125, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2014           115, 110, 115, 115 },
2015
2016         /* Klackon: theoretical, copied from Gnome */
2017         { 115, 115, 110, 105,  95, 110, 115, 130, 115, 110, 115,
2018           120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
2019           120, 101, 110, 110, 120, 120, 130, 130, 130,  95, 140,
2020           115, 110, 115, 115 },
2021
2022         /* Kobold: theoretical, copied from Half-Orc */
2023         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2024           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2025           115, 125, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2026           115, 110, 115, 115 },
2027
2028         /* Nibelung: theoretical, copied from Dwarf */
2029         { 115, 120, 120, 110, 110,  95, 125, 135, 115, 120, 115,
2030           125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
2031           120, 105, 115, 115, 120, 120, 130, 130, 130,  95, 140,
2032           115, 135, 115, 115 },
2033
2034         /* Dark Elf */
2035         { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
2036           115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
2037           110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
2038           110, 101, 115, 110 },
2039
2040         /* Draconian: theoretical, copied from High_Elf */
2041         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
2042           125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
2043           125, 115, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2044           110, 110, 115, 110 },
2045
2046         /* Mind Flayer: theoretical, copied from High_Elf */
2047         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
2048           125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
2049           125, 115, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2050           110, 110, 115, 110 },
2051
2052         /* Imp: theoretical, copied from High_Elf */
2053         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
2054           125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
2055           125, 115, 120, 120, 120, 120, 130, 130, 130, 120, 120,
2056           110, 110, 115, 110 },
2057
2058         /* Golem: theoretical, copied from High_Elf */
2059         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
2060           125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
2061           125, 115, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2062           110, 110, 115, 110 },
2063
2064         /* Skeleton: theoretical, copied from half-orc */
2065         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2066           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2067           115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
2068           115, 110, 125, 115 },
2069
2070         /* Zombie: Theoretical, copied from half-orc */
2071         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2072           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2073           115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
2074           115, 110, 125, 115 },
2075
2076         /* Vampire: Theoretical, copied from half-orc */
2077         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2078           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2079           115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
2080           115, 110, 125, 115 },
2081
2082         /* Spectre: Theoretical, copied from half-orc */
2083         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2084           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2085           115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
2086           115, 110, 125, 115 },
2087
2088         /* Sprite: Theoretical, copied from half-orc */
2089         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2090           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2091           115, 125, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2092           115, 110, 105, 115 },
2093
2094         /* Beastman: Theoretical, copied from half-orc */
2095         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2096           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2097           115, 125, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2098           115, 110, 115, 115 },
2099
2100         /* Ent */
2101         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
2102           120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
2103           120, 115, 110, 110, 120, 110, 100, 125, 100,  95, 140,
2104           110, 110, 105, 110 },
2105
2106         /* Angel */
2107         {  95,  95,  95,  95,  95,  95,  95,  95,  95,  95,  95,
2108            95,  95,  95,  95,  95,  95,  95,  95,  95,  95,  95,
2109            95,  95,  95,  95,  95,  95,  95,  95,  95,  95, 160,
2110            95,  95,  95,  95 },
2111
2112         /* Demon */
2113         { 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
2114           140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
2115           140, 140, 140, 140, 140, 140, 140, 140, 140, 160, 120,
2116           140, 140, 140, 140 },
2117
2118         /* Dunadan */
2119         { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
2120           124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
2121           115, 105, 125, 125, 125, 125, 105, 120, 105,  95, 140,
2122           100, 120, 110, 100 },
2123
2124         /* Shadow Fairy */
2125         { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
2126           115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
2127           110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
2128           110, 101, 115, 110 },
2129
2130         /* Kutar */
2131         { 110, 110, 105, 105, 110, 115, 115, 115, 110, 105, 110,
2132           115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
2133           115, 115, 125, 125, 125, 125, 105, 115, 105,  95, 140,
2134           110, 115, 100, 110 },
2135
2136         /* Android */
2137         { 105, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
2138           124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
2139           115, 105, 125, 125, 125, 125, 105, 120, 105,  95, 140,
2140           100, 120, 110, 100 },
2141 };
2142
2143
2144
2145 /*!
2146  * @brief 店舗価格を決定する /
2147  * Determine the price of an item (qty one) in a store.
2148  * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
2149  * @param greed 店主の強欲度
2150  * @param flip TRUEならば店主にとっての買取価格、FALSEなら売出価格を計算
2151  * @return なし
2152  * @details 
2153  * <pre>
2154  * This function takes into account the player's charisma, and the
2155  * shop-keepers friendliness, and the shop-keeper's base greed, but
2156  * never lets a shop-keeper lose money in a transaction.
2157  * The "greed" value should exceed 100 when the player is "buying" the
2158  * item, and should be less than 100 when the player is "selling" it.
2159  * Hack -- the black market always charges twice as much as it should.
2160  * Charisma adjustment runs from 80 to 130
2161  * Racial adjustment runs from 95 to 130
2162  * Since greed/charisma/racial adjustments are centered at 100, we need
2163  * to adjust (by 200) to extract a usable multiplier.  Note that the
2164  * "greed" value is always something (?).
2165  * </pre>
2166  */
2167 static s32b price_item(object_type *o_ptr, int greed, bool flip)
2168 {
2169         int     factor;
2170         int     adjust;
2171         s32b    price;
2172
2173
2174         /* Get the value of one of the items */
2175         price = object_value(o_ptr);
2176
2177         /* Worthless items */
2178         if (price <= 0) return (0L);
2179
2180
2181         /* Compute the racial factor */
2182         factor = rgold_adj[ot_ptr->owner_race][p_ptr->prace];
2183
2184         /* Add in the charisma factor */
2185         factor += adj_chr_gold[p_ptr->stat_ind[A_CHR]];
2186
2187
2188         /* Shop is buying */
2189         if (flip)
2190         {
2191                 /* Adjust for greed */
2192                 adjust = 100 + (300 - (greed + factor));
2193
2194                 /* Never get "silly" */
2195                 if (adjust > 100) adjust = 100;
2196
2197                 /* Mega-Hack -- Black market sucks */
2198                 if (cur_store_num == STORE_BLACK)
2199                         price = price / 2;
2200
2201                 /* Compute the final price (with rounding) */
2202                 /* Hack -- prevent underflow */
2203                 price = (price * adjust + 50L) / 100L;
2204         }
2205
2206         /* Shop is selling */
2207         else
2208         {
2209                 /* Adjust for greed */
2210                 adjust = 100 + ((greed + factor) - 300);
2211
2212                 /* Never get "silly" */
2213                 if (adjust < 100) adjust = 100;
2214
2215                 /* Mega-Hack -- Black market sucks */
2216                 if (cur_store_num == STORE_BLACK)
2217                         price = price * 2;
2218
2219                 /* Compute the final price (with rounding) */
2220                 /* Hack -- prevent overflow */
2221                 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
2222         }
2223
2224         /* Note -- Never become "free" */
2225         if (price <= 0L) return (1L);
2226
2227         /* Return the price */
2228         return (price);
2229 }
2230
2231
2232 /*!
2233  * @brief 安価な消耗品の販売数を増やし、低確率で割引にする /
2234  * Certain "cheap" objects should be created in "piles"
2235  * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
2236  * @return なし
2237  * @details 
2238  * <pre>
2239  * Some objects can be sold at a "discount" (in small piles)
2240  * </pre>
2241  */
2242 static void mass_produce(object_type *o_ptr)
2243 {
2244         int size = 1;
2245         DISCOUNT_RATE discount = 0;
2246
2247         s32b cost = object_value(o_ptr);
2248
2249
2250         /* Analyze the type */
2251         switch (o_ptr->tval)
2252         {
2253                 /* Food, Flasks, and Lites */
2254                 case TV_FOOD:
2255                 case TV_FLASK:
2256                 case TV_LITE:
2257                 {
2258                         if (cost <= 5L) size += damroll(3, 5);
2259                         if (cost <= 20L) size += damroll(3, 5);
2260                         if (cost <= 50L) size += damroll(2, 2);
2261                         break;
2262                 }
2263
2264                 case TV_POTION:
2265                 case TV_SCROLL:
2266                 {
2267                         if (cost <= 60L) size += damroll(3, 5);
2268                         if (cost <= 240L) size += damroll(1, 5);
2269                         if (o_ptr->sval == SV_SCROLL_STAR_IDENTIFY) size += damroll(3, 5);
2270                         if (o_ptr->sval == SV_SCROLL_STAR_REMOVE_CURSE) size += damroll(1, 4);
2271                         break;
2272                 }
2273
2274                 case TV_LIFE_BOOK:
2275                 case TV_SORCERY_BOOK:
2276                 case TV_NATURE_BOOK:
2277                 case TV_CHAOS_BOOK:
2278                 case TV_DEATH_BOOK:
2279                 case TV_TRUMP_BOOK:
2280                 case TV_ARCANE_BOOK:
2281                 case TV_CRAFT_BOOK:
2282                 case TV_DAEMON_BOOK:
2283                 case TV_CRUSADE_BOOK:
2284                 case TV_MUSIC_BOOK:
2285                 case TV_HISSATSU_BOOK:
2286                 case TV_HEX_BOOK:
2287                 {
2288                         if (cost <= 50L) size += damroll(2, 3);
2289                         if (cost <= 500L) size += damroll(1, 3);
2290                         break;
2291                 }
2292
2293                 case TV_SOFT_ARMOR:
2294                 case TV_HARD_ARMOR:
2295                 case TV_SHIELD:
2296                 case TV_GLOVES:
2297                 case TV_BOOTS:
2298                 case TV_CLOAK:
2299                 case TV_HELM:
2300                 case TV_CROWN:
2301                 case TV_SWORD:
2302                 case TV_POLEARM:
2303                 case TV_HAFTED:
2304                 case TV_DIGGING:
2305                 case TV_BOW:
2306                 {
2307                         if (object_is_artifact(o_ptr)) break;
2308                         if (object_is_ego(o_ptr)) break;
2309                         if (cost <= 10L) size += damroll(3, 5);
2310                         if (cost <= 100L) size += damroll(3, 5);
2311                         break;
2312                 }
2313
2314                 case TV_SPIKE:
2315                 case TV_SHOT:
2316                 case TV_ARROW:
2317                 case TV_BOLT:
2318                 {
2319                         if (cost <= 5L) size += damroll(5, 5);
2320                         if (cost <= 50L) size += damroll(5, 5);
2321                         if (cost <= 500L) size += damroll(5, 5);
2322                         break;
2323                 }
2324
2325                 case TV_FIGURINE:
2326                 {
2327                         if (cost <= 100L) size += damroll(2, 2);
2328                         if (cost <= 1000L) size += damroll(2, 2);
2329                         break;
2330                 }
2331
2332                 case TV_CAPTURE:
2333                 case TV_STATUE:
2334                 case TV_CARD:
2335                 {
2336                         size = 1;
2337                         break;
2338                 }
2339
2340                 /*
2341                  * Because many rods (and a few wands and staffs) are useful mainly
2342                  * in quantity, the Black Market will occasionally have a bunch of
2343                  * one kind. -LM-
2344                  */
2345                 case TV_ROD:
2346                 case TV_WAND:
2347                 case TV_STAFF:
2348                 {
2349                         if ((cur_store_num == STORE_BLACK) && one_in_(3))
2350                         {
2351                                 if (cost < 1601L) size += damroll(1, 5);
2352                                 else if (cost < 3201L) size += damroll(1, 3);
2353                         }
2354                         break;
2355                 }
2356         }
2357
2358
2359         /* Pick a discount */
2360         if (cost < 5)
2361         {
2362                 discount = 0;
2363         }
2364         else if (one_in_(25))
2365         {
2366                 discount = 25;
2367         }
2368         else if (one_in_(150))
2369         {
2370                 discount = 50;
2371         }
2372         else if (one_in_(300))
2373         {
2374                 discount = 75;
2375         }
2376         else if (one_in_(500))
2377         {
2378                 discount = 90;
2379         }
2380
2381         if (o_ptr->art_name)
2382         {
2383                 discount = 0;
2384         }
2385
2386         /* Save the discount */
2387         o_ptr->discount = discount;
2388
2389         /* Save the total pile size */
2390         o_ptr->number = size - (size * discount / 100);
2391
2392         /* Ensure that mass-produced rods and wands get the correct pvals. */
2393         if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
2394         {
2395                 o_ptr->pval *= (PARAMETER_VALUE)o_ptr->number;
2396         }
2397 }
2398
2399
2400
2401 /*!
2402  * @brief 店舗に並べた品を同一品であるかどうか判定する /
2403  * Determine if a store item can "absorb" another item
2404  * @param o_ptr 判定するオブジェクト構造体の参照ポインタ1
2405  * @param j_ptr 判定するオブジェクト構造体の参照ポインタ2
2406  * @return 同一扱いできるならTRUEを返す
2407  * @details 
2408  * <pre>
2409  * See "object_similar()" for the same function for the "player"
2410  * </pre>
2411  */
2412 static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
2413 {
2414         int i;
2415
2416         /* Hack -- Identical items cannot be stacked */
2417         if (o_ptr == j_ptr) return (0);
2418
2419         /* Different objects cannot be stacked */
2420         if (o_ptr->k_idx != j_ptr->k_idx) return (0);
2421
2422         /* Different charges (etc) cannot be stacked, unless wands or rods. */
2423         if ((o_ptr->pval != j_ptr->pval) && (o_ptr->tval != TV_WAND) && (o_ptr->tval != TV_ROD)) return (0);
2424
2425         /* Require many identical values */
2426         if (o_ptr->to_h != j_ptr->to_h) return (0);
2427         if (o_ptr->to_d != j_ptr->to_d) return (0);
2428         if (o_ptr->to_a != j_ptr->to_a) return (0);
2429
2430         /* Require identical "ego-item" names */
2431         if (o_ptr->name2 != j_ptr->name2) return (0);
2432
2433         /* Artifacts don't stack! */
2434         if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return (0);
2435
2436         /* Hack -- Identical art_flags! */
2437         for (i = 0; i < TR_FLAG_SIZE; i++)
2438                 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return (0);
2439
2440         /* Hack -- Never stack "powerful" items */
2441         if (o_ptr->xtra1 || j_ptr->xtra1) return (0);
2442
2443         /* Hack -- Never stack recharging items */
2444         if (o_ptr->timeout || j_ptr->timeout) return (0);
2445
2446         /* Require many identical values */
2447         if (o_ptr->ac != j_ptr->ac)   return (0);
2448         if (o_ptr->dd != j_ptr->dd)   return (0);
2449         if (o_ptr->ds != j_ptr->ds)   return (0);
2450
2451         /* Hack -- Never stack chests */
2452         if (o_ptr->tval == TV_CHEST) return (0);
2453         if (o_ptr->tval == TV_STATUE) return (0);
2454         if (o_ptr->tval == TV_CAPTURE) return (0);
2455
2456         /* Require matching discounts */
2457         if (o_ptr->discount != j_ptr->discount) return (0);
2458
2459         /* They match, so they must be similar */
2460         return (TRUE);
2461 }
2462
2463
2464 /*!
2465  * @brief 店舗に並べた品を重ね合わせできるかどうか判定する /
2466  * Allow a store item to absorb another item
2467  * @param o_ptr 判定するオブジェクト構造体の参照ポインタ1
2468  * @param j_ptr 判定するオブジェクト構造体の参照ポインタ2
2469  * @return 重ね合わせできるならTRUEを返す
2470  * @details 
2471  * <pre>
2472  * See "object_similar()" for the same function for the "player"
2473  * </pre>
2474  */
2475 static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
2476 {
2477         int max_num = (o_ptr->tval == TV_ROD) ?
2478                 MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99;
2479         int total = o_ptr->number + j_ptr->number;
2480         int diff = (total > max_num) ? total - max_num : 0;
2481
2482         /* Combine quantity, lose excess items */
2483         o_ptr->number = (total > max_num) ? max_num : total;
2484
2485         /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
2486         if (o_ptr->tval == TV_ROD)
2487         {
2488                 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
2489         }
2490
2491         /* Hack -- if wands are stacking, combine the charges. -LM- */
2492         if (o_ptr->tval == TV_WAND)
2493         {
2494                 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
2495         }
2496 }
2497
2498
2499 /*!
2500  * @brief 店舗に品を置くスペースがあるかどうかの判定を返す /
2501  * Check to see if the shop will be carrying too many objects   -RAK-
2502  * @param o_ptr 店舗に置きたいオブジェクト構造体の参照ポインタ
2503  * @return 置き場がないなら0、重ね合わせできるアイテムがあるなら-1、スペースがあるなら1を返す。
2504  * @details 
2505  * <pre>
2506  * Note that the shop, just like a player, will not accept things
2507  * it cannot hold.      Before, one could "nuke" potions this way.
2508  * Return value is now int:
2509  *  0 : No space
2510  * -1 : Can be combined to existing slot.
2511  *  1 : Cannot be combined but there are empty spaces.
2512  * </pre>
2513  */
2514 static int store_check_num(object_type *o_ptr)
2515 {
2516         int        i;
2517         object_type *j_ptr;
2518
2519         /* The "home" acts like the player */
2520         if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
2521         {
2522                 bool old_stack_force_notes = stack_force_notes;
2523                 bool old_stack_force_costs = stack_force_costs;
2524
2525                 if (cur_store_num != STORE_HOME)
2526                 {
2527                         stack_force_notes = FALSE;
2528                         stack_force_costs = FALSE;
2529                 }
2530
2531                 /* Check all the items */
2532                 for (i = 0; i < st_ptr->stock_num; i++)
2533                 {
2534                         /* Get the existing item */
2535                         j_ptr = &st_ptr->stock[i];
2536
2537                         /* Can the new object be combined with the old one? */
2538                         if (object_similar(j_ptr, o_ptr))
2539                         {
2540                                 if (cur_store_num != STORE_HOME)
2541                                 {
2542                                         stack_force_notes = old_stack_force_notes;
2543                                         stack_force_costs = old_stack_force_costs;
2544                                 }
2545
2546                                 return -1;
2547                         }
2548                 }
2549
2550                 if (cur_store_num != STORE_HOME)
2551                 {
2552                         stack_force_notes = old_stack_force_notes;
2553                         stack_force_costs = old_stack_force_costs;
2554                 }
2555         }
2556
2557         /* Normal stores do special stuff */
2558         else
2559         {
2560                 /* Check all the items */
2561                 for (i = 0; i < st_ptr->stock_num; i++)
2562                 {
2563                         /* Get the existing item */
2564                         j_ptr = &st_ptr->stock[i];
2565
2566                         /* Can the new object be combined with the old one? */
2567                         if (store_object_similar(j_ptr, o_ptr)) return -1;
2568                 }
2569         }
2570
2571         /* Free space is always usable */
2572         /*
2573          * オプション powerup_home が設定されていると
2574          * 我が家が 20 ページまで使える
2575          */
2576         if ((cur_store_num == STORE_HOME) && ( powerup_home == FALSE )) {
2577                 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) {
2578                         return 1;
2579                 }
2580         }
2581         else{
2582                 if (st_ptr->stock_num < st_ptr->stock_size) {
2583                         return 1;
2584                 }
2585         }
2586
2587         /* But there was no room at the inn... */
2588         return 0;
2589 }
2590
2591 /*!
2592  * @brief オブジェクトが祝福されているかの判定を返す /
2593  * @param o_ptr 判定したいオブジェクト構造体の参照ポインタ
2594  * @return アイテムが祝福されたアイテムならばTRUEを返す
2595  */
2596 static bool is_blessed(object_type *o_ptr)
2597 {
2598         BIT_FLAGS flgs[TR_FLAG_SIZE];
2599         object_flags(o_ptr, flgs);
2600         if (have_flag(flgs, TR_BLESSED)) return (TRUE);
2601         else return (FALSE);
2602 }
2603
2604
2605
2606 /*!
2607  * @brief オブジェクトが所定の店舗で引き取れるかどうかを返す /
2608  * Determine if the current store will purchase the given item
2609  * @param o_ptr 判定したいオブジェクト構造体の参照ポインタ
2610  * @return アイテムが買い取れるならばTRUEを返す
2611  * @note
2612  * Note that a shop-keeper must refuse to buy "worthless" items
2613  */
2614 static bool store_will_buy(object_type *o_ptr)
2615 {
2616         /* Hack -- The Home is simple */
2617         if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) return (TRUE);
2618
2619         /* Switch on the store */
2620         switch (cur_store_num)
2621         {
2622                 /* General Store */
2623                 case STORE_GENERAL:
2624                 {
2625                         /* Analyze the type */
2626                         switch (o_ptr->tval)
2627                         {
2628                                 case TV_POTION:
2629                                         if (o_ptr->sval != SV_POTION_WATER) return FALSE;
2630
2631                                 case TV_WHISTLE:
2632                                 case TV_FOOD:
2633                                 case TV_LITE:
2634                                 case TV_FLASK:
2635                                 case TV_SPIKE:
2636                                 case TV_SHOT:
2637                                 case TV_ARROW:
2638                                 case TV_BOLT:
2639                                 case TV_DIGGING:
2640                                 case TV_CLOAK:
2641                                 case TV_BOTTLE: /* 'Green', recycling Angband */
2642                                 case TV_FIGURINE:
2643                                 case TV_STATUE:
2644                                 case TV_CAPTURE:
2645                                 case TV_CARD:
2646                                 break;
2647                                 default:
2648                                 return (FALSE);
2649                         }
2650                         break;
2651                 }
2652
2653                 /* Armoury */
2654                 case STORE_ARMOURY:
2655                 {
2656                         /* Analyze the type */
2657                         switch (o_ptr->tval)
2658                         {
2659                                 case TV_BOOTS:
2660                                 case TV_GLOVES:
2661                                 case TV_CROWN:
2662                                 case TV_HELM:
2663                                 case TV_SHIELD:
2664                                 case TV_CLOAK:
2665                                 case TV_SOFT_ARMOR:
2666                                 case TV_HARD_ARMOR:
2667                                 case TV_DRAG_ARMOR:
2668                                 break;
2669                                 default:
2670                                 return (FALSE);
2671                         }
2672                         break;
2673                 }
2674
2675                 /* Weapon Shop */
2676                 case STORE_WEAPON:
2677                 {
2678                         /* Analyze the type */
2679                         switch (o_ptr->tval)
2680                         {
2681                                 case TV_SHOT:
2682                                 case TV_BOLT:
2683                                 case TV_ARROW:
2684                                 case TV_BOW:
2685                                 case TV_DIGGING:
2686                                 case TV_POLEARM:
2687                                 case TV_SWORD:
2688                                 case TV_HISSATSU_BOOK:
2689                                 break;
2690                                 case TV_HAFTED:
2691                                 {
2692                                         if(o_ptr->sval == SV_WIZSTAFF) return (FALSE);
2693                                 }
2694                                 break;
2695                                 default:
2696                                 return (FALSE);
2697                         }
2698                         break;
2699                 }
2700
2701                 /* Temple */
2702                 case STORE_TEMPLE:
2703                 {
2704                         /* Analyze the type */
2705                         switch (o_ptr->tval)
2706                         {
2707                                 case TV_LIFE_BOOK:
2708                                 case TV_CRUSADE_BOOK:
2709                                 case TV_SCROLL:
2710                                 case TV_POTION:
2711                                 case TV_HAFTED:
2712                                 {
2713                                         break;
2714                                 }
2715                                 case TV_FIGURINE:
2716                                 case TV_STATUE:
2717                                 {
2718                                         monster_race *r_ptr = &r_info[o_ptr->pval];
2719
2720                                         /* Decline evil */
2721                                         if (!(r_ptr->flags3 & RF3_EVIL))
2722                                         {
2723                                                 /* Accept good */
2724                                                 if (r_ptr->flags3 & RF3_GOOD) break;
2725
2726                                                 /* Accept animals */
2727                                                 if (r_ptr->flags3 & RF3_ANIMAL) break;
2728
2729                                                 /* Accept mimics */
2730                                                 if (my_strchr("?!", r_ptr->d_char)) break;
2731                                         }
2732                                 }
2733                                 case TV_POLEARM:
2734                                 case TV_SWORD:
2735                                 {
2736                                         if (is_blessed(o_ptr)) break;
2737                                 }
2738                                 default:
2739                                 return (FALSE);
2740                         }
2741                         break;
2742                 }
2743
2744                 /* Alchemist */
2745                 case STORE_ALCHEMIST:
2746                 {
2747                         /* Analyze the type */
2748                         switch (o_ptr->tval)
2749                         {
2750                                 case TV_SCROLL:
2751                                 case TV_POTION:
2752                                 break;
2753                                 default:
2754                                 return (FALSE);
2755                         }
2756                         break;
2757                 }
2758
2759                 /* Magic Shop */
2760                 case STORE_MAGIC:
2761                 {
2762                         /* Analyze the type */
2763                         switch (o_ptr->tval)
2764                         {
2765                                 case TV_SORCERY_BOOK:
2766                                 case TV_NATURE_BOOK:
2767                                 case TV_CHAOS_BOOK:
2768                                 case TV_DEATH_BOOK:
2769                                 case TV_TRUMP_BOOK:
2770                                 case TV_ARCANE_BOOK:
2771                                 case TV_CRAFT_BOOK:
2772                                 case TV_DAEMON_BOOK:
2773                                 case TV_MUSIC_BOOK:
2774                                 case TV_HEX_BOOK:
2775                                 case TV_AMULET:
2776                                 case TV_RING:
2777                                 case TV_STAFF:
2778                                 case TV_WAND:
2779                                 case TV_ROD:
2780                                 case TV_SCROLL:
2781                                 case TV_POTION:
2782                                 case TV_FIGURINE:
2783                                 break;
2784                                 case TV_HAFTED:
2785                                 {
2786                                         if(o_ptr->sval == SV_WIZSTAFF) break;
2787                                         else return (FALSE);
2788                                 }
2789                                 default:
2790                                 return (FALSE);
2791                         }
2792                         break;
2793                 }
2794                 /* Bookstore Shop */
2795                 case STORE_BOOK:
2796                 {
2797                         /* Analyze the type */
2798                         switch (o_ptr->tval)
2799                         {
2800                                 case TV_SORCERY_BOOK:
2801                                 case TV_NATURE_BOOK:
2802                                 case TV_CHAOS_BOOK:
2803                                 case TV_DEATH_BOOK:
2804                                 case TV_LIFE_BOOK:
2805                                 case TV_TRUMP_BOOK:
2806                                 case TV_ARCANE_BOOK:
2807                                 case TV_CRAFT_BOOK:
2808                                 case TV_DAEMON_BOOK:
2809                                 case TV_CRUSADE_BOOK:
2810                                 case TV_MUSIC_BOOK:
2811                                 case TV_HEX_BOOK:
2812                                         break;
2813                                 default:
2814                                         return (FALSE);
2815                         }
2816                         break;
2817                 }
2818         }
2819
2820         /* Ignore "worthless" items */
2821         if (object_value(o_ptr) <= 0) return (FALSE);
2822
2823         /* Assume okay */
2824         return (TRUE);
2825 }
2826
2827
2828 /*!
2829  * @brief 現在の町の指定された店舗のアイテムを整理する /
2830  * Combine and reorder items in store.
2831  * @param store_num 店舗ID
2832  * @return 実際に整理が行われたならばTRUEを返す。
2833  */
2834 bool combine_and_reorder_home(int store_num)
2835 {
2836         int         i, j, k;
2837         s32b        o_value;
2838         object_type forge, *o_ptr, *j_ptr;
2839         bool        flag = FALSE, combined;
2840         store_type  *old_st_ptr = st_ptr;
2841         bool        old_stack_force_notes = stack_force_notes;
2842         bool        old_stack_force_costs = stack_force_costs;
2843
2844         st_ptr = &town[1].store[store_num];
2845         if (store_num != STORE_HOME)
2846         {
2847                 stack_force_notes = FALSE;
2848                 stack_force_costs = FALSE;
2849         }
2850
2851         do
2852         {
2853                 combined = FALSE;
2854
2855                 /* Combine the items in the home (backwards) */
2856                 for (i = st_ptr->stock_num - 1; i > 0; i--)
2857                 {
2858                         o_ptr = &st_ptr->stock[i];
2859
2860                         /* Skip empty items */
2861                         if (!o_ptr->k_idx) continue;
2862
2863                         /* Scan the items above that item */
2864                         for (j = 0; j < i; j++)
2865                         {
2866                                 int max_num;
2867
2868                                 j_ptr = &st_ptr->stock[j];
2869
2870                                 /* Skip empty items */
2871                                 if (!j_ptr->k_idx) continue;
2872
2873                                 /*
2874                                  * Get maximum number of the stack if these
2875                                  * are similar, get zero otherwise.
2876                                  */
2877                                 max_num = object_similar_part(j_ptr, o_ptr);
2878
2879                                 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
2880                                 if (max_num && j_ptr->number < max_num)
2881                                 {
2882                                         if (o_ptr->number + j_ptr->number <= max_num)
2883                                         {
2884                                                 /* Add together the item counts */
2885                                                 object_absorb(j_ptr, o_ptr);
2886
2887                                                 /* One object is gone */
2888                                                 st_ptr->stock_num--;
2889
2890                                                 /* Slide everything down */
2891                                                 for (k = i; k < st_ptr->stock_num; k++)
2892                                                 {
2893                                                         /* Structure copy */
2894                                                         st_ptr->stock[k] = st_ptr->stock[k + 1];
2895                                                 }
2896
2897                                                 /* Erase the "final" slot */
2898                                                 object_wipe(&st_ptr->stock[k]);
2899                                         }
2900                                         else
2901                                         {
2902                                                 ITEM_NUMBER old_num = o_ptr->number;
2903                                                 ITEM_NUMBER remain = j_ptr->number + o_ptr->number - max_num;
2904
2905                                                 /* Add together the item counts */
2906                                                 object_absorb(j_ptr, o_ptr);
2907
2908                                                 o_ptr->number = remain;
2909
2910                                                 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
2911                                                 if (o_ptr->tval == TV_ROD)
2912                                                 {
2913                                                         o_ptr->pval =  o_ptr->pval * remain / old_num;
2914                                                         o_ptr->timeout = o_ptr->timeout * remain / old_num;
2915                                                 }
2916
2917                                                 /* Hack -- if wands are stacking, combine the charges. -LM- */
2918                                                 else if (o_ptr->tval == TV_WAND)
2919                                                 {
2920                                                         o_ptr->pval = o_ptr->pval * remain / old_num;
2921                                                 }
2922                                         }
2923
2924                                         /* Take note */
2925                                         combined = TRUE;
2926                                         break;
2927                                 }
2928                         }
2929                 }
2930
2931                 flag |= combined;
2932         }
2933         while (combined);
2934
2935         /* Re-order the items in the home (forwards) */
2936         for (i = 0; i < st_ptr->stock_num; i++)
2937         {
2938                 o_ptr = &st_ptr->stock[i];
2939
2940                 /* Skip empty slots */
2941                 if (!o_ptr->k_idx) continue;
2942
2943                 /* Get the "value" of the item */
2944                 o_value = object_value(o_ptr);
2945
2946                 /* Scan every occupied slot */
2947                 for (j = 0; j < st_ptr->stock_num; j++)
2948                 {
2949                         if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
2950                 }
2951
2952                 /* Never move down */
2953                 if (j >= i) continue;
2954
2955                 /* Take note */
2956                 flag = TRUE;
2957                 j_ptr = &forge;
2958
2959                 /* Save a copy of the moving item */
2960                 object_copy(j_ptr, &st_ptr->stock[i]);
2961
2962                 /* Slide the objects */
2963                 for (k = i; k > j; k--)
2964                 {
2965                         /* Slide the item */
2966                         object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
2967                 }
2968
2969                 /* Insert the moving item */
2970                 object_copy(&st_ptr->stock[j], j_ptr);
2971         }
2972
2973         st_ptr = old_st_ptr;
2974         if (store_num != STORE_HOME)
2975         {
2976                 stack_force_notes = old_stack_force_notes;
2977                 stack_force_costs = old_stack_force_costs;
2978         }
2979
2980         return flag;
2981 }
2982
2983
2984 /*!
2985  * @brief 我が家にオブジェクトを加える /
2986  * Add the item "o_ptr" to the inventory of the "Home"
2987  * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
2988  * @return 収めた先のID
2989  * @details
2990  * <pre>
2991  * In all cases, return the slot (or -1) where the object was placed
2992  * Note that this is a hacked up version of "inven_carry()".
2993  * Also note that it may not correctly "adapt" to "knowledge" bacoming
2994  * known, the player may have to pick stuff up and drop it again.
2995  * </pre>
2996  */
2997 static int home_carry(object_type *o_ptr)
2998 {
2999         int                             slot;
3000         s32b                       value;
3001         int     i;
3002         object_type *j_ptr;
3003         bool old_stack_force_notes = stack_force_notes;
3004         bool old_stack_force_costs = stack_force_costs;
3005
3006         if (cur_store_num != STORE_HOME)
3007         {
3008                 stack_force_notes = FALSE;
3009                 stack_force_costs = FALSE;
3010         }
3011
3012         /* Check each existing item (try to combine) */
3013         for (slot = 0; slot < st_ptr->stock_num; slot++)
3014         {
3015                 /* Get the existing item */
3016                 j_ptr = &st_ptr->stock[slot];
3017
3018                 /* The home acts just like the player */
3019                 if (object_similar(j_ptr, o_ptr))
3020                 {
3021                         /* Save the new number of items */
3022                         object_absorb(j_ptr, o_ptr);
3023
3024                         if (cur_store_num != STORE_HOME)
3025                         {
3026                                 stack_force_notes = old_stack_force_notes;
3027                                 stack_force_costs = old_stack_force_costs;
3028                         }
3029
3030                         /* All done */
3031                         return (slot);
3032                 }
3033         }
3034
3035         if (cur_store_num != STORE_HOME)
3036         {
3037                 stack_force_notes = old_stack_force_notes;
3038                 stack_force_costs = old_stack_force_costs;
3039         }
3040
3041         /* No space? */
3042         /*
3043          * 隠し機能: オプション powerup_home が設定されていると
3044          *           我が家が 20 ページまで使える
3045          */
3046         /* No space? */
3047         if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE)) {
3048                 if (st_ptr->stock_num >= st_ptr->stock_size) {
3049                         return (-1);
3050                 }
3051         }
3052         else{
3053                 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10)) {
3054                         return (-1);
3055                 }
3056         }
3057
3058
3059         /* Determine the "value" of the item */
3060         value = object_value(o_ptr);
3061
3062         /* Check existing slots to see if we must "slide" */
3063         for (slot = 0; slot < st_ptr->stock_num; slot++)
3064         {
3065                 if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
3066         }
3067
3068         /* Slide the others up */
3069         for (i = st_ptr->stock_num; i > slot; i--)
3070         {
3071                 st_ptr->stock[i] = st_ptr->stock[i-1];
3072         }
3073
3074         /* More stuff now */
3075         st_ptr->stock_num++;
3076
3077         /* Insert the new item */
3078         st_ptr->stock[slot] = *o_ptr;
3079
3080         chg_virtue(V_SACRIFICE, -1);
3081
3082         (void)combine_and_reorder_home(cur_store_num);
3083
3084         /* Return the location */
3085         return (slot);
3086 }
3087
3088
3089 /*!
3090  * @brief 店舗にオブジェクトを加える /
3091  * Add the item "o_ptr" to a real stores inventory.
3092  * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
3093  * @return 収めた先のID
3094  * @details
3095  * <pre>
3096  * In all cases, return the slot (or -1) where the object was placed
3097  * Note that this is a hacked up version of "inven_carry()".
3098  * Also note that it may not correctly "adapt" to "knowledge" bacoming
3099  * known, the player may have to pick stuff up and drop it again.
3100  * </pre>
3101  */
3102 static int store_carry(object_type *o_ptr)
3103 {
3104         int     i, slot;
3105         s32b    value, j_value;
3106         object_type *j_ptr;
3107
3108
3109         /* Evaluate the object */
3110         value = object_value(o_ptr);
3111
3112         /* Cursed/Worthless items "disappear" when sold */
3113         if (value <= 0) return (-1);
3114
3115         /* All store items are fully *identified* */
3116         o_ptr->ident |= IDENT_MENTAL;
3117
3118         /* Erase the inscription */
3119         o_ptr->inscription = 0;
3120
3121         /* Erase the "feeling" */
3122         o_ptr->feeling = FEEL_NONE;
3123
3124         /* Check each existing item (try to combine) */
3125         for (slot = 0; slot < st_ptr->stock_num; slot++)
3126         {
3127                 /* Get the existing item */
3128                 j_ptr = &st_ptr->stock[slot];
3129
3130                 /* Can the existing items be incremented? */
3131                 if (store_object_similar(j_ptr, o_ptr))
3132                 {
3133                         /* Hack -- extra items disappear */
3134                         store_object_absorb(j_ptr, o_ptr);
3135
3136                         /* All done */
3137                         return (slot);
3138                 }
3139         }
3140
3141         /* No space? */
3142         if (st_ptr->stock_num >= st_ptr->stock_size) return (-1);
3143
3144
3145         /* Check existing slots to see if we must "slide" */
3146         for (slot = 0; slot < st_ptr->stock_num; slot++)
3147         {
3148                 /* Get that item */
3149                 j_ptr = &st_ptr->stock[slot];
3150
3151                 /* Objects sort by decreasing type */
3152                 if (o_ptr->tval > j_ptr->tval) break;
3153                 if (o_ptr->tval < j_ptr->tval) continue;
3154
3155                 /* Objects sort by increasing sval */
3156                 if (o_ptr->sval < j_ptr->sval) break;
3157                 if (o_ptr->sval > j_ptr->sval) continue;
3158
3159                 /*
3160                  * Hack:  otherwise identical rods sort by
3161                  * increasing recharge time --dsb
3162                  */
3163                 if (o_ptr->tval == TV_ROD)
3164                 {
3165                         if (o_ptr->pval < j_ptr->pval) break;
3166                         if (o_ptr->pval > j_ptr->pval) continue;
3167                 }
3168
3169                 /* Evaluate that slot */
3170                 j_value = object_value(j_ptr);
3171
3172                 /* Objects sort by decreasing value */
3173                 if (value > j_value) break;
3174                 if (value < j_value) continue;
3175         }
3176
3177         /* Slide the others up */
3178         for (i = st_ptr->stock_num; i > slot; i--)
3179         {
3180                 st_ptr->stock[i] = st_ptr->stock[i-1];
3181         }
3182
3183         /* More stuff now */
3184         st_ptr->stock_num++;
3185
3186         /* Insert the new item */
3187         st_ptr->stock[slot] = *o_ptr;
3188
3189         /* Return the location */
3190         return (slot);
3191 }
3192
3193
3194 /*!
3195  * @brief 店舗のオブジェクト数を増やす /
3196  * Add the item "o_ptr" to a real stores inventory.
3197  * @param item 増やしたいアイテムのID
3198  * @param num 増やしたい数
3199  * @return なし
3200  * @details
3201  * <pre>
3202  * Increase, by a given amount, the number of a certain item
3203  * in a certain store.  This can result in zero items.
3204  * </pre>
3205  * @todo numは本来ITEM_NUMBER型にしたい。
3206  */
3207 static void store_item_increase(INVENTORY_IDX item, int num)
3208 {
3209         int             cnt;
3210         object_type *o_ptr;
3211
3212         o_ptr = &st_ptr->stock[item];
3213
3214         /* Verify the number */
3215         cnt = o_ptr->number + num;
3216         if (cnt > 255) cnt = 255;
3217         else if (cnt < 0) cnt = 0;
3218         num = cnt - o_ptr->number;
3219
3220         /* Save the new number */
3221         o_ptr->number += (ITEM_NUMBER)num;
3222 }
3223
3224
3225 /*!
3226  * @brief 店舗のオブジェクト数を削除する /
3227  * Remove a slot if it is empty
3228  * @param item 削除したいアイテムのID
3229  * @return なし
3230  */
3231 static void store_item_optimize(INVENTORY_IDX item)
3232 {
3233         int             j;
3234         object_type *o_ptr;
3235
3236         o_ptr = &st_ptr->stock[item];
3237
3238         /* Must exist */
3239         if (!o_ptr->k_idx) return;
3240
3241         /* Must have no items */
3242         if (o_ptr->number) return;
3243
3244         /* One less item */
3245         st_ptr->stock_num--;
3246
3247         /* Slide everyone */
3248         for (j = item; j < st_ptr->stock_num; j++)
3249         {
3250                 st_ptr->stock[j] = st_ptr->stock[j + 1];
3251         }
3252
3253         /* Nuke the final slot */
3254         object_wipe(&st_ptr->stock[j]);
3255 }
3256
3257 /*!
3258  * @brief ブラックマーケット用の無価値品の排除判定 /
3259  * This function will keep 'crap' out of the black market.
3260  * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
3261  * @return ブラックマーケットにとって無価値な品ならばTRUEを返す
3262  * @details
3263  * <pre>
3264  * Crap is defined as any item that is "available" elsewhere
3265  * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com>
3266  * </pre>
3267  */
3268 static bool black_market_crap(object_type *o_ptr)
3269 {
3270         int     i, j;
3271
3272         /* Ego items are never crap */
3273         if (object_is_ego(o_ptr)) return (FALSE);
3274
3275         /* Good items are never crap */
3276         if (o_ptr->to_a > 0) return (FALSE);
3277         if (o_ptr->to_h > 0) return (FALSE);
3278         if (o_ptr->to_d > 0) return (FALSE);
3279
3280         /* Check all stores */
3281         for (i = 0; i < MAX_STORES; i++)
3282         {
3283                 if (i == STORE_HOME) continue;
3284                 if (i == STORE_MUSEUM) continue;
3285
3286                 /* Check every item in the store */
3287                 for (j = 0; j < town[p_ptr->town_num].store[i].stock_num; j++)
3288                 {
3289                         object_type *j_ptr = &town[p_ptr->town_num].store[i].stock[j];
3290
3291                         /* Duplicate item "type", assume crappy */
3292                         if (o_ptr->k_idx == j_ptr->k_idx) return (TRUE);
3293                 }
3294         }
3295
3296         /* Assume okay */
3297         return (FALSE);
3298 }
3299
3300
3301 /*!
3302  * @brief 店舗の品揃え変化のためにアイテムを削除する /
3303  * Attempt to delete (some of) a random item from the store
3304  * @return なし
3305  * @details
3306  * <pre>
3307  * Hack -- we attempt to "maintain" piles of items when possible.
3308  * </pre>
3309  */
3310 static void store_delete(void)
3311 {
3312         INVENTORY_IDX what;
3313         int num;
3314
3315         /* Pick a random slot */
3316         what = (INVENTORY_IDX)randint0(st_ptr->stock_num);
3317
3318         /* Determine how many items are here */
3319         num = st_ptr->stock[what].number;
3320
3321         /* Hack -- sometimes, only destroy half the items */
3322         if (randint0(100) < 50) num = (num + 1) / 2;
3323
3324         /* Hack -- sometimes, only destroy a single item */
3325         if (randint0(100) < 50) num = 1;
3326
3327         /* Hack -- decrement the maximum timeouts and total charges of rods and wands. -LM- */
3328         if ((st_ptr->stock[what].tval == TV_ROD) || (st_ptr->stock[what].tval == TV_WAND))
3329         {
3330                 st_ptr->stock[what].pval -= num * st_ptr->stock[what].pval / st_ptr->stock[what].number;
3331         }
3332
3333         /* Actually destroy (part of) the item */
3334         store_item_increase(what, -num);
3335         store_item_optimize(what);
3336 }
3337
3338
3339 /*!
3340  * @brief 店舗の品揃え変化のためにアイテムを追加する /
3341  * Creates a random item and gives it to a store
3342  * @return なし
3343  * @details
3344  * <pre>
3345  * This algorithm needs to be rethought.  A lot.
3346  * Currently, "normal" stores use a pre-built array.
3347  * Note -- the "level" given to "obj_get_num()" is a "favored"
3348  * level, that is, there is a much higher chance of getting
3349  * items with a level approaching that of the given level...
3350  * Should we check for "permission" to have the given item?
3351  * </pre>
3352  */
3353 static void store_create(void)
3354 {
3355         OBJECT_IDX i;
3356         int tries;
3357         DEPTH level;
3358
3359         object_type forge;
3360         object_type *q_ptr;
3361
3362
3363         /* Paranoia -- no room left */
3364         if (st_ptr->stock_num >= st_ptr->stock_size) return;
3365
3366
3367         /* Hack -- consider up to four items */
3368         for (tries = 0; tries < 4; tries++)
3369         {
3370                 /* Black Market */
3371                 if (cur_store_num == STORE_BLACK)
3372                 {
3373                         /* Pick a level for object/magic */
3374                         level = 25 + randint0(25);
3375
3376                         /* Random item (usually of given level) */
3377                         i = get_obj_num(level);
3378
3379                         /* Handle failure */
3380                         if (!i) continue;
3381                 }
3382
3383                 /* Normal Store */
3384                 else
3385                 {
3386                         /* Hack -- Pick an item to sell */
3387                         i = st_ptr->table[randint0(st_ptr->table_num)];
3388
3389                         /* Hack -- fake level for apply_magic() */
3390                         level = rand_range(1, STORE_OBJ_LEVEL);
3391                 }
3392
3393                 q_ptr = &forge;
3394
3395                 /* Create a new object of the chosen kind */
3396                 object_prep(q_ptr, i);
3397
3398                 /* Apply some "low-level" magic (no artifacts) */
3399                 apply_magic(q_ptr, level, AM_NO_FIXED_ART);
3400
3401                 /* Require valid object */
3402                 if (!store_will_buy(q_ptr)) continue;
3403
3404                 /* Hack -- Charge lite's */
3405                 if (q_ptr->tval == TV_LITE)
3406                 {
3407                         if (q_ptr->sval == SV_LITE_TORCH) q_ptr->xtra4 = FUEL_TORCH / 2;
3408                         if (q_ptr->sval == SV_LITE_LANTERN) q_ptr->xtra4 = FUEL_LAMP / 2;
3409                 }
3410
3411
3412                 /* The item is "known" */
3413                 object_known(q_ptr);
3414
3415                 /* Mark it storebought */
3416                 q_ptr->ident |= IDENT_STORE;
3417
3418                 /* Mega-Hack -- no chests in stores */
3419                 if (q_ptr->tval == TV_CHEST) continue;
3420
3421                 /* Prune the black market */
3422                 if (cur_store_num == STORE_BLACK)
3423                 {
3424                         /* Hack -- No "crappy" items */
3425                         if (black_market_crap(q_ptr)) continue;
3426
3427                         /* Hack -- No "cheap" items */
3428                         if (object_value(q_ptr) < 10) continue;
3429
3430                         /* No "worthless" items */
3431                         /* if (object_value(q_ptr) <= 0) continue; */
3432                 }
3433
3434                 /* Prune normal stores */
3435                 else
3436                 {
3437                         /* No "worthless" items */
3438                         if (object_value(q_ptr) <= 0) continue;
3439                 }
3440
3441
3442                 /* Mass produce and/or Apply discount */
3443                 mass_produce(q_ptr);
3444
3445                 /* Attempt to carry the (known) item */
3446                 (void)store_carry(q_ptr);
3447
3448                 /* Definitely done */
3449                 break;
3450         }
3451 }
3452
3453
3454 /*!
3455  * @brief 店舗の割引対象外にするかどうかを判定 /
3456  * Eliminate need to bargain if player has haggled well in the past
3457  * @param minprice アイテムの最低販売価格
3458  * @return 割引を禁止するならTRUEを返す。
3459  */
3460 static bool noneedtobargain(PRICE minprice)
3461 {
3462         s32b good = st_ptr->good_buy;
3463         s32b bad = st_ptr->bad_buy;
3464
3465         /* Cheap items are "boring" */
3466         if (minprice < 10L) return (TRUE);
3467
3468         /* Perfect haggling */
3469         if (good == MAX_SHORT) return (TRUE);
3470
3471         /* Reward good haggles, punish bad haggles, notice price */
3472         if (good > ((3 * bad) + (5 + (minprice/50)))) return (TRUE);
3473
3474         /* Return the flag */
3475         return (FALSE);
3476 }
3477
3478
3479 /*!
3480  * @brief 店主の持つプレイヤーに対する売買の良し悪し経験を記憶する /
3481  * Update the bargain info
3482  * @param price 実際の取引価格
3483  * @param minprice 店主の提示した価格
3484  * @param num 売買数 
3485  * @return なし
3486  */
3487 static void updatebargain(PRICE price, PRICE minprice, int num)
3488 {
3489         /* Hack -- auto-haggle */
3490         if (!manual_haggle) return;
3491
3492         /* Cheap items are "boring" */
3493         if ((minprice/num) < 10L) return;
3494
3495         /* Count the successful haggles */
3496         if (price == minprice)
3497         {
3498                 /* Just count the good haggles */
3499                 if (st_ptr->good_buy < MAX_SHORT)
3500                 {
3501                         st_ptr->good_buy++;
3502                 }
3503         }
3504
3505         /* Count the failed haggles */
3506         else
3507         {
3508                 /* Just count the bad haggles */
3509                 if (st_ptr->bad_buy < MAX_SHORT)
3510                 {
3511                         st_ptr->bad_buy++;
3512                 }
3513         }
3514 }
3515
3516
3517 /*!
3518  * @brief 店の商品リストを再表示する /
3519  * Re-displays a single store entry
3520  * @param pos 表示行
3521  * @return なし
3522  */
3523 static void display_entry(int pos)
3524 {
3525         int             i, cur_col;
3526         object_type     *o_ptr;
3527         s32b            x;
3528
3529         GAME_TEXT o_name[MAX_NLEN];
3530         char            out_val[160];
3531
3532         int maxwid = 75;
3533
3534         o_ptr = &st_ptr->stock[pos];
3535
3536         /* Get the "offset" */
3537         i = (pos % store_bottom);
3538
3539         /* Label it, clear the line --(-- */
3540         (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
3541         prt(out_val, i+6, 0);
3542
3543         cur_col = 3;
3544         if (show_item_graph)
3545         {
3546                 TERM_COLOR a = object_attr(o_ptr);
3547                 SYMBOL_CODE c = object_char(o_ptr);
3548
3549                 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
3550                 if (use_bigtile) cur_col++;
3551
3552                 cur_col += 2;
3553         }
3554
3555         /* Describe an item in the home */
3556         if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
3557         {
3558                 maxwid = 75;
3559
3560                 /* Leave room for weights, if necessary -DRS- */
3561                 if (show_weights) maxwid -= 10;
3562
3563                 object_desc(o_name, o_ptr, 0);
3564                 o_name[maxwid] = '\0';
3565                 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
3566
3567                 /* Show weights */
3568                 if(show_weights)
3569                 {
3570                         /* Only show the weight of an individual item */
3571                         WEIGHT wgt = o_ptr->weight;
3572 #ifdef JP
3573                         sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt));
3574                         put_str(out_val, i+6, 67);
3575 #else
3576                         (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10);
3577                         put_str(out_val, i+6, 68);
3578 #endif
3579
3580                 }
3581         }
3582
3583         /* Describe an item (fully) in a store */
3584         else
3585         {
3586                 /* Must leave room for the "price" */
3587                 maxwid = 65;
3588
3589                 /* Leave room for weights, if necessary -DRS- */
3590                 if (show_weights) maxwid -= 7;
3591
3592                 /* Describe the object (fully) */
3593                 object_desc(o_name, o_ptr, 0);
3594                 o_name[maxwid] = '\0';
3595                 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
3596
3597                 /* Show weights */
3598                 if (show_weights)
3599                 {
3600                         /* Only show the weight of an individual item */
3601                         int wgt = o_ptr->weight;
3602 #ifdef JP
3603                         sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
3604                         put_str(out_val, i+6, 60);
3605 #else
3606                         (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
3607                         put_str(out_val, i+6, 61);
3608 #endif
3609
3610                 }
3611
3612                 /* Display a "fixed" cost */
3613                 if (o_ptr->ident & (IDENT_FIXED))
3614                 {
3615                         /* Extract the "minimum" price */
3616                         x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
3617
3618                         /* Actually draw the price (not fixed) */
3619 #ifdef JP
3620 (void)sprintf(out_val, "%9ld固", (long)x);
3621 #else
3622                         (void)sprintf(out_val, "%9ld F", (long)x);
3623 #endif
3624
3625                         put_str(out_val, i+6, 68);
3626                 }
3627
3628                 /* Display a "taxed" cost */
3629                 else if (!manual_haggle)
3630                 {
3631                         /* Extract the "minimum" price */
3632                         x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
3633
3634                         /* Hack -- Apply Sales Tax if needed */
3635                         if (!noneedtobargain(x)) x += x / 10;
3636
3637                         /* Actually draw the price (with tax) */
3638                         (void)sprintf(out_val, "%9ld  ", (long)x);
3639                         put_str(out_val, i+6, 68);
3640                 }
3641
3642                 /* Display a "haggle" cost */
3643                 else
3644                 {
3645                         /* Extrect the "maximum" price */
3646                         x = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
3647
3648                         /* Actually draw the price (not fixed) */
3649                         (void)sprintf(out_val, "%9ld  ", (long)x);
3650                         put_str(out_val, i+6, 68);
3651                 }
3652         }
3653 }
3654
3655
3656 /*!
3657  * @brief 店の商品リストを表示する /
3658  * Displays a store's inventory                 -RAK-
3659  * @return なし
3660  * @details
3661  * All prices are listed as "per individual object".  -BEN-
3662  */
3663 static void display_inventory(void)
3664 {
3665         int i, k;
3666
3667         /* Display the next 12 items */
3668         for (k = 0; k < store_bottom; k++)
3669         {
3670                 /* Do not display "dead" items */
3671                 if (store_top + k >= st_ptr->stock_num) break;
3672
3673                 /* Display that line */
3674                 display_entry(store_top + k);
3675         }
3676
3677         /* Erase the extra lines and the "more" prompt */
3678         for (i = k; i < store_bottom + 1; i++) prt("", i + 6, 0);
3679
3680         /* Assume "no current page" */
3681 #ifdef JP
3682         put_str("          ", 5, 20);
3683 #else
3684         put_str("        ", 5, 20);
3685 #endif
3686
3687
3688         /* Visual reminder of "more items" */
3689         if (st_ptr->stock_num > store_bottom)
3690         {
3691                 /* Show "more" reminder (after the last item) */
3692 #ifdef JP
3693                 prt("-続く-", k + 6, 3);
3694 #else
3695                 prt("-more-", k + 6, 3);
3696 #endif
3697
3698
3699                 /* Indicate the "current page" */
3700                 /* Trailing spaces are to display (Page xx) and (Page x) */
3701 #ifdef JP
3702                 put_str(format("(%dページ)  ", store_top/store_bottom + 1), 5, 20);
3703 #else
3704                 put_str(format("(Page %d)  ", store_top/store_bottom + 1), 5, 20);
3705 #endif
3706
3707         }
3708
3709         if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM)
3710         {
3711                 k = st_ptr->stock_size;
3712
3713                 if (cur_store_num == STORE_HOME && !powerup_home) k /= 10;
3714 #ifdef JP
3715                 put_str(format("アイテム数:  %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 27);
3716 #else
3717                 put_str(format("Objects:  %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 30);
3718 #endif
3719         }
3720 }
3721
3722
3723 /*!
3724  * @brief プレイヤーの所持金を表示する /
3725  * Displays players gold                                        -RAK-
3726  * @return なし
3727  * @details
3728  */
3729 static void store_prt_gold(void)
3730 {
3731         char out_val[64];
3732
3733 #ifdef JP
3734         prt("手持ちのお金: ", 19 + xtra_stock, 53);
3735 #else
3736         prt("Gold Remaining: ", 19 + xtra_stock, 53);
3737 #endif
3738
3739
3740         sprintf(out_val, "%9ld", (long)p_ptr->au);
3741         prt(out_val, 19 + xtra_stock, 68);
3742 }
3743
3744 /*!
3745  * @brief 店舗情報全体を表示するメインルーチン /
3746  * Displays store (after clearing screen)               -RAK-
3747  * @return なし
3748  * @details
3749  */
3750 static void display_store(void)
3751 {
3752         char buf[80];
3753
3754         Term_clear();
3755
3756         /* The "Home" is special */
3757         if (cur_store_num == STORE_HOME)
3758         {
3759                 /* Put the owner name */
3760                 put_str(_("我が家", "Your Home"), 3, 31);
3761
3762                 /* Label the item descriptions */
3763                 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
3764
3765                 /* If showing weights, show label */
3766                 if (show_weights)
3767                 {
3768                         put_str(_("  重さ", "Weight"), 5, 70);
3769                 }
3770         }
3771
3772         /* The "Home" is special */
3773         else if (cur_store_num == STORE_MUSEUM)
3774         {
3775                 /* Put the owner name */
3776                 put_str(_("博物館", "Museum"), 3, 31);
3777
3778                 /* Label the item descriptions */
3779                 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
3780
3781                 /* If showing weights, show label */
3782                 if (show_weights)
3783                 {
3784                         put_str(_("  重さ", "Weight"), 5, 70);
3785                 }
3786         }
3787
3788         /* Normal stores */
3789         else
3790         {
3791                 concptr store_name = (f_name + f_info[cur_store_feat].name);
3792                 concptr owner_name = (ot_ptr->owner_name);
3793                 concptr race_name = race_info[ot_ptr->owner_race].title;
3794
3795                 /* Put the owner name and race */
3796                 sprintf(buf, "%s (%s)", owner_name, race_name);
3797                 put_str(buf, 3, 10);
3798
3799                 /* Show the max price in the store (above prices) */
3800                 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
3801                 prt(buf, 3, 50);
3802
3803                 /* Label the item descriptions */
3804                 put_str(_("商品の一覧", "Item Description"), 5, 5);
3805
3806
3807                 /* If showing weights, show label */
3808                 if (show_weights)
3809                 {
3810                         put_str(_("  重さ", "Weight"), 5, 60);
3811                 }
3812
3813                 /* Label the asking price (in stores) */
3814                 put_str(_(" 価格", "Price"), 5, 72);
3815         }
3816
3817         /* Display the current gold */
3818         store_prt_gold();
3819
3820         /* Draw in the inventory */
3821         display_inventory();
3822 }
3823
3824
3825
3826 /*!
3827  * @brief 店舗からアイテムを選択する /
3828  * Get the ID of a store item and return its value      -RAK-
3829  * @param com_val 選択IDを返す参照ポインタ
3830  * @param pmt メッセージキャプション
3831  * @param i 選択範囲の最小値
3832  * @param j 選択範囲の最大値
3833  * @return 実際に選択したらTRUE、キャンセルしたらFALSE
3834  */
3835 static int get_stock(COMMAND_CODE *com_val, concptr pmt, int i, int j)
3836 {
3837         char command;
3838         char out_val[160];
3839         char lo, hi;
3840
3841         /* Get the item index */
3842         if (repeat_pull(com_val))
3843         {
3844                 /* Verify the item */
3845                 if ((*com_val >= i) && (*com_val <= j))
3846                 {
3847                         /* Success */
3848                         return (TRUE);
3849                 }
3850         }
3851
3852         /* Paranoia */
3853         msg_print(NULL);
3854
3855         /* Assume failure */
3856         *com_val = (-1);
3857
3858         /* Build the prompt */
3859         lo = I2A(i);
3860         hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
3861 #ifdef JP
3862         (void)sprintf(out_val, "(%s:%c-%c, ESCで中断) %s",
3863                 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "アイテム" : "商品"), 
3864                                   lo, hi, pmt);
3865 #else
3866         (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
3867                                   lo, hi, pmt);
3868 #endif
3869
3870
3871         /* Ask until done */
3872         while (TRUE)
3873         {
3874                 COMMAND_CODE k;
3875
3876                 /* Escape */
3877                 if (!get_com(out_val, &command, FALSE)) break;
3878
3879                 /* Convert */
3880                 if (islower(command))
3881                         k = A2I(command);
3882                 else if (isupper(command))
3883                         k = A2I(tolower(command)) + 26;
3884                 else
3885                         k = -1;
3886
3887                 /* Legal responses */
3888                 if ((k >= i) && (k <= j))
3889                 {
3890                         *com_val = k;
3891                         break;
3892                 }
3893
3894                 bell();
3895         }
3896
3897         /* Clear the prompt */
3898         prt("", 0, 0);
3899
3900         if (command == ESCAPE) return (FALSE);
3901
3902         repeat_push(*com_val);
3903
3904         /* Success */
3905         return (TRUE);
3906 }
3907
3908
3909 /*!
3910  * @brief 店主の不満度を増やし、プレイヤーを締め出す判定と処理を行う /
3911  * Increase the insult counter and get angry if too many -RAK-
3912  * @return プレイヤーを締め出す場合TRUEを返す
3913  */
3914 static int increase_insults(void)
3915 {
3916         /* Increase insults */
3917         st_ptr->insult_cur++;
3918
3919         /* Become insulted */
3920         if (st_ptr->insult_cur > ot_ptr->insult_max)
3921         {
3922                 /* Complain */
3923                 say_comment_4();
3924
3925                 /* Reset insults */
3926                 st_ptr->insult_cur = 0;
3927                 st_ptr->good_buy = 0;
3928                 st_ptr->bad_buy = 0;
3929
3930                 /* Open tomorrow */
3931                 st_ptr->store_open = turn + TURNS_PER_TICK*TOWN_DAWN/8 + randint1(TURNS_PER_TICK*TOWN_DAWN/8);
3932
3933                 /* Closed */
3934                 return (TRUE);
3935         }
3936
3937         /* Not closed */
3938         return (FALSE);
3939 }
3940
3941
3942 /*!
3943  * @brief 店主の不満度を減らす /
3944  * Decrease insults                             -RAK-
3945  * @return プレイヤーを締め出す場合TRUEを返す
3946  */
3947 static void decrease_insults(void)
3948 {
3949         /* Decrease insults */
3950         if (st_ptr->insult_cur) st_ptr->insult_cur--;
3951 }
3952
3953
3954 /*!
3955  * @brief 店主の不満度が増えた場合のみのメッセージを表示する /
3956  * Have insulted while haggling                         -RAK-
3957  * @return プレイヤーを締め出す場合TRUEを返す
3958  */
3959 static int haggle_insults(void)
3960 {
3961         /* Increase insults */
3962         if (increase_insults()) return (TRUE);
3963
3964         /* Display and flush insult */
3965         say_comment_5();
3966
3967         /* Still okay */
3968         return (FALSE);
3969 }
3970
3971
3972 /*
3973  * Mega-Hack -- Enable "increments"
3974  */
3975 static bool allow_inc = FALSE;
3976
3977 /*
3978  * Mega-Hack -- Last "increment" during haggling
3979  */
3980 static s32b last_inc = 0L;
3981
3982
3983 /*!
3984  * @brief 交渉価格を確認と認証の是非を行う /
3985  * Get a haggle
3986  * @param pmt メッセージ
3987  * @param poffer 別途価格提示をした場合の値を返す参照ポインタ
3988  * @param price 現在の交渉価格
3989  * @param final 最終確定価格ならばTRUE
3990  * @return プレイヤーを締め出す場合TRUEを返す
3991  */
3992 static int get_haggle(concptr pmt, s32b *poffer, PRICE price, int final)
3993 {
3994         s32b            i;
3995
3996         concptr         p;
3997
3998         char                            buf[128];
3999         char            out_val[160];
4000
4001
4002         /* Clear old increment if necessary */
4003         if (!allow_inc) last_inc = 0L;
4004
4005
4006         /* Final offer */
4007         if (final)
4008         {
4009 #ifdef JP
4010                 sprintf(buf, "%s [承諾] ", pmt);
4011 #else
4012                 sprintf(buf, "%s [accept] ", pmt);
4013 #endif
4014
4015         }
4016
4017         /* Old (negative) increment, and not final */
4018         else if (last_inc < 0)
4019         {
4020 #ifdef JP
4021                 sprintf(buf, "%s [-$%ld] ", pmt, (long)(ABS(last_inc)));
4022 #else
4023                 sprintf(buf, "%s [-%ld] ", pmt, (long)(ABS(last_inc)));
4024 #endif
4025
4026         }
4027
4028         /* Old (positive) increment, and not final */
4029         else if (last_inc > 0)
4030         {
4031 #ifdef JP
4032                 sprintf(buf, "%s [+$%ld] ", pmt, (long)(ABS(last_inc)));
4033 #else
4034                 sprintf(buf, "%s [+%ld] ", pmt, (long)(ABS(last_inc)));
4035 #endif
4036
4037         }
4038
4039         /* Normal haggle */
4040         else
4041         {
4042                 sprintf(buf, "%s ", pmt);
4043         }
4044
4045
4046         /* Paranoia */
4047         msg_print(NULL);
4048
4049
4050         /* Ask until done */
4051         while (TRUE)
4052         {
4053                 bool res;
4054
4055                 /* Display prompt */
4056                 prt(buf, 0, 0);
4057
4058                 /* Default */
4059                 strcpy(out_val, "");
4060
4061                 /*
4062                  * Ask the user for a response.
4063                  * Don't allow to use numpad as cursor key.
4064                  */
4065                 res = askfor_aux(out_val, 32, FALSE);
4066
4067                 /* Clear prompt */
4068                 prt("", 0, 0);
4069
4070                 /* Cancelled */
4071                 if (!res) return FALSE;
4072
4073                 /* Skip leading spaces */
4074                 for (p = out_val; *p == ' '; p++) /* loop */;
4075
4076                 /* Empty response */
4077                 if (*p == '\0')
4078                 {
4079                         /* Accept current price */
4080                         if (final)
4081                         {
4082                                 *poffer = price;
4083                                 last_inc = 0L;
4084                                 break;
4085                         }
4086
4087                         /* Use previous increment */
4088                         if (allow_inc && last_inc)
4089                         {
4090                                 *poffer += last_inc;
4091                                 break;
4092                         }
4093                 }
4094
4095                 /* Normal response */
4096                 else
4097                 {
4098                         /* Extract a number */
4099                         i = atol(p);
4100
4101                         /* Handle "incremental" number */
4102                         if ((*p == '+' || *p == '-'))
4103                         {
4104                                 /* Allow increments */
4105                                 if (allow_inc)
4106                                 {
4107                                         /* Use the given "increment" */
4108                                         *poffer += i;
4109                                         last_inc = i;
4110                                         break;
4111                                 }
4112                         }
4113
4114                         /* Handle normal number */
4115                         else
4116                         {
4117                                 /* Use the given "number" */
4118                                 *poffer = i;
4119                                 last_inc = 0L;
4120                                 break;
4121                         }
4122                 }
4123
4124                 /* Warning */
4125 #ifdef JP
4126                 msg_print("値がおかしいです。");
4127 #else
4128                 msg_print("Invalid response.");
4129 #endif
4130
4131                 msg_print(NULL);
4132         }
4133
4134         /* Success */
4135         return (TRUE);
4136 }
4137
4138
4139 /*!
4140  * @brief 店主がプレイヤーからの交渉価格を判断する /
4141  * Receive an offer (from the player)
4142  * @param pmt メッセージ
4143  * @param poffer 店主からの交渉価格を返す参照ポインタ
4144  * @param last_offer 現在の交渉価格
4145  * @param factor 店主の価格基準倍率
4146  * @param price アイテムの実価値
4147  * @param final 最終価格確定ならばTRUE
4148  * @return プレイヤーの価格に対して不服ならばTRUEを返す /
4149  * Return TRUE if offer is NOT okay
4150  */
4151 static bool receive_offer(concptr pmt, s32b *poffer,
4152                           s32b last_offer, int factor,
4153                           PRICE price, int final)
4154 {
4155         /* Haggle till done */
4156         while (TRUE)
4157         {
4158                 /* Get a haggle (or cancel) */
4159                 if (!get_haggle(pmt, poffer, price, final)) return (TRUE);
4160
4161                 /* Acceptable offer */
4162                 if (((*poffer) * factor) >= (last_offer * factor)) break;
4163
4164                 /* Insult, and check for kicked out */
4165                 if (haggle_insults()) return (TRUE);
4166
4167                 /* Reject offer (correctly) */
4168                 (*poffer) = last_offer;
4169         }
4170
4171         /* Success */
4172         return (FALSE);
4173 }
4174
4175
4176 /*!
4177  * @brief プレイヤーが購入する時の値切り処理メインルーチン /
4178  * Haggling routine                             -RAK-
4179  * @param o_ptr オブジェクトの構造体参照ポインタ
4180  * @param price 最終価格を返す参照ポインタ
4181  * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
4182  * Return TRUE if purchase is NOT successful
4183  */
4184 static bool purchase_haggle(object_type *o_ptr, s32b *price)
4185 {
4186         s32b                       cur_ask, final_ask;
4187         s32b                       last_offer, offer;
4188         s32b                       x1, x2, x3;
4189         s32b                       min_per, max_per;
4190         int                        flag, loop_flag, noneed;
4191         int                        annoyed = 0, final = FALSE;
4192
4193         bool            cancel = FALSE;
4194
4195 #ifdef JP
4196         concptr pmt = "提示価格";
4197 #else
4198         concptr         pmt = "Asking";
4199 #endif
4200
4201
4202         char            out_val[160];
4203
4204
4205         *price = 0;
4206
4207
4208         /* Extract the starting offer and the final offer */
4209         cur_ask = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
4210         final_ask = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
4211
4212         /* Determine if haggling is necessary */
4213         noneed = noneedtobargain(final_ask);
4214
4215         /* No need to haggle */
4216         if (noneed || !manual_haggle)
4217         {
4218                 /* No need to haggle */
4219                 if (noneed)
4220                 {
4221                         /* Message summary */
4222 #ifdef JP
4223                         msg_print("結局この金額にまとまった。");
4224 #else
4225                         msg_print("You eventually agree upon the price.");
4226 #endif
4227
4228                         msg_print(NULL);
4229                 }
4230
4231                 /* No haggle option */
4232                 else
4233                 {
4234                         /* Message summary */
4235 #ifdef JP
4236                         msg_print("すんなりとこの金額にまとまった。");
4237 #else
4238                         msg_print("You quickly agree upon the price.");
4239 #endif
4240
4241                         msg_print(NULL);
4242
4243                         /* Apply Sales Tax */
4244                         final_ask += final_ask / 10;
4245                 }
4246
4247                 /* Final price */
4248                 cur_ask = final_ask;
4249
4250                 /* Go to final offer */
4251 #ifdef JP
4252                 pmt = "最終提示価格";
4253 #else
4254                 pmt = "Final Offer";
4255 #endif
4256
4257                 final = TRUE;
4258         }
4259
4260
4261         /* Haggle for the whole pile */
4262         cur_ask *= o_ptr->number;
4263         final_ask *= o_ptr->number;
4264
4265
4266         /* Haggle parameters */
4267         min_per = ot_ptr->haggle_per;
4268         max_per = min_per * 3;
4269
4270         /* Mega-Hack -- artificial "last offer" value */
4271         last_offer = object_value(o_ptr) * o_ptr->number;
4272         last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
4273         if (last_offer <= 0) last_offer = 1;
4274
4275         /* No offer yet */
4276         offer = 0;
4277
4278         /* No incremental haggling yet */
4279         allow_inc = FALSE;
4280
4281         /* Haggle until done */
4282         for (flag = FALSE; !flag; )
4283         {
4284                 loop_flag = TRUE;
4285
4286                 while (!flag && loop_flag)
4287                 {
4288                         (void)sprintf(out_val, "%s :  %ld", pmt, (long)cur_ask);
4289                         put_str(out_val, 1, 0);
4290 #ifdef JP
4291                         cancel = receive_offer("提示する金額? ",
4292 #else
4293                         cancel = receive_offer("What do you offer? ",
4294 #endif
4295
4296                                                &offer, last_offer, 1, cur_ask, final);
4297
4298                         if (cancel)
4299                         {
4300                                 flag = TRUE;
4301                         }
4302                         else if (offer > cur_ask)
4303                         {
4304                                 say_comment_6();
4305                                 offer = last_offer;
4306                         }
4307                         else if (offer == cur_ask)
4308                         {
4309                                 flag = TRUE;
4310                                 *price = offer;
4311                         }
4312                         else
4313                         {
4314                                 loop_flag = FALSE;
4315                         }
4316                 }
4317
4318                 if (!flag)
4319                 {
4320                         x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
4321                         if (x1 < min_per)
4322                         {
4323                                 if (haggle_insults())
4324                                 {
4325                                         flag = TRUE;
4326                                         cancel = TRUE;
4327                                 }
4328                         }
4329                         else if (x1 > max_per)
4330                         {
4331                                 x1 = x1 * 3 / 4;
4332                                 if (x1 < max_per) x1 = max_per;
4333                         }
4334                         x2 = rand_range(x1-2, x1+2);
4335                         x3 = ((cur_ask - offer) * x2 / 100L) + 1;
4336                         /* don't let the price go up */
4337                         if (x3 < 0) x3 = 0;
4338                         cur_ask -= x3;
4339
4340                         /* Too little */
4341                         if (cur_ask < final_ask)
4342                         {
4343                                 final = TRUE;
4344                                 cur_ask = final_ask;
4345 #ifdef JP
4346                                 pmt = "最終提示価格";
4347 #else
4348                                 pmt = "Final Offer";
4349 #endif
4350
4351                                 annoyed++;
4352                                 if (annoyed > 3)
4353                                 {
4354                                         (void)(increase_insults());
4355                                         cancel = TRUE;
4356                                         flag = TRUE;
4357                                 }
4358                         }
4359                         else if (offer >= cur_ask)
4360                         {
4361                                 flag = TRUE;
4362                                 *price = offer;
4363                         }
4364
4365                         if (!flag)
4366                         {
4367                                 last_offer = offer;
4368                                 allow_inc = TRUE;
4369                                 prt("", 1, 0);
4370 #ifdef JP
4371 (void)sprintf(out_val, "前回の提示金額: $%ld",
4372 #else
4373                                 (void)sprintf(out_val, "Your last offer: %ld",
4374 #endif
4375
4376                                                           (long)last_offer);
4377                                 put_str(out_val, 1, 39);
4378                                 say_comment_2(cur_ask, annoyed);
4379                         }
4380                 }
4381         }
4382
4383         if (cancel) return (TRUE);
4384
4385         updatebargain(*price, final_ask, o_ptr->number);
4386
4387         /* Do not cancel */
4388         return (FALSE);
4389 }
4390
4391
4392 /*!
4393  * @brief プレイヤーが売却する時の値切り処理メインルーチン /
4394  * Haggling routine                             -RAK-
4395  * @param o_ptr オブジェクトの構造体参照ポインタ
4396  * @param price 最終価格を返す参照ポインタ
4397  * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
4398  * Return TRUE if purchase is NOT successful
4399  */
4400 static bool sell_haggle(object_type *o_ptr, s32b *price)
4401 {
4402         s32b    purse, cur_ask, final_ask;
4403         s32b    last_offer = 0, offer = 0;
4404         s32b    x1, x2, x3;
4405         s32b    min_per, max_per;
4406         int     flag, loop_flag, noneed;
4407         int     annoyed = 0, final = FALSE;
4408         bool    cancel = FALSE;
4409 #ifdef JP
4410         concptr pmt = "提示金額";
4411 #else
4412         concptr    pmt = "Offer";
4413 #endif
4414
4415         char    out_val[160];
4416
4417
4418         *price = 0;
4419
4420
4421         /* Obtain the starting offer and the final offer */
4422         cur_ask = price_item(o_ptr, ot_ptr->max_inflate, TRUE);
4423         final_ask = price_item(o_ptr, ot_ptr->min_inflate, TRUE);
4424
4425         /* Determine if haggling is necessary */
4426         noneed = noneedtobargain(final_ask);
4427
4428         /* Get the owner's payout limit */
4429         purse = (s32b)(ot_ptr->max_cost);
4430
4431         /* No need to haggle */
4432         if (noneed || !manual_haggle || (final_ask >= purse))
4433         {
4434                 /* Apply Sales Tax (if needed) */
4435                 if (!manual_haggle && !noneed)
4436                 {
4437                         final_ask -= final_ask / 10;
4438                 }
4439
4440                 /* No reason to haggle */
4441                 if (final_ask >= purse)
4442                 {
4443 #ifdef JP
4444                         msg_print("即座にこの金額にまとまった。");
4445 #else
4446                         msg_print("You instantly agree upon the price.");
4447 #endif
4448
4449                         msg_print(NULL);
4450
4451                         /* Offer full purse */
4452                         final_ask = purse;
4453                 }
4454
4455                 /* No need to haggle */
4456                 else if (noneed)
4457                 {
4458 #ifdef JP
4459                         msg_print("結局この金額にまとまった。");
4460 #else
4461                         msg_print("You eventually agree upon the price.");
4462 #endif
4463
4464                         msg_print(NULL);
4465                 }
4466
4467                 /* No haggle option */
4468                 else
4469                 {
4470                         /* Message summary */
4471 #ifdef JP
4472                         msg_print("すんなりとこの金額にまとまった。");
4473 #else
4474                         msg_print("You quickly agree upon the price.");
4475 #endif
4476
4477                         msg_print(NULL);
4478                 }
4479
4480                 /* Final price */
4481                 cur_ask = final_ask;
4482
4483                 /* Final offer */
4484                 final = TRUE;
4485 #ifdef JP
4486                 pmt = "最終提示金額";
4487 #else
4488                 pmt = "Final Offer";
4489 #endif
4490
4491         }
4492
4493         /* Haggle for the whole pile */
4494         cur_ask *= o_ptr->number;
4495         final_ask *= o_ptr->number;
4496
4497
4498         /* Display commands */
4499
4500         /* Haggling parameters */
4501         min_per = ot_ptr->haggle_per;
4502         max_per = min_per * 3;
4503
4504         /* Mega-Hack -- artificial "last offer" value */
4505         last_offer = object_value(o_ptr) * o_ptr->number;
4506         last_offer = last_offer * ot_ptr->max_inflate / 100L;
4507
4508         /* No offer yet */
4509         offer = 0;
4510
4511         /* No incremental haggling yet */
4512         allow_inc = FALSE;
4513
4514         /* Haggle */
4515         for (flag = FALSE; !flag; )
4516         {
4517                 while (1)
4518                 {
4519                         loop_flag = TRUE;
4520
4521                         (void)sprintf(out_val, "%s :  %ld", pmt, (long)cur_ask);
4522                         put_str(out_val, 1, 0);
4523 #ifdef JP
4524                         cancel = receive_offer("提示する価格? ",
4525 #else
4526                         cancel = receive_offer("What price do you ask? ",
4527 #endif
4528
4529                                                                    &offer, last_offer, -1, cur_ask, final);
4530
4531                         if (cancel)
4532                         {
4533                                 flag = TRUE;
4534                         }
4535                         else if (offer < cur_ask)
4536                         {
4537                                 say_comment_6();
4538                                 /* rejected, reset offer for incremental haggling */
4539                                 offer = last_offer;
4540                         }
4541                         else if (offer == cur_ask)
4542                         {
4543                                 flag = TRUE;
4544                                 *price = offer;
4545                         }
4546                         else
4547                         {
4548                                 loop_flag = FALSE;
4549                         }
4550
4551                         /* Stop */
4552                         if (flag || !loop_flag) break;
4553                 }
4554
4555                 if (!flag)
4556                 {
4557                         x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
4558                         if (x1 < min_per)
4559                         {
4560                                 if (haggle_insults())
4561                                 {
4562                                         flag = TRUE;
4563                                         cancel = TRUE;
4564                                 }
4565                         }
4566                         else if (x1 > max_per)
4567                         {
4568                                 x1 = x1 * 3 / 4;
4569                                 if (x1 < max_per) x1 = max_per;
4570                         }
4571                         x2 = rand_range(x1-2, x1+2);
4572                         x3 = ((offer - cur_ask) * x2 / 100L) + 1;
4573                         /* don't let the price go down */
4574                         if (x3 < 0) x3 = 0;
4575                         cur_ask += x3;
4576
4577                         if (cur_ask > final_ask)
4578                         {
4579                                 cur_ask = final_ask;
4580                                 final = TRUE;
4581 #ifdef JP
4582                                 pmt = "最終提示金額";
4583 #else
4584                                 pmt = "Final Offer";
4585 #endif
4586
4587                                 annoyed++;
4588                                 if (annoyed > 3)
4589                                 {
4590                                         flag = TRUE;
4591 #ifdef JP
4592                                 /* 追加 $0 で買い取られてしまうのを防止 By FIRST*/
4593                                         cancel = TRUE;
4594 #endif
4595                                         (void)(increase_insults());
4596                                 }
4597                         }
4598                         else if (offer <= cur_ask)
4599                         {
4600                                 flag = TRUE;
4601                                 *price = offer;
4602                         }
4603
4604                         if (!flag)
4605                         {
4606                                 last_offer = offer;
4607                                 allow_inc = TRUE;
4608                                 prt("", 1, 0);
4609                                 (void)sprintf(out_val,
4610 #ifdef JP
4611                                               "前回の提示価格 $%ld", (long)last_offer);
4612 #else
4613                                                           "Your last bid %ld", (long)last_offer);
4614 #endif
4615
4616                                 put_str(out_val, 1, 39);
4617                                 say_comment_3(cur_ask, annoyed);
4618                         }
4619                 }
4620         }
4621
4622         if (cancel) return (TRUE);
4623
4624         updatebargain(*price, final_ask, o_ptr->number);
4625
4626         /* Do not cancel */
4627         return (FALSE);
4628 }
4629
4630
4631 /*!
4632  * @brief 店からの購入処理のメインルーチン /
4633  * Buy an item from a store                     -RAK-
4634  * @return なし
4635  */
4636 static void store_purchase(void)
4637 {
4638         int i, choice;
4639         COMMAND_CODE item, item_new;
4640
4641         ITEM_NUMBER amt;
4642
4643         PRICE price, best;
4644
4645         object_type forge;
4646         object_type *j_ptr;
4647
4648         object_type *o_ptr;
4649
4650         GAME_TEXT o_name[MAX_NLEN];
4651
4652         char out_val[160];
4653
4654         if (cur_store_num == STORE_MUSEUM)
4655         {
4656 #ifdef JP
4657                 msg_print("博物館から取り出すことはできません。");
4658 #else
4659                 msg_print("Museum.");
4660 #endif
4661                 return;
4662         }
4663
4664         /* Empty? */
4665         if (st_ptr->stock_num <= 0)
4666         {
4667                 if (cur_store_num == STORE_HOME)
4668 #ifdef JP
4669                         msg_print("我が家には何も置いてありません。");
4670 #else
4671                         msg_print("Your home is empty.");
4672 #endif
4673
4674                 else
4675 #ifdef JP
4676                         msg_print("現在商品の在庫を切らしています。");
4677 #else
4678                         msg_print("I am currently out of stock.");
4679 #endif
4680
4681                 return;
4682         }
4683
4684
4685         /* Find the number of objects on this and following pages */
4686         i = (st_ptr->stock_num - store_top);
4687
4688         /* And then restrict it to the current page */
4689         if (i > store_bottom) i = store_bottom;
4690
4691         /* Prompt */
4692 #ifdef JP
4693         /* ブラックマーケットの時は別のメッセージ */
4694         switch( cur_store_num ) {
4695                 case 7:
4696                         sprintf(out_val, "どのアイテムを取りますか? ");
4697                         break;
4698                 case 6:
4699                         sprintf(out_val, "どれ? ");
4700                         break;
4701                 default:
4702                         sprintf(out_val, "どの品物が欲しいんだい? ");
4703                         break;
4704         }
4705 #else
4706         if (cur_store_num == STORE_HOME)
4707         {
4708                 sprintf(out_val, "Which item do you want to take? ");
4709         }
4710         else
4711         {
4712                 sprintf(out_val, "Which item are you interested in? ");
4713         }
4714 #endif
4715
4716
4717         /* Get the item number to be bought */
4718         if (!get_stock(&item, out_val, 0, i - 1)) return;
4719
4720         /* Get the actual index */
4721         item = item + store_top;
4722
4723         /* Get the actual item */
4724         o_ptr = &st_ptr->stock[item];
4725
4726         /* Assume the player wants just one of them */
4727         amt = 1;
4728         j_ptr = &forge;
4729
4730         /* Get a copy of the object */
4731         object_copy(j_ptr, o_ptr);
4732
4733         /*
4734          * If a rod or wand, allocate total maximum timeouts or charges
4735          * between those purchased and left on the shelf.
4736          */
4737         reduce_charges(j_ptr, o_ptr->number - amt);
4738
4739         /* Modify quantity */
4740         j_ptr->number = amt;
4741
4742         /* Hack -- require room in pack */
4743         if (!inven_carry_okay(j_ptr))
4744         {
4745                 msg_print(_("そんなにアイテムを持てない。", "You cannot carry that many different items."));
4746                 return;
4747         }
4748
4749         /* Determine the "best" price (per item) */
4750         best = price_item(j_ptr, ot_ptr->min_inflate, FALSE);
4751
4752         /* Find out how many the player wants */
4753         if (o_ptr->number > 1)
4754         {
4755                 /* Hack -- note cost of "fixed" items */
4756                 if ((cur_store_num != STORE_HOME) &&
4757                     (o_ptr->ident & IDENT_FIXED))
4758                 {
4759                         msg_format(_("一つにつき $%ldです。", "That costs %ld gold per item."), (long)(best));
4760                 }
4761
4762                 /* Get a quantity */
4763                 amt = get_quantity(NULL, o_ptr->number);
4764
4765                 /* Allow user abort */
4766                 if (amt <= 0) return;
4767         }
4768         j_ptr = &forge;
4769
4770         /* Get desired object */
4771         object_copy(j_ptr, o_ptr);
4772
4773         /*
4774          * If a rod or wand, allocate total maximum timeouts or charges
4775          * between those purchased and left on the shelf.
4776          */
4777         reduce_charges(j_ptr, o_ptr->number - amt);
4778
4779         /* Modify quantity */
4780         j_ptr->number = amt;
4781
4782         /* Hack -- require room in pack */
4783         if (!inven_carry_okay(j_ptr))
4784         {
4785                 msg_print(_("ザックにそのアイテムを入れる隙間がない。", "You cannot carry that many items."));
4786                 return;
4787         }
4788
4789         /* Attempt to buy it */
4790         if (cur_store_num != STORE_HOME)
4791         {
4792                 /* Fixed price, quick buy */
4793                 if (o_ptr->ident & (IDENT_FIXED))
4794                 {
4795                         /* Assume accept */
4796                         choice = 0;
4797
4798                         /* Go directly to the "best" deal */
4799                         price = (best * j_ptr->number);
4800                 }
4801
4802                 /* Haggle for it */
4803                 else
4804                 {
4805                         /* Describe the object (fully) */
4806                         object_desc(o_name, j_ptr, 0);
4807                         msg_format(_("%s(%c)を購入する。", "Buying %s (%c)."), o_name, I2A(item));
4808                         msg_print(NULL);
4809
4810                         /* Haggle for a final price */
4811                         choice = purchase_haggle(j_ptr, &price);
4812
4813                         /* Hack -- Got kicked out */
4814                         if (st_ptr->store_open >= turn) return;
4815                 }
4816
4817                 /* Player wants it */
4818                 if (choice == 0)
4819                 {
4820                         /* Fix the item price (if "correctly" haggled) */
4821                         if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
4822
4823                         /* Player can afford it */
4824                         if (p_ptr->au >= price)
4825                         {
4826                                 /* Say "okay" */
4827                                 say_comment_1();
4828
4829                                 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
4830                                         chg_virtue(V_JUSTICE, -1);
4831                                 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
4832                                         chg_virtue(V_NATURE, -1);
4833
4834                                 /* Make a sound */
4835                                 sound(SOUND_BUY);
4836
4837                                 /* Be happy */
4838                                 decrease_insults();
4839
4840                                 /* Spend the money */
4841                                 p_ptr->au -= price;
4842
4843                                 /* Update the display */
4844                                 store_prt_gold();
4845
4846                                 /* Hack -- buying an item makes you aware of it */
4847                                 object_aware(j_ptr);
4848
4849                                 /* Hack -- clear the "fixed" flag from the item */
4850                                 j_ptr->ident &= ~(IDENT_FIXED);
4851
4852                                 /* Describe the transaction */
4853                                 object_desc(o_name, j_ptr, 0);
4854
4855                                 msg_format(_("%sを $%ldで購入しました。", "You bought %s for %ld gold."), o_name, (long)price);
4856
4857                                 strcpy(record_o_name, o_name);
4858                                 record_turn = turn;
4859
4860                                 if (record_buy) do_cmd_write_nikki(NIKKI_BUY, 0, o_name);
4861                                 object_desc(o_name, o_ptr, OD_NAME_ONLY);
4862                                 if(record_rand_art && o_ptr->art_name)
4863                                         do_cmd_write_nikki(NIKKI_ART, 0, o_name);
4864
4865                                 /* Erase the inscription */
4866                                 j_ptr->inscription = 0;
4867
4868                                 /* Erase the "feeling" */
4869                                 j_ptr->feeling = FEEL_NONE;
4870                                 j_ptr->ident &= ~(IDENT_STORE);
4871                                 /* Give it to the player */
4872                                 item_new = inven_carry(j_ptr);
4873
4874                                 /* Describe the final result */
4875                                 object_desc(o_name, &inventory[item_new], 0);
4876                                 msg_format(_("%s(%c)を手に入れた。", "You have %s (%c)."), o_name, index_to_label(item_new));
4877
4878                                 /* Auto-inscription */
4879                                 autopick_alter_item(item_new, FALSE);
4880
4881                                 /* Now, reduce the original stack's pval. */
4882                                 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
4883                                 {
4884                                         o_ptr->pval -= j_ptr->pval;
4885                                 }
4886                                 handle_stuff();
4887
4888                                 /* Note how many slots the store used to have */
4889                                 i = st_ptr->stock_num;
4890
4891                                 /* Remove the bought items from the store */
4892                                 store_item_increase(item, -amt);
4893                                 store_item_optimize(item);
4894
4895                                 /* Store is empty */
4896                                 if (st_ptr->stock_num == 0)
4897                                 {
4898                                         /* Shuffle */
4899                                         if (one_in_(STORE_SHUFFLE))
4900                                         {
4901                                                 char buf[80];
4902                                                 msg_print(_("店主は引退した。", "The shopkeeper retires."));
4903
4904                                                 /* Shuffle the store */
4905                                                 store_shuffle(cur_store_num);
4906
4907                                                 prt("",3,0);
4908                                                 sprintf(buf, "%s (%s)",
4909                                                         ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
4910                                                 put_str(buf, 3, 10);
4911                                                 sprintf(buf, "%s (%ld)",
4912                                                         (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
4913                                                 prt(buf, 3, 50);
4914                                         }
4915
4916                                         /* Maintain */
4917                                         else
4918                                         {
4919                                                 msg_print(_("店主は新たな在庫を取り出した。", "The shopkeeper brings out some new stock."));
4920                                         }
4921
4922                                         /* New inventory */
4923                                         for (i = 0; i < 10; i++)
4924                                         {
4925                                                 /* Maintain the store */
4926                                                 store_maint(p_ptr->town_num, cur_store_num);
4927                                         }
4928
4929                                         /* Start over */
4930                                         store_top = 0;
4931                                         display_inventory();
4932                                 }
4933
4934                                 /* The item is gone */
4935                                 else if (st_ptr->stock_num != i)
4936                                 {
4937                                         /* Pick the correct screen */
4938                                         if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
4939                                         display_inventory();
4940                                 }
4941
4942                                 /* Item is still here */
4943                                 else
4944                                 {
4945                                         /* Redraw the item */
4946                                         display_entry(item);
4947                                 }
4948                         }
4949
4950                         /* Player cannot afford it */
4951                         else
4952                         {
4953                                 /* Simple message (no insult) */
4954                                 msg_print(_("お金が足りません。", "You do not have enough gold."));
4955                         }
4956                 }
4957         }
4958
4959         /* Home is much easier */
4960         else
4961         {
4962                 bool combined_or_reordered;
4963
4964                 /* Distribute charges of wands/rods */
4965                 distribute_charges(o_ptr, j_ptr, amt);
4966
4967                 /* Give it to the player */
4968                 item_new = inven_carry(j_ptr);
4969
4970                 /* Describe just the result */
4971                 object_desc(o_name, &inventory[item_new], 0);
4972
4973                 msg_format(_("%s(%c)を取った。", "You have %s (%c)."), o_name, index_to_label(item_new));
4974                 handle_stuff();
4975
4976                 /* Take note if we take the last one */
4977                 i = st_ptr->stock_num;
4978
4979                 /* Remove the items from the home */
4980                 store_item_increase(item, -amt);
4981                 store_item_optimize(item);
4982
4983                 combined_or_reordered = combine_and_reorder_home(STORE_HOME);
4984
4985                 /* Hack -- Item is still here */
4986                 if (i == st_ptr->stock_num)
4987                 {
4988                         if (combined_or_reordered) display_inventory();
4989
4990                         /* Redraw the item */
4991                         else display_entry(item);
4992                 }
4993
4994                 /* The item is gone */
4995                 else
4996                 {
4997                         /* Nothing left */
4998                         if (st_ptr->stock_num == 0) store_top = 0;
4999
5000                         /* Nothing left on that screen */
5001                         else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
5002                         display_inventory();
5003
5004                         chg_virtue(V_SACRIFICE, 1);
5005                 }
5006         }
5007
5008         /* Not kicked out */
5009         return;
5010 }
5011
5012
5013 /*!
5014  * @brief 店からの売却処理のメインルーチン /
5015  * Sell an item to the store (or home)
5016  * @return なし
5017  */
5018 static void store_sell(void)
5019 {
5020         int choice;
5021         OBJECT_IDX item;
5022         int item_pos;
5023         int amt;
5024
5025         PRICE price, value, dummy;
5026
5027         object_type forge;
5028         object_type *q_ptr;
5029
5030         object_type *o_ptr;
5031
5032         concptr q, s;
5033
5034         GAME_TEXT o_name[MAX_NLEN];
5035
5036
5037         /* Prepare a prompt */
5038         if (cur_store_num == STORE_HOME)
5039                 q = _("どのアイテムを置きますか? ", "Drop which item? ");
5040
5041         else if (cur_store_num == STORE_MUSEUM)
5042                 q = _("どのアイテムを寄贈しますか? ", "Give which item? ");
5043
5044         else
5045                 q = _("どのアイテムを売りますか? ", "Sell which item? ");
5046
5047         /* Only allow items the store will buy */
5048         item_tester_hook = store_will_buy;
5049
5050         /* 我が家でおかしなメッセージが出るオリジナルのバグを修正 */
5051         if (cur_store_num == STORE_HOME)
5052         {
5053                 s = _("置けるアイテムを持っていません。", "You don't have any item to drop.");
5054         }
5055         else if (cur_store_num == STORE_MUSEUM)
5056         {
5057                 s = _("寄贈できるアイテムを持っていません。", "You don't have any item to give.");
5058         }
5059         else
5060         {
5061                 s = _("欲しい物がないですねえ。", "You have nothing that I want.");
5062         }
5063
5064         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
5065         if (!o_ptr) return;
5066
5067         /* Hack -- Cannot remove cursed items */
5068         if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
5069         {
5070                 msg_print(_("ふーむ、どうやらそれは呪われているようだね。", "Hmmm, it seems to be cursed."));
5071                 return;
5072         }
5073
5074         /* Assume one item */
5075         amt = 1;
5076
5077         /* Find out how many the player wants (letter means "all") */
5078         if (o_ptr->number > 1)
5079         {
5080                 /* Get a quantity */
5081                 amt = get_quantity(NULL, o_ptr->number);
5082
5083                 /* Allow user abort */
5084                 if (amt <= 0) return;
5085         }
5086         q_ptr = &forge;
5087
5088         /* Get a copy of the object */
5089         object_copy(q_ptr, o_ptr);
5090
5091         /* Modify quantity */
5092         q_ptr->number = amt;
5093
5094         /*
5095          * Hack -- If a rod or wand, allocate total maximum
5096          * timeouts or charges to those being sold. -LM-
5097          */
5098         if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
5099         {
5100                 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
5101         }
5102
5103         /* Get a full description */
5104         object_desc(o_name, q_ptr, 0);
5105
5106         /* Remove any inscription, feeling for stores */
5107         if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
5108         {
5109                 q_ptr->inscription = 0;
5110                 q_ptr->feeling = FEEL_NONE;
5111         }
5112
5113         /* Is there room in the store (or the home?) */
5114         if (!store_check_num(q_ptr))
5115         {
5116                 if (cur_store_num == STORE_HOME)
5117                         msg_print(_("我が家にはもう置く場所がない。", "Your home is full."));
5118
5119                 else if (cur_store_num == STORE_MUSEUM)
5120                         msg_print(_("博物館はもう満杯だ。", "Museum is full."));
5121
5122                 else
5123                         msg_print(_("すいませんが、店にはもう置く場所がありません。", "I have not the room in my store to keep it."));
5124
5125                 return;
5126         }
5127
5128
5129         /* Real store */
5130         if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
5131         {
5132                 /* Describe the transaction */
5133                 msg_format(_("%s(%c)を売却する。", "Selling %s (%c)."), o_name, index_to_label(item));
5134
5135                 msg_print(NULL);
5136
5137                 /* Haggle for it */
5138                 choice = sell_haggle(q_ptr, &price);
5139
5140                 /* Kicked out */
5141                 if (st_ptr->store_open >= turn) return;
5142
5143                 /* Sold... */
5144                 if (choice == 0)
5145                 {
5146                         /* Say "okay" */
5147                         say_comment_1();
5148
5149                         /* Make a sound */
5150                         sound(SOUND_SELL);
5151
5152                         /* Be happy */
5153                         if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
5154                                 chg_virtue(V_JUSTICE, -1);
5155
5156                         if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
5157                                 chg_virtue(V_NATURE, 1);
5158                         decrease_insults();
5159
5160                         /* Get some money */
5161                         p_ptr->au += price;
5162
5163                         /* Update the display */
5164                         store_prt_gold();
5165
5166                         /* Get the "apparent" value */
5167                         dummy = object_value(q_ptr) * q_ptr->number;
5168
5169                         identify_item(o_ptr);
5170                         q_ptr = &forge;
5171
5172                         /* Get a copy of the object */
5173                         object_copy(q_ptr, o_ptr);
5174
5175                         /* Modify quantity */
5176                         q_ptr->number = amt;
5177
5178                         /* Make it look like to be known */
5179                         q_ptr->ident |= IDENT_STORE;
5180
5181                         /*
5182                          * Hack -- If a rod or wand, let the shopkeeper know just
5183                          * how many charges he really paid for. -LM-
5184                          */
5185                         if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
5186                         {
5187                                 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
5188                         }
5189
5190                         /* Get the "actual" value */
5191                         value = object_value(q_ptr) * q_ptr->number;
5192
5193                         /* Get the description all over again */
5194                         object_desc(o_name, q_ptr, 0);
5195
5196                         /* Describe the result (in message buffer) */
5197                         msg_format(_("%sを $%ldで売却しました。", "You sold %s for %ld gold."), o_name, (long)price);
5198
5199                         if (record_sell) do_cmd_write_nikki(NIKKI_SELL, 0, o_name);
5200
5201                         if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
5202                         {
5203                          /* Analyze the prices (and comment verbally) unless a figurine*/
5204                         purchase_analyze(price, value, dummy);
5205                         }
5206
5207                         /*
5208                          * Hack -- Allocate charges between those wands or rods sold
5209                          * and retained, unless all are being sold. -LM-
5210                          */
5211                         distribute_charges(o_ptr, q_ptr, amt);
5212
5213                         /* Reset timeouts of the sold items */
5214                         q_ptr->timeout = 0;
5215
5216                         /* Take the item from the player, describe the result */
5217                         inven_item_increase(item, -amt);
5218                         inven_item_describe(item);
5219
5220                         /* If items remain, auto-inscribe before optimizing */
5221                         if (o_ptr->number > 0)
5222                                 autopick_alter_item(item, FALSE);
5223
5224                         inven_item_optimize(item);
5225                         handle_stuff();
5226
5227                         /* The store gets that (known) item */
5228                         item_pos = store_carry(q_ptr);
5229
5230                         /* Re-display if item is now in store */
5231                         if (item_pos >= 0)
5232                         {
5233                                 store_top = (item_pos / store_bottom) * store_bottom;
5234                                 display_inventory();
5235                         }
5236                 }
5237         }
5238
5239         /* Player is at museum */
5240         else if (cur_store_num == STORE_MUSEUM)
5241         {
5242                 char o2_name[MAX_NLEN];
5243                 object_desc(o2_name, q_ptr, OD_NAME_ONLY);
5244
5245                 if (-1 == store_check_num(q_ptr))
5246                 {
5247                         msg_print(_("それと同じ品物は既に博物館にあるようです。", "The same object as it is already in the Museum."));
5248                 }
5249                 else
5250                 {
5251                         msg_print(_("博物館に寄贈したものは取り出すことができません!!", "You cannot take items which is given to the Museum back!!"));
5252                 }
5253
5254                 if (!get_check(format(_("本当に%sを寄贈しますか?", "Really give %s to the Museum? "), o2_name))) return;
5255
5256                 identify_item(q_ptr);
5257                 q_ptr->ident |= IDENT_MENTAL;
5258
5259                 /* Distribute charges of wands/rods */
5260                 distribute_charges(o_ptr, q_ptr, amt);
5261                 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
5262                 choice = 0;
5263
5264                 /* Take it from the players inventory */
5265                 inven_item_increase(item, -amt);
5266                 inven_item_describe(item);
5267                 inven_item_optimize(item);
5268                 handle_stuff();
5269
5270                 /* Let the home carry it */
5271                 item_pos = home_carry(q_ptr);
5272
5273                 /* Update store display */
5274                 if (item_pos >= 0)
5275                 {
5276                         store_top = (item_pos / store_bottom) * store_bottom;
5277                         display_inventory();
5278                 }
5279         }
5280         /* Player is at home */
5281         else
5282         {
5283                 /* Distribute charges of wands/rods */
5284                 distribute_charges(o_ptr, q_ptr, amt);
5285                 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
5286
5287                 choice = 0;
5288
5289                 /* Take it from the players inventory */
5290                 inven_item_increase(item, -amt);
5291                 inven_item_describe(item);
5292                 inven_item_optimize(item);
5293                 handle_stuff();
5294
5295                 /* Let the home carry it */
5296                 item_pos = home_carry(q_ptr);
5297
5298                 /* Update store display */
5299                 if (item_pos >= 0)
5300                 {
5301                         store_top = (item_pos / store_bottom) * store_bottom;
5302                         display_inventory();
5303                 }
5304         }
5305
5306         if ((choice == 0) && (item >= INVEN_RARM))
5307         {
5308                 calc_android_exp();
5309                 kamaenaoshi(item);
5310         }
5311 }
5312
5313
5314 /*!
5315  * @brief 店のアイテムを調べるコマンドのメインルーチン /
5316  * Examine an item in a store                      -JDL-
5317  * @return なし
5318  */
5319 static void store_examine(void)
5320 {
5321         int         i;
5322         COMMAND_CODE item;
5323         object_type *o_ptr;
5324         GAME_TEXT o_name[MAX_NLEN];
5325         char        out_val[160];
5326
5327         /* Empty? */
5328         if (st_ptr->stock_num <= 0)
5329         {
5330                 if (cur_store_num == STORE_HOME)
5331                         msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
5332                 else if (cur_store_num == STORE_MUSEUM)
5333                         msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
5334                 else
5335                         msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
5336                 return;
5337         }
5338
5339         /* Find the number of objects on this and following pages */
5340         i = (st_ptr->stock_num - store_top);
5341
5342         /* And then restrict it to the current page */
5343         if (i > store_bottom) i = store_bottom;
5344
5345         /* Prompt */
5346         sprintf(out_val, _("どれを調べますか?", "Which item do you want to examine? "));
5347
5348         /* Get the item number to be examined */
5349         if (!get_stock(&item, out_val, 0, i - 1)) return;
5350
5351         /* Get the actual index */
5352         item = item + store_top;
5353
5354         /* Get the actual item */
5355         o_ptr = &st_ptr->stock[item];
5356
5357         /* Require full knowledge */
5358         if (!(o_ptr->ident & IDENT_MENTAL))
5359         {
5360                 /* This can only happen in the home */
5361                 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
5362                 return;
5363         }
5364
5365         object_desc(o_name, o_ptr, 0);
5366         msg_format(_("%sを調べている...", "Examining %s..."), o_name);
5367
5368         if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL))
5369                 msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
5370
5371         return;
5372 }
5373
5374
5375 /*!
5376  * @brief 博物館のアイテムを除去するコマンドのメインルーチン /
5377  * Remove an item from museum (Originally from TOband)
5378  * @return なし
5379  */
5380 static void museum_remove_object(void)
5381 {
5382         int i;
5383         COMMAND_CODE item;
5384         object_type *o_ptr;
5385         GAME_TEXT o_name[MAX_NLEN];
5386         char out_val[160];
5387
5388         /* Empty? */
5389         if (st_ptr->stock_num <= 0)
5390         {
5391                 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
5392                 return;
5393         }
5394
5395         /* Find the number of objects on this and following pages */
5396         i = st_ptr->stock_num - store_top;
5397
5398         /* And then restrict it to the current page */
5399         if (i > store_bottom) i = store_bottom;
5400
5401         /* Prompt */
5402         sprintf(out_val, _("どのアイテムの展示をやめさせますか?", "Which item do you want to order to remove? "));
5403
5404         /* Get the item number to be removed */
5405         if (!get_stock(&item, out_val, 0, i - 1)) return;
5406
5407         /* Get the actual index */
5408         item = item + store_top;
5409
5410         /* Get the actual item */
5411         o_ptr = &st_ptr->stock[item];
5412
5413         object_desc(o_name, o_ptr, 0);
5414
5415         msg_print(_("展示をやめさせたアイテムは二度と見ることはできません!", "You cannot see items which is removed from the Museum!"));
5416         if (!get_check(format(_("本当に%sの展示をやめさせますか?", "Really order to remove %s from the Museum? "), o_name))) return;
5417
5418         msg_format(_("%sの展示をやめさせた。", "You ordered to remove %s."), o_name);
5419
5420         /* Remove the items from the home */
5421         store_item_increase(item, -o_ptr->number);
5422         store_item_optimize(item);
5423
5424         (void)combine_and_reorder_home(STORE_MUSEUM);
5425
5426         /* The item is gone */
5427
5428         /* Nothing left */
5429         if (st_ptr->stock_num == 0) store_top = 0;
5430
5431         /* Nothing left on that screen */
5432         else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
5433         display_inventory();
5434
5435         return;
5436 }
5437
5438
5439 /*
5440  * Hack -- set this to leave the store
5441  */
5442 static bool leave_store = FALSE;
5443
5444
5445 /*!
5446  * @brief 店舗処理コマンド選択のメインルーチン /
5447  * Process a command in a store
5448  * @return なし
5449  * @note
5450  * <pre>
5451  * Note that we must allow the use of a few "special" commands
5452  * in the stores which are not allowed in the dungeon, and we
5453  * must disable some commands which are allowed in the dungeon
5454  * but not in the stores, to prevent chaos.
5455  * </pre>
5456  */
5457 static void store_process_command(void)
5458 {
5459         /* Handle repeating the last command */
5460         repeat_check();
5461
5462         if (rogue_like_commands && command_cmd == 'l')
5463         {
5464                 command_cmd = 'x';      /* hack! */
5465         }
5466
5467         /* Parse the command */
5468         switch (command_cmd)
5469         {
5470                 /* Leave */
5471                 case ESCAPE:
5472                 {
5473                         leave_store = TRUE;
5474                         break;
5475                 }
5476
5477                 /* 日本語版追加 */
5478                 /* 1 ページ戻るコマンド: 我が家のページ数が多いので重宝するはず By BUG */
5479                 case '-':
5480                 {
5481                         if (st_ptr->stock_num <= store_bottom) {
5482                                 msg_print(_("これで全部です。", "Entire inventory is shown."));
5483                         }
5484                         else{
5485                                 store_top -= store_bottom;
5486                                 if ( store_top < 0 )
5487                                         store_top = ((st_ptr->stock_num - 1 )/store_bottom) * store_bottom;
5488                                 if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) )
5489                                         if ( store_top >= store_bottom ) store_top = store_bottom;
5490                                 display_inventory();
5491                         }
5492                         break;
5493                 }
5494
5495                 /* Browse */
5496                 case ' ':
5497                 {
5498                         if (st_ptr->stock_num <= store_bottom)
5499                         {
5500                                 msg_print(_("これで全部です。", "Entire inventory is shown."));
5501                         }
5502                         else
5503                         {
5504                                 store_top += store_bottom;
5505                                 /*
5506                                  * 隠しオプション(powerup_home)がセットされていないときは
5507                                  * 我が家では 2 ページまでしか表示しない
5508                                  */
5509                                 if ((cur_store_num == STORE_HOME) && 
5510                                     (powerup_home == FALSE) && 
5511                                         (st_ptr->stock_num >= STORE_INVEN_MAX))
5512                                 {
5513                                         if (store_top >= (STORE_INVEN_MAX - 1))
5514                                         {
5515                                                 store_top = 0;
5516                                         }
5517                                 }
5518                                 else
5519                                 {
5520                                         if (store_top >= st_ptr->stock_num) store_top = 0;
5521                                 }
5522
5523                                 display_inventory();
5524                         }
5525                         break;
5526                 }
5527
5528                 case KTRL('R'):
5529                 {
5530                         do_cmd_redraw();
5531                         display_store();
5532                         break;
5533                 }
5534
5535                 /* Get (purchase) */
5536                 case 'g':
5537                 {
5538                         store_purchase();
5539                         break;
5540                 }
5541
5542                 /* Drop (Sell) */
5543                 case 'd':
5544                 {
5545                         store_sell();
5546                         break;
5547                 }
5548
5549                 /* Examine */
5550                 case 'x':
5551                 {
5552                         store_examine();
5553                         break;
5554                 }
5555
5556                 /* Ignore return */
5557                 case '\r':
5558                 {
5559                         break;
5560                 }
5561
5562                 /*** Inventory Commands ***/
5563
5564                 /* Wear/wield equipment */
5565                 case 'w':
5566                 {
5567                         do_cmd_wield();
5568                         break;
5569                 }
5570
5571                 /* Take off equipment */
5572                 case 't':
5573                 {
5574                         do_cmd_takeoff();
5575                         break;
5576                 }
5577
5578                 /* Destroy an item */
5579                 case 'k':
5580                 {
5581                         do_cmd_destroy();
5582                         break;
5583                 }
5584
5585                 /* Equipment list */
5586                 case 'e':
5587                 {
5588                         do_cmd_equip();
5589                         break;
5590                 }
5591
5592                 /* Inventory list */
5593                 case 'i':
5594                 {
5595                         do_cmd_inven();
5596                         break;
5597                 }
5598
5599
5600                 /*** Various commands ***/
5601
5602                 /* Identify an object */
5603                 case 'I':
5604                 {
5605                         do_cmd_observe();
5606                         break;
5607                 }
5608
5609                 /* Hack -- toggle windows */
5610                 case KTRL('I'):
5611                 {
5612                         toggle_inven_equip();
5613                         break;
5614                 }
5615
5616                 /*** Use various objects ***/
5617
5618                 /* Browse a book */
5619                 case 'b':
5620                 {
5621                         if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
5622                              (p_ptr->pclass == CLASS_BERSERKER) ||
5623                              (p_ptr->pclass == CLASS_NINJA) ||
5624                              (p_ptr->pclass == CLASS_MIRROR_MASTER) 
5625                              ) do_cmd_mind_browse();
5626                         else if (p_ptr->pclass == CLASS_SMITH)
5627                                 do_cmd_kaji(TRUE);
5628                         else if (p_ptr->pclass == CLASS_MAGIC_EATER)
5629                                 do_cmd_magic_eater(TRUE, FALSE);
5630                         else if (p_ptr->pclass == CLASS_SNIPER)
5631                                 do_cmd_snipe_browse();
5632                         else do_cmd_browse();
5633                         break;
5634                 }
5635
5636                 /* Inscribe an object */
5637                 case '{':
5638                 {
5639                         do_cmd_inscribe();
5640                         break;
5641                 }
5642
5643                 /* Uninscribe an object */
5644                 case '}':
5645                 {
5646                         do_cmd_uninscribe();
5647                         break;
5648                 }
5649
5650
5651
5652                 /*** Help and Such ***/
5653
5654                 /* Help */
5655                 case '?':
5656                 {
5657                         do_cmd_help();
5658                         break;
5659                 }
5660
5661                 /* Identify symbol */
5662                 case '/':
5663                 {
5664                         do_cmd_query_symbol();
5665                         break;
5666                 }
5667
5668                 /* Character description */
5669                 case 'C':
5670                 {
5671                         p_ptr->town_num = old_town_num;
5672                         do_cmd_change_name();
5673                         p_ptr->town_num = inner_town_num;
5674                         display_store();
5675                         break;
5676                 }
5677
5678
5679                 /*** System Commands ***/
5680
5681                 /* Hack -- User interface */
5682                 case '!':
5683                 {
5684                         (void)Term_user(0);
5685                         break;
5686                 }
5687
5688                 /* Single line from a pref file */
5689                 case '"':
5690                 {
5691                         p_ptr->town_num = old_town_num;
5692                         do_cmd_pref();
5693                         p_ptr->town_num = inner_town_num;
5694                         break;
5695                 }
5696
5697                 /* Interact with macros */
5698                 case '@':
5699                 {
5700                         p_ptr->town_num = old_town_num;
5701                         do_cmd_macros();
5702                         p_ptr->town_num = inner_town_num;
5703                         break;
5704                 }
5705
5706                 /* Interact with visuals */
5707                 case '%':
5708                 {
5709                         p_ptr->town_num = old_town_num;
5710                         do_cmd_visuals();
5711                         p_ptr->town_num = inner_town_num;
5712                         break;
5713                 }
5714
5715                 /* Interact with colors */
5716                 case '&':
5717                 {
5718                         p_ptr->town_num = old_town_num;
5719                         do_cmd_colors();
5720                         p_ptr->town_num = inner_town_num;
5721                         break;
5722                 }
5723
5724                 /* Interact with options */
5725                 case '=':
5726                 {
5727                         do_cmd_options();
5728                         (void)combine_and_reorder_home(STORE_HOME);
5729                         do_cmd_redraw();
5730                         display_store();
5731                         break;
5732                 }
5733
5734                 /*** Misc Commands ***/
5735
5736                 /* Take notes */
5737                 case ':':
5738                 {
5739                         do_cmd_note();
5740                         break;
5741                 }
5742
5743                 /* Version info */
5744                 case 'V':
5745                 {
5746                         do_cmd_version();
5747                         break;
5748                 }
5749
5750                 /* Repeat level feeling */
5751                 case KTRL('F'):
5752                 {
5753                         do_cmd_feeling();
5754                         break;
5755                 }
5756
5757                 /* Show previous message */
5758                 case KTRL('O'):
5759                 {
5760                         do_cmd_message_one();
5761                         break;
5762                 }
5763
5764                 /* Show previous messages */
5765                 case KTRL('P'):
5766                 {
5767                         do_cmd_messages(0);
5768                         break;
5769                 }
5770
5771                 case '|':
5772                 {
5773                         do_cmd_nikki();
5774                         break;
5775                 }
5776
5777                 /* Check artifacts, uniques etc. */
5778                 case '~':
5779                 {
5780                         do_cmd_knowledge();
5781                         break;
5782                 }
5783
5784                 /* Load "screen dump" */
5785                 case '(':
5786                 {
5787                         do_cmd_load_screen();
5788                         break;
5789                 }
5790
5791                 /* Save "screen dump" */
5792                 case ')':
5793                 {
5794                         do_cmd_save_screen();
5795                         break;
5796                 }
5797
5798                 /* Hack -- Unknown command */
5799                 default:
5800                 {
5801                         if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
5802                         {
5803                                 museum_remove_object();
5804                         }
5805                         else
5806                         {
5807                                 msg_print(_("そのコマンドは店の中では使えません。", "That command does not work in stores."));
5808                         }
5809                         break;
5810                 }
5811         }
5812 }
5813
5814
5815 /*!
5816  * @brief 店舗処理全体のメインルーチン /
5817  * Enter a store, and interact with it. *
5818  * @return なし
5819  * @note
5820  * <pre>
5821  * Note that we use the standard "request_command()" function
5822  * to get a command, allowing us to use "command_arg" and all
5823  * command macros and other nifty stuff, but we use the special
5824  * "shopping" argument, to force certain commands to be converted
5825  * into other commands, normally, we convert "p" (pray) and "m"
5826  * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
5827  * </pre>
5828  */
5829 void do_cmd_store(void)
5830 {
5831         int which;
5832         int maintain_num;
5833         int i;
5834         cave_type *c_ptr;
5835         bool need_redraw_store_inv; /* To redraw missiles damage and prices in store */
5836         TERM_LEN w, h;
5837
5838         if(p_ptr->wild_mode) return;
5839         Term_get_size(&w, &h);
5840
5841         /* Calculate stocks per 1 page */
5842         xtra_stock = MIN(14+26, ((h > 24) ? (h - 24) : 0));
5843         store_bottom = MIN_STOCK + xtra_stock;
5844
5845         /* Access the player grid */
5846         c_ptr = &cave[p_ptr->y][p_ptr->x];
5847
5848         /* Verify a store */
5849         if (!cave_have_flag_grid(c_ptr, FF_STORE))
5850         {
5851                 msg_print(_("ここには店がありません。", "You see no store here."));
5852                 return;
5853         }
5854
5855         /* Extract the store code */
5856         which = f_info[c_ptr->feat].subtype;
5857
5858         old_town_num = p_ptr->town_num;
5859         if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
5860         if (dun_level) p_ptr->town_num = NO_TOWN;
5861         inner_town_num = p_ptr->town_num;
5862
5863         /* Hack -- Check the "locked doors" */
5864         if ((town[p_ptr->town_num].store[which].store_open >= turn) ||
5865             (ironman_shops))
5866         {
5867                 msg_print(_("ドアに鍵がかかっている。", "The doors are locked."));
5868                 p_ptr->town_num = old_town_num;
5869                 return;
5870         }
5871
5872         /* Calculate the number of store maintainances since the last visit */
5873         maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
5874
5875         /* Maintain the store max. 10 times */
5876         if (maintain_num > 10) maintain_num = 10;
5877
5878         if (maintain_num)
5879         {
5880                 /* Maintain the store */
5881                 for (i = 0; i < maintain_num; i++)
5882                         store_maint(p_ptr->town_num, which);
5883
5884                 /* Save the visit */
5885                 town[p_ptr->town_num].store[which].last_visit = turn;
5886         }
5887
5888         forget_lite();
5889         forget_view();
5890
5891         /* Hack -- Character is in "icky" mode */
5892         character_icky = TRUE;
5893
5894         /* command reset */
5895         command_arg = 0;
5896         command_rep = 0;
5897         command_new = 0;
5898
5899         /* Do not expand macros */
5900         get_com_no_macros = TRUE;
5901
5902         /* Save the store number */
5903         cur_store_num = which;
5904
5905         /* Hack -- save the store feature */
5906         cur_store_feat = c_ptr->feat;
5907
5908         /* Save the store and owner pointers */
5909         st_ptr = &town[p_ptr->town_num].store[cur_store_num];
5910         ot_ptr = &owners[cur_store_num][st_ptr->owner];
5911
5912         /* Start at the beginning */
5913         store_top = 0;
5914
5915         play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
5916
5917         display_store();
5918
5919         /* Do not leave */
5920         leave_store = FALSE;
5921
5922         /* Interact with player */
5923         while (!leave_store)
5924         {
5925                 /* Hack -- Clear line 1 */
5926                 prt("", 1, 0);
5927
5928                 /* Clear */
5929                 clear_from(20 + xtra_stock);
5930
5931                 /* Basic commands */
5932                 prt(_(" ESC) 建物から出る", " ESC) Exit from Building."), 21 + xtra_stock, 0);
5933
5934                 /* Browse if necessary */
5935                 if (st_ptr->stock_num > store_bottom)
5936                 {
5937                         prt(_(" -)前ページ", " -) Previous page"), 22 + xtra_stock, 0);
5938                         prt(_(" スペース) 次ページ", " SPACE) Next page"), 23 + xtra_stock, 0);
5939                 }
5940
5941                 /* Home commands */
5942                 if (cur_store_num == STORE_HOME)
5943                 {
5944                         prt(_("g) アイテムを取る", "g) Get an item."), 21 + xtra_stock, 27);
5945                         prt(_("d) アイテムを置く", "d) Drop an item."), 22 + xtra_stock, 27);
5946                         prt(_("x) 家のアイテムを調べる", "x) eXamine an item in the home."), 23 + xtra_stock, 27);
5947                 }
5948
5949                 /* Museum commands */
5950                 else if (cur_store_num == STORE_MUSEUM)
5951                 {
5952                         prt(_("d) アイテムを置く", "d) Drop an item."), 21 + xtra_stock, 27);
5953                         prt(_("r) アイテムの展示をやめる", "r) order to Remove an item."), 22 + xtra_stock, 27);
5954                         prt(_("x) 博物館のアイテムを調べる", "x) eXamine an item in the museum."), 23 + xtra_stock, 27);
5955                 }
5956
5957                 /* Shop commands */
5958                 else
5959                 {
5960                         prt(_("p) 商品を買う", "p) Purchase an item."), 21 + xtra_stock, 30);
5961                         prt(_("s) アイテムを売る", "s) Sell an item."), 22 + xtra_stock, 30);
5962                         prt(_("x) 商品を調べる", "x) eXamine an item in the shop"), 23 + xtra_stock,30);
5963                 }
5964
5965                 /* 基本的なコマンドの追加表示 */
5966                 prt(_("i/e) 持ち物/装備の一覧", "i/e) Inventry/Equipment list"), 21 + xtra_stock, 56);
5967
5968                 if (rogue_like_commands)
5969                 {
5970                         prt(_("w/T) 装備する/はずす", "w/T) Wear/Take off equipment"), 22 + xtra_stock, 56);
5971                 }
5972                 else
5973                 {
5974                         prt(_("w/t) 装備する/はずす", "w/t) Wear/Take off equipment"), 22 + xtra_stock, 56);
5975                 }
5976
5977                 /* Prompt */
5978                 prt(_("コマンド:", "You may: "), 20 + xtra_stock, 0);
5979
5980                 request_command(TRUE);
5981
5982                 /* Process the command */
5983                 store_process_command();
5984
5985                 /*
5986                  * Hack -- To redraw missiles damage and prices in store
5987                  * If player's charisma changes, or if player changes a bow, PU_BONUS is set
5988                  */
5989                 need_redraw_store_inv = (p_ptr->update & PU_BONUS) ? TRUE : FALSE;
5990
5991                 /* Hack -- Character is still in "icky" mode */
5992                 character_icky = TRUE;
5993
5994                 handle_stuff();
5995
5996                 /* Pack Overflow */
5997                 if (inventory[INVEN_PACK].k_idx)
5998                 {
5999                         INVENTORY_IDX item = INVEN_PACK;
6000
6001                         object_type *o_ptr = &inventory[item];
6002
6003                         /* Hack -- Flee from the store */
6004                         if (cur_store_num != STORE_HOME)
6005                         {
6006                                 if (cur_store_num == STORE_MUSEUM)
6007                                         msg_print(_("ザックからアイテムがあふれそうなので、あわてて博物館から出た...", "Your pack is so full that you flee the Museum..."));
6008                                 else
6009                                         msg_print(_("ザックからアイテムがあふれそうなので、あわてて店から出た...", "Your pack is so full that you flee the store..."));
6010
6011                                 /* Leave */
6012                                 leave_store = TRUE;
6013                         }
6014
6015                         /* Hack -- Flee from the home */
6016                         else if (!store_check_num(o_ptr))
6017                         {
6018                                 msg_print(_("ザックからアイテムがあふれそうなので、あわてて家から出た...", "Your pack is so full that you flee your home..."));
6019                                 /* Leave */
6020                                 leave_store = TRUE;
6021                         }
6022
6023                         /* Hack -- Drop items into the home */
6024                         else
6025                         {
6026                                 int item_pos;
6027
6028                                 object_type forge;
6029                                 object_type *q_ptr;
6030
6031                                 GAME_TEXT o_name[MAX_NLEN];
6032
6033                                 /* Give a message */
6034                                 msg_print(_("ザックからアイテムがあふれてしまった!", "Your pack overflows!"));
6035
6036                                 q_ptr = &forge;
6037
6038                                 object_copy(q_ptr, o_ptr);
6039                                 object_desc(o_name, q_ptr, 0);
6040
6041                                 msg_format(_("%sが落ちた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
6042
6043                                 /* Remove it from the players inventory */
6044                                 inven_item_increase(item, -255);
6045                                 inven_item_describe(item);
6046                                 inven_item_optimize(item);
6047                                 handle_stuff();
6048
6049                                 /* Let the home carry it */
6050                                 item_pos = home_carry(q_ptr);
6051
6052                                 /* Redraw the home */
6053                                 if (item_pos >= 0)
6054                                 {
6055                                         store_top = (item_pos / store_bottom) * store_bottom;
6056                                         display_inventory();
6057                                 }
6058                         }
6059                 }
6060
6061                 /* Hack -- Redisplay store prices if charisma changes */
6062                 /* Hack -- Redraw missiles damage if player changes bow */
6063                 if (need_redraw_store_inv) display_inventory();
6064
6065                 /* Hack -- get kicked out of the store */
6066                 if (st_ptr->store_open >= turn) leave_store = TRUE;
6067         }
6068
6069         select_floor_music();
6070
6071         p_ptr->town_num = old_town_num;
6072
6073         /* Free turn */
6074         p_ptr->energy_use = 100;
6075
6076
6077         /* Hack -- Character is no longer in "icky" mode */
6078         character_icky = FALSE;
6079
6080
6081         /* Hack -- Cancel automatic command */
6082         command_new = 0;
6083
6084         /* Hack -- Cancel "see" mode */
6085         command_see = FALSE;
6086
6087         /* Allow expanding macros */
6088         get_com_no_macros = FALSE;
6089
6090         msg_erase();
6091         Term_clear();
6092
6093         /* Update everything */
6094         p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
6095         p_ptr->update |= (PU_MONSTERS);
6096
6097         /* Redraw entire screen */
6098         p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
6099         p_ptr->redraw |= (PR_MAP);
6100         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
6101 }
6102
6103
6104
6105 /*!
6106  * @brief 現在の町の店主を交代させる /
6107  * Shuffle one of the stores.
6108  * @param which 店舗種類のID
6109  * @return なし
6110  */
6111 void store_shuffle(int which)
6112 {
6113         int i, j;
6114
6115
6116         /* Ignore home */
6117         if (which == STORE_HOME) return;
6118         if (which == STORE_MUSEUM) return;
6119
6120
6121         /* Save the store index */
6122         cur_store_num = which;
6123
6124         /* Activate that store */
6125         st_ptr = &town[p_ptr->town_num].store[cur_store_num];
6126
6127         j = st_ptr->owner;
6128         /* Pick a new owner */
6129         while(1)
6130         {
6131                 st_ptr->owner = (byte)randint0(MAX_OWNERS);
6132                 if (j == st_ptr->owner) continue;
6133                 for (i = 1;i < max_towns; i++)
6134                 {
6135                         if (i == p_ptr->town_num) continue;
6136                         if (st_ptr->owner == town[i].store[cur_store_num].owner) break;
6137                 }
6138                 if (i == max_towns) break;
6139         }
6140
6141         /* Activate the new owner */
6142         ot_ptr = &owners[cur_store_num][st_ptr->owner];
6143
6144
6145         /* Reset the owner data */
6146         st_ptr->insult_cur = 0;
6147         st_ptr->store_open = 0;
6148         st_ptr->good_buy = 0;
6149         st_ptr->bad_buy = 0;
6150
6151
6152         /* Hack -- discount all the items */
6153         for (i = 0; i < st_ptr->stock_num; i++)
6154         {
6155                 object_type *o_ptr;
6156
6157                 o_ptr = &st_ptr->stock[i];
6158
6159                 if (!object_is_artifact(o_ptr))
6160                 {
6161                         /* Hack -- Sell all non-artifact old items for "half price" */
6162                         o_ptr->discount = 50;
6163
6164                         /* Hack -- Items are no longer "fixed price" */
6165                         o_ptr->ident &= ~(IDENT_FIXED);
6166
6167                         /* Mega-Hack -- Note that the item is "on sale" */
6168                         o_ptr->inscription = quark_add(_("売出中", "on sale"));
6169                 }
6170         }
6171 }
6172
6173
6174 /*!
6175  * @brief 店の品揃えを変化させる /
6176  * Maintain the inventory at the stores.
6177  * @param town_num 町のID
6178  * @param store_num 店舗種類のID
6179  * @return なし
6180  */
6181 void store_maint(int town_num, int store_num)
6182 {
6183         INVENTORY_IDX j;
6184
6185         cur_store_num = store_num;
6186
6187         /* Ignore home */
6188         if (store_num == STORE_HOME) return;
6189         if (store_num == STORE_MUSEUM) return;
6190
6191         /* Activate that store */
6192         st_ptr = &town[town_num].store[store_num];
6193
6194         /* Activate the owner */
6195         ot_ptr = &owners[store_num][st_ptr->owner];
6196
6197         /* Store keeper forgives the player */
6198         st_ptr->insult_cur = 0;
6199
6200         /* Mega-Hack -- prune the black market */
6201         if (store_num == STORE_BLACK)
6202         {
6203                 /* Destroy crappy black market items */
6204                 for (j = st_ptr->stock_num - 1; j >= 0; j--)
6205                 {
6206                         object_type *o_ptr = &st_ptr->stock[j];
6207
6208                         /* Destroy crappy items */
6209                         if (black_market_crap(o_ptr))
6210                         {
6211                                 /* Destroy the item */
6212                                 store_item_increase(j, 0 - o_ptr->number);
6213                                 store_item_optimize(j);
6214                         }
6215                 }
6216         }
6217
6218
6219         /* Choose the number of slots to keep */
6220         j = st_ptr->stock_num;
6221
6222         /* Sell a few items */
6223         j = j - randint1(STORE_TURNOVER);
6224
6225         /* Never keep more than "STORE_MAX_KEEP" slots */
6226         if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
6227
6228         /* Always "keep" at least "STORE_MIN_KEEP" items */
6229         if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
6230
6231         /* Hack -- prevent "underflow" */
6232         if (j < 0) j = 0;
6233
6234         /* Destroy objects until only "j" slots are left */
6235         while (st_ptr->stock_num > j) store_delete();
6236
6237
6238         /* Choose the number of slots to fill */
6239         j = st_ptr->stock_num;
6240
6241         /* Buy some more items */
6242         j = j + randint1(STORE_TURNOVER);
6243
6244         /* Never keep more than "STORE_MAX_KEEP" slots */
6245         if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
6246
6247         /* Always "keep" at least "STORE_MIN_KEEP" items */
6248         if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
6249
6250         /* Hack -- prevent "overflow" */
6251         if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
6252
6253         /* Acquire some new items */
6254         while (st_ptr->stock_num < j) store_create();
6255 }
6256
6257
6258 /*!
6259  * @brief 店舗情報を初期化する /
6260  * Initialize the stores
6261  * @param town_num 町のID
6262  * @param store_num 店舗種類のID
6263  * @return なし
6264  */
6265 void store_init(int town_num, int store_num)
6266 {
6267         int k;
6268         cur_store_num = store_num;
6269
6270         /* Activate that store */
6271         st_ptr = &town[town_num].store[store_num];
6272
6273
6274         /* Pick an owner */
6275         while(1)
6276         {
6277                 int i;
6278
6279                 st_ptr->owner = (byte)randint0(MAX_OWNERS);
6280                 for (i = 1;i < max_towns; i++)
6281                 {
6282                         if (i == town_num) continue;
6283                         if (st_ptr->owner == town[i].store[store_num].owner) break;
6284                 }
6285                 if (i == max_towns) break;
6286         }
6287
6288         /* Activate the new owner */
6289         ot_ptr = &owners[store_num][st_ptr->owner];
6290
6291
6292         /* Initialize the store */
6293         st_ptr->store_open = 0;
6294         st_ptr->insult_cur = 0;
6295         st_ptr->good_buy = 0;
6296         st_ptr->bad_buy = 0;
6297
6298         /* Nothing in stock */
6299         st_ptr->stock_num = 0;
6300
6301         /*
6302          * MEGA-HACK - Last visit to store is
6303          * BEFORE player birth to enable store restocking
6304          */
6305         st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6306
6307         /* Clear any old items */
6308         for (k = 0; k < st_ptr->stock_size; k++)
6309         {
6310                 object_wipe(&st_ptr->stock[k]);
6311         }
6312 }
6313
6314
6315 /*!
6316  * @brief アイテムを町のブラックマーケットに移動させる /
6317  * @param o_ptr 移動させたいオブジェクトの構造体参照ポインタ
6318  * @return なし
6319  */
6320 void move_to_black_market(object_type *o_ptr)
6321 {
6322         /* Not in town */
6323         if (!p_ptr->town_num) return;
6324
6325         st_ptr = &town[p_ptr->town_num].store[STORE_BLACK];
6326
6327         o_ptr->ident |= IDENT_STORE;
6328
6329         (void)store_carry(o_ptr);
6330
6331         object_wipe(o_ptr); /* Don't leave a bogus object behind... */
6332 }
6333