OSDN Git Service

32c021343a9d7730d7ab71cf6f9e559cb8bfd4f6
[hengband/hengband.git] / src / bldg.c
1 /*!
2  @file bldg.c
3  @brief 町の施設処理 / Building commands
4  @date 2013/12/23
5  @author
6  Created by Ken Wigle for Kangband - a variant of Angband 2.8.3
7  -KMW-
8  
9  Rewritten for Kangband 2.8.3i using Kamband's version of
10  bldg.c as written by Ivan Tkatchev
11  
12  Changed for ZAngband by Robert Ruehlmann
13 */
14
15 #include "angband.h"
16 #include "util.h"
17 #include "term.h"
18
19 #include "core.h"
20 #include "core/show-file.h"
21 #include "io/write-diary.h"
22 #include "cmd/cmd-dump.h"
23 #include "cmd/cmd-magiceat.h"
24 #include "floor.h"
25 #include "floor-events.h"
26 #include "floor-save.h"
27 #include "autopick.h"
28 #include "objectkind.h"
29 #include "object-boost.h"
30 #include "object-flavor.h"
31 #include "object-hook.h"
32 #include "monster.h"
33 #include "monsterrace-hook.h"
34 #include "melee.h"
35 #include "wild.h"
36 #include "world.h"
37 #include "sort.h"
38
39 #include "avatar.h"
40 #include "bldg.h"
41 #include "dungeon.h"
42 #include "mutation.h"
43 #include "quest.h"
44 #include "artifact.h"
45 #include "cmd-spell.h"
46 #include "rumor.h"
47 #include "spells.h"
48 #include "spells-object.h"
49 #include "spells-status.h"
50 #include "realm-hex.h"
51 #include "dungeon-file.h"
52
53 #include "files.h"
54 #include "player-status.h"
55 #include "player-effects.h"
56 #include "player-class.h"
57 #include "player-personality.h"
58 #include "player-inventory.h"
59 #include "scores.h"
60 #include "shoot.h"
61 #include "view-mainwindow.h"
62 #include "monsterrace.h"
63 #include "autopick.h"
64
65 #include "market/poker.h"
66 #include "market/building-util.h"
67 #include "view/display-fruit.h"
68
69 /*
70  * todo MAX_BLDGが定義されていない旨のエラーが出る……がコンパイルには成功する
71  * Buildings
72  */
73 building_type building[MAX_BLDG];
74
75 MONRACE_IDX battle_mon[4];
76 u32b mon_odds[4];
77 int battle_odds;
78 PRICE kakekin;
79 int sel_monster;
80
81 bool reinit_wilderness = FALSE;
82 MONSTER_IDX today_mon;
83
84 /*!
85  * todo MAX_ARENA_MONSが定義されていない旨のエラーが出る……がコンパイルには成功する
86  * @brief 闘技場のモンスターID及び報酬アイテムテーブル
87  */
88 const arena_type arena_info[MAX_ARENA_MONS + 2] =
89 {
90         { MON_NOBORTA,       TV_AMULET, SV_AMULET_ADORNMENT           },
91         { MON_MORI_TROLL,    TV_FOOD,   SV_FOOD_PINT_OF_WINE          },
92         { MON_IMP,           TV_POTION, SV_POTION_SPEED               },
93         { MON_LION_HEART,    0,         0                             },
94         { MON_MASTER_YEEK,   TV_POTION, SV_POTION_CURING              },
95         { MON_SABRE_TIGER,   TV_WAND,   SV_WAND_STONE_TO_MUD          },
96         { MON_LIZARD_KING,   TV_WAND,   SV_WAND_TELEPORT_AWAY         },
97         { MON_WYVERN,        TV_POTION, SV_POTION_HEALING             },
98         { MON_ARCH_VILE,     TV_POTION, SV_POTION_RESISTANCE          },
99         { MON_ELF_LORD   ,   TV_POTION, SV_POTION_ENLIGHTENMENT       },
100         { MON_GHOUL_KING,    TV_FOOD,   SV_FOOD_RESTORING             },
101         { MON_COLBRAN,       TV_RING,   SV_RING_ELEC                  },
102         { MON_BICLOPS,       TV_WAND,   SV_WAND_ACID_BALL             },
103         { MON_M_MINDCRAFTER, TV_POTION, SV_POTION_SELF_KNOWLEDGE      },
104         { MON_GROO,          TV_SCROLL, SV_SCROLL_ACQUIREMENT         },
105         { MON_RAAL,          TV_SCROLL, SV_SCROLL_STAR_DESTRUCTION    },
106         { MON_DREADMASTER,   TV_WAND,   SV_WAND_HYPODYNAMIA            },
107         { MON_ULTRA_PALADIN, TV_STAFF,  SV_STAFF_DISPEL_EVIL          },
108         { MON_BARNEY,        TV_RING,   SV_RING_RES_CHAOS             },
109         { MON_TROLL_KING,    TV_SCROLL, SV_SCROLL_MASS_GENOCIDE       },
110         { MON_BARON_HELL,    TV_POTION, SV_POTION_AUGMENTATION        },
111         { MON_F_ANGEL,       TV_SCROLL, SV_SCROLL_RUNE_OF_PROTECTION  },
112         { MON_G_C_DRAKE,     TV_WAND,   SV_WAND_DRAGON_FIRE           },
113         { MON_IRON_LICH,     TV_STAFF,  SV_STAFF_DESTRUCTION          },
114         { MON_DROLEM,        TV_POTION, SV_POTION_STAR_HEALING        },
115         { MON_G_TITAN,       TV_WAND,   SV_WAND_GENOCIDE              },
116         { MON_G_BALROG,      TV_POTION, SV_POTION_EXPERIENCE          },
117         { MON_ELDER_VAMPIRE, TV_RING,   SV_RING_SUSTAIN               },
118         { MON_NIGHTWALKER,   TV_WAND,   SV_WAND_STRIKING              },
119         { MON_S_TYRANNO,     TV_SCROLL, SV_SCROLL_STAR_ACQUIREMENT    },
120         { MON_G_MASTER_MYS,  TV_ROD,    SV_ROD_IDENTIFY               },
121         { MON_LORD_CHAOS,    TV_POTION, SV_POTION_LIFE                },
122         { MON_SHADOWLORD,    TV_POTION, SV_POTION_STAR_ENLIGHTENMENT  },
123         { MON_ULT_BEHOLDER,  TV_AMULET, SV_AMULET_REFLECTION          },
124         { MON_JABBERWOCK,    TV_ROD,    SV_ROD_HEALING                },
125         { MON_LOCKE_CLONE,   TV_WAND,   SV_WAND_DISINTEGRATE          },
126         { MON_WYRM_SPACE,    TV_ROD,    SV_ROD_RESTORATION            },
127         { MON_SHAMBLER,      TV_SCROLL, SV_SCROLL_STAR_ACQUIREMENT    },
128         { MON_BLACK_REAVER,  TV_RING,   SV_RING_LORDLY                },
129         { MON_FENGHUANG,     TV_STAFF,  SV_STAFF_THE_MAGI             },
130         { MON_WYRM_POWER,    TV_SCROLL, SV_SCROLL_ARTIFACT            },
131         { 0,                 0,         0                             }, /* Victory prizing */
132         { MON_HAGURE,        TV_SCROLL, SV_SCROLL_ARTIFACT            },
133 };
134
135 /*!
136  * @brief 施設毎に設定された種族、職業、魔法領域フラグがプレイヤーと一致するかを判定する。
137  * @details 各種ギルドや寺院など、特定の職業ならば優遇措置を得られる施設、
138  * あるいは食堂など特定の種族では利用できない施設の判定処理を行う。
139  * @param player_ptr プレーヤーへの参照ポインタ
140  * @param bldg 施設構造体の参照ポインタ
141  * @return 種族、職業、魔法領域のいずれかが一致しているかの是非。
142  */
143 static bool is_owner(player_type *player_ptr, building_type *bldg)
144 {
145         if (bldg->member_class[player_ptr->pclass] == BUILDING_OWNER)
146         {
147                 return TRUE;
148         }
149
150         if (bldg->member_race[player_ptr->prace] == BUILDING_OWNER)
151         {
152                 return TRUE;
153         }
154
155         REALM_IDX realm1 = player_ptr->realm1;
156         REALM_IDX realm2 = player_ptr->realm2;
157         if ((is_magic(realm1) && (bldg->member_realm[realm1] == BUILDING_OWNER)) ||
158                 (is_magic(realm2) && (bldg->member_realm[realm2] == BUILDING_OWNER)))
159         {
160                 return TRUE;
161         }
162
163         return FALSE;
164 }
165
166
167 /*!
168  * @brief 施設毎に設定された種族、職業、魔法領域フラグがプレイヤーと一致するかを判定する。
169  (スペルマスターの特別判定つき)
170  * @details 各種ギルドや寺院など、特定の職業ならば優遇措置を得られる施設、
171  * あるいは食堂など特定の種族では利用できない施設の判定処理を行う。
172  * @param player_ptr プレーヤーへの参照ポインタ
173  * @param bldg 施設構造体の参照ポインタ
174  * @return 種族、職業、魔法領域のいずれかが一致しているかの是非。
175  * @todo is_owner()との実質的な多重実装なので、リファクタリングを行うべきである。
176  */
177 static bool is_member(player_type *player_ptr, building_type *bldg)
178 {
179         if (bldg->member_class[player_ptr->pclass])
180         {
181                 return TRUE;
182         }
183
184         if (bldg->member_race[player_ptr->prace])
185         {
186                 return TRUE;
187         }
188
189         REALM_IDX realm1 = player_ptr->realm1;
190         REALM_IDX realm2 = player_ptr->realm2;
191         if ((is_magic(realm1) && bldg->member_realm[realm1]) ||
192                 (is_magic(realm2) && bldg->member_realm[realm2]))
193         {
194                 return TRUE;
195         }
196
197         if (player_ptr->pclass != CLASS_SORCERER) return FALSE;
198
199         for (int i = 0; i < MAX_MAGIC; i++)
200         {
201                 if (bldg->member_realm[i + 1]) return TRUE;
202         }
203
204         return FALSE;
205 }
206
207
208 /*!
209  * @brief 所持金を表示する。
210  * @param player_ptr プレーヤーへの参照ポインタ
211  * @return なし
212  */
213 static void building_prt_gold(player_type *player_ptr)
214 {
215         char tmp_str[80];
216         prt(_("手持ちのお金: ", "Gold Remaining: "), 23, 53);
217         sprintf(tmp_str, "%9ld", (long)player_ptr->au);
218         prt(tmp_str, 23, 68);
219 }
220
221
222 /*!
223  * @brief 施設のサービス一覧を表示する / Display a building.
224  * @param player_ptr プレーヤーへの参照ポインタ
225  * @param bldg 施設構造体の参照ポインタ
226  * @return なし
227  */
228 static void show_building(player_type *player_ptr, building_type* bldg)
229 {
230         char buff[20];
231         byte action_color;
232         char tmp_str[80];
233
234         Term_clear();
235         sprintf(tmp_str, "%s (%s) %35s", bldg->owner_name, bldg->owner_race, bldg->name);
236         prt(tmp_str, 2, 1);
237
238         for (int i = 0; i < 8; i++)
239         {
240                 if (!bldg->letters[i]) continue;
241
242                 if (bldg->action_restr[i] == 0)
243                 {
244                         if ((is_owner(player_ptr, bldg) && (bldg->member_costs[i] == 0)) ||
245                                 (!is_owner(player_ptr, bldg) && (bldg->other_costs[i] == 0)))
246                         {
247                                 action_color = TERM_WHITE;
248                                 buff[0] = '\0';
249                         }
250                         else if (is_owner(player_ptr, bldg))
251                         {
252                                 action_color = TERM_YELLOW;
253                                 sprintf(buff, _("($%ld)", "(%ldgp)"), (long int)bldg->member_costs[i]);
254                         }
255                         else
256                         {
257                                 action_color = TERM_YELLOW;
258                                 sprintf(buff, _("($%ld)", "(%ldgp)"), (long int)bldg->other_costs[i]);
259                         }
260
261                         sprintf(tmp_str, " %c) %s %s", bldg->letters[i], bldg->act_names[i], buff);
262                         c_put_str(action_color, tmp_str, 19 + (i / 2), 35 * (i % 2));
263                         continue;
264                 }
265
266                 if (bldg->action_restr[i] == 1)
267                 {
268                         if (!is_member(player_ptr, bldg))
269                         {
270                                 action_color = TERM_L_DARK;
271                                 strcpy(buff, _("(閉店)", "(closed)"));
272                         }
273                         else if ((is_owner(player_ptr, bldg) && (bldg->member_costs[i] == 0)) ||
274                                 (is_member(player_ptr, bldg) && (bldg->other_costs[i] == 0)))
275                         {
276                                 action_color = TERM_WHITE;
277                                 buff[0] = '\0';
278                         }
279                         else if (is_owner(player_ptr, bldg))
280                         {
281                                 action_color = TERM_YELLOW;
282                                 sprintf(buff, _("($%ld)", "(%ldgp)"), (long int)bldg->member_costs[i]);
283                         }
284                         else
285                         {
286                                 action_color = TERM_YELLOW;
287                                 sprintf(buff, _("($%ld)", "(%ldgp)"), (long int)bldg->other_costs[i]);
288                         }
289
290                         sprintf(tmp_str, " %c) %s %s", bldg->letters[i], bldg->act_names[i], buff);
291                         c_put_str(action_color, tmp_str, 19 + (i / 2), 35 * (i % 2));
292                         continue;
293                 }
294
295                 if (!is_owner(player_ptr, bldg))
296                 {
297                         action_color = TERM_L_DARK;
298                         strcpy(buff, _("(閉店)", "(closed)"));
299                 }
300                 else if (bldg->member_costs[i] != 0)
301                 {
302                         action_color = TERM_YELLOW;
303                         sprintf(buff, _("($%ld)", "(%ldgp)"), (long int)bldg->member_costs[i]);
304                 }
305                 else
306                 {
307                         action_color = TERM_WHITE;
308                         buff[0] = '\0';
309                 }
310
311                 sprintf(tmp_str, " %c) %s %s", bldg->letters[i], bldg->act_names[i], buff);
312                 c_put_str(action_color, tmp_str, 19 + (i / 2), 35 * (i % 2));
313         }
314
315         prt(_(" ESC) 建物を出る", " ESC) Exit building"), 23, 0);
316 }
317
318
319 /*!
320  * @brief 闘技場に入るコマンドの処理 / arena commands
321  * @param player_ptr プレーヤーへの参照ポインタ
322  * @param cmd 闘技場処理のID
323  * @return なし
324  */
325 static void arena_comm(player_type *player_ptr, int cmd)
326 {
327         monster_race    *r_ptr;
328         concptr            name;
329
330         switch (cmd)
331         {
332         case BACT_ARENA:
333                 if (player_ptr->arena_number == MAX_ARENA_MONS)
334                 {
335                         clear_bldg(5, 19);
336                         prt(_("アリーナの優勝者!", "               Arena Victor!"), 5, 0);
337                         prt(_("おめでとう!あなたは全ての敵を倒しました。", "Congratulations!  You have defeated all before you."), 7, 0);
338                         prt(_("賞金として $1,000,000 が与えられます。", "For that, receive the prize: 1,000,000 gold pieces"), 8, 0);
339
340                         prt("", 10, 0);
341                         prt("", 11, 0);
342                         player_ptr->au += 1000000L;
343                         msg_print(_("スペースキーで続行", "Press the space bar to continue"));
344                         msg_print(NULL);
345                         player_ptr->arena_number++;
346                         break;
347                 }
348
349                 if (player_ptr->arena_number > MAX_ARENA_MONS)
350                 {
351                         if (player_ptr->arena_number < MAX_ARENA_MONS + 2)
352                         {
353                                 msg_print(_("君のために最強の挑戦者を用意しておいた。", "The strongest challenger is waiting for you."));
354                                 msg_print(NULL);
355                                 if (get_check(_("挑戦するかね?", "Do you fight? ")))
356                                 {
357                                         msg_print(_("死ぬがよい。", "Die, maggots."));
358                                         msg_print(NULL);
359
360                                         player_ptr->exit_bldg = FALSE;
361                                         reset_tim_flags(player_ptr);
362
363                                         /* Save the surface floor as saved floor */
364                                         prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS);
365
366                                         player_ptr->current_floor_ptr->inside_arena = TRUE;
367                                         player_ptr->leaving = TRUE;
368                                         player_ptr->leave_bldg = TRUE;
369                                 }
370                                 else
371                                 {
372                                         msg_print(_("残念だ。", "We are disappointed."));
373                                 }
374                         }
375                         else
376                         {
377                                 msg_print(_("あなたはアリーナに入り、しばらくの間栄光にひたった。",
378                                         "You enter the arena briefly and bask in your glory."));
379                                 msg_print(NULL);
380                         }
381
382                         break;
383                 }
384
385                 if (player_ptr->riding && (player_ptr->pclass != CLASS_BEASTMASTER) && (player_ptr->pclass != CLASS_CAVALRY))
386                 {
387                         msg_print(_("ペットに乗ったままではアリーナへ入れさせてもらえなかった。",
388                                 "You don't have permission to enter with pet."));
389                         msg_print(NULL);
390                         break;
391                 }
392
393                 player_ptr->exit_bldg = FALSE;
394                 reset_tim_flags(player_ptr);
395                 prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS);
396
397                 player_ptr->current_floor_ptr->inside_arena = TRUE;
398                 player_ptr->leaving = TRUE;
399                 player_ptr->leave_bldg = TRUE;
400                 break;
401         case BACT_POSTER:
402                 if (player_ptr->arena_number == MAX_ARENA_MONS)
403                 {
404                         msg_print(_("あなたは勝利者だ。 アリーナでのセレモニーに参加しなさい。",
405                                 "You are victorious. Enter the arena for the ceremony."));
406                         break;
407                 }
408
409                 if (player_ptr->arena_number > MAX_ARENA_MONS)
410                 {
411                         msg_print(_("あなたはすべての敵に勝利した。", "You have won against all foes."));
412                         break;
413                 }
414
415                 r_ptr = &r_info[arena_info[player_ptr->arena_number].r_idx];
416                 name = (r_name + r_ptr->name);
417                 msg_format(_("%s に挑戦するものはいないか?", "Do I hear any challenges against: %s"), name);
418
419                 player_ptr->monster_race_idx = arena_info[player_ptr->arena_number].r_idx;
420                 player_ptr->window |= (PW_MONSTER);
421                 handle_stuff(player_ptr);
422                 break;
423         case BACT_ARENA_RULES:
424                 screen_save();
425
426                 /* Peruse the arena help file */
427                 (void)show_file(player_ptr, TRUE, _("arena_j.txt", "arena.txt"), NULL, 0, 0);
428                 screen_load();
429                 break;
430         }
431 }
432
433
434 /*!
435  * @brief カジノ1プレイごとのメインルーチン / gamble_comm
436  * @param player_ptr プレーヤーへの参照ポインタ
437  * @param cmd プレイするゲームID
438  * @return なし
439  */
440 static bool gamble_comm(player_type *player_ptr, int cmd)
441 {
442         int i;
443         int roll1, roll2, roll3, choice, odds, win;
444         s32b wager;
445         s32b maxbet;
446         s32b oldgold;
447
448         char out_val[160], tmp_str[80], again;
449         concptr p;
450
451         screen_save();
452
453         if (cmd == BACT_GAMBLE_RULES)
454         {
455                 (void)show_file(player_ptr, TRUE, _("jgambling.txt", "gambling.txt"), NULL, 0, 0);
456                 screen_load();
457                 return TRUE;
458         }
459
460         if (player_ptr->au < 1)
461         {
462                 msg_print(_("おい!おまえ一文なしじゃないか!こっから出ていけ!",
463                         "Hey! You don't have gold - get out of here!"));
464                 msg_print(NULL);
465                 screen_load();
466                 return FALSE;
467         }
468
469         clear_bldg(5, 23);
470         maxbet = player_ptr->lev * 200;
471         maxbet = MIN(maxbet, player_ptr->au);
472
473         strcpy(out_val, "");
474         sprintf(tmp_str, _("賭け金 (1-%ld)?", "Your wager (1-%ld) ? "), (long int)maxbet);
475
476
477         /*
478          * Use get_string() because we may need more than
479          * the s16b value returned by get_quantity().
480          */
481         if (!get_string(tmp_str, out_val, 32))
482         {
483                 msg_print(NULL);
484                 screen_load();
485                 return TRUE;
486         }
487
488         for (p = out_val; *p == ' '; p++);
489
490         wager = atol(p);
491         if (wager > player_ptr->au)
492         {
493                 msg_print(_("おい!金が足りないじゃないか!出ていけ!", "Hey! You don't have the gold - get out of here!"));
494                 msg_print(NULL);
495                 screen_load();
496                 return FALSE;
497         }
498         else if (wager > maxbet)
499         {
500                 msg_format(_("%ldゴールドだけ受けよう。残りは取っときな。",
501                         "I'll take %ld gold of that. Keep the rest."), (long int)maxbet);
502                 wager = maxbet;
503         }
504         else if (wager < 1)
505         {
506                 msg_print(_("OK、1ゴールドからはじめよう。", "Ok, we'll start with 1 gold."));
507                 wager = 1;
508         }
509         msg_print(NULL);
510         win = FALSE;
511         odds = 0;
512         oldgold = player_ptr->au;
513
514         sprintf(tmp_str, _("ゲーム前の所持金: %9ld", "Gold before game: %9ld"), (long int)oldgold);
515         prt(tmp_str, 20, 2);
516         sprintf(tmp_str, _("現在の掛け金:     %9ld", "Current Wager:    %9ld"), (long int)wager);
517         prt(tmp_str, 21, 2);
518
519         do
520         {
521                 player_ptr->au -= wager;
522                 switch (cmd)
523                 {
524                 case BACT_IN_BETWEEN: /* Game of In-Between */
525                         c_put_str(TERM_GREEN, _("イン・ビトイーン", "In Between"), 5, 2);
526
527                         odds = 4;
528                         win = FALSE;
529                         roll1 = randint1(10);
530                         roll2 = randint1(10);
531                         choice = randint1(10);
532                         sprintf(tmp_str, _("黒ダイス: %d        黒ダイス: %d", "Black die: %d       Black Die: %d"), roll1, roll2);
533
534                         prt(tmp_str, 8, 3);
535                         sprintf(tmp_str, _("赤ダイス: %d", "Red die: %d"), choice);
536
537                         prt(tmp_str, 11, 14);
538                         if (((choice > roll1) && (choice < roll2)) ||
539                                 ((choice < roll1) && (choice > roll2)))
540                                 win = TRUE;
541                         break;
542                 case BACT_CRAPS:  /* Game of Craps */
543                         c_put_str(TERM_GREEN, _("クラップス", "Craps"), 5, 2);
544
545                         win = 3;
546                         odds = 2;
547                         roll1 = randint1(6);
548                         roll2 = randint1(6);
549                         roll3 = roll1 + roll2;
550                         choice = roll3;
551                         sprintf(tmp_str, _("1振りめ: %d %d      Total: %d",
552                                 "First roll: %d %d    Total: %d"), roll1, roll2, roll3);
553                         prt(tmp_str, 7, 5);
554                         if ((roll3 == 7) || (roll3 == 11))
555                                 win = TRUE;
556                         else if ((roll3 == 2) || (roll3 == 3) || (roll3 == 12))
557                                 win = FALSE;
558                         else
559                         {
560                                 do
561                                 {
562                                         msg_print(_("なにかキーを押すともう一回振ります。", "Hit any key to roll again"));
563
564                                         msg_print(NULL);
565                                         roll1 = randint1(6);
566                                         roll2 = randint1(6);
567                                         roll3 = roll1 + roll2;
568                                         sprintf(tmp_str, _("出目: %d %d          合計:      %d",
569                                                 "Roll result: %d %d   Total:     %d"), roll1, roll2, roll3);
570                                         prt(tmp_str, 8, 5);
571                                         if (roll3 == choice)
572                                                 win = TRUE;
573                                         else if (roll3 == 7)
574                                                 win = FALSE;
575                                 } while ((win != TRUE) && (win != FALSE));
576                         }
577                         
578                         break;
579
580                 case BACT_SPIN_WHEEL:  /* Spin the Wheel Game */
581                         win = FALSE;
582                         odds = 9;
583                         c_put_str(TERM_GREEN, _("ルーレット", "Wheel"), 5, 2);
584
585                         prt("0  1  2  3  4  5  6  7  8  9", 7, 5);
586                         prt("--------------------------------", 8, 3);
587                         strcpy(out_val, "");
588                         get_string(_("何番? (0-9): ", "Pick a number (0-9): "), out_val, 32);
589
590                         for (p = out_val; iswspace(*p); p++);
591                         choice = atol(p);
592                         if (choice < 0)
593                         {
594                                 msg_print(_("0番にしとくぜ。", "I'll put you down for 0."));
595                                 choice = 0;
596                         }
597                         else if (choice > 9)
598                         {
599                                 msg_print(_("OK、9番にしとくぜ。", "Ok, I'll put you down for 9."));
600                                 choice = 9;
601                         }
602                         msg_print(NULL);
603                         roll1 = randint0(10);
604                         sprintf(tmp_str, _("ルーレットは回り、止まった。勝者は %d番だ。",
605                                 "The wheel spins to a stop and the winner is %d"), roll1);
606                         prt(tmp_str, 13, 3);
607                         prt("", 9, 0);
608                         prt("*", 9, (3 * roll1 + 5));
609                         if (roll1 == choice)
610                                 win = TRUE;
611                         break;
612
613                 case BACT_DICE_SLOTS: /* The Dice Slots */
614                         c_put_str(TERM_GREEN, _("ダイス・スロット", "Dice Slots"), 5, 2);
615                         c_put_str(TERM_YELLOW, _("レモン   レモン            2", ""), 6, 37);
616                         c_put_str(TERM_YELLOW, _("レモン   レモン   レモン   5", ""), 7, 37);
617                         c_put_str(TERM_ORANGE, _("オレンジ オレンジ オレンジ 10", ""), 8, 37);
618                         c_put_str(TERM_UMBER, _("剣       剣       剣       20", ""), 9, 37);
619                         c_put_str(TERM_SLATE, _("盾       盾       盾       50", ""), 10, 37);
620                         c_put_str(TERM_VIOLET, _("プラム   プラム   プラム   200", ""), 11, 37);
621                         c_put_str(TERM_RED, _("チェリー チェリー チェリー 1000", ""), 12, 37);
622
623                         win = FALSE;
624                         roll1 = randint1(21);
625                         for (i = 6; i > 0; i--)
626                         {
627                                 if ((roll1 - i) < 1)
628                                 {
629                                         roll1 = 7 - i;
630                                         break;
631                                 }
632                                 roll1 -= i;
633                         }
634                         roll2 = randint1(21);
635                         for (i = 6; i > 0; i--)
636                         {
637                                 if ((roll2 - i) < 1)
638                                 {
639                                         roll2 = 7 - i;
640                                         break;
641                                 }
642                                 roll2 -= i;
643                         }
644                         choice = randint1(21);
645                         for (i = 6; i > 0; i--)
646                         {
647                                 if ((choice - i) < 1)
648                                 {
649                                         choice = 7 - i;
650                                         break;
651                                 }
652                                 choice -= i;
653                         }
654                         put_str("/--------------------------\\", 7, 2);
655                         prt("\\--------------------------/", 17, 2);
656                         display_fruit(8, 3, roll1 - 1);
657                         display_fruit(8, 12, roll2 - 1);
658                         display_fruit(8, 21, choice - 1);
659                         if ((roll1 == roll2) && (roll2 == choice))
660                         {
661                                 win = TRUE;
662                                 switch (roll1)
663                                 {
664                                 case 1:
665                                         odds = 5; break;
666                                 case 2:
667                                         odds = 10; break;
668                                 case 3:
669                                         odds = 20; break;
670                                 case 4:
671                                         odds = 50; break;
672                                 case 5:
673                                         odds = 200; break;
674                                 case 6:
675                                         odds = 1000; break;
676                                 }
677                         }
678                         else if ((roll1 == 1) && (roll2 == 1))
679                         {
680                                 win = TRUE;
681                                 odds = 2;
682                         }
683                         break;
684                 case BACT_POKER:
685                         win = FALSE;
686                         odds = do_poker();
687                         if (odds) win = TRUE;
688                         break;
689                 }
690
691                 if (win)
692                 {
693                         prt(_("あなたの勝ち", "YOU WON"), 16, 37);
694
695                         player_ptr->au += odds * wager;
696                         sprintf(tmp_str, _("倍率: %d", "Payoff: %d"), odds);
697
698                         prt(tmp_str, 17, 37);
699                 }
700                 else
701                 {
702                         prt(_("あなたの負け", "You Lost"), 16, 37);
703                         prt("", 17, 37);
704                 }
705
706                 sprintf(tmp_str, _("現在の所持金:     %9ld", "Current Gold:     %9ld"), (long int)player_ptr->au);
707
708                 prt(tmp_str, 22, 2);
709                 prt(_("もう一度(Y/N)?", "Again(Y/N)?"), 18, 37);
710
711                 move_cursor(18, 52);
712                 again = inkey();
713                 prt("", 16, 37);
714                 prt("", 17, 37);
715                 prt("", 18, 37);
716                 if (wager > player_ptr->au)
717                 {
718                         msg_print(_("おい!金が足りないじゃないか!ここから出て行け!",
719                                 "Hey! You don't have the gold - get out of here!"));
720                         msg_print(NULL);
721
722                         /* Get out here */
723                         break;
724                 }
725         } while ((again == 'y') || (again == 'Y'));
726
727         prt("", 18, 37);
728         if (player_ptr->au >= oldgold)
729         {
730                 msg_print(_("「今回は儲けたな!でも次はこっちが勝ってやるからな、絶対に!」",
731                         "You came out a winner! We'll win next time, I'm sure."));
732                 chg_virtue(player_ptr, V_CHANCE, 3);
733         }
734         else
735         {
736                 msg_print(_("「金をスッてしまったな、わはは!うちに帰った方がいいぜ。」", "You lost gold! Haha, better head home."));
737                 chg_virtue(player_ptr, V_CHANCE, -3);
738         }
739
740         msg_print(NULL);
741         screen_load();
742         return TRUE;
743 }
744
745
746 /*!
747  * @brief モンスター闘技場に参加するモンスターを更新する。
748  * @param player_ptr プレーヤーへの参照ポインタ
749  * @return なし
750  */
751 void update_gambling_monsters(player_type *player_ptr)
752 {
753         int total, i;
754         int max_dl = 0;
755         int mon_level;
756         int power[4];
757         bool tekitou;
758
759         for (i = 0; i < current_world_ptr->max_d_idx; i++)
760         {
761                 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
762         }
763
764         mon_level = randint1(MIN(max_dl, 122)) + 5;
765         if (randint0(100) < 60)
766         {
767                 i = randint1(MIN(max_dl, 122)) + 5;
768                 mon_level = MAX(i, mon_level);
769         }
770
771         if (randint0(100) < 30)
772         {
773                 i = randint1(MIN(max_dl, 122)) + 5;
774                 mon_level = MAX(i, mon_level);
775         }
776
777         while (TRUE)
778         {
779                 total = 0;
780                 tekitou = FALSE;
781                 for (i = 0; i < 4; i++)
782                 {
783                         MONRACE_IDX r_idx;
784                         int j;
785                         while (TRUE)
786                         {
787                                 get_mon_num_prep(player_ptr, monster_can_entry_arena, NULL);
788                                 r_idx = get_mon_num(player_ptr, mon_level, GMN_ARENA);
789                                 if (!r_idx) continue;
790
791                                 if ((r_info[r_idx].flags1 & RF1_UNIQUE) || (r_info[r_idx].flags7 & RF7_UNIQUE2))
792                                 {
793                                         if ((r_info[r_idx].level + 10) > mon_level) continue;
794                                 }
795
796                                 for (j = 0; j < i; j++)
797                                         if (r_idx == battle_mon[j]) break;
798                                 if (j < i) continue;
799
800                                 break;
801                         }
802                         battle_mon[i] = r_idx;
803                         if (r_info[r_idx].level < 45) tekitou = TRUE;
804                 }
805
806                 for (i = 0; i < 4; i++)
807                 {
808                         monster_race *r_ptr = &r_info[battle_mon[i]];
809                         int num_taisei = count_bits(r_ptr->flagsr & (RFR_IM_ACID | RFR_IM_ELEC | RFR_IM_FIRE | RFR_IM_COLD | RFR_IM_POIS));
810
811                         if (r_ptr->flags1 & RF1_FORCE_MAXHP)
812                                 power[i] = r_ptr->hdice * r_ptr->hside * 2;
813                         else
814                                 power[i] = r_ptr->hdice * (r_ptr->hside + 1);
815                         power[i] = power[i] * (100 + r_ptr->level) / 100;
816                         if (r_ptr->speed > 110)
817                                 power[i] = power[i] * (r_ptr->speed * 2 - 110) / 100;
818                         if (r_ptr->speed < 110)
819                                 power[i] = power[i] * (r_ptr->speed - 20) / 100;
820                         if (num_taisei > 2)
821                                 power[i] = power[i] * (num_taisei * 2 + 5) / 10;
822                         else if (r_ptr->a_ability_flags2 & RF6_INVULNER)
823                                 power[i] = power[i] * 4 / 3;
824                         else if (r_ptr->a_ability_flags2 & RF6_HEAL)
825                                 power[i] = power[i] * 4 / 3;
826                         else if (r_ptr->a_ability_flags1 & RF5_DRAIN_MANA)
827                                 power[i] = power[i] * 11 / 10;
828                         if (r_ptr->flags1 & RF1_RAND_25)
829                                 power[i] = power[i] * 9 / 10;
830                         if (r_ptr->flags1 & RF1_RAND_50)
831                                 power[i] = power[i] * 9 / 10;
832                         if (r_ptr->flagsr & RFR_RES_ALL) power[i] *= 100000;
833                         if (r_ptr->arena_ratio) power[i] = power[i] * r_ptr->arena_ratio / 100;
834                         total += power[i];
835                 }
836
837                 for (i = 0; i < 4; i++)
838                 {
839                         if (power[i] <= 0) break;
840                         power[i] = total * 60 / power[i];
841                         if (tekitou && ((power[i] < 160) || power[i] > 1500)) break;
842                         if ((power[i] < 160) && randint0(20)) break;
843                         if (power[i] < 101) power[i] = 100 + randint1(5);
844                         mon_odds[i] = power[i];
845                 }
846
847                 if (i == 4) break;
848         }
849 }
850
851
852 /*!
853  * @brief モンスター闘技場のメインルーチン
854  * @param player_ptr プレーヤーへの参照ポインタ
855  * @return 賭けを開始したか否か
856  */
857 static bool kakutoujou(player_type *player_ptr)
858 {
859         PRICE maxbet;
860         PRICE wager;
861         char out_val[160], tmp_str[80];
862         concptr p;
863
864         if ((current_world_ptr->game_turn - current_world_ptr->arena_start_turn) > TURNS_PER_TICK * 250)
865         {
866                 update_gambling_monsters(player_ptr);
867                 current_world_ptr->arena_start_turn = current_world_ptr->game_turn;
868         }
869
870         screen_save();
871
872         /* No money */
873         if (player_ptr->au <= 1)
874         {
875                 msg_print(_("おい!おまえ一文なしじゃないか!こっから出ていけ!", "Hey! You don't have gold - get out of here!"));
876                 msg_print(NULL);
877                 screen_load();
878                 return FALSE;
879         }
880
881         clear_bldg(4, 10);
882
883         prt(_("モンスター                                                     倍率",
884                 "Monsters                                                       Odds"), 4, 4);
885         for (int i = 0; i < 4; i++)
886         {
887                 char buf[80];
888                 monster_race *r_ptr = &r_info[battle_mon[i]];
889
890                 sprintf(buf, _("%d) %-58s  %4ld.%02ld倍", "%d) %-58s  %4ld.%02ld"), i + 1,
891                         _(format("%s%s", r_name + r_ptr->name, (r_ptr->flags1 & RF1_UNIQUE) ? "もどき" : "      "),
892                                 format("%s%s", (r_ptr->flags1 & RF1_UNIQUE) ? "Fake " : "", r_name + r_ptr->name)),
893                                 (long int)mon_odds[i] / 100, (long int)mon_odds[i] % 100);
894                 prt(buf, 5 + i, 1);
895         }
896
897         prt(_("どれに賭けますか:", "Which monster: "), 0, 0);
898         while (TRUE)
899         {
900                 int i = inkey();
901
902                 if (i == ESCAPE)
903                 {
904                         screen_load();
905                         return FALSE;
906                 }
907
908                 if (i >= '1' && i <= '4')
909                 {
910                         sel_monster = i - '1';
911                         battle_odds = mon_odds[sel_monster];
912                         break;
913                 }
914
915                 else bell();
916         }
917
918         clear_bldg(4, 4);
919         for (int i = 0; i < 4; i++)
920                 if (i != sel_monster) clear_bldg(i + 5, i + 5);
921
922         maxbet = player_ptr->lev * 200;
923
924         /* We can't bet more than we have */
925         maxbet = MIN(maxbet, player_ptr->au);
926
927         /* Get the wager */
928         strcpy(out_val, "");
929         sprintf(tmp_str, _("賭け金 (1-%ld)?", "Your wager (1-%ld) ? "), (long int)maxbet);
930
931         /*
932          * Use get_string() because we may need more than
933          * the s16b value returned by get_quantity().
934          */
935         if (!get_string(tmp_str, out_val, 32))
936         {
937                 screen_load();
938                 return FALSE;
939         }
940
941         for (p = out_val; *p == ' '; p++);
942
943         wager = atol(p);
944         if (wager > player_ptr->au)
945         {
946                 msg_print(_("おい!金が足りないじゃないか!出ていけ!", "Hey! You don't have the gold - get out of here!"));
947
948                 msg_print(NULL);
949                 screen_load();
950                 return FALSE;
951         }
952         else if (wager > maxbet)
953         {
954                 msg_format(_("%ldゴールドだけ受けよう。残りは取っときな。", "I'll take %ld gold of that. Keep the rest."), (long int)maxbet);
955
956                 wager = maxbet;
957         }
958         else if (wager < 1)
959         {
960                 msg_print(_("OK、1ゴールドでいこう。", "Ok, we'll start with 1 gold."));
961                 wager = 1;
962         }
963
964         msg_print(NULL);
965         battle_odds = MAX(wager + 1, wager * battle_odds / 100);
966         kakekin = wager;
967         player_ptr->au -= wager;
968         reset_tim_flags(player_ptr);
969
970         prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS);
971
972         player_ptr->phase_out = TRUE;
973         player_ptr->leaving = TRUE;
974         player_ptr->leave_bldg = TRUE;
975
976         screen_load();
977         return TRUE;
978 }
979
980
981 /*!
982  * @brief 本日の賞金首情報を表示する。
983  * @param player_ptr プレーヤーへの参照ポインタ
984  * @return なし
985  */
986 static void today_target(player_type *player_ptr)
987 {
988         char buf[160];
989         monster_race *r_ptr = &r_info[today_mon];
990
991         clear_bldg(4, 18);
992         c_put_str(TERM_YELLOW, _("本日の賞金首", "Wanted monster that changes from day to day"), 5, 10);
993         sprintf(buf, _("ターゲット: %s", "target: %s"), r_name + r_ptr->name);
994         c_put_str(TERM_YELLOW, buf, 6, 10);
995         sprintf(buf, _("死体 ---- $%d", "corpse   ---- $%d"), (int)r_ptr->level * 50 + 100);
996         prt(buf, 8, 10);
997         sprintf(buf, _("骨   ---- $%d", "skeleton ---- $%d"), (int)r_ptr->level * 30 + 60);
998         prt(buf, 9, 10);
999         player_ptr->today_mon = today_mon;
1000 }
1001
1002
1003 /*!
1004  * @brief ツチノコの賞金首情報を表示する。
1005  * @return なし
1006  */
1007 static void tsuchinoko(void)
1008 {
1009         clear_bldg(4, 18);
1010         c_put_str(TERM_YELLOW, _("一獲千金の大チャンス!!!", "Big chance for quick money!!!"), 5, 10);
1011         c_put_str(TERM_YELLOW, _("ターゲット:幻の珍獣「ツチノコ」", "target: the rarest animal 'Tsuchinoko'"), 6, 10);
1012         c_put_str(TERM_WHITE, _("生け捕り ---- $1,000,000", "catch alive ---- $1,000,000"), 8, 10);
1013         c_put_str(TERM_WHITE, _("死体     ----   $200,000", "corpse      ----   $200,000"), 9, 10);
1014         c_put_str(TERM_WHITE, _("骨       ----   $100,000", "bones       ----   $100,000"), 10, 10);
1015 }
1016
1017
1018 /*!
1019  * @brief 通常の賞金首情報を表示する。
1020  * @return なし
1021  */
1022 static void show_bounty(void)
1023 {
1024         TERM_LEN y = 0;
1025
1026         clear_bldg(4, 18);
1027         prt(_("死体を持ち帰れば報酬を差し上げます。", "Offer a prize when you bring a wanted monster's corpse"), 4, 10);
1028         c_put_str(TERM_YELLOW, _("現在の賞金首", "Wanted monsters"), 6, 10);
1029
1030         for (int i = 0; i < MAX_BOUNTY; i++)
1031         {
1032                 byte color;
1033                 concptr done_mark;
1034                 monster_race *r_ptr = &r_info[(current_world_ptr->bounty_r_idx[i] > 10000 ? current_world_ptr->bounty_r_idx[i] - 10000 : current_world_ptr->bounty_r_idx[i])];
1035
1036                 if (current_world_ptr->bounty_r_idx[i] > 10000)
1037                 {
1038                         color = TERM_RED;
1039                         done_mark = _("(済)", "(done)");
1040                 }
1041                 else
1042                 {
1043                         color = TERM_WHITE;
1044                         done_mark = "";
1045                 }
1046
1047                 c_prt(color, format("%s %s", r_name + r_ptr->name, done_mark), y + 7, 10);
1048
1049                 y = (y + 1) % 10;
1050                 if (!y && (i < MAX_BOUNTY - 1))
1051                 {
1052                         prt(_("何かキーを押してください", "Hit any key."), 0, 0);
1053                         (void)inkey();
1054                         prt("", 0, 0);
1055                         clear_bldg(7, 18);
1056                 }
1057         }
1058 }
1059
1060
1061 /*!
1062  * 賞金首の報酬テーブル / List of prize object
1063  */
1064 static struct {
1065         OBJECT_TYPE_VALUE tval; /*!< ベースアイテムのメイン種別ID */
1066         OBJECT_SUBTYPE_VALUE sval; /*!< ベースアイテムのサブ種別ID */
1067 } prize_list[MAX_BOUNTY] =
1068 {
1069         {TV_POTION, SV_POTION_CURING},
1070         {TV_POTION, SV_POTION_SPEED},
1071         {TV_POTION, SV_POTION_SPEED},
1072         {TV_POTION, SV_POTION_RESISTANCE},
1073         {TV_POTION, SV_POTION_ENLIGHTENMENT},
1074
1075         {TV_POTION, SV_POTION_HEALING},
1076         {TV_POTION, SV_POTION_RESTORE_MANA},
1077         {TV_SCROLL, SV_SCROLL_STAR_DESTRUCTION},
1078         {TV_POTION, SV_POTION_STAR_ENLIGHTENMENT},
1079         {TV_SCROLL, SV_SCROLL_SUMMON_PET},
1080
1081         {TV_SCROLL, SV_SCROLL_GENOCIDE},
1082         {TV_POTION, SV_POTION_STAR_HEALING},
1083         {TV_POTION, SV_POTION_STAR_HEALING},
1084         {TV_POTION, SV_POTION_NEW_LIFE},
1085         {TV_SCROLL, SV_SCROLL_MASS_GENOCIDE},
1086
1087         {TV_POTION, SV_POTION_LIFE},
1088         {TV_POTION, SV_POTION_LIFE},
1089         {TV_POTION, SV_POTION_AUGMENTATION},
1090         {TV_POTION, SV_POTION_INVULNERABILITY},
1091         {TV_SCROLL, SV_SCROLL_ARTIFACT},
1092 };
1093
1094
1095 /*!
1096  * @brief 賞金首の引き換え処理 / Get prize
1097  * @param player_ptr プレーヤーへの参照ポインタ
1098  * @return 各種賞金首のいずれかでも換金が行われたか否か。
1099  */
1100 static bool kankin(player_type *player_ptr)
1101 {
1102         bool change = FALSE;
1103         GAME_TEXT o_name[MAX_NLEN];
1104         object_type *o_ptr;
1105
1106         for (INVENTORY_IDX i = 0; i <= INVEN_LARM; i++)
1107         {
1108                 o_ptr = &player_ptr->inventory_list[i];
1109                 if ((o_ptr->tval == TV_CAPTURE) && (o_ptr->pval == MON_TSUCHINOKO))
1110                 {
1111                         char buf[MAX_NLEN + 20];
1112                         object_desc(player_ptr, o_name, o_ptr, 0);
1113                         sprintf(buf, _("%s を換金しますか?", "Convert %s into money? "), o_name);
1114                         if (get_check(buf))
1115                         {
1116                                 msg_format(_("賞金 %ld$を手に入れた。", "You get %ldgp."), (long int)(1000000L * o_ptr->number));
1117                                 player_ptr->au += 1000000L * o_ptr->number;
1118                                 player_ptr->redraw |= (PR_GOLD);
1119                                 vary_item(player_ptr, i, -o_ptr->number);
1120                         }
1121
1122                         change = TRUE;
1123                 }
1124         }
1125
1126         for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++)
1127         {
1128                 o_ptr = &player_ptr->inventory_list[i];
1129                 if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_CORPSE) && (o_ptr->pval == MON_TSUCHINOKO))
1130                 {
1131                         char buf[MAX_NLEN + 20];
1132                         object_desc(player_ptr, o_name, o_ptr, 0);
1133                         sprintf(buf, _("%s を換金しますか?", "Convert %s into money? "), o_name);
1134                         if (get_check(buf))
1135                         {
1136                                 msg_format(_("賞金 %ld$を手に入れた。", "You get %ldgp."), (long int)(200000L * o_ptr->number));
1137                                 player_ptr->au += 200000L * o_ptr->number;
1138                                 player_ptr->redraw |= (PR_GOLD);
1139                                 vary_item(player_ptr, i, -o_ptr->number);
1140                         }
1141
1142                         change = TRUE;
1143                 }
1144         }
1145
1146         for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++)
1147         {
1148                 o_ptr = &player_ptr->inventory_list[i];
1149                 if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_SKELETON) && (o_ptr->pval == MON_TSUCHINOKO))
1150                 {
1151                         char buf[MAX_NLEN + 20];
1152                         object_desc(player_ptr, o_name, o_ptr, 0);
1153                         sprintf(buf, _("%s を換金しますか?", "Convert %s into money? "), o_name);
1154                         if (get_check(buf))
1155                         {
1156                                 msg_format(_("賞金 %ld$を手に入れた。", "You get %ldgp."), (long int)(100000L * o_ptr->number));
1157                                 player_ptr->au += 100000L * o_ptr->number;
1158                                 player_ptr->redraw |= (PR_GOLD);
1159                                 vary_item(player_ptr, i, -o_ptr->number);
1160                         }
1161                         change = TRUE;
1162                 }
1163         }
1164
1165         for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++)
1166         {
1167                 o_ptr = &player_ptr->inventory_list[i];
1168                 if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_CORPSE) && (streq(r_name + r_info[o_ptr->pval].name, r_name + r_info[today_mon].name)))
1169                 {
1170                         char buf[MAX_NLEN + 20];
1171                         object_desc(player_ptr, o_name, o_ptr, 0);
1172                         sprintf(buf, _("%s を換金しますか?", "Convert %s into money? "), o_name);
1173                         if (get_check(buf))
1174                         {
1175                                 msg_format(_("賞金 %ld$を手に入れた。", "You get %ldgp."), (long int)((r_info[today_mon].level * 50 + 100) * o_ptr->number));
1176                                 player_ptr->au += (r_info[today_mon].level * 50 + 100) * o_ptr->number;
1177                                 player_ptr->redraw |= (PR_GOLD);
1178                                 vary_item(player_ptr, i, -o_ptr->number);
1179                         }
1180                         change = TRUE;
1181                 }
1182         }
1183
1184         for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++)
1185         {
1186                 o_ptr = &player_ptr->inventory_list[i];
1187
1188                 if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_SKELETON) && (streq(r_name + r_info[o_ptr->pval].name, r_name + r_info[today_mon].name)))
1189                 {
1190                         char buf[MAX_NLEN + 20];
1191                         object_desc(player_ptr, o_name, o_ptr, 0);
1192                         sprintf(buf, _("%s を換金しますか?", "Convert %s into money? "), o_name);
1193                         if (get_check(buf))
1194                         {
1195                                 msg_format(_("賞金 %ld$を手に入れた。", "You get %ldgp."), (long int)((r_info[today_mon].level * 30 + 60) * o_ptr->number));
1196                                 player_ptr->au += (r_info[today_mon].level * 30 + 60) * o_ptr->number;
1197                                 player_ptr->redraw |= (PR_GOLD);
1198                                 vary_item(player_ptr, i, -o_ptr->number);
1199                         }
1200
1201                         change = TRUE;
1202                 }
1203         }
1204
1205         for (int j = 0; j < MAX_BOUNTY; j++)
1206         {
1207                 for (INVENTORY_IDX i = INVEN_PACK - 1; i >= 0; i--)
1208                 {
1209                         o_ptr = &player_ptr->inventory_list[i];
1210                         if ((o_ptr->tval != TV_CORPSE) || (o_ptr->pval != current_world_ptr->bounty_r_idx[j])) continue;
1211
1212                         char buf[MAX_NLEN + 20];
1213                         int num, k;
1214                         INVENTORY_IDX item_new;
1215                         object_type forge;
1216
1217                         object_desc(player_ptr, o_name, o_ptr, 0);
1218                         sprintf(buf, _("%sを渡しますか?", "Hand %s over? "), o_name);
1219                         if (!get_check(buf)) continue;
1220
1221                         vary_item(player_ptr, i, -o_ptr->number);
1222                         chg_virtue(player_ptr, V_JUSTICE, 5);
1223                         current_world_ptr->bounty_r_idx[j] += 10000;
1224
1225                         for (num = 0, k = 0; k < MAX_BOUNTY; k++)
1226                         {
1227                                 if (current_world_ptr->bounty_r_idx[k] >= 10000) num++;
1228                         }
1229
1230                         msg_format(_("これで合計 %d ポイント獲得しました。", "You earned %d point%s total."), num, (num > 1 ? "s" : ""));
1231
1232                         object_prep(&forge, lookup_kind(prize_list[num - 1].tval, prize_list[num - 1].sval));
1233                         apply_magic(player_ptr, &forge, player_ptr->current_floor_ptr->object_level, AM_NO_FIXED_ART);
1234
1235                         object_aware(player_ptr, &forge);
1236                         object_known(&forge);
1237
1238                         /*
1239                          * Hand it --- Assume there is an empty slot.
1240                          * Since a corpse is handed at first,
1241                          * there is at least one empty slot.
1242                          */
1243                         item_new = inven_carry(player_ptr, &forge);
1244                         object_desc(player_ptr, o_name, &forge, 0);
1245                         msg_format(_("%s(%c)を貰った。", "You get %s (%c). "), o_name, index_to_label(item_new));
1246
1247                         autopick_alter_item(player_ptr, item_new, FALSE);
1248                         handle_stuff(player_ptr);
1249                         change = TRUE;
1250                 }
1251         }
1252
1253         if (change) return TRUE;
1254
1255         msg_print(_("賞金を得られそうなものは持っていなかった。", "You have nothing."));
1256         msg_print(NULL);
1257         return FALSE;
1258 }
1259
1260
1261 /*!
1262  * @brief 宿屋の利用サブルーチン
1263  * @details inn commands\n
1264  * Note that resting for the night was a perfect way to avoid player\n
1265  * ghosts in the town *if* you could only make it to the inn in time (-:\n
1266  * Now that the ghosts are temporarily disabled in 2.8.X, this function\n
1267  * will not be that useful.  I will keep it in the hopes the player\n
1268  * ghost code does become a reality again. Does help to avoid filthy urchins.\n
1269  * Resting at night is also a quick way to restock stores -KMW-\n
1270  * @param cmd 宿屋の利用施設ID
1271  * @return 施設の利用が実際に行われたか否か。
1272  */
1273 static bool inn_comm(player_type *customer_ptr, int cmd)
1274 {
1275         switch (cmd)
1276         {
1277         case BACT_FOOD: /* Buy food & drink */
1278                 if (customer_ptr->food >= PY_FOOD_FULL)
1279                 {
1280                         msg_print(_("今は満腹だ。", "You are full now."));
1281                         return FALSE;
1282                 }
1283
1284                 msg_print(_("バーテンはいくらかの食べ物とビールをくれた。", "The barkeep gives you some gruel and a beer."));
1285                 (void)set_food(customer_ptr, PY_FOOD_MAX - 1);
1286                 break;
1287
1288         case BACT_REST: /* Rest for the night */
1289         {
1290                 if ((customer_ptr->poisoned) || (customer_ptr->cut))
1291                 {
1292                         msg_print(_("あなたに必要なのは部屋ではなく、治療者です。", "You need a healer, not a room."));
1293                         msg_print(NULL);
1294                         msg_print(_("すみません、でもうちで誰かに死なれちゃ困りますんで。", "Sorry, but don't want anyone dying in here."));
1295                         break;
1296                 }
1297
1298                 s32b oldturn = current_world_ptr->game_turn;
1299                 int prev_day, prev_hour, prev_min;
1300
1301                 extract_day_hour_min(customer_ptr, &prev_day, &prev_hour, &prev_min);
1302                 if ((prev_hour >= 6) && (prev_hour <= 17))
1303                         exe_write_diary(customer_ptr, DIARY_DESCRIPTION, 0, _("宿屋に泊まった。", "stayed during the day at the inn."));
1304                 else
1305                         exe_write_diary(customer_ptr, DIARY_DESCRIPTION, 0, _("宿屋に泊まった。", "stayed overnight at the inn."));
1306
1307                 current_world_ptr->game_turn = (current_world_ptr->game_turn / (TURNS_PER_TICK * TOWN_DAWN / 2) + 1) * (TURNS_PER_TICK * TOWN_DAWN / 2);
1308                 if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit)
1309                 {
1310                         current_world_ptr->dungeon_turn += MIN((current_world_ptr->game_turn - oldturn), TURNS_PER_TICK * 250) * INN_DUNGEON_TURN_ADJ;
1311                         if (current_world_ptr->dungeon_turn > current_world_ptr->dungeon_turn_limit) current_world_ptr->dungeon_turn = current_world_ptr->dungeon_turn_limit;
1312                 }
1313
1314                 prevent_turn_overflow(customer_ptr);
1315
1316                 if ((prev_hour >= 18) && (prev_hour <= 23)) exe_write_diary(customer_ptr, DIARY_DIALY, 0, NULL);
1317                 customer_ptr->chp = customer_ptr->mhp;
1318
1319                 if (ironman_nightmare)
1320                 {
1321                         msg_print(_("眠りに就くと恐ろしい光景が心をよぎった。", "Horrible visions flit through your mind as you sleep."));
1322
1323                         while (TRUE)
1324                         {
1325                                 sanity_blast(customer_ptr, NULL, FALSE);
1326                                 if (!one_in_(3)) break;
1327                         }
1328
1329                         msg_print(_("あなたは絶叫して目を覚ました。", "You awake screaming."));
1330                         exe_write_diary(customer_ptr, DIARY_DESCRIPTION, 0, _("悪夢にうなされてよく眠れなかった。", "had a nightmare."));
1331                         break;
1332                 }
1333
1334                 set_blind(customer_ptr, 0);
1335                 set_confused(customer_ptr, 0);
1336                 customer_ptr->stun = 0;
1337                 customer_ptr->chp = customer_ptr->mhp;
1338                 customer_ptr->csp = customer_ptr->msp;
1339                 if (customer_ptr->pclass == CLASS_MAGIC_EATER)
1340                 {
1341                         int i;
1342                         for (i = 0; i < 72; i++)
1343                         {
1344                                 customer_ptr->magic_num1[i] = customer_ptr->magic_num2[i] * EATER_CHARGE;
1345                         }
1346
1347                         for (; i < 108; i++)
1348                         {
1349                                 customer_ptr->magic_num1[i] = 0;
1350                         }
1351                 }
1352
1353                 if ((prev_hour >= 6) && (prev_hour <= 17))
1354                 {
1355                         msg_print(_("あなたはリフレッシュして目覚め、夕方を迎えた。", "You awake refreshed for the evening."));
1356                         exe_write_diary(customer_ptr, DIARY_DESCRIPTION, 0, _("夕方を迎えた。", "awoke refreshed."));
1357                         break;
1358                 }
1359
1360                 msg_print(_("あなたはリフレッシュして目覚め、新たな日を迎えた。", "You awake refreshed for the new day."));
1361                 exe_write_diary(customer_ptr, DIARY_DESCRIPTION, 0, _("すがすがしい朝を迎えた。", "awoke refreshed."));
1362                 break;
1363         }
1364         case BACT_RUMORS: /* Listen for rumors */
1365         {
1366                 display_rumor(customer_ptr, TRUE);
1367                 break;
1368         }
1369         }
1370
1371         return TRUE;
1372 }
1373
1374
1375 /*!
1376  * @brief クエスト情報を表示しつつ処理する。/ Display quest information
1377  * @param player_ptr プレーヤーへの参照ポインタ
1378  * @param questnum クエストのID
1379  * @param do_init クエストの開始処理(TRUE)、結果処理か(FALSE)
1380  * @return なし
1381  */
1382 static void get_questinfo(player_type *player_ptr, IDX questnum, bool do_init)
1383 {
1384         for (int i = 0; i < 10; i++)
1385         {
1386                 quest_text[i][0] = '\0';
1387         }
1388
1389         quest_text_line = 0;
1390
1391         floor_type *floor_ptr = player_ptr->current_floor_ptr;
1392         QUEST_IDX old_quest = floor_ptr->inside_quest;
1393         floor_ptr->inside_quest = questnum;
1394
1395         init_flags = INIT_SHOW_TEXT;
1396         if (do_init) init_flags |= INIT_ASSIGN;
1397
1398         process_dungeon_file(player_ptr, "q_info.txt", 0, 0, 0, 0);
1399         floor_ptr->inside_quest = old_quest;
1400
1401         GAME_TEXT tmp_str[80];
1402         sprintf(tmp_str, _("クエスト情報 (危険度: %d 階相当)", "Quest Information (Danger level: %d)"), (int)quest[questnum].level);
1403         prt(tmp_str, 5, 0);
1404         prt(quest[questnum].name, 7, 0);
1405
1406         for (int i = 0; i < 10; i++)
1407         {
1408                 c_put_str(TERM_YELLOW, quest_text[i], i + 8, 0);
1409         }
1410 }
1411
1412 /*!
1413  * @brief クエスト処理のメインルーチン / Request a quest from the Lord.
1414  * @param player_ptr プレーヤーへの参照ポインタ
1415  * @return なし
1416  */
1417 static void castle_quest(player_type *player_ptr)
1418 {
1419         clear_bldg(4, 18);
1420         QUEST_IDX q_index = player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x].special;
1421
1422         if (!q_index)
1423         {
1424                 put_str(_("今のところクエストはありません。", "I don't have a quest for you at the moment."), 8, 0);
1425                 return;
1426         }
1427
1428         quest_type *q_ptr;
1429         q_ptr = &quest[q_index];
1430         if (q_ptr->status == QUEST_STATUS_COMPLETED)
1431         {
1432                 q_ptr->status = QUEST_STATUS_REWARDED;
1433                 get_questinfo(player_ptr, q_index, FALSE);
1434                 reinit_wilderness = TRUE;
1435                 return;
1436         }
1437
1438         if (q_ptr->status == QUEST_STATUS_FAILED)
1439         {
1440                 get_questinfo(player_ptr, q_index, FALSE);
1441                 q_ptr->status = QUEST_STATUS_FAILED_DONE;
1442                 reinit_wilderness = TRUE;
1443                 return;
1444         }
1445
1446         if (q_ptr->status == QUEST_STATUS_TAKEN)
1447         {
1448                 put_str(_("あなたは現在のクエストを終了させていません!", "You have not completed your current quest yet!"), 8, 0);
1449                 put_str(_("CTRL-Qを使えばクエストの状態がチェックできます。", "Use CTRL-Q to check the status of your quest."), 9, 0);
1450                 put_str(_("クエストを終わらせたら戻って来て下さい。", "Return when you have completed your quest."), 12, 0);
1451                 return;
1452         }
1453
1454         if (q_ptr->status != QUEST_STATUS_UNTAKEN) return;
1455
1456         q_ptr->status = QUEST_STATUS_TAKEN;
1457         reinit_wilderness = TRUE;
1458         if (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL)
1459         {
1460                 get_questinfo(player_ptr, q_index, TRUE);
1461                 return;
1462         }
1463
1464         if (q_ptr->r_idx == 0)
1465         {
1466                 q_ptr->r_idx = get_mon_num(player_ptr, q_ptr->level + 4 + randint1(6), 0);
1467         }
1468
1469         monster_race *r_ptr;
1470         r_ptr = &r_info[q_ptr->r_idx];
1471         while ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->rarity != 1))
1472         {
1473                 q_ptr->r_idx = get_mon_num(player_ptr, q_ptr->level + 4 + randint1(6), 0);
1474                 r_ptr = &r_info[q_ptr->r_idx];
1475         }
1476
1477         if (q_ptr->max_num == 0)
1478         {
1479                 if (randint1(10) > 7)
1480                         q_ptr->max_num = 1;
1481                 else
1482                         q_ptr->max_num = randint1(3) + 1;
1483         }
1484
1485         q_ptr->cur_num = 0;
1486         concptr name = (r_name + r_ptr->name);
1487 #ifdef JP
1488         msg_format("クエスト: %sを %d体倒す", name, q_ptr->max_num);
1489 #else
1490         msg_format("Your quest: kill %d %s", q_ptr->max_num, name);
1491 #endif
1492         get_questinfo(player_ptr, q_index, TRUE);
1493 }
1494
1495
1496 /*!
1497  * @brief 町に関するヘルプを表示する / Display town history
1498  * @param player_ptr プレーヤーへの参照ポインタ
1499  * @return なし
1500  */
1501 static void town_history(player_type *player_ptr)
1502 {
1503         screen_save();
1504         (void)show_file(player_ptr, TRUE, _("jbldg.txt", "bldg.txt"), NULL, 0, 0);
1505         screen_load();
1506 }
1507
1508
1509 /*!
1510  * @brief 攻撃時スレイによるダメージ期待値修正計算 / critical happens at i / 10000
1511  * @param dam 基本ダメージ
1512  * @param mult スレイ倍率(掛け算部分)
1513  * @param div スレイ倍率(割り算部分)
1514  * @param force 理力特別計算フラグ
1515  * @return ダメージ期待値
1516  */
1517 static HIT_POINT calc_slaydam(HIT_POINT dam, int mult, int div, bool force)
1518 {
1519         int tmp;
1520         if (force)
1521         {
1522                 tmp = dam * 60;
1523                 tmp *= mult * 3;
1524                 tmp /= div * 2;
1525                 tmp += dam * 60 * 2;
1526                 tmp /= 60;
1527                 return tmp;
1528         }
1529
1530         tmp = dam * 60;
1531         tmp *= mult;
1532         tmp /= div;
1533         tmp /= 60;
1534         return tmp;
1535 }
1536
1537
1538 /*!
1539  * @brief 攻撃時の期待値計算(スレイ→重量クリティカル→切れ味効果)
1540  * @param player_ptr プレーヤーへの参照ポインタ
1541  * @param dam 基本ダメージ
1542  * @param mult スレイ倍率(掛け算部分)
1543  * @param div スレイ倍率(割り算部分)
1544  * @param force 理力特別計算フラグ
1545  * @param weight 重量
1546  * @param plus 武器ダメージ修正
1547  * @param meichuu 命中値
1548  * @param dokubari 毒針処理か否か
1549  * @param vorpal_mult 切れ味倍率(掛け算部分)
1550  * @param vorpal_div 切れ味倍率(割り算部分)
1551  * @return ダメージ期待値
1552  */
1553 static u32b calc_expect_dice(player_type *owner_ptr, u32b dam, int mult, int div, bool force, WEIGHT weight, int plus, s16b meichuu, bool dokubari, int vorpal_mult, int vorpal_div)
1554 {
1555         dam = calc_slaydam(dam, mult, div, force);
1556         dam = calc_expect_crit(owner_ptr, weight, plus, dam, meichuu, dokubari);
1557         dam = calc_slaydam(dam, vorpal_mult, vorpal_div, FALSE);
1558         return dam;
1559 }
1560
1561
1562 /*!
1563  * @brief 武器の各条件毎のダメージ期待値を表示する。
1564  * @param r 表示行
1565  * @param c 表示列
1566  * @param mindice ダイス部分最小値
1567  * @param maxdice ダイス部分最大値
1568  * @param blows 攻撃回数
1569  * @param dam_bonus ダメージ修正値
1570  * @param attr 条件内容
1571  * @param color 条件内容の表示色
1572  * @details
1573  * Display the damage figure of an object\n
1574  * (used by compare_weapon_aux)\n
1575  * \n
1576  * Only accurate for the current weapon, because it includes\n
1577  * the current +dam of the player.\n
1578  * @return なし
1579  */
1580 static void show_weapon_dmg(int r, int c, int mindice, int maxdice, int blows, int dam_bonus, concptr attr, byte color)
1581 {
1582         c_put_str(color, attr, r, c);
1583         GAME_TEXT tmp_str[80];
1584         int mindam = blows * (mindice + dam_bonus);
1585         int maxdam = blows * (maxdice + dam_bonus);
1586         sprintf(tmp_str, _("1ターン: %d-%d ダメージ", "Attack: %d-%d damage"), mindam, maxdam);
1587         put_str(tmp_str, r, c + 8);
1588 }
1589
1590
1591 /*!
1592  * @brief 武器一つ毎のダメージ情報を表示する。
1593  * @param o_ptr オブジェクトの構造体の参照ポインタ。
1594  * @param col 表示する行の上端
1595  * @param r 表示する列の左端
1596  * @details
1597  * Show the damage figures for the various monster types\n
1598  * \n
1599  * Only accurate for the current weapon, because it includes\n
1600  * the current number of blows for the player.\n
1601  * @return なし
1602  */
1603 static void compare_weapon_aux(player_type *owner_ptr, object_type *o_ptr, int col, int r)
1604 {
1605         BIT_FLAGS flgs[TR_FLAG_SIZE];
1606         int blow = owner_ptr->num_blow[0];
1607         bool force = FALSE;
1608         bool dokubari = FALSE;
1609
1610         int eff_dd = o_ptr->dd + owner_ptr->to_dd[0];
1611         int eff_ds = o_ptr->ds + owner_ptr->to_ds[0];
1612
1613         int mindice = eff_dd;
1614         int maxdice = eff_ds * eff_dd;
1615         int mindam = 0;
1616         int maxdam = 0;
1617         int vorpal_mult = 1;
1618         int vorpal_div = 1;
1619         int dmg_bonus = o_ptr->to_d + owner_ptr->to_d[0];
1620
1621         object_flags(o_ptr, flgs);
1622         if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) dokubari = TRUE;
1623
1624         mindam = calc_expect_crit(owner_ptr, o_ptr->weight, o_ptr->to_h, mindice, owner_ptr->to_h[0], dokubari);
1625         maxdam = calc_expect_crit(owner_ptr, o_ptr->weight, o_ptr->to_h, maxdice, owner_ptr->to_h[0], dokubari);
1626         show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("会心:", "Critical:"), TERM_L_RED);
1627         if ((have_flag(flgs, TR_VORPAL) || hex_spelling(owner_ptr, HEX_RUNESWORD)))
1628         {
1629                 if ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD))
1630                 {
1631                         vorpal_mult = 5;
1632                         vorpal_div = 3;
1633                 }
1634                 else
1635                 {
1636                         vorpal_mult = 11;
1637                         vorpal_div = 9;
1638                 }
1639
1640                 mindam = calc_expect_dice(owner_ptr, mindice, 1, 1, FALSE, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1641                 maxdam = calc_expect_dice(owner_ptr, maxdice, 1, 1, FALSE, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1642                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("切れ味:", "Vorpal:"), TERM_L_RED);
1643         }
1644
1645         if ((owner_ptr->pclass != CLASS_SAMURAI) && have_flag(flgs, TR_FORCE_WEAPON) && (owner_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
1646         {
1647                 force = TRUE;
1648
1649                 mindam = calc_expect_dice(owner_ptr, mindice, 1, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1650                 maxdam = calc_expect_dice(owner_ptr, maxdice, 1, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1651                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("理力:", "Force  :"), TERM_L_BLUE);
1652         }
1653
1654         if (have_flag(flgs, TR_KILL_ANIMAL))
1655         {
1656                 mindam = calc_expect_dice(owner_ptr, mindice, 4, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1657                 maxdam = calc_expect_dice(owner_ptr, maxdice, 4, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1658                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("動物:", "Animals:"), TERM_YELLOW);
1659         }
1660         else if (have_flag(flgs, TR_SLAY_ANIMAL))
1661         {
1662                 mindam = calc_expect_dice(owner_ptr, mindice, 5, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1663                 maxdam = calc_expect_dice(owner_ptr, maxdice, 5, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1664                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("動物:", "Animals:"), TERM_YELLOW);
1665         }
1666
1667         if (have_flag(flgs, TR_KILL_EVIL))
1668         {
1669                 mindam = calc_expect_dice(owner_ptr, mindice, 7, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1670                 maxdam = calc_expect_dice(owner_ptr, maxdice, 7, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1671                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("邪悪:", "Evil:"), TERM_YELLOW);
1672         }
1673         else if (have_flag(flgs, TR_SLAY_EVIL))
1674         {
1675                 mindam = calc_expect_dice(owner_ptr, mindice, 2, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1676                 maxdam = calc_expect_dice(owner_ptr, maxdice, 2, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1677                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("邪悪:", "Evil:"), TERM_YELLOW);
1678         }
1679
1680         if (have_flag(flgs, TR_KILL_HUMAN))
1681         {
1682                 mindam = calc_expect_dice(owner_ptr, mindice, 4, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1683                 maxdam = calc_expect_dice(owner_ptr, maxdice, 4, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1684                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("人間:", "Human:"), TERM_YELLOW);
1685         }
1686         else if (have_flag(flgs, TR_SLAY_HUMAN))
1687         {
1688                 mindam = calc_expect_dice(owner_ptr, mindice, 5, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1689                 maxdam = calc_expect_dice(owner_ptr, maxdice, 5, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1690                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("人間:", "Human:"), TERM_YELLOW);
1691         }
1692
1693         if (have_flag(flgs, TR_KILL_UNDEAD))
1694         {
1695                 mindam = calc_expect_dice(owner_ptr, mindice, 5, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1696                 maxdam = calc_expect_dice(owner_ptr, maxdice, 5, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1697                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("不死:", "Undead:"), TERM_YELLOW);
1698         }
1699         else if (have_flag(flgs, TR_SLAY_UNDEAD))
1700         {
1701                 mindam = calc_expect_dice(owner_ptr, mindice, 3, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1702                 maxdam = calc_expect_dice(owner_ptr, maxdice, 3, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1703                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("不死:", "Undead:"), TERM_YELLOW);
1704         }
1705
1706         if (have_flag(flgs, TR_KILL_DEMON))
1707         {
1708                 mindam = calc_expect_dice(owner_ptr, mindice, 5, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1709                 maxdam = calc_expect_dice(owner_ptr, maxdice, 5, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1710                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("悪魔:", "Demons:"), TERM_YELLOW);
1711         }
1712         else if (have_flag(flgs, TR_SLAY_DEMON))
1713         {
1714                 mindam = calc_expect_dice(owner_ptr, mindice, 3, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1715                 maxdam = calc_expect_dice(owner_ptr, maxdice, 3, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1716                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("悪魔:", "Demons:"), TERM_YELLOW);
1717         }
1718
1719         if (have_flag(flgs, TR_KILL_ORC))
1720         {
1721                 mindam = calc_expect_dice(owner_ptr, mindice, 5, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1722                 maxdam = calc_expect_dice(owner_ptr, maxdice, 5, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1723                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("オーク:", "Orcs:"), TERM_YELLOW);
1724         }
1725         else if (have_flag(flgs, TR_SLAY_ORC))
1726         {
1727                 mindam = calc_expect_dice(owner_ptr, mindice, 3, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1728                 maxdam = calc_expect_dice(owner_ptr, maxdice, 3, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1729                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("オーク:", "Orcs:"), TERM_YELLOW);
1730         }
1731
1732         if (have_flag(flgs, TR_KILL_TROLL))
1733         {
1734                 mindam = calc_expect_dice(owner_ptr, mindice, 5, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1735                 maxdam = calc_expect_dice(owner_ptr, maxdice, 5, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1736                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("トロル:", "Trolls:"), TERM_YELLOW);
1737         }
1738         else if (have_flag(flgs, TR_SLAY_TROLL))
1739         {
1740                 mindam = calc_expect_dice(owner_ptr, mindice, 3, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1741                 maxdam = calc_expect_dice(owner_ptr, maxdice, 3, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1742                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("トロル:", "Trolls:"), TERM_YELLOW);
1743         }
1744
1745         if (have_flag(flgs, TR_KILL_GIANT))
1746         {
1747                 mindam = calc_expect_dice(owner_ptr, mindice, 5, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1748                 maxdam = calc_expect_dice(owner_ptr, maxdice, 5, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1749                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("巨人:", "Giants:"), TERM_YELLOW);
1750         }
1751         else if (have_flag(flgs, TR_SLAY_GIANT))
1752         {
1753                 mindam = calc_expect_dice(owner_ptr, mindice, 3, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1754                 maxdam = calc_expect_dice(owner_ptr, maxdice, 3, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1755                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("巨人:", "Giants:"), TERM_YELLOW);
1756         }
1757
1758         if (have_flag(flgs, TR_KILL_DRAGON))
1759         {
1760                 mindam = calc_expect_dice(owner_ptr, mindice, 5, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1761                 maxdam = calc_expect_dice(owner_ptr, maxdice, 5, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1762                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("竜:", "Dragons:"), TERM_YELLOW);
1763         }
1764         else if (have_flag(flgs, TR_SLAY_DRAGON))
1765         {
1766                 mindam = calc_expect_dice(owner_ptr, mindice, 3, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1767                 maxdam = calc_expect_dice(owner_ptr, maxdice, 3, 1, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1768                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("竜:", "Dragons:"), TERM_YELLOW);
1769         }
1770
1771         if (have_flag(flgs, TR_BRAND_ACID))
1772         {
1773                 mindam = calc_expect_dice(owner_ptr, mindice, 5, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1774                 maxdam = calc_expect_dice(owner_ptr, maxdice, 5, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1775                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("酸属性:", "Acid:"), TERM_RED);
1776         }
1777
1778         if (have_flag(flgs, TR_BRAND_ELEC))
1779         {
1780                 mindam = calc_expect_dice(owner_ptr, mindice, 5, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1781                 maxdam = calc_expect_dice(owner_ptr, maxdice, 5, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1782                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("電属性:", "Elec:"), TERM_RED);
1783         }
1784
1785         if (have_flag(flgs, TR_BRAND_FIRE))
1786         {
1787                 mindam = calc_expect_dice(owner_ptr, mindice, 5, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1788                 maxdam = calc_expect_dice(owner_ptr, maxdice, 5, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1789                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("炎属性:", "Fire:"), TERM_RED);
1790         }
1791
1792         if (have_flag(flgs, TR_BRAND_COLD))
1793         {
1794                 mindam = calc_expect_dice(owner_ptr, mindice, 5, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1795                 maxdam = calc_expect_dice(owner_ptr, maxdice, 5, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1796                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("冷属性:", "Cold:"), TERM_RED);
1797         }
1798
1799         if (have_flag(flgs, TR_BRAND_POIS))
1800         {
1801                 mindam = calc_expect_dice(owner_ptr, mindice, 5, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1802                 maxdam = calc_expect_dice(owner_ptr, maxdice, 5, 2, force, o_ptr->weight, o_ptr->to_h, owner_ptr->to_h[0], dokubari, vorpal_mult, vorpal_div);
1803                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("毒属性:", "Poison:"), TERM_RED);
1804         }
1805 }
1806
1807
1808 /*!
1809  * @brief 武器匠における武器一つ毎の完全情報を表示する。
1810  * @param player_type プレーヤーへの参照ポインタ
1811  * @param o_ptr オブジェクトの構造体の参照ポインタ。
1812  * @param row 表示する列の左端
1813  * @param col 表示する行の上端
1814  * @details
1815  * Displays all info about a weapon
1816  *
1817  * Only accurate for the current weapon, because it includes
1818  * various info about the player's +to_dam and number of blows.
1819  * @return なし
1820  */
1821 static void list_weapon(player_type *player_ptr, object_type *o_ptr, TERM_LEN row, TERM_LEN col)
1822 {
1823         GAME_TEXT o_name[MAX_NLEN];
1824         GAME_TEXT tmp_str[80];
1825
1826         DICE_NUMBER eff_dd = o_ptr->dd + player_ptr->to_dd[0];
1827         DICE_SID eff_ds = o_ptr->ds + player_ptr->to_ds[0];
1828         HIT_RELIABILITY reli = player_ptr->skill_thn + (player_ptr->to_h[0] + o_ptr->to_h) * BTH_PLUS_ADJ;
1829
1830         object_desc(player_ptr, o_name, o_ptr, OD_NAME_ONLY);
1831         c_put_str(TERM_YELLOW, o_name, row, col);
1832         sprintf(tmp_str, _("攻撃回数: %d", "Number of Blows: %d"), player_ptr->num_blow[0]);
1833         put_str(tmp_str, row + 1, col);
1834
1835         sprintf(tmp_str, _("命中率:  0  50 100 150 200 (敵のAC)", "To Hit:  0  50 100 150 200 (AC)"));
1836         put_str(tmp_str, row + 2, col);
1837         sprintf(tmp_str, "        %2d  %2d  %2d  %2d  %2d (%%)",
1838                 (int)hit_chance(player_ptr, reli, 0),
1839                 (int)hit_chance(player_ptr, reli, 50),
1840                 (int)hit_chance(player_ptr, reli, 100),
1841                 (int)hit_chance(player_ptr, reli, 150),
1842                 (int)hit_chance(player_ptr, reli, 200));
1843         put_str(tmp_str, row + 3, col);
1844         c_put_str(TERM_YELLOW, _("可能なダメージ:", "Possible Damage:"), row + 5, col);
1845
1846         sprintf(tmp_str, _("攻撃一回につき %d-%d", "One Strike: %d-%d damage"),
1847                 (int)(eff_dd + o_ptr->to_d + player_ptr->to_d[0]),
1848                 (int)(eff_ds * eff_dd + o_ptr->to_d + player_ptr->to_d[0]));
1849         put_str(tmp_str, row + 6, col + 1);
1850
1851         sprintf(tmp_str, _("1ターンにつき %d-%d", "One Attack: %d-%d damage"),
1852                 (int)(player_ptr->num_blow[0] * (eff_dd + o_ptr->to_d + player_ptr->to_d[0])),
1853                 (int)(player_ptr->num_blow[0] * (eff_ds * eff_dd + o_ptr->to_d + player_ptr->to_d[0])));
1854         put_str(tmp_str, row + 7, col + 1);
1855 }
1856
1857
1858 /*!
1859  * @brief 武器匠鑑定1回分(オブジェクト2種)の処理。/ Compare weapons
1860  * @details
1861  * Copies the weapons to compare into the weapon-slot and\n
1862  * compares the values for both weapons.\n
1863  * 武器1つだけで比較をしないなら費用は半額になる。
1864  * @param bcost 基本鑑定費用
1865  * @return 最終的にかかった費用
1866  */
1867 static PRICE compare_weapons(player_type *customer_ptr, PRICE bcost)
1868 {
1869         object_type *o_ptr[2];
1870         object_type orig_weapon;
1871         object_type *i_ptr;
1872         TERM_LEN row = 2;
1873         TERM_LEN wid = 38, mgn = 2;
1874         bool old_character_xtra = current_world_ptr->character_xtra;
1875         char ch;
1876         PRICE total = 0;
1877         PRICE cost = 0; /* First time no price */
1878
1879         screen_save();
1880         clear_bldg(0, 22);
1881         i_ptr = &customer_ptr->inventory_list[INVEN_RARM];
1882         object_copy(&orig_weapon, i_ptr);
1883
1884         item_tester_hook = item_tester_hook_orthodox_melee_weapons;
1885         concptr q = _("第一の武器は?", "What is your first weapon? ");
1886         concptr s = _("比べるものがありません。", "You have nothing to compare.");
1887
1888         OBJECT_IDX item;
1889         o_ptr[0] = choose_object(customer_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT), 0);
1890         if (!o_ptr[0])
1891         {
1892                 screen_load();
1893                 return 0;
1894         }
1895
1896         int n = 1;
1897         total = bcost;
1898
1899         while (TRUE)
1900         {
1901                 clear_bldg(0, 22);
1902                 item_tester_hook = item_tester_hook_orthodox_melee_weapons;
1903                 current_world_ptr->character_xtra = TRUE;
1904                 for (int i = 0; i < n; i++)
1905                 {
1906                         int col = (wid * i + mgn);
1907                         if (o_ptr[i] != i_ptr) object_copy(i_ptr, o_ptr[i]);
1908
1909                         customer_ptr->update |= PU_BONUS;
1910                         handle_stuff(customer_ptr);
1911
1912                         list_weapon(customer_ptr, o_ptr[i], row, col);
1913                         compare_weapon_aux(customer_ptr, o_ptr[i], col, row + 8);
1914                         object_copy(i_ptr, &orig_weapon);
1915                 }
1916
1917                 customer_ptr->update |= PU_BONUS;
1918                 handle_stuff(customer_ptr);
1919
1920                 current_world_ptr->character_xtra = old_character_xtra;
1921 #ifdef JP
1922                 put_str(format("[ 比較対象: 's'で変更 ($%d) ]", cost), 1, (wid + mgn));
1923                 put_str("(一番高いダメージが適用されます。複数の倍打効果は足し算されません。)", row + 4, 0);
1924                 prt("現在の技量から判断すると、あなたの武器は以下のような威力を発揮します:", 0, 0);
1925 #else
1926                 put_str(format("[ 's' Select secondary weapon($%d) ]", cost), 1, (wid + mgn));
1927                 put_str("(Only highest damage applies per monster. Special damage not cumulative.)", row + 4, 0);
1928                 prt("Based on your current abilities, here is what your weapons will do", 0, 0);
1929 #endif
1930
1931                 flush();
1932                 ch = inkey();
1933                 if (ch != 's') break;
1934
1935                 if (total + cost > customer_ptr->au)
1936                 {
1937                         msg_print(_("お金が足りません!", "You don't have enough money!"));
1938                         msg_print(NULL);
1939                         continue;
1940                 }
1941
1942                 q = _("第二の武器は?", "What is your second weapon? ");
1943                 s = _("比べるものがありません。", "You have nothing to compare.");
1944                 OBJECT_IDX item2;
1945                 o_ptr[1] = choose_object(customer_ptr, &item2, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT), 0);
1946                 if (!o_ptr[1]) continue;
1947
1948                 total += cost;
1949                 cost = bcost / 2;
1950                 n = 2;
1951         }
1952
1953         screen_load();
1954         return total;
1955 }
1956
1957
1958 /*!
1959  * @brief ACから回避率、ダメージ減少率を計算し表示する。 / Evaluate AC
1960  * @details
1961  * Calculate and display the dodge-rate and the protection-rate
1962  * based on AC
1963  * @param iAC プレイヤーのAC。
1964  * @return 常にTRUEを返す。
1965  */
1966 static bool eval_ac(ARMOUR_CLASS iAC)
1967 {
1968 #ifdef JP
1969         const char memo[] =
1970                 "ダメージ軽減率とは、敵の攻撃が当たった時そのダメージを\n"
1971                 "何パーセント軽減するかを示します。\n"
1972                 "ダメージ軽減は通常の直接攻撃(種類が「攻撃する」と「粉砕する」の物)\n"
1973                 "に対してのみ効果があります。\n \n"
1974                 "敵のレベルとは、その敵が通常何階に現れるかを示します。\n \n"
1975                 "回避率は敵の直接攻撃を何パーセントの確率で避けるかを示し、\n"
1976                 "敵のレベルとあなたのACによって決定されます。\n \n"
1977                 "ダメージ期待値とは、敵の100ポイントの通常攻撃に対し、\n"
1978                 "回避率とダメージ軽減率を考慮したダメージの期待値を示します。\n";
1979 #else
1980         const char memo[] =
1981                 "'Protection Rate' means how much damage is reduced by your armor.\n"
1982                 "Note that the Protection rate is effective only against normal "
1983                 "'attack' and 'shatter' type melee attacks, "
1984                 "and has no effect against any other types such as 'poison'.\n \n"
1985                 "'Dodge Rate' indicates the success rate on dodging the "
1986                 "monster's melee attacks.  "
1987                 "It is depend on the level of the monster and your AC.\n \n"
1988                 "'Average Damage' indicates the expected amount of damage "
1989                 "when you are attacked by normal melee attacks with power=100.";
1990 #endif
1991
1992         int protection;
1993         TERM_LEN col, row = 2;
1994         DEPTH lvl;
1995         char buf[80 * 20], *t;
1996
1997         if (iAC < 0) iAC = 0;
1998
1999         protection = 100 * MIN(iAC, 150) / 250;
2000         screen_save();
2001         clear_bldg(0, 22);
2002
2003         put_str(format(_("あなたの現在のAC: %3d", "Your current AC : %3d"), iAC), row++, 0);
2004         put_str(format(_("ダメージ軽減率  : %3d%%", "Protection rate : %3d%%"), protection), row++, 0);
2005         row++;
2006
2007         put_str(_("敵のレベル      :", "Level of Monster:"), row + 0, 0);
2008         put_str(_("回避率          :", "Dodge Rate      :"), row + 1, 0);
2009         put_str(_("ダメージ期待値  :", "Average Damage  :"), row + 2, 0);
2010
2011         for (col = 17 + 1, lvl = 0; lvl <= 100; lvl += 10, col += 5)
2012         {
2013                 int quality = 60 + lvl * 3; /* attack quality with power 60 */
2014                 int dodge;   /* 回避率(%) */
2015                 int average; /* ダメージ期待値 */
2016
2017                 put_str(format("%3d", lvl), row + 0, col);
2018
2019                 /* 回避率を計算 */
2020                 dodge = 5 + (MIN(100, 100 * (iAC * 3 / 4) / quality) * 9 + 5) / 10;
2021                 put_str(format("%3d%%", dodge), row + 1, col);
2022
2023                 /* 100点の攻撃に対してのダメージ期待値を計算 */
2024                 average = (100 - dodge) * (100 - protection) / 100;
2025                 put_str(format("%3d", average), row + 2, col);
2026         }
2027
2028         roff_to_buf(memo, 70, buf, sizeof(buf));
2029         for (t = buf; t[0]; t += strlen(t) + 1)
2030                 put_str(t, (row++) + 4, 4);
2031
2032         prt(_("現在のあなたの装備からすると、あなたの防御力はこれくらいです:", "Defense abilities from your current Armor Class are evaluated below."), 0, 0);
2033
2034         flush();
2035         (void)inkey();
2036         screen_load();
2037
2038         return TRUE;
2039 }
2040
2041
2042 /*!
2043  * @brief 修復材料のオブジェクトから修復対象に特性を移植する。
2044  * @param to_ptr 修復対象オブジェクトの構造体の参照ポインタ。
2045  * @param from_ptr 修復材料オブジェクトの構造体の参照ポインタ。
2046  * @return 修復対象になるならTRUEを返す。
2047  */
2048 static void give_one_ability_of_object(object_type *to_ptr, object_type *from_ptr)
2049 {
2050         BIT_FLAGS to_flgs[TR_FLAG_SIZE];
2051         BIT_FLAGS from_flgs[TR_FLAG_SIZE];
2052         object_flags(to_ptr, to_flgs);
2053         object_flags(from_ptr, from_flgs);
2054
2055         int n = 0;
2056         int cand[TR_FLAG_MAX];
2057         for (int i = 0; i < TR_FLAG_MAX; i++)
2058         {
2059                 switch (i)
2060                 {
2061                 case TR_IGNORE_ACID:
2062                 case TR_IGNORE_ELEC:
2063                 case TR_IGNORE_FIRE:
2064                 case TR_IGNORE_COLD:
2065                 case TR_ACTIVATE:
2066                 case TR_RIDING:
2067                 case TR_THROW:
2068                 case TR_SHOW_MODS:
2069                 case TR_HIDE_TYPE:
2070                 case TR_ES_ATTACK:
2071                 case TR_ES_AC:
2072                 case TR_FULL_NAME:
2073                 case TR_FIXED_FLAVOR:
2074                         break;
2075                 default:
2076                         if (have_flag(from_flgs, i) && !have_flag(to_flgs, i))
2077                         {
2078                                 if (!(is_pval_flag(i) && (from_ptr->pval < 1))) cand[n++] = i;
2079                         }
2080                 }
2081         }
2082
2083         if (n <= 0) return;
2084
2085         int tr_idx = cand[randint0(n)];
2086         add_flag(to_ptr->art_flags, tr_idx);
2087         if (is_pval_flag(tr_idx)) to_ptr->pval = MAX(to_ptr->pval, 1);
2088         int bmax = MIN(3, MAX(1, 40 / (to_ptr->dd * to_ptr->ds)));
2089         if (tr_idx == TR_BLOWS) to_ptr->pval = MIN(to_ptr->pval, bmax);
2090         if (tr_idx == TR_SPEED) to_ptr->pval = MIN(to_ptr->pval, 4);
2091 }
2092
2093
2094 /*!
2095  * @brief アイテム修復処理のメインルーチン / Repair broken weapon
2096  * @param player_ptr プレーヤーへの参照ポインタ
2097  * @param bcost 基本修復費用
2098  * @return 実際にかかった費用
2099  */
2100 static PRICE repair_broken_weapon_aux(player_type *player_ptr, PRICE bcost)
2101 {
2102         clear_bldg(0, 22);
2103         int row = 7;
2104         prt(_("修復には材料となるもう1つの武器が必要です。", "Hand one material weapon to repair a broken weapon."), row, 2);
2105         prt(_("材料に使用した武器はなくなります!", "The material weapon will disappear after repairing!!"), row + 1, 2);
2106
2107         concptr q = _("どの折れた武器を修復しますか?", "Repair which broken weapon? ");
2108         concptr s = _("修復できる折れた武器がありません。", "You have no broken weapon to repair.");
2109         item_tester_hook = item_tester_hook_broken_weapon;
2110
2111         OBJECT_IDX item;
2112         object_type *o_ptr;
2113         o_ptr = choose_object(player_ptr, &item, q, s, (USE_INVEN | USE_EQUIP), 0);
2114         if (!o_ptr) return 0;
2115
2116         if (!object_is_ego(o_ptr) && !object_is_artifact(o_ptr))
2117         {
2118                 msg_format(_("それは直してもしょうがないぜ。", "It is worthless to repair."));
2119                 return 0;
2120         }
2121
2122         if (o_ptr->number > 1)
2123         {
2124                 msg_format(_("一度に複数を修復することはできません!", "They are too many to repair at once!"));
2125                 return 0;
2126         }
2127
2128         char basenm[MAX_NLEN];
2129         object_desc(player_ptr, basenm, o_ptr, OD_NAME_ONLY);
2130         prt(format(_("修復する武器 : %s", "Repairing: %s"), basenm), row + 3, 2);
2131
2132         q = _("材料となる武器は?", "Which weapon for material? ");
2133         s = _("材料となる武器がありません。", "You have no material to repair.");
2134
2135         item_tester_hook = item_tester_hook_orthodox_melee_weapons;
2136         OBJECT_IDX mater;
2137         object_type *mo_ptr;
2138         mo_ptr = choose_object(player_ptr, &mater, q, s, (USE_INVEN | USE_EQUIP), 0);
2139         if (!mo_ptr) return 0;
2140         if (mater == item)
2141         {
2142                 msg_print(_("クラインの壷じゃない!", "This is not a klein bottle!"));
2143                 return 0;
2144         }
2145
2146         object_desc(player_ptr, basenm, mo_ptr, OD_NAME_ONLY);
2147         prt(format(_("材料とする武器: %s", "Material : %s"), basenm), row + 4, 2);
2148         PRICE cost = bcost + object_value_real(o_ptr) * 2;
2149         if (!get_check(format(_("$%dかかりますがよろしいですか? ", "Costs %d gold, okay? "), cost))) return 0;
2150
2151         if (player_ptr->au < cost)
2152         {
2153                 object_desc(player_ptr, basenm, o_ptr, OD_NAME_ONLY);
2154                 msg_format(_("%sを修復するだけのゴールドがありません!", "You do not have the gold to repair %s!"), basenm);
2155                 msg_print(NULL);
2156                 return 0;
2157         }
2158
2159         player_ptr->total_weight -= o_ptr->weight;
2160         KIND_OBJECT_IDX k_idx;
2161         if (o_ptr->sval == SV_BROKEN_DAGGER)
2162         {
2163                 int n = 1;
2164                 k_idx = 0;
2165                 for (KIND_OBJECT_IDX j = 1; j < max_k_idx; j++)
2166                 {
2167                         object_kind *k_aux_ptr = &k_info[j];
2168
2169                         if (k_aux_ptr->tval != TV_SWORD) continue;
2170                         if ((k_aux_ptr->sval == SV_BROKEN_DAGGER) ||
2171                                 (k_aux_ptr->sval == SV_BROKEN_SWORD) ||
2172                                 (k_aux_ptr->sval == SV_POISON_NEEDLE)) continue;
2173                         if (k_aux_ptr->weight > 99) continue;
2174
2175                         if (one_in_(n))
2176                         {
2177                                 k_idx = j;
2178                                 n++;
2179                         }
2180                 }
2181         }
2182         else
2183         {
2184                 OBJECT_TYPE_VALUE tval = (one_in_(5) ? mo_ptr->tval : TV_SWORD);
2185                 while (TRUE)
2186                 {
2187                         object_kind *ck_ptr;
2188                         k_idx = lookup_kind(tval, SV_ANY);
2189                         ck_ptr = &k_info[k_idx];
2190
2191                         if (tval == TV_SWORD)
2192                         {
2193                                 if ((ck_ptr->sval == SV_BROKEN_DAGGER) ||
2194                                         (ck_ptr->sval == SV_BROKEN_SWORD) ||
2195                                         (ck_ptr->sval == SV_DIAMOND_EDGE) ||
2196                                         (ck_ptr->sval == SV_POISON_NEEDLE)) continue;
2197                         }
2198                         if (tval == TV_POLEARM)
2199                         {
2200                                 if ((ck_ptr->sval == SV_DEATH_SCYTHE) ||
2201                                         (ck_ptr->sval == SV_TSURIZAO)) continue;
2202                         }
2203                         if (tval == TV_HAFTED)
2204                         {
2205                                 if ((ck_ptr->sval == SV_GROND) ||
2206                                         (ck_ptr->sval == SV_WIZSTAFF) ||
2207                                         (ck_ptr->sval == SV_NAMAKE_HAMMER)) continue;
2208                         }
2209
2210                         break;
2211                 }
2212         }
2213
2214         int dd_bonus = o_ptr->dd - k_info[o_ptr->k_idx].dd;
2215         int ds_bonus = o_ptr->ds - k_info[o_ptr->k_idx].ds;
2216         dd_bonus += mo_ptr->dd - k_info[mo_ptr->k_idx].dd;
2217         ds_bonus += mo_ptr->ds - k_info[mo_ptr->k_idx].ds;
2218
2219         object_kind *k_ptr;
2220         k_ptr = &k_info[k_idx];
2221         o_ptr->k_idx = k_idx;
2222         o_ptr->weight = k_ptr->weight;
2223         o_ptr->tval = k_ptr->tval;
2224         o_ptr->sval = k_ptr->sval;
2225         o_ptr->dd = k_ptr->dd;
2226         o_ptr->ds = k_ptr->ds;
2227
2228         for (int i = 0; i < TR_FLAG_SIZE; i++) o_ptr->art_flags[i] |= k_ptr->flags[i];
2229         if (k_ptr->pval) o_ptr->pval = MAX(o_ptr->pval, randint1(k_ptr->pval));
2230         if (have_flag(k_ptr->flags, TR_ACTIVATE)) o_ptr->xtra2 = (byte)k_ptr->act_idx;
2231
2232         if (dd_bonus > 0)
2233         {
2234                 o_ptr->dd++;
2235                 for (int i = 1; i < dd_bonus; i++)
2236                 {
2237                         if (one_in_(o_ptr->dd + i)) o_ptr->dd++;
2238                 }
2239         }
2240
2241         if (ds_bonus > 0)
2242         {
2243                 o_ptr->ds++;
2244                 for (int i = 1; i < ds_bonus; i++)
2245                 {
2246                         if (one_in_(o_ptr->ds + i)) o_ptr->ds++;
2247                 }
2248         }
2249
2250         if (have_flag(k_ptr->flags, TR_BLOWS))
2251         {
2252                 int bmax = MIN(3, MAX(1, 40 / (o_ptr->dd * o_ptr->ds)));
2253                 o_ptr->pval = MIN(o_ptr->pval, bmax);
2254         }
2255
2256         give_one_ability_of_object(o_ptr, mo_ptr);
2257         o_ptr->to_d += MAX(0, (mo_ptr->to_d / 3));
2258         o_ptr->to_h += MAX(0, (mo_ptr->to_h / 3));
2259         o_ptr->to_a += MAX(0, (mo_ptr->to_a));
2260
2261         if ((o_ptr->name1 == ART_NARSIL) ||
2262                 (object_is_random_artifact(o_ptr) && one_in_(1)) ||
2263                 (object_is_ego(o_ptr) && one_in_(7)))
2264         {
2265                 if (object_is_ego(o_ptr))
2266                 {
2267                         add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
2268                         add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
2269                 }
2270
2271                 give_one_ability_of_object(o_ptr, mo_ptr);
2272                 if (!activation_index(o_ptr)) one_activation(o_ptr);
2273
2274                 if (o_ptr->name1 == ART_NARSIL)
2275                 {
2276                         one_high_resistance(o_ptr);
2277                         one_ability(o_ptr);
2278                 }
2279
2280                 msg_print(_("これはかなりの業物だったようだ。", "This blade seems to be exceptional."));
2281         }
2282
2283         object_desc(player_ptr, basenm, o_ptr, OD_NAME_ONLY);
2284 #ifdef JP
2285         msg_format("$%dで%sに修復しました。", cost, basenm);
2286 #else
2287         msg_format("Repaired into %s for %d gold.", basenm, cost);
2288 #endif
2289         msg_print(NULL);
2290         o_ptr->ident &= ~(IDENT_BROKEN);
2291         o_ptr->discount = 99;
2292
2293         player_ptr->total_weight += o_ptr->weight;
2294         calc_android_exp(player_ptr);
2295         inven_item_increase(player_ptr, mater, -1);
2296         inven_item_optimize(player_ptr, mater);
2297
2298         player_ptr->update |= PU_BONUS;
2299         handle_stuff(player_ptr);
2300         return (cost);
2301 }
2302
2303
2304 /*!
2305  * @brief アイテム修復処理の過渡ルーチン / Repair broken weapon
2306  * @param player_ptr プレーヤーへの参照ポインタ
2307  * @param bcost 基本鑑定費用
2308  * @return 実際にかかった費用
2309  */
2310 static int repair_broken_weapon(player_type *player_ptr, PRICE bcost)
2311 {
2312         PRICE cost;
2313         screen_save();
2314         cost = repair_broken_weapon_aux(player_ptr, bcost);
2315         screen_load();
2316         return cost;
2317 }
2318
2319
2320 /*!
2321  * @brief アイテムの強化を行う。 / Enchant item
2322  * @param player_ptr プレーヤーへの参照ポインタ
2323  * @param cost 1回毎の費用
2324  * @param to_hit 命中をアップさせる量
2325  * @param to_dam ダメージをアップさせる量
2326  * @param to_ac ACをアップさせる量
2327  * @return 実際に行ったらTRUE
2328  */
2329 static bool enchant_item(player_type *player_ptr, PRICE cost, HIT_PROB to_hit, HIT_POINT to_dam, ARMOUR_CLASS to_ac)
2330 {
2331         clear_bldg(4, 18);
2332         int maxenchant = (player_ptr->lev / 5);
2333         prt(format(_("現在のあなたの技量だと、+%d まで改良できます。", "  Based on your skill, we can improve up to +%d."), maxenchant), 5, 0);
2334         prt(format(_(" 改良の料金は一個につき$%d です。", "  The price for the service is %d gold per item."), cost), 7, 0);
2335
2336         concptr q = _("どのアイテムを改良しますか?", "Improve which item? ");
2337         concptr s = _("改良できるものがありません。", "You have nothing to improve.");
2338
2339         OBJECT_IDX item;
2340         object_type *o_ptr;
2341         o_ptr = choose_object(player_ptr, &item, q, s, (USE_INVEN | USE_EQUIP | IGNORE_BOTHHAND_SLOT), item_tester_tval);
2342         if (!o_ptr) return FALSE;
2343
2344         char tmp_str[MAX_NLEN];
2345         if (player_ptr->au < (cost * o_ptr->number))
2346         {
2347                 object_desc(player_ptr, tmp_str, o_ptr, OD_NAME_ONLY);
2348                 msg_format(_("%sを改良するだけのゴールドがありません!", "You do not have the gold to improve %s!"), tmp_str);
2349                 return FALSE;
2350         }
2351
2352         bool okay = FALSE;
2353         for (int i = 0; i < to_hit; i++)
2354         {
2355                 if ((o_ptr->to_h < maxenchant) && enchant(player_ptr, o_ptr, 1, (ENCH_TOHIT | ENCH_FORCE)))
2356                 {
2357                         okay = TRUE;
2358                         break;
2359                 }
2360         }
2361
2362         for (int i = 0; i < to_dam; i++)
2363         {
2364                 if ((o_ptr->to_d < maxenchant) && enchant(player_ptr, o_ptr, 1, (ENCH_TODAM | ENCH_FORCE)))
2365                 {
2366                         okay = TRUE;
2367                         break;
2368                 }
2369         }
2370
2371         for (int i = 0; i < to_ac; i++)
2372         {
2373                 if ((o_ptr->to_a < maxenchant) && enchant(player_ptr, o_ptr, 1, (ENCH_TOAC | ENCH_FORCE)))
2374                 {
2375                         okay = TRUE;
2376                         break;
2377                 }
2378         }
2379
2380         if (!okay)
2381         {
2382                 if (flush_failure) flush();
2383                 msg_print(_("改良に失敗した。", "The improvement failed."));
2384                 return FALSE;
2385         }
2386
2387         object_desc(player_ptr, tmp_str, o_ptr, OD_NAME_AND_ENCHANT);
2388 #ifdef JP
2389         msg_format("$%dで%sに改良しました。", cost * o_ptr->number, tmp_str);
2390 #else
2391         msg_format("Improved into %s for %d gold.", tmp_str, cost * o_ptr->number);
2392 #endif
2393
2394         player_ptr->au -= (cost * o_ptr->number);
2395         if (item >= INVEN_RARM) calc_android_exp(player_ptr);
2396         return TRUE;
2397 }
2398
2399
2400 /*!
2401  * @brief 魔道具の使用回数を回復させる施設のメインルーチン / Recharge rods, wands and staffs
2402  * @details
2403  * The player can select the number of charges to add\n
2404  * (up to a limit), and the recharge never fails.\n
2405  *\n
2406  * The cost for rods depends on the level of the rod. The prices\n
2407  * for recharging wands and staffs are dependent on the cost of\n
2408  * the base-item.\n
2409  * @param player_ptr プレーヤーへの参照ポインタ
2410  * @return なし
2411  */
2412 static void building_recharge(player_type *player_ptr)
2413 {
2414         msg_flag = FALSE;
2415         clear_bldg(4, 18);
2416         prt(_("  再充填の費用はアイテムの種類によります。", "  The prices of recharge depend on the type."), 6, 0);
2417         item_tester_hook = item_tester_hook_recharge;
2418
2419         concptr q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2420         concptr s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2421
2422         OBJECT_IDX item;
2423         object_type *o_ptr;
2424         o_ptr = choose_object(player_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
2425         if (!o_ptr) return;
2426
2427         object_kind *k_ptr;
2428         k_ptr = &k_info[o_ptr->k_idx];
2429
2430         /*
2431          * We don't want to give the player free info about
2432          * the level of the item or the number of charges.
2433          */
2434          /* The item must be "known" */
2435         char tmp_str[MAX_NLEN];
2436         if (!object_is_known(o_ptr))
2437         {
2438                 msg_format(_("充填する前に鑑定されている必要があります!", "The item must be identified first!"));
2439                 msg_print(NULL);
2440
2441                 if ((player_ptr->au >= 50) &&
2442                         get_check(_("$50で鑑定しますか? ", "Identify for 50 gold? ")))
2443
2444                 {
2445                         player_ptr->au -= 50;
2446                         identify_item(player_ptr, o_ptr);
2447                         object_desc(player_ptr, tmp_str, o_ptr, 0);
2448                         msg_format(_("%s です。", "You have: %s."), tmp_str);
2449
2450                         autopick_alter_item(player_ptr, item, FALSE);
2451                         building_prt_gold(player_ptr);
2452                 }
2453
2454                 return;
2455         }
2456
2457         DEPTH lev = k_info[o_ptr->k_idx].level;
2458         PRICE price;
2459         if (o_ptr->tval == TV_ROD)
2460         {
2461                 if (o_ptr->timeout > 0)
2462                 {
2463                         price = (lev * 50 * o_ptr->timeout) / k_ptr->pval;
2464                 }
2465                 else
2466                 {
2467                         price = 0;
2468                         msg_format(_("それは再充填する必要はありません。", "That doesn't need to be recharged."));
2469                         return;
2470                 }
2471         }
2472         else if (o_ptr->tval == TV_STAFF)
2473         {
2474                 price = (k_info[o_ptr->k_idx].cost / 10) * o_ptr->number;
2475                 price = MAX(10, price);
2476         }
2477         else
2478         {
2479                 price = (k_info[o_ptr->k_idx].cost / 10);
2480                 price = MAX(10, price);
2481         }
2482
2483         if (o_ptr->tval == TV_WAND
2484                 && (o_ptr->pval / o_ptr->number >= k_ptr->pval))
2485         {
2486                 if (o_ptr->number > 1)
2487                 {
2488                         msg_print(_("この魔法棒はもう充分に充填されています。", "These wands are already fully charged."));
2489                 }
2490                 else
2491                 {
2492                         msg_print(_("この魔法棒はもう充分に充填されています。", "This wand is already fully charged."));
2493                 }
2494
2495                 return;
2496         }
2497         else if (o_ptr->tval == TV_STAFF && o_ptr->pval >= k_ptr->pval)
2498         {
2499                 if (o_ptr->number > 1)
2500                 {
2501                         msg_print(_("この杖はもう充分に充填されています。", "These staffs are already fully charged."));
2502                 }
2503                 else
2504                 {
2505                         msg_print(_("この杖はもう充分に充填されています。", "This staff is already fully charged."));
2506                 }
2507
2508                 return;
2509         }
2510
2511         if (player_ptr->au < price)
2512         {
2513                 object_desc(player_ptr, tmp_str, o_ptr, OD_NAME_ONLY);
2514 #ifdef JP
2515                 msg_format("%sを再充填するには$%d 必要です!", tmp_str, price);
2516 #else
2517                 msg_format("You need %d gold to recharge %s!", price, tmp_str);
2518 #endif
2519                 return;
2520         }
2521
2522         PARAMETER_VALUE charges;
2523         if (o_ptr->tval == TV_ROD)
2524         {
2525 #ifdef JP
2526                 if (get_check(format("そのロッドを$%d で再充填しますか?", price)))
2527 #else
2528                 if (get_check(format("Recharge the %s for %d gold? ",
2529                         ((o_ptr->number > 1) ? "rods" : "rod"), price)))
2530 #endif
2531
2532                 {
2533                         o_ptr->timeout = 0;
2534                 }
2535                 else
2536                 {
2537                         return;
2538                 }
2539         }
2540         else
2541         {
2542                 int max_charges;
2543                 if (o_ptr->tval == TV_STAFF)
2544                         max_charges = k_ptr->pval - o_ptr->pval;
2545                 else
2546                         max_charges = o_ptr->number * k_ptr->pval - o_ptr->pval;
2547
2548                 charges = (PARAMETER_VALUE)get_quantity(format(_("一回分$%d で何回分充填しますか?", "Add how many charges for %d gold? "), price),
2549                         MIN(player_ptr->au / price, max_charges));
2550
2551                 if (charges < 1) return;
2552
2553                 price *= charges;
2554                 o_ptr->pval += charges;
2555                 o_ptr->ident &= ~(IDENT_EMPTY);
2556         }
2557
2558         object_desc(player_ptr, tmp_str, o_ptr, 0);
2559 #ifdef JP
2560         msg_format("%sを$%d で再充填しました。", tmp_str, price);
2561 #else
2562         msg_format("%^s %s recharged for %d gold.", tmp_str, ((o_ptr->number > 1) ? "were" : "was"), price);
2563 #endif
2564         player_ptr->update |= (PU_COMBINE | PU_REORDER);
2565         player_ptr->window |= (PW_INVEN);
2566         player_ptr->au -= price;
2567 }
2568
2569
2570 /*!
2571  * @brief 魔道具の使用回数を回復させる施設の一括処理向けサブルーチン / Recharge rods, wands and staffs
2572  * @details
2573  * The player can select the number of charges to add\n
2574  * (up to a limit), and the recharge never fails.\n
2575  *\n
2576  * The cost for rods depends on the level of the rod. The prices\n
2577  * for recharging wands and staffs are dependent on the cost of\n
2578  * the base-item.\n
2579  * @param player_ptr プレーヤーへの参照ポインタ
2580  * @return なし
2581  */
2582 static void building_recharge_all(player_type *player_ptr)
2583 {
2584         msg_flag = FALSE;
2585         clear_bldg(4, 18);
2586         prt(_("  再充填の費用はアイテムの種類によります。", "  The prices of recharge depend on the type."), 6, 0);
2587
2588         PRICE price = 0;
2589         PRICE total_cost = 0;
2590         for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++)
2591         {
2592                 object_type *o_ptr;
2593                 o_ptr = &player_ptr->inventory_list[i];
2594
2595                 if (o_ptr->tval < TV_STAFF || o_ptr->tval > TV_ROD) continue;
2596                 if (!object_is_known(o_ptr)) total_cost += 50;
2597
2598                 DEPTH lev = k_info[o_ptr->k_idx].level;
2599                 object_kind *k_ptr;
2600                 k_ptr = &k_info[o_ptr->k_idx];
2601
2602                 switch (o_ptr->tval)
2603                 {
2604                 case TV_ROD:
2605                         price = (lev * 50 * o_ptr->timeout) / k_ptr->pval;
2606                         break;
2607
2608                 case TV_STAFF:
2609                         price = (k_info[o_ptr->k_idx].cost / 10) * o_ptr->number;
2610                         price = MAX(10, price);
2611                         price = (k_ptr->pval - o_ptr->pval) * price;
2612                         break;
2613
2614                 case TV_WAND:
2615                         price = (k_info[o_ptr->k_idx].cost / 10);
2616                         price = MAX(10, price);
2617                         price = (o_ptr->number * k_ptr->pval - o_ptr->pval) * price;
2618                         break;
2619                 }
2620
2621                 if (price > 0) total_cost += price;
2622         }
2623
2624         if (!total_cost)
2625         {
2626                 msg_print(_("充填する必要はありません。", "No need to recharge."));
2627                 msg_print(NULL);
2628                 return;
2629         }
2630
2631         if (player_ptr->au < total_cost)
2632         {
2633                 msg_format(_("すべてのアイテムを再充填するには$%d 必要です!", "You need %d gold to recharge all items!"), total_cost);
2634                 msg_print(NULL);
2635                 return;
2636         }
2637
2638         if (!get_check(format(_("すべてのアイテムを $%d で再充填しますか?", "Recharge all items for %d gold? "), total_cost))) return;
2639
2640         for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++)
2641         {
2642                 object_type *o_ptr;
2643                 o_ptr = &player_ptr->inventory_list[i];
2644                 object_kind *k_ptr;
2645                 k_ptr = &k_info[o_ptr->k_idx];
2646
2647                 if (o_ptr->tval < TV_STAFF || o_ptr->tval > TV_ROD) continue;
2648
2649                 if (!object_is_known(o_ptr))
2650                 {
2651                         identify_item(player_ptr, o_ptr);
2652                         autopick_alter_item(player_ptr, i, FALSE);
2653                 }
2654
2655                 switch (o_ptr->tval)
2656                 {
2657                 case TV_ROD:
2658                         o_ptr->timeout = 0;
2659                         break;
2660                 case TV_STAFF:
2661                         if (o_ptr->pval < k_ptr->pval) o_ptr->pval = k_ptr->pval;
2662
2663                         o_ptr->ident &= ~(IDENT_EMPTY);
2664                         break;
2665                 case TV_WAND:
2666                         if (o_ptr->pval < o_ptr->number * k_ptr->pval)
2667                                 o_ptr->pval = o_ptr->number * k_ptr->pval;
2668
2669                         o_ptr->ident &= ~(IDENT_EMPTY);
2670                         break;
2671                 }
2672         }
2673
2674         msg_format(_("$%d で再充填しました。", "You pay %d gold."), total_cost);
2675         msg_print(NULL);
2676         player_ptr->update |= (PU_COMBINE | PU_REORDER);
2677         player_ptr->window |= (PW_INVEN);
2678         player_ptr->au -= total_cost;
2679 }
2680
2681
2682 /*!
2683  * @brief 施設でモンスターの情報を知るメインルーチン / research_mon -KMW-
2684  * @param player_ptr プレーヤーへの参照ポインタ
2685  * @return 常にTRUEを返す。
2686  * @todo 返り値が意味不明なので直した方が良いかもしれない。
2687  */
2688 static bool research_mon(player_type *player_ptr)
2689 {
2690         char buf[128];
2691         bool notpicked;
2692         bool recall = FALSE;
2693         u16b why = 0;
2694         MONSTER_IDX *who;
2695
2696         bool all = FALSE;
2697         bool uniq = FALSE;
2698         bool norm = FALSE;
2699         char temp[80] = "";
2700
2701         static int old_sym = '\0';
2702         static IDX old_i = 0;
2703         screen_save();
2704
2705         char sym;
2706         if (!get_com(_("モンスターの文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^M名前):",
2707                 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE))
2708
2709         {
2710                 screen_load();
2711                 return FALSE;
2712         }
2713
2714         IDX i;
2715         for (i = 0; ident_info[i]; ++i)
2716         {
2717                 if (sym == ident_info[i][0]) break;
2718         }
2719
2720         /* XTRA HACK WHATSEARCH */
2721         if (sym == KTRL('A'))
2722         {
2723                 all = TRUE;
2724                 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
2725         }
2726         else if (sym == KTRL('U'))
2727         {
2728                 all = uniq = TRUE;
2729                 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
2730         }
2731         else if (sym == KTRL('N'))
2732         {
2733                 all = norm = TRUE;
2734                 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
2735         }
2736         else if (sym == KTRL('M'))
2737         {
2738                 all = TRUE;
2739                 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"), temp, 70))
2740                 {
2741                         temp[0] = 0;
2742                         screen_load();
2743
2744                         return FALSE;
2745                 }
2746
2747                 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""), temp);
2748         }
2749         else if (ident_info[i])
2750         {
2751                 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
2752         }
2753         else
2754         {
2755                 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
2756         }
2757
2758         /* Display the result */
2759         prt(buf, 16, 10);
2760
2761         /* Allocate the "who" array */
2762         C_MAKE(who, max_r_idx, MONRACE_IDX);
2763
2764         /* Collect matching monsters */
2765         int n = 0;
2766         for (i = 1; i < max_r_idx; i++)
2767         {
2768                 monster_race *r_ptr = &r_info[i];
2769
2770                 /* Empty monster */
2771                 if (!r_ptr->name) continue;
2772
2773                 /* XTRA HACK WHATSEARCH */
2774                 /* Require non-unique monsters if needed */
2775                 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
2776
2777                 /* Require unique monsters if needed */
2778                 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
2779
2780                 /* 名前検索 */
2781                 if (temp[0])
2782                 {
2783                         for (int xx = 0; temp[xx] && xx < 80; xx++)
2784                         {
2785 #ifdef JP
2786                                 if (iskanji(temp[xx]))
2787                                 {
2788                                         xx++;
2789                                         continue;
2790                                 }
2791 #endif
2792                                 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
2793                         }
2794
2795                         char temp2[80];
2796 #ifdef JP
2797                         strcpy(temp2, r_name + r_ptr->E_name);
2798 #else
2799                         strcpy(temp2, r_name + r_ptr->name);
2800 #endif
2801                         for (int xx = 0; temp2[xx] && xx < 80; xx++)
2802                         {
2803                                 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
2804                         }
2805
2806 #ifdef JP
2807                         if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
2808 #else
2809                         if (my_strstr(temp2, temp))
2810 #endif
2811                                 who[n++] = i;
2812                 }
2813                 else if (all || (r_ptr->d_char == sym))
2814                 {
2815                         who[n++] = i;
2816                 }
2817         }
2818
2819         if (n == 0)
2820         {
2821                 C_KILL(who, max_r_idx, MONRACE_IDX);
2822                 screen_load();
2823
2824                 return FALSE;
2825         }
2826
2827         why = 2;
2828         char query = 'y';
2829
2830         if (why)
2831         {
2832                 ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
2833         }
2834
2835         if (old_sym == sym && old_i < n) i = old_i;
2836         else i = n - 1;
2837
2838         notpicked = TRUE;
2839         MONRACE_IDX r_idx;
2840         while (notpicked)
2841         {
2842                 r_idx = who[i];
2843                 roff_top(r_idx);
2844                 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ' 'で続行, ESC]", " [(r)ecall, ESC, space to continue]"));
2845                 while (TRUE)
2846                 {
2847                         if (recall)
2848                         {
2849                                 lore_do_probe(player_ptr, r_idx);
2850                                 monster_race_track(player_ptr, r_idx);
2851                                 handle_stuff(player_ptr);
2852                                 screen_roff(player_ptr, r_idx, 0x01);
2853                                 notpicked = FALSE;
2854                                 old_sym = sym;
2855                                 old_i = i;
2856                         }
2857
2858                         query = inkey();
2859                         if (query != 'r') break;
2860
2861                         recall = !recall;
2862                 }
2863
2864                 if (query == ESCAPE) break;
2865
2866                 if (query == '-')
2867                 {
2868                         if (++i == n)
2869                         {
2870                                 i = 0;
2871                                 if (!expand_list) break;
2872                         }
2873
2874                         continue;
2875                 }
2876
2877                 if (i-- == 0)
2878                 {
2879                         i = n - 1;
2880                         if (!expand_list) break;
2881                 }
2882         }
2883
2884         C_KILL(who, max_r_idx, MONRACE_IDX);
2885         screen_load();
2886         return !notpicked;
2887 }
2888
2889
2890 /*!
2891  * @brief 施設の処理実行メインルーチン / Execute a building command
2892  * @param player_ptr プレーヤーへの参照ポインタ
2893  * @param bldg 施設構造体の参照ポインタ
2894  * @param i 実行したい施設のサービステーブルの添字
2895  * @return なし
2896  */
2897 static void bldg_process_command(player_type *player_ptr, building_type *bldg, int i)
2898 {
2899         msg_flag = FALSE;
2900         msg_erase();
2901
2902         PRICE bcost;
2903         if (is_owner(player_ptr, bldg))
2904                 bcost = bldg->member_costs[i];
2905         else
2906                 bcost = bldg->other_costs[i];
2907
2908         /* action restrictions */
2909         if (((bldg->action_restr[i] == 1) && !is_member(player_ptr, bldg)) ||
2910                 ((bldg->action_restr[i] == 2) && !is_owner(player_ptr, bldg)))
2911         {
2912                 msg_print(_("それを選択する権利はありません!", "You have no right to choose that!"));
2913                 return;
2914         }
2915
2916         BACT_IDX bact = bldg->actions[i];
2917         if ((bact != BACT_RECHARGE) &&
2918                 (((bldg->member_costs[i] > player_ptr->au) && is_owner(player_ptr, bldg)) ||
2919                 ((bldg->other_costs[i] > player_ptr->au) && !is_owner(player_ptr, bldg))))
2920         {
2921                 msg_print(_("お金が足りません!", "You do not have the gold!"));
2922                 return;
2923         }
2924
2925         bool paid = FALSE;
2926         switch (bact)
2927         {
2928         case BACT_NOTHING:
2929                 /* Do nothing */
2930                 break;
2931         case BACT_RESEARCH_ITEM:
2932                 paid = identify_fully(player_ptr, FALSE);
2933                 break;
2934         case BACT_TOWN_HISTORY:
2935                 town_history(player_ptr);
2936                 break;
2937         case BACT_RACE_LEGENDS:
2938                 race_legends(player_ptr);
2939                 break;
2940         case BACT_QUEST:
2941                 castle_quest(player_ptr);
2942                 break;
2943         case BACT_KING_LEGENDS:
2944         case BACT_ARENA_LEGENDS:
2945         case BACT_LEGENDS:
2946                 show_highclass(player_ptr);
2947                 break;
2948         case BACT_POSTER:
2949         case BACT_ARENA_RULES:
2950         case BACT_ARENA:
2951                 arena_comm(player_ptr, bact);
2952                 break;
2953         case BACT_IN_BETWEEN:
2954         case BACT_CRAPS:
2955         case BACT_SPIN_WHEEL:
2956         case BACT_DICE_SLOTS:
2957         case BACT_GAMBLE_RULES:
2958         case BACT_POKER:
2959                 gamble_comm(player_ptr, bact);
2960                 break;
2961         case BACT_REST:
2962         case BACT_RUMORS:
2963         case BACT_FOOD:
2964                 paid = inn_comm(player_ptr, bact);
2965                 break;
2966         case BACT_RESEARCH_MONSTER:
2967                 paid = research_mon(player_ptr);
2968                 break;
2969         case BACT_COMPARE_WEAPONS:
2970                 paid = TRUE;
2971                 bcost = compare_weapons(player_ptr, bcost);
2972                 break;
2973         case BACT_ENCHANT_WEAPON:
2974                 item_tester_hook = object_allow_enchant_melee_weapon;
2975                 enchant_item(player_ptr, bcost, 1, 1, 0);
2976                 break;
2977         case BACT_ENCHANT_ARMOR:
2978                 item_tester_hook = object_is_armour;
2979                 enchant_item(player_ptr, bcost, 0, 0, 1);
2980                 break;
2981         case BACT_RECHARGE:
2982                 building_recharge(player_ptr);
2983                 break;
2984         case BACT_RECHARGE_ALL:
2985                 building_recharge_all(player_ptr);
2986                 break;
2987         case BACT_IDENTS:
2988                 if (!get_check(_("持ち物を全て鑑定してよろしいですか?", "Do you pay for identify all your possession? "))) break;
2989                 identify_pack(player_ptr);
2990                 msg_print(_(" 持ち物全てが鑑定されました。", "Your possessions have been identified."));
2991                 paid = TRUE;
2992                 break;
2993         case BACT_IDENT_ONE:
2994                 paid = ident_spell(player_ptr, FALSE);
2995                 break;
2996         case BACT_LEARN:
2997                 do_cmd_study(player_ptr);
2998                 break;
2999         case BACT_HEALING:
3000                 paid = cure_critical_wounds(player_ptr, 200);
3001                 break;
3002         case BACT_RESTORE:
3003                 paid = restore_all_status(player_ptr);
3004                 break;
3005         case BACT_ENCHANT_ARROWS:
3006                 item_tester_hook = item_tester_hook_ammo;
3007                 enchant_item(player_ptr, bcost, 1, 1, 0);
3008                 break;
3009         case BACT_ENCHANT_BOW:
3010                 item_tester_tval = TV_BOW;
3011                 enchant_item(player_ptr, bcost, 1, 1, 0);
3012                 break;
3013
3014         case BACT_RECALL:
3015                 if (recall_player(player_ptr, 1)) paid = TRUE;
3016                 break;
3017
3018         case BACT_TELEPORT_LEVEL:
3019                 clear_bldg(4, 20);
3020                 paid = free_level_recall(player_ptr);
3021                 break;
3022
3023         case BACT_LOSE_MUTATION:
3024                 if (player_ptr->muta1 || player_ptr->muta2 || (player_ptr->muta3 & ~MUT3_GOOD_LUCK) ||
3025                         (player_ptr->pseikaku != SEIKAKU_LUCKY && (player_ptr->muta3 & MUT3_GOOD_LUCK)))
3026                 {
3027                         while (!lose_mutation(player_ptr, 0));
3028                         paid = TRUE;
3029                         break;
3030                 }
3031
3032                 msg_print(_("治すべき突然変異が無い。", "You have no mutations."));
3033                 msg_print(NULL);
3034                 break;
3035
3036         case BACT_BATTLE:
3037                 kakutoujou(player_ptr);
3038                 break;
3039
3040         case BACT_TSUCHINOKO:
3041                 tsuchinoko();
3042                 break;
3043
3044         case BACT_BOUNTY:
3045                 show_bounty();
3046                 break;
3047
3048         case BACT_TARGET:
3049                 today_target(player_ptr);
3050                 break;
3051
3052         case BACT_KANKIN:
3053                 kankin(player_ptr);
3054                 break;
3055
3056         case BACT_HEIKOUKA:
3057                 msg_print(_("平衡化の儀式を行なった。", "You received an equalization ritual."));
3058                 set_virtue(player_ptr, V_COMPASSION, 0);
3059                 set_virtue(player_ptr, V_HONOUR, 0);
3060                 set_virtue(player_ptr, V_JUSTICE, 0);
3061                 set_virtue(player_ptr, V_SACRIFICE, 0);
3062                 set_virtue(player_ptr, V_KNOWLEDGE, 0);
3063                 set_virtue(player_ptr, V_FAITH, 0);
3064                 set_virtue(player_ptr, V_ENLIGHTEN, 0);
3065                 set_virtue(player_ptr, V_ENCHANT, 0);
3066                 set_virtue(player_ptr, V_CHANCE, 0);
3067                 set_virtue(player_ptr, V_NATURE, 0);
3068                 set_virtue(player_ptr, V_HARMONY, 0);
3069                 set_virtue(player_ptr, V_VITALITY, 0);
3070                 set_virtue(player_ptr, V_UNLIFE, 0);
3071                 set_virtue(player_ptr, V_PATIENCE, 0);
3072                 set_virtue(player_ptr, V_TEMPERANCE, 0);
3073                 set_virtue(player_ptr, V_DILIGENCE, 0);
3074                 set_virtue(player_ptr, V_VALOUR, 0);
3075                 set_virtue(player_ptr, V_INDIVIDUALISM, 0);
3076                 get_virtues(player_ptr);
3077                 paid = TRUE;
3078                 break;
3079
3080         case BACT_TELE_TOWN:
3081                 paid = tele_town(player_ptr);
3082                 break;
3083
3084         case BACT_EVAL_AC:
3085                 paid = eval_ac(player_ptr->dis_ac + player_ptr->dis_to_a);
3086                 break;
3087
3088         case BACT_BROKEN_WEAPON:
3089                 paid = TRUE;
3090                 bcost = repair_broken_weapon(player_ptr, bcost);
3091                 break;
3092         }
3093
3094         if (paid) player_ptr->au -= bcost;
3095 }
3096
3097
3098 /*!
3099  * @brief 施設入り口にプレイヤーが乗った際の処理 / Do building commands
3100  * @param プレーヤーへの参照ポインタ
3101  * @return なし
3102  */
3103 void do_cmd_bldg(player_type *player_ptr)
3104 {
3105         if (player_ptr->wild_mode) return;
3106
3107         take_turn(player_ptr, 100);
3108
3109         if (!cave_have_flag_bold(player_ptr->current_floor_ptr, player_ptr->y, player_ptr->x, FF_BLDG))
3110         {
3111                 msg_print(_("ここには建物はない。", "You see no building here."));
3112                 return;
3113         }
3114
3115         int which = f_info[player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x].feat].subtype;
3116
3117         building_type *bldg;
3118         bldg = &building[which];
3119
3120         reinit_wilderness = FALSE;
3121
3122         if ((which == 2) && (player_ptr->arena_number < 0))
3123         {
3124                 msg_print(_("「敗者に用はない。」", "'There's no place here for a LOSER like you!'"));
3125                 return;
3126         }
3127         else if ((which == 2) && player_ptr->current_floor_ptr->inside_arena)
3128         {
3129                 if (!player_ptr->exit_bldg && player_ptr->current_floor_ptr->m_cnt > 0)
3130                 {
3131                         prt(_("ゲートは閉まっている。モンスターがあなたを待っている!", "The gates are closed.  The monster awaits!"), 0, 0);
3132                 }
3133                 else
3134                 {
3135                         prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS | CFM_NO_RETURN);
3136                         player_ptr->current_floor_ptr->inside_arena = FALSE;
3137                         player_ptr->leaving = TRUE;
3138                         command_new = SPECIAL_KEY_BUILDING;
3139                         free_turn(player_ptr);
3140                 }
3141
3142                 return;
3143         }
3144         else if (player_ptr->phase_out)
3145         {
3146                 prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS | CFM_NO_RETURN);
3147                 player_ptr->leaving = TRUE;
3148                 player_ptr->phase_out = FALSE;
3149                 command_new = SPECIAL_KEY_BUILDING;
3150                 free_turn(player_ptr);
3151                 return;
3152         }
3153         else
3154         {
3155                 player_ptr->oldpy = player_ptr->y;
3156                 player_ptr->oldpx = player_ptr->x;
3157         }
3158
3159         forget_lite(player_ptr->current_floor_ptr);
3160         forget_view(player_ptr->current_floor_ptr);
3161         current_world_ptr->character_icky++;
3162
3163         command_arg = 0;
3164         command_rep = 0;
3165         command_new = 0;
3166
3167         show_building(player_ptr, bldg);
3168         player_ptr->leave_bldg = FALSE;
3169         play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
3170
3171         bool validcmd;
3172         while (!player_ptr->leave_bldg)
3173         {
3174                 validcmd = FALSE;
3175                 prt("", 1, 0);
3176
3177                 building_prt_gold(player_ptr);
3178
3179                 char command = inkey();
3180
3181                 if (command == ESCAPE)
3182                 {
3183                         player_ptr->leave_bldg = TRUE;
3184                         player_ptr->current_floor_ptr->inside_arena = FALSE;
3185                         player_ptr->phase_out = FALSE;
3186                         break;
3187                 }
3188
3189                 int i;
3190                 for (i = 0; i < 8; i++)
3191                 {
3192                         if (bldg->letters[i] && (bldg->letters[i] == command))
3193                         {
3194                                 validcmd = TRUE;
3195                                 break;
3196                         }
3197                 }
3198
3199                 if (validcmd) bldg_process_command(player_ptr, bldg, i);
3200
3201                 handle_stuff(player_ptr);
3202         }
3203
3204         select_floor_music(player_ptr);
3205
3206         msg_flag = FALSE;
3207         msg_erase();
3208
3209         if (reinit_wilderness) player_ptr->leaving = TRUE;
3210
3211         current_world_ptr->character_icky--;
3212         Term_clear();
3213
3214         player_ptr->update |= (PU_VIEW | PU_MONSTERS | PU_BONUS | PU_LITE | PU_MON_LITE);
3215         player_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
3216         player_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
3217 }
3218
3219
3220 /*!
3221  * @brief 今日の賞金首を確定する / Determine today's bounty monster
3222  * @param player_type プレーヤーへの参照ポインタ
3223  * @return なし
3224  * @note conv_old is used if loaded 0.0.3 or older save file
3225  */
3226 void determine_daily_bounty(player_type *player_ptr, bool conv_old)
3227 {
3228         int max_dl = 3, i;
3229         if (!conv_old)
3230         {
3231                 for (i = 0; i < current_world_ptr->max_d_idx; i++)
3232                 {
3233                         if (max_dlv[i] < d_info[i].mindepth) continue;
3234                         if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
3235                 }
3236         }
3237         else
3238         {
3239                 max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
3240         }
3241
3242         get_mon_num_prep(player_ptr, NULL, NULL);
3243
3244         while (TRUE)
3245         {
3246                 today_mon = get_mon_num(player_ptr, max_dl, GMN_ARENA);
3247                 monster_race *r_ptr;
3248                 r_ptr = &r_info[today_mon];
3249
3250                 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3251                 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
3252                 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
3253                 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
3254                 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
3255                 if (r_ptr->rarity > 10) continue;
3256                 break;
3257         }
3258 }
3259
3260
3261 /*!
3262  * @brief 賞金首となるユニークを確定する / Determine bounty uniques
3263  * @param player_ptr プレーヤーへの参照ポインタ
3264  * @return なし
3265  */
3266 void determine_bounty_uniques(player_type *player_ptr)
3267 {
3268         get_mon_num_prep(player_ptr, NULL, NULL);
3269         for (int i = 0; i < MAX_BOUNTY; i++)
3270         {
3271                 while (TRUE)
3272                 {
3273                         current_world_ptr->bounty_r_idx[i] = get_mon_num(player_ptr, MAX_DEPTH - 1, GMN_ARENA);
3274                         monster_race *r_ptr;
3275                         r_ptr = &r_info[current_world_ptr->bounty_r_idx[i]];
3276
3277                         if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
3278
3279                         if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)))
3280                                 continue;
3281
3282                         if (r_ptr->rarity > 100) continue;
3283
3284                         if (no_questor_or_bounty_uniques(current_world_ptr->bounty_r_idx[i]))
3285                                 continue;
3286
3287                         int j;
3288                         for (j = 0; j < i; j++)
3289                         {
3290                                 if (current_world_ptr->bounty_r_idx[i] == current_world_ptr->bounty_r_idx[j])
3291                                         break;
3292                         }
3293
3294                         if (j == i) break;
3295                 }
3296         }
3297
3298         for (int i = 0; i < MAX_BOUNTY - 1; i++)
3299         {
3300                 for (int j = i; j < MAX_BOUNTY; j++)
3301                 {
3302                         MONRACE_IDX tmp;
3303                         if (r_info[current_world_ptr->bounty_r_idx[i]].level > r_info[current_world_ptr->bounty_r_idx[j]].level)
3304                         {
3305                                 tmp = current_world_ptr->bounty_r_idx[i];
3306                                 current_world_ptr->bounty_r_idx[i] = current_world_ptr->bounty_r_idx[j];
3307                                 current_world_ptr->bounty_r_idx[j] = tmp;
3308                         }
3309                 }
3310         }
3311 }