OSDN Git Service

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