OSDN Git Service

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