OSDN Git Service

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