OSDN Git Service

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