OSDN Git Service

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