OSDN Git Service

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