OSDN Git Service

[Fix] #39962 read_dead_file() にsize_t 引数を追加 / Added size_t argument to read_dead_file()
[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                         {
1345                                 do
1346                                 {
1347                                         msg_print(_("なにかキーを押すともう一回振ります。", "Hit any key to roll again"));
1348
1349                                         msg_print(NULL);
1350                                         roll1 = randint1(6);
1351                                         roll2 = randint1(6);
1352                                         roll3 = roll1 + roll2;
1353                                         sprintf(tmp_str, _("出目: %d %d          合計:      %d",
1354                                                 "Roll result: %d %d   Total:     %d"), roll1, roll2, roll3);
1355                                         prt(tmp_str, 8, 5);
1356                                         if (roll3 == choice)
1357                                                 win = TRUE;
1358                                         else if (roll3 == 7)
1359                                                 win = FALSE;
1360                                 } while ((win != TRUE) && (win != FALSE));
1361                         }
1362                         
1363                         break;
1364
1365                 case BACT_SPIN_WHEEL:  /* Spin the Wheel Game */
1366                         win = FALSE;
1367                         odds = 9;
1368                         c_put_str(TERM_GREEN, _("ルーレット", "Wheel"), 5, 2);
1369
1370                         prt("0  1  2  3  4  5  6  7  8  9", 7, 5);
1371                         prt("--------------------------------", 8, 3);
1372                         strcpy(out_val, "");
1373                         get_string(_("何番? (0-9): ", "Pick a number (0-9): "), out_val, 32);
1374
1375                         for (p = out_val; iswspace(*p); p++);
1376                         choice = atol(p);
1377                         if (choice < 0)
1378                         {
1379                                 msg_print(_("0番にしとくぜ。", "I'll put you down for 0."));
1380                                 choice = 0;
1381                         }
1382                         else if (choice > 9)
1383                         {
1384                                 msg_print(_("OK、9番にしとくぜ。", "Ok, I'll put you down for 9."));
1385                                 choice = 9;
1386                         }
1387                         msg_print(NULL);
1388                         roll1 = randint0(10);
1389                         sprintf(tmp_str, _("ルーレットは回り、止まった。勝者は %d番だ。",
1390                                 "The wheel spins to a stop and the winner is %d"), roll1);
1391                         prt(tmp_str, 13, 3);
1392                         prt("", 9, 0);
1393                         prt("*", 9, (3 * roll1 + 5));
1394                         if (roll1 == choice)
1395                                 win = TRUE;
1396                         break;
1397
1398                 case BACT_DICE_SLOTS: /* The Dice Slots */
1399                         c_put_str(TERM_GREEN, _("ダイス・スロット", "Dice Slots"), 5, 2);
1400                         c_put_str(TERM_YELLOW, _("レモン   レモン            2", ""), 6, 37);
1401                         c_put_str(TERM_YELLOW, _("レモン   レモン   レモン   5", ""), 7, 37);
1402                         c_put_str(TERM_ORANGE, _("オレンジ オレンジ オレンジ 10", ""), 8, 37);
1403                         c_put_str(TERM_UMBER, _("剣       剣       剣       20", ""), 9, 37);
1404                         c_put_str(TERM_SLATE, _("盾       盾       盾       50", ""), 10, 37);
1405                         c_put_str(TERM_VIOLET, _("プラム   プラム   プラム   200", ""), 11, 37);
1406                         c_put_str(TERM_RED, _("チェリー チェリー チェリー 1000", ""), 12, 37);
1407
1408                         win = FALSE;
1409                         roll1 = randint1(21);
1410                         for (i = 6; i > 0; i--)
1411                         {
1412                                 if ((roll1 - i) < 1)
1413                                 {
1414                                         roll1 = 7 - i;
1415                                         break;
1416                                 }
1417                                 roll1 -= i;
1418                         }
1419                         roll2 = randint1(21);
1420                         for (i = 6; i > 0; i--)
1421                         {
1422                                 if ((roll2 - i) < 1)
1423                                 {
1424                                         roll2 = 7 - i;
1425                                         break;
1426                                 }
1427                                 roll2 -= i;
1428                         }
1429                         choice = randint1(21);
1430                         for (i = 6; i > 0; i--)
1431                         {
1432                                 if ((choice - i) < 1)
1433                                 {
1434                                         choice = 7 - i;
1435                                         break;
1436                                 }
1437                                 choice -= i;
1438                         }
1439                         put_str("/--------------------------\\", 7, 2);
1440                         prt("\\--------------------------/", 17, 2);
1441                         display_fruit(8, 3, roll1 - 1);
1442                         display_fruit(8, 12, roll2 - 1);
1443                         display_fruit(8, 21, choice - 1);
1444                         if ((roll1 == roll2) && (roll2 == choice))
1445                         {
1446                                 win = TRUE;
1447                                 switch (roll1)
1448                                 {
1449                                 case 1:
1450                                         odds = 5; break;
1451                                 case 2:
1452                                         odds = 10; break;
1453                                 case 3:
1454                                         odds = 20; break;
1455                                 case 4:
1456                                         odds = 50; break;
1457                                 case 5:
1458                                         odds = 200; break;
1459                                 case 6:
1460                                         odds = 1000; break;
1461                                 }
1462                         }
1463                         else if ((roll1 == 1) && (roll2 == 1))
1464                         {
1465                                 win = TRUE;
1466                                 odds = 2;
1467                         }
1468                         break;
1469                 case BACT_POKER:
1470                         win = FALSE;
1471                         odds = do_poker();
1472                         if (odds) win = TRUE;
1473                         break;
1474                 }
1475
1476                 if (win)
1477                 {
1478                         prt(_("あなたの勝ち", "YOU WON"), 16, 37);
1479
1480                         player_ptr->au += odds * wager;
1481                         sprintf(tmp_str, _("倍率: %d", "Payoff: %d"), odds);
1482
1483                         prt(tmp_str, 17, 37);
1484                 }
1485                 else
1486                 {
1487                         prt(_("あなたの負け", "You Lost"), 16, 37);
1488                         prt("", 17, 37);
1489                 }
1490
1491                 sprintf(tmp_str, _("現在の所持金:     %9ld", "Current Gold:     %9ld"), (long int)player_ptr->au);
1492
1493                 prt(tmp_str, 22, 2);
1494                 prt(_("もう一度(Y/N)?", "Again(Y/N)?"), 18, 37);
1495
1496                 move_cursor(18, 52);
1497                 again = inkey();
1498                 prt("", 16, 37);
1499                 prt("", 17, 37);
1500                 prt("", 18, 37);
1501                 if (wager > player_ptr->au)
1502                 {
1503                         msg_print(_("おい!金が足りないじゃないか!ここから出て行け!",
1504                                 "Hey! You don't have the gold - get out of here!"));
1505                         msg_print(NULL);
1506
1507                         /* Get out here */
1508                         break;
1509                 }
1510         } while ((again == 'y') || (again == 'Y'));
1511
1512         prt("", 18, 37);
1513         if (player_ptr->au >= oldgold)
1514         {
1515                 msg_print(_("「今回は儲けたな!でも次はこっちが勝ってやるからな、絶対に!」",
1516                         "You came out a winner! We'll win next time, I'm sure."));
1517                 chg_virtue(player_ptr, V_CHANCE, 3);
1518         }
1519         else
1520         {
1521                 msg_print(_("「金をスッてしまったな、わはは!うちに帰った方がいいぜ。」", "You lost gold! Haha, better head home."));
1522                 chg_virtue(player_ptr, V_CHANCE, -3);
1523         }
1524
1525         msg_print(NULL);
1526         screen_load();
1527         return TRUE;
1528 }
1529
1530
1531 /*!
1532  * @brief モンスター闘技場に参加するモンスターを更新する。
1533  * @param player_ptr プレーヤーへの参照ポインタ
1534  * @return なし
1535  */
1536 void update_gambling_monsters(player_type *player_ptr)
1537 {
1538         int total, i;
1539         int max_dl = 0;
1540         int mon_level;
1541         int power[4];
1542         bool tekitou;
1543         bool old_inside_battle = player_ptr->phase_out;
1544
1545         for (i = 0; i < current_world_ptr->max_d_idx; i++)
1546         {
1547                 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
1548         }
1549
1550         mon_level = randint1(MIN(max_dl, 122)) + 5;
1551         if (randint0(100) < 60)
1552         {
1553                 i = randint1(MIN(max_dl, 122)) + 5;
1554                 mon_level = MAX(i, mon_level);
1555         }
1556
1557         if (randint0(100) < 30)
1558         {
1559                 i = randint1(MIN(max_dl, 122)) + 5;
1560                 mon_level = MAX(i, mon_level);
1561         }
1562
1563         while (TRUE)
1564         {
1565                 total = 0;
1566                 tekitou = FALSE;
1567                 for (i = 0; i < 4; i++)
1568                 {
1569                         MONRACE_IDX r_idx;
1570                         int j;
1571                         while (TRUE)
1572                         {
1573                                 get_mon_num_prep(player_ptr, monster_can_entry_arena, NULL);
1574                                 player_ptr->phase_out = TRUE;
1575                                 r_idx = get_mon_num(player_ptr, mon_level);
1576                                 player_ptr->phase_out = old_inside_battle;
1577                                 if (!r_idx) continue;
1578
1579                                 if ((r_info[r_idx].flags1 & RF1_UNIQUE) || (r_info[r_idx].flags7 & RF7_UNIQUE2))
1580                                 {
1581                                         if ((r_info[r_idx].level + 10) > mon_level) continue;
1582                                 }
1583
1584                                 for (j = 0; j < i; j++)
1585                                         if (r_idx == battle_mon[j]) break;
1586                                 if (j < i) continue;
1587
1588                                 break;
1589                         }
1590                         battle_mon[i] = r_idx;
1591                         if (r_info[r_idx].level < 45) tekitou = TRUE;
1592                 }
1593
1594                 for (i = 0; i < 4; i++)
1595                 {
1596                         monster_race *r_ptr = &r_info[battle_mon[i]];
1597                         int num_taisei = count_bits(r_ptr->flagsr & (RFR_IM_ACID | RFR_IM_ELEC | RFR_IM_FIRE | RFR_IM_COLD | RFR_IM_POIS));
1598
1599                         if (r_ptr->flags1 & RF1_FORCE_MAXHP)
1600                                 power[i] = r_ptr->hdice * r_ptr->hside * 2;
1601                         else
1602                                 power[i] = r_ptr->hdice * (r_ptr->hside + 1);
1603                         power[i] = power[i] * (100 + r_ptr->level) / 100;
1604                         if (r_ptr->speed > 110)
1605                                 power[i] = power[i] * (r_ptr->speed * 2 - 110) / 100;
1606                         if (r_ptr->speed < 110)
1607                                 power[i] = power[i] * (r_ptr->speed - 20) / 100;
1608                         if (num_taisei > 2)
1609                                 power[i] = power[i] * (num_taisei * 2 + 5) / 10;
1610                         else if (r_ptr->a_ability_flags2 & RF6_INVULNER)
1611                                 power[i] = power[i] * 4 / 3;
1612                         else if (r_ptr->a_ability_flags2 & RF6_HEAL)
1613                                 power[i] = power[i] * 4 / 3;
1614                         else if (r_ptr->a_ability_flags1 & RF5_DRAIN_MANA)
1615                                 power[i] = power[i] * 11 / 10;
1616                         if (r_ptr->flags1 & RF1_RAND_25)
1617                                 power[i] = power[i] * 9 / 10;
1618                         if (r_ptr->flags1 & RF1_RAND_50)
1619                                 power[i] = power[i] * 9 / 10;
1620                         if (r_ptr->flagsr & RFR_RES_ALL) power[i] *= 100000;
1621                         if (r_ptr->arena_ratio) power[i] = power[i] * r_ptr->arena_ratio / 100;
1622                         total += power[i];
1623                 }
1624
1625                 for (i = 0; i < 4; i++)
1626                 {
1627                         if (power[i] <= 0) break;
1628                         power[i] = total * 60 / power[i];
1629                         if (tekitou && ((power[i] < 160) || power[i] > 1500)) break;
1630                         if ((power[i] < 160) && randint0(20)) break;
1631                         if (power[i] < 101) power[i] = 100 + randint1(5);
1632                         mon_odds[i] = power[i];
1633                 }
1634
1635                 if (i == 4) break;
1636         }
1637 }
1638
1639
1640 /*!
1641  * @brief モンスター闘技場のメインルーチン
1642  * @param player_ptr プレーヤーへの参照ポインタ
1643  * @return 賭けを開始したか否か
1644  */
1645 static bool kakutoujou(player_type *player_ptr)
1646 {
1647         PRICE maxbet;
1648         PRICE wager;
1649         char out_val[160], tmp_str[80];
1650         concptr p;
1651
1652         if ((current_world_ptr->game_turn - current_world_ptr->arena_start_turn) > TURNS_PER_TICK * 250)
1653         {
1654                 update_gambling_monsters(player_ptr);
1655                 current_world_ptr->arena_start_turn = current_world_ptr->game_turn;
1656         }
1657
1658         screen_save();
1659
1660         /* No money */
1661         if (player_ptr->au <= 1)
1662         {
1663                 msg_print(_("おい!おまえ一文なしじゃないか!こっから出ていけ!", "Hey! You don't have gold - get out of here!"));
1664                 msg_print(NULL);
1665                 screen_load();
1666                 return FALSE;
1667         }
1668
1669         clear_bldg(4, 10);
1670
1671         prt(_("モンスター                                                     倍率",
1672                 "Monsters                                                       Odds"), 4, 4);
1673         for (int i = 0; i < 4; i++)
1674         {
1675                 char buf[80];
1676                 monster_race *r_ptr = &r_info[battle_mon[i]];
1677
1678                 sprintf(buf, _("%d) %-58s  %4ld.%02ld倍", "%d) %-58s  %4ld.%02ld"), i + 1,
1679                         _(format("%s%s", r_name + r_ptr->name, (r_ptr->flags1 & RF1_UNIQUE) ? "もどき" : "      "),
1680                                 format("%s%s", (r_ptr->flags1 & RF1_UNIQUE) ? "Fake " : "", r_name + r_ptr->name)),
1681                                 (long int)mon_odds[i] / 100, (long int)mon_odds[i] % 100);
1682                 prt(buf, 5 + i, 1);
1683         }
1684
1685         prt(_("どれに賭けますか:", "Which monster: "), 0, 0);
1686         while (TRUE)
1687         {
1688                 int i = inkey();
1689
1690                 if (i == ESCAPE)
1691                 {
1692                         screen_load();
1693                         return FALSE;
1694                 }
1695
1696                 if (i >= '1' && i <= '4')
1697                 {
1698                         sel_monster = i - '1';
1699                         battle_odds = mon_odds[sel_monster];
1700                         break;
1701                 }
1702
1703                 else bell();
1704         }
1705
1706         clear_bldg(4, 4);
1707         for (int i = 0; i < 4; i++)
1708                 if (i != sel_monster) clear_bldg(i + 5, i + 5);
1709
1710         maxbet = player_ptr->lev * 200;
1711
1712         /* We can't bet more than we have */
1713         maxbet = MIN(maxbet, player_ptr->au);
1714
1715         /* Get the wager */
1716         strcpy(out_val, "");
1717         sprintf(tmp_str, _("賭け金 (1-%ld)?", "Your wager (1-%ld) ? "), (long int)maxbet);
1718
1719         /*
1720          * Use get_string() because we may need more than
1721          * the s16b value returned by get_quantity().
1722          */
1723         if (!get_string(tmp_str, out_val, 32))
1724         {
1725                 screen_load();
1726                 return FALSE;
1727         }
1728
1729         for (p = out_val; *p == ' '; p++);
1730
1731         wager = atol(p);
1732         if (wager > player_ptr->au)
1733         {
1734                 msg_print(_("おい!金が足りないじゃないか!出ていけ!", "Hey! You don't have the gold - get out of here!"));
1735
1736                 msg_print(NULL);
1737                 screen_load();
1738                 return FALSE;
1739         }
1740         else if (wager > maxbet)
1741         {
1742                 msg_format(_("%ldゴールドだけ受けよう。残りは取っときな。", "I'll take %ld gold of that. Keep the rest."), (long int)maxbet);
1743
1744                 wager = maxbet;
1745         }
1746         else if (wager < 1)
1747         {
1748                 msg_print(_("OK、1ゴールドでいこう。", "Ok, we'll start with 1 gold."));
1749                 wager = 1;
1750         }
1751
1752         msg_print(NULL);
1753         battle_odds = MAX(wager + 1, wager * battle_odds / 100);
1754         kakekin = wager;
1755         player_ptr->au -= wager;
1756         reset_tim_flags(player_ptr);
1757
1758         prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS);
1759
1760         player_ptr->phase_out = TRUE;
1761         player_ptr->leaving = TRUE;
1762         player_ptr->leave_bldg = TRUE;
1763
1764         screen_load();
1765         return TRUE;
1766 }
1767
1768
1769 /*!
1770  * @brief 本日の賞金首情報を表示する。
1771  * @param player_ptr プレーヤーへの参照ポインタ
1772  * @return なし
1773  */
1774 static void today_target(player_type *player_ptr)
1775 {
1776         char buf[160];
1777         monster_race *r_ptr = &r_info[today_mon];
1778
1779         clear_bldg(4, 18);
1780         c_put_str(TERM_YELLOW, _("本日の賞金首", "Wanted monster that changes from day to day"), 5, 10);
1781         sprintf(buf, _("ターゲット: %s", "target: %s"), r_name + r_ptr->name);
1782         c_put_str(TERM_YELLOW, buf, 6, 10);
1783         sprintf(buf, _("死体 ---- $%d", "corpse   ---- $%d"), (int)r_ptr->level * 50 + 100);
1784         prt(buf, 8, 10);
1785         sprintf(buf, _("骨   ---- $%d", "skeleton ---- $%d"), (int)r_ptr->level * 30 + 60);
1786         prt(buf, 9, 10);
1787         player_ptr->today_mon = today_mon;
1788 }
1789
1790
1791 /*!
1792  * @brief ツチノコの賞金首情報を表示する。
1793  * @return なし
1794  */
1795 static void tsuchinoko(void)
1796 {
1797         clear_bldg(4, 18);
1798         c_put_str(TERM_YELLOW, _("一獲千金の大チャンス!!!", "Big chance for quick money!!!"), 5, 10);
1799         c_put_str(TERM_YELLOW, _("ターゲット:幻の珍獣「ツチノコ」", "target: the rarest animal 'Tsuchinoko'"), 6, 10);
1800         c_put_str(TERM_WHITE, _("生け捕り ---- $1,000,000", "catch alive ---- $1,000,000"), 8, 10);
1801         c_put_str(TERM_WHITE, _("死体     ----   $200,000", "corpse      ----   $200,000"), 9, 10);
1802         c_put_str(TERM_WHITE, _("骨       ----   $100,000", "bones       ----   $100,000"), 10, 10);
1803 }
1804
1805
1806 /*!
1807  * @brief 通常の賞金首情報を表示する。
1808  * @return なし
1809  */
1810 static void show_bounty(void)
1811 {
1812         TERM_LEN y = 0;
1813
1814         clear_bldg(4, 18);
1815         prt(_("死体を持ち帰れば報酬を差し上げます。", "Offer a prize when you bring a wanted monster's corpse"), 4, 10);
1816         c_put_str(TERM_YELLOW, _("現在の賞金首", "Wanted monsters"), 6, 10);
1817
1818         for (int i = 0; i < MAX_BOUNTY; i++)
1819         {
1820                 byte color;
1821                 concptr done_mark;
1822                 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])];
1823
1824                 if (current_world_ptr->bounty_r_idx[i] > 10000)
1825                 {
1826                         color = TERM_RED;
1827                         done_mark = _("(済)", "(done)");
1828                 }
1829                 else
1830                 {
1831                         color = TERM_WHITE;
1832                         done_mark = "";
1833                 }
1834
1835                 c_prt(color, format("%s %s", r_name + r_ptr->name, done_mark), y + 7, 10);
1836
1837                 y = (y + 1) % 10;
1838                 if (!y && (i < MAX_BOUNTY - 1))
1839                 {
1840                         prt(_("何かキーを押してください", "Hit any key."), 0, 0);
1841                         (void)inkey();
1842                         prt("", 0, 0);
1843                         clear_bldg(7, 18);
1844                 }
1845         }
1846 }
1847
1848
1849 /*!
1850  * 賞金首の報酬テーブル / List of prize object
1851  */
1852 static struct {
1853         OBJECT_TYPE_VALUE tval; /*!< ベースアイテムのメイン種別ID */
1854         OBJECT_SUBTYPE_VALUE sval; /*!< ベースアイテムのサブ種別ID */
1855 } prize_list[MAX_BOUNTY] =
1856 {
1857         {TV_POTION, SV_POTION_CURING},
1858         {TV_POTION, SV_POTION_SPEED},
1859         {TV_POTION, SV_POTION_SPEED},
1860         {TV_POTION, SV_POTION_RESISTANCE},
1861         {TV_POTION, SV_POTION_ENLIGHTENMENT},
1862
1863         {TV_POTION, SV_POTION_HEALING},
1864         {TV_POTION, SV_POTION_RESTORE_MANA},
1865         {TV_SCROLL, SV_SCROLL_STAR_DESTRUCTION},
1866         {TV_POTION, SV_POTION_STAR_ENLIGHTENMENT},
1867         {TV_SCROLL, SV_SCROLL_SUMMON_PET},
1868
1869         {TV_SCROLL, SV_SCROLL_GENOCIDE},
1870         {TV_POTION, SV_POTION_STAR_HEALING},
1871         {TV_POTION, SV_POTION_STAR_HEALING},
1872         {TV_POTION, SV_POTION_NEW_LIFE},
1873         {TV_SCROLL, SV_SCROLL_MASS_GENOCIDE},
1874
1875         {TV_POTION, SV_POTION_LIFE},
1876         {TV_POTION, SV_POTION_LIFE},
1877         {TV_POTION, SV_POTION_AUGMENTATION},
1878         {TV_POTION, SV_POTION_INVULNERABILITY},
1879         {TV_SCROLL, SV_SCROLL_ARTIFACT},
1880 };
1881
1882
1883 /*!
1884  * @brief 賞金首の引き換え処理 / Get prize
1885  * @param player_ptr プレーヤーへの参照ポインタ
1886  * @return 各種賞金首のいずれかでも換金が行われたか否か。
1887  */
1888 static bool kankin(player_type *player_ptr)
1889 {
1890         bool change = FALSE;
1891         GAME_TEXT o_name[MAX_NLEN];
1892         object_type *o_ptr;
1893
1894         for (INVENTORY_IDX i = 0; i <= INVEN_LARM; i++)
1895         {
1896                 o_ptr = &player_ptr->inventory_list[i];
1897                 if ((o_ptr->tval == TV_CAPTURE) && (o_ptr->pval == MON_TSUCHINOKO))
1898                 {
1899                         char buf[MAX_NLEN + 20];
1900                         object_desc(player_ptr, o_name, o_ptr, 0);
1901                         sprintf(buf, _("%s を換金しますか?", "Convert %s into money? "), o_name);
1902                         if (get_check(buf))
1903                         {
1904                                 msg_format(_("賞金 %ld$を手に入れた。", "You get %ldgp."), (long int)(1000000L * o_ptr->number));
1905                                 player_ptr->au += 1000000L * o_ptr->number;
1906                                 player_ptr->redraw |= (PR_GOLD);
1907                                 vary_item(player_ptr, i, -o_ptr->number);
1908                         }
1909
1910                         change = TRUE;
1911                 }
1912         }
1913
1914         for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++)
1915         {
1916                 o_ptr = &player_ptr->inventory_list[i];
1917                 if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_CORPSE) && (o_ptr->pval == MON_TSUCHINOKO))
1918                 {
1919                         char buf[MAX_NLEN + 20];
1920                         object_desc(player_ptr, o_name, o_ptr, 0);
1921                         sprintf(buf, _("%s を換金しますか?", "Convert %s into money? "), o_name);
1922                         if (get_check(buf))
1923                         {
1924                                 msg_format(_("賞金 %ld$を手に入れた。", "You get %ldgp."), (long int)(200000L * o_ptr->number));
1925                                 player_ptr->au += 200000L * o_ptr->number;
1926                                 player_ptr->redraw |= (PR_GOLD);
1927                                 vary_item(player_ptr, i, -o_ptr->number);
1928                         }
1929
1930                         change = TRUE;
1931                 }
1932         }
1933
1934         for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++)
1935         {
1936                 o_ptr = &player_ptr->inventory_list[i];
1937                 if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_SKELETON) && (o_ptr->pval == MON_TSUCHINOKO))
1938                 {
1939                         char buf[MAX_NLEN + 20];
1940                         object_desc(player_ptr, o_name, o_ptr, 0);
1941                         sprintf(buf, _("%s を換金しますか?", "Convert %s into money? "), o_name);
1942                         if (get_check(buf))
1943                         {
1944                                 msg_format(_("賞金 %ld$を手に入れた。", "You get %ldgp."), (long int)(100000L * o_ptr->number));
1945                                 player_ptr->au += 100000L * o_ptr->number;
1946                                 player_ptr->redraw |= (PR_GOLD);
1947                                 vary_item(player_ptr, i, -o_ptr->number);
1948                         }
1949                         change = TRUE;
1950                 }
1951         }
1952
1953         for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++)
1954         {
1955                 o_ptr = &player_ptr->inventory_list[i];
1956                 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)))
1957                 {
1958                         char buf[MAX_NLEN + 20];
1959                         object_desc(player_ptr, o_name, o_ptr, 0);
1960                         sprintf(buf, _("%s を換金しますか?", "Convert %s into money? "), o_name);
1961                         if (get_check(buf))
1962                         {
1963                                 msg_format(_("賞金 %ld$を手に入れた。", "You get %ldgp."), (long int)((r_info[today_mon].level * 50 + 100) * o_ptr->number));
1964                                 player_ptr->au += (r_info[today_mon].level * 50 + 100) * o_ptr->number;
1965                                 player_ptr->redraw |= (PR_GOLD);
1966                                 vary_item(player_ptr, i, -o_ptr->number);
1967                         }
1968                         change = TRUE;
1969                 }
1970         }
1971
1972         for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++)
1973         {
1974                 o_ptr = &player_ptr->inventory_list[i];
1975
1976                 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)))
1977                 {
1978                         char buf[MAX_NLEN + 20];
1979                         object_desc(player_ptr, o_name, o_ptr, 0);
1980                         sprintf(buf, _("%s を換金しますか?", "Convert %s into money? "), o_name);
1981                         if (get_check(buf))
1982                         {
1983                                 msg_format(_("賞金 %ld$を手に入れた。", "You get %ldgp."), (long int)((r_info[today_mon].level * 30 + 60) * o_ptr->number));
1984                                 player_ptr->au += (r_info[today_mon].level * 30 + 60) * o_ptr->number;
1985                                 player_ptr->redraw |= (PR_GOLD);
1986                                 vary_item(player_ptr, i, -o_ptr->number);
1987                         }
1988
1989                         change = TRUE;
1990                 }
1991         }
1992
1993         for (int j = 0; j < MAX_BOUNTY; j++)
1994         {
1995                 for (INVENTORY_IDX i = INVEN_PACK - 1; i >= 0; i--)
1996                 {
1997                         o_ptr = &player_ptr->inventory_list[i];
1998                         if ((o_ptr->tval != TV_CORPSE) || (o_ptr->pval != current_world_ptr->bounty_r_idx[j])) continue;
1999
2000                         char buf[MAX_NLEN + 20];
2001                         int num, k;
2002                         INVENTORY_IDX item_new;
2003                         object_type forge;
2004
2005                         object_desc(player_ptr, o_name, o_ptr, 0);
2006                         sprintf(buf, _("%sを渡しますか?", "Hand %s over? "), o_name);
2007                         if (!get_check(buf)) continue;
2008
2009                         vary_item(player_ptr, i, -o_ptr->number);
2010                         chg_virtue(player_ptr, V_JUSTICE, 5);
2011                         current_world_ptr->bounty_r_idx[j] += 10000;
2012
2013                         for (num = 0, k = 0; k < MAX_BOUNTY; k++)
2014                         {
2015                                 if (current_world_ptr->bounty_r_idx[k] >= 10000) num++;
2016                         }
2017
2018                         msg_format(_("これで合計 %d ポイント獲得しました。", "You earned %d point%s total."), num, (num > 1 ? "s" : ""));
2019
2020                         object_prep(&forge, lookup_kind(prize_list[num - 1].tval, prize_list[num - 1].sval));
2021                         apply_magic(player_ptr, &forge, player_ptr->current_floor_ptr->object_level, AM_NO_FIXED_ART);
2022
2023                         object_aware(player_ptr, &forge);
2024                         object_known(&forge);
2025
2026                         /*
2027                          * Hand it --- Assume there is an empty slot.
2028                          * Since a corpse is handed at first,
2029                          * there is at least one empty slot.
2030                          */
2031                         item_new = inven_carry(player_ptr, &forge);
2032                         object_desc(player_ptr, o_name, &forge, 0);
2033                         msg_format(_("%s(%c)を貰った。", "You get %s (%c). "), o_name, index_to_label(item_new));
2034
2035                         autopick_alter_item(player_ptr, item_new, FALSE);
2036                         handle_stuff(player_ptr);
2037                         change = TRUE;
2038                 }
2039         }
2040
2041         if (change) return TRUE;
2042
2043         msg_print(_("賞金を得られそうなものは持っていなかった。", "You have nothing."));
2044         msg_print(NULL);
2045         return FALSE;
2046 }
2047
2048
2049 /*!
2050  * @brief 宿屋の利用サブルーチン
2051  * @details inn commands\n
2052  * Note that resting for the night was a perfect way to avoid player\n
2053  * ghosts in the town *if* you could only make it to the inn in time (-:\n
2054  * Now that the ghosts are temporarily disabled in 2.8.X, this function\n
2055  * will not be that useful.  I will keep it in the hopes the player\n
2056  * ghost code does become a reality again. Does help to avoid filthy urchins.\n
2057  * Resting at night is also a quick way to restock stores -KMW-\n
2058  * @param cmd 宿屋の利用施設ID
2059  * @return 施設の利用が実際に行われたか否か。
2060  */
2061 static bool inn_comm(player_type *customer_ptr, int cmd)
2062 {
2063         switch (cmd)
2064         {
2065         case BACT_FOOD: /* Buy food & drink */
2066                 if (customer_ptr->food >= PY_FOOD_FULL)
2067                 {
2068                         msg_print(_("今は満腹だ。", "You are full now."));
2069                         return FALSE;
2070                 }
2071
2072                 msg_print(_("バーテンはいくらかの食べ物とビールをくれた。", "The barkeep gives you some gruel and a beer."));
2073                 (void)set_food(customer_ptr, PY_FOOD_MAX - 1);
2074                 break;
2075
2076         case BACT_REST: /* Rest for the night */
2077         {
2078                 if ((customer_ptr->poisoned) || (customer_ptr->cut))
2079                 {
2080                         msg_print(_("あなたに必要なのは部屋ではなく、治療者です。", "You need a healer, not a room."));
2081                         msg_print(NULL);
2082                         msg_print(_("すみません、でもうちで誰かに死なれちゃ困りますんで。", "Sorry, but don't want anyone dying in here."));
2083                         break;
2084                 }
2085
2086                 s32b oldturn = current_world_ptr->game_turn;
2087                 int prev_day, prev_hour, prev_min;
2088
2089                 extract_day_hour_min(customer_ptr, &prev_day, &prev_hour, &prev_min);
2090                 if ((prev_hour >= 6) && (prev_hour <= 17))
2091                         exe_write_diary(customer_ptr, DIARY_DESCRIPTION, 0, _("宿屋に泊まった。", "stay over daytime at the inn."));
2092                 else
2093                         exe_write_diary(customer_ptr, DIARY_DESCRIPTION, 0, _("宿屋に泊まった。", "stay over night at the inn."));
2094
2095                 current_world_ptr->game_turn = (current_world_ptr->game_turn / (TURNS_PER_TICK * TOWN_DAWN / 2) + 1) * (TURNS_PER_TICK * TOWN_DAWN / 2);
2096                 if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit)
2097                 {
2098                         current_world_ptr->dungeon_turn += MIN((current_world_ptr->game_turn - oldturn), TURNS_PER_TICK * 250) * INN_DUNGEON_TURN_ADJ;
2099                         if (current_world_ptr->dungeon_turn > current_world_ptr->dungeon_turn_limit) current_world_ptr->dungeon_turn = current_world_ptr->dungeon_turn_limit;
2100                 }
2101
2102                 prevent_turn_overflow(customer_ptr);
2103
2104                 if ((prev_hour >= 18) && (prev_hour <= 23)) exe_write_diary(customer_ptr, DIARY_DIALY, 0, NULL);
2105                 customer_ptr->chp = customer_ptr->mhp;
2106
2107                 if (ironman_nightmare)
2108                 {
2109                         msg_print(_("眠りに就くと恐ろしい光景が心をよぎった。", "Horrible visions flit through your mind as you sleep."));
2110
2111                         while (TRUE)
2112                         {
2113                                 sanity_blast(customer_ptr, NULL, FALSE);
2114                                 if (!one_in_(3)) break;
2115                         }
2116
2117                         msg_print(_("あなたは絶叫して目を覚ました。", "You awake screaming."));
2118                         exe_write_diary(customer_ptr, DIARY_DESCRIPTION, 0, _("悪夢にうなされてよく眠れなかった。", "be troubled by a nightmare."));
2119                         break;
2120                 }
2121
2122                 set_blind(customer_ptr, 0);
2123                 set_confused(customer_ptr, 0);
2124                 customer_ptr->stun = 0;
2125                 customer_ptr->chp = customer_ptr->mhp;
2126                 customer_ptr->csp = customer_ptr->msp;
2127                 if (customer_ptr->pclass == CLASS_MAGIC_EATER)
2128                 {
2129                         int i;
2130                         for (i = 0; i < 72; i++)
2131                         {
2132                                 customer_ptr->magic_num1[i] = customer_ptr->magic_num2[i] * EATER_CHARGE;
2133                         }
2134
2135                         for (; i < 108; i++)
2136                         {
2137                                 customer_ptr->magic_num1[i] = 0;
2138                         }
2139                 }
2140
2141                 if ((prev_hour >= 6) && (prev_hour <= 17))
2142                 {
2143                         msg_print(_("あなたはリフレッシュして目覚め、夕方を迎えた。", "You awake refreshed for the evening."));
2144                         exe_write_diary(customer_ptr, DIARY_DESCRIPTION, 0, _("夕方を迎えた。", "awake refreshed."));
2145                         break;
2146                 }
2147
2148                 msg_print(_("あなたはリフレッシュして目覚め、新たな日を迎えた。", "You awake refreshed for the new day."));
2149                 exe_write_diary(customer_ptr, DIARY_DESCRIPTION, 0, _("すがすがしい朝を迎えた。", "awake refreshed."));
2150                 break;
2151         }
2152         case BACT_RUMORS: /* Listen for rumors */
2153         {
2154                 display_rumor(customer_ptr, TRUE);
2155                 break;
2156         }
2157         }
2158
2159         return TRUE;
2160 }
2161
2162
2163 /*!
2164  * @brief クエスト情報を表示しつつ処理する。/ Display quest information
2165  * @param player_ptr プレーヤーへの参照ポインタ
2166  * @param questnum クエストのID
2167  * @param do_init クエストの開始処理(TRUE)、結果処理か(FALSE)
2168  * @return なし
2169  */
2170 static void get_questinfo(player_type *player_ptr, IDX questnum, bool do_init)
2171 {
2172         for (int i = 0; i < 10; i++)
2173         {
2174                 quest_text[i][0] = '\0';
2175         }
2176
2177         quest_text_line = 0;
2178
2179         floor_type *floor_ptr = player_ptr->current_floor_ptr;
2180         QUEST_IDX old_quest = floor_ptr->inside_quest;
2181         floor_ptr->inside_quest = questnum;
2182
2183         init_flags = INIT_SHOW_TEXT;
2184         if (do_init) init_flags |= INIT_ASSIGN;
2185
2186         process_dungeon_file(player_ptr, "q_info.txt", 0, 0, 0, 0);
2187         floor_ptr->inside_quest = old_quest;
2188
2189         GAME_TEXT tmp_str[80];
2190         sprintf(tmp_str, _("クエスト情報 (危険度: %d 階相当)", "Quest Information (Danger level: %d)"), (int)quest[questnum].level);
2191         prt(tmp_str, 5, 0);
2192         prt(quest[questnum].name, 7, 0);
2193
2194         for (int i = 0; i < 10; i++)
2195         {
2196                 c_put_str(TERM_YELLOW, quest_text[i], i + 8, 0);
2197         }
2198 }
2199
2200 /*!
2201  * @brief クエスト処理のメインルーチン / Request a quest from the Lord.
2202  * @param player_ptr プレーヤーへの参照ポインタ
2203  * @return なし
2204  */
2205 static void castle_quest(player_type *player_ptr)
2206 {
2207         clear_bldg(4, 18);
2208         QUEST_IDX q_index = player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x].special;
2209
2210         if (!q_index)
2211         {
2212                 put_str(_("今のところクエストはありません。", "I don't have a quest for you at the moment."), 8, 0);
2213                 return;
2214         }
2215
2216         quest_type *q_ptr;
2217         q_ptr = &quest[q_index];
2218         if (q_ptr->status == QUEST_STATUS_COMPLETED)
2219         {
2220                 q_ptr->status = QUEST_STATUS_REWARDED;
2221                 get_questinfo(player_ptr, q_index, FALSE);
2222                 reinit_wilderness = TRUE;
2223                 return;
2224         }
2225
2226         if (q_ptr->status == QUEST_STATUS_FAILED)
2227         {
2228                 get_questinfo(player_ptr, q_index, FALSE);
2229                 q_ptr->status = QUEST_STATUS_FAILED_DONE;
2230                 reinit_wilderness = TRUE;
2231                 return;
2232         }
2233
2234         if (q_ptr->status == QUEST_STATUS_TAKEN)
2235         {
2236                 put_str(_("あなたは現在のクエストを終了させていません!", "You have not completed your current quest yet!"), 8, 0);
2237                 put_str(_("CTRL-Qを使えばクエストの状態がチェックできます。", "Use CTRL-Q to check the status of your quest."), 9, 0);
2238                 put_str(_("クエストを終わらせたら戻って来て下さい。", "Return when you have completed your quest."), 12, 0);
2239                 return;
2240         }
2241
2242         if (q_ptr->status != QUEST_STATUS_UNTAKEN) return;
2243
2244         q_ptr->status = QUEST_STATUS_TAKEN;
2245         reinit_wilderness = TRUE;
2246         if (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL)
2247         {
2248                 get_questinfo(player_ptr, q_index, TRUE);
2249                 return;
2250         }
2251
2252         if (q_ptr->r_idx == 0)
2253         {
2254                 q_ptr->r_idx = get_mon_num(player_ptr, q_ptr->level + 4 + randint1(6));
2255         }
2256
2257         monster_race *r_ptr;
2258         r_ptr = &r_info[q_ptr->r_idx];
2259         while ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->rarity != 1))
2260         {
2261                 q_ptr->r_idx = get_mon_num(player_ptr, q_ptr->level) + 4 + randint1(6);
2262                 r_ptr = &r_info[q_ptr->r_idx];
2263         }
2264
2265         if (q_ptr->max_num == 0)
2266         {
2267                 if (randint1(10) > 7)
2268                         q_ptr->max_num = 1;
2269                 else
2270                         q_ptr->max_num = randint1(3) + 1;
2271         }
2272
2273         q_ptr->cur_num = 0;
2274         concptr name = (r_name + r_ptr->name);
2275 #ifdef JP
2276         msg_format("クエスト: %sを %d体倒す", name, q_ptr->max_num);
2277 #else
2278         msg_format("Your quest: kill %d %s", q_ptr->max_num, name);
2279 #endif
2280         get_questinfo(player_ptr, q_index, TRUE);
2281 }
2282
2283
2284 /*!
2285  * @brief 町に関するヘルプを表示する / Display town history
2286  * @param player_ptr プレーヤーへの参照ポインタ
2287  * @return なし
2288  */
2289 static void town_history(player_type *player_ptr)
2290 {
2291         screen_save();
2292         (void)show_file(player_ptr, TRUE, _("jbldg.txt", "bldg.txt"), NULL, 0, 0);
2293         screen_load();
2294 }
2295
2296
2297 /*!
2298  * @brief 攻撃時スレイによるダメージ期待値修正計算 / critical happens at i / 10000
2299  * @param dam 基本ダメージ
2300  * @param mult スレイ倍率(掛け算部分)
2301  * @param div スレイ倍率(割り算部分)
2302  * @param force 理力特別計算フラグ
2303  * @return ダメージ期待値
2304  */
2305 static HIT_POINT calc_slaydam(HIT_POINT dam, int mult, int div, bool force)
2306 {
2307         int tmp;
2308         if (force)
2309         {
2310                 tmp = dam * 60;
2311                 tmp *= mult * 3;
2312                 tmp /= div * 2;
2313                 tmp += dam * 60 * 2;
2314                 tmp /= 60;
2315                 return tmp;
2316         }
2317
2318         tmp = dam * 60;
2319         tmp *= mult;
2320         tmp /= div;
2321         tmp /= 60;
2322         return tmp;
2323 }
2324
2325
2326 /*!
2327  * @brief 攻撃時の期待値計算(スレイ→重量クリティカル→切れ味効果)
2328  * @param player_ptr プレーヤーへの参照ポインタ
2329  * @param dam 基本ダメージ
2330  * @param mult スレイ倍率(掛け算部分)
2331  * @param div スレイ倍率(割り算部分)
2332  * @param force 理力特別計算フラグ
2333  * @param weight 重量
2334  * @param plus 武器ダメージ修正
2335  * @param meichuu 命中値
2336  * @param dokubari 毒針処理か否か
2337  * @param vorpal_mult 切れ味倍率(掛け算部分)
2338  * @param vorpal_div 切れ味倍率(割り算部分)
2339  * @return ダメージ期待値
2340  */
2341 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)
2342 {
2343         dam = calc_slaydam(dam, mult, div, force);
2344         dam = calc_expect_crit(owner_ptr, weight, plus, dam, meichuu, dokubari);
2345         dam = calc_slaydam(dam, vorpal_mult, vorpal_div, FALSE);
2346         return dam;
2347 }
2348
2349
2350 /*!
2351  * @brief 武器の各条件毎のダメージ期待値を表示する。
2352  * @param r 表示行
2353  * @param c 表示列
2354  * @param mindice ダイス部分最小値
2355  * @param maxdice ダイス部分最大値
2356  * @param blows 攻撃回数
2357  * @param dam_bonus ダメージ修正値
2358  * @param attr 条件内容
2359  * @param color 条件内容の表示色
2360  * @details
2361  * Display the damage figure of an object\n
2362  * (used by compare_weapon_aux)\n
2363  * \n
2364  * Only accurate for the current weapon, because it includes\n
2365  * the current +dam of the player.\n
2366  * @return なし
2367  */
2368 static void show_weapon_dmg(int r, int c, int mindice, int maxdice, int blows, int dam_bonus, concptr attr, byte color)
2369 {
2370         c_put_str(color, attr, r, c);
2371         GAME_TEXT tmp_str[80];
2372         int mindam = blows * (mindice + dam_bonus);
2373         int maxdam = blows * (maxdice + dam_bonus);
2374         sprintf(tmp_str, _("1ターン: %d-%d ダメージ", "Attack: %d-%d damage"), mindam, maxdam);
2375         put_str(tmp_str, r, c + 8);
2376 }
2377
2378
2379 /*!
2380  * @brief 武器一つ毎のダメージ情報を表示する。
2381  * @param o_ptr オブジェクトの構造体の参照ポインタ。
2382  * @param col 表示する行の上端
2383  * @param r 表示する列の左端
2384  * @details
2385  * Show the damage figures for the various monster types\n
2386  * \n
2387  * Only accurate for the current weapon, because it includes\n
2388  * the current number of blows for the player.\n
2389  * @return なし
2390  */
2391 static void compare_weapon_aux(player_type *owner_ptr, object_type *o_ptr, int col, int r)
2392 {
2393         BIT_FLAGS flgs[TR_FLAG_SIZE];
2394         int blow = owner_ptr->num_blow[0];
2395         bool force = FALSE;
2396         bool dokubari = FALSE;
2397
2398         int eff_dd = o_ptr->dd + owner_ptr->to_dd[0];
2399         int eff_ds = o_ptr->ds + owner_ptr->to_ds[0];
2400
2401         int mindice = eff_dd;
2402         int maxdice = eff_ds * eff_dd;
2403         int mindam = 0;
2404         int maxdam = 0;
2405         int vorpal_mult = 1;
2406         int vorpal_div = 1;
2407         int dmg_bonus = o_ptr->to_d + owner_ptr->to_d[0];
2408
2409         object_flags(o_ptr, flgs);
2410         if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) dokubari = TRUE;
2411
2412         mindam = calc_expect_crit(owner_ptr, o_ptr->weight, o_ptr->to_h, mindice, owner_ptr->to_h[0], dokubari);
2413         maxdam = calc_expect_crit(owner_ptr, o_ptr->weight, o_ptr->to_h, maxdice, owner_ptr->to_h[0], dokubari);
2414         show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("会心:", "Critical:"), TERM_L_RED);
2415         if ((have_flag(flgs, TR_VORPAL) || hex_spelling(owner_ptr, HEX_RUNESWORD)))
2416         {
2417                 if ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD))
2418                 {
2419                         vorpal_mult = 5;
2420                         vorpal_div = 3;
2421                 }
2422                 else
2423                 {
2424                         vorpal_mult = 11;
2425                         vorpal_div = 9;
2426                 }
2427
2428                 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);
2429                 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);
2430                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("切れ味:", "Vorpal:"), TERM_L_RED);
2431         }
2432
2433         if ((owner_ptr->pclass != CLASS_SAMURAI) && have_flag(flgs, TR_FORCE_WEAPON) && (owner_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
2434         {
2435                 force = TRUE;
2436
2437                 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);
2438                 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);
2439                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("理力:", "Force  :"), TERM_L_BLUE);
2440         }
2441
2442         if (have_flag(flgs, TR_KILL_ANIMAL))
2443         {
2444                 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);
2445                 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);
2446                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("動物:", "Animals:"), TERM_YELLOW);
2447         }
2448         else if (have_flag(flgs, TR_SLAY_ANIMAL))
2449         {
2450                 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);
2451                 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);
2452                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("動物:", "Animals:"), TERM_YELLOW);
2453         }
2454
2455         if (have_flag(flgs, TR_KILL_EVIL))
2456         {
2457                 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);
2458                 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);
2459                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("邪悪:", "Evil:"), TERM_YELLOW);
2460         }
2461         else if (have_flag(flgs, TR_SLAY_EVIL))
2462         {
2463                 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);
2464                 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);
2465                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("邪悪:", "Evil:"), TERM_YELLOW);
2466         }
2467
2468         if (have_flag(flgs, TR_KILL_HUMAN))
2469         {
2470                 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);
2471                 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);
2472                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("人間:", "Human:"), TERM_YELLOW);
2473         }
2474         else if (have_flag(flgs, TR_SLAY_HUMAN))
2475         {
2476                 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);
2477                 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);
2478                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("人間:", "Human:"), TERM_YELLOW);
2479         }
2480
2481         if (have_flag(flgs, TR_KILL_UNDEAD))
2482         {
2483                 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);
2484                 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);
2485                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("不死:", "Undead:"), TERM_YELLOW);
2486         }
2487         else if (have_flag(flgs, TR_SLAY_UNDEAD))
2488         {
2489                 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);
2490                 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);
2491                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("不死:", "Undead:"), TERM_YELLOW);
2492         }
2493
2494         if (have_flag(flgs, TR_KILL_DEMON))
2495         {
2496                 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);
2497                 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);
2498                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("悪魔:", "Demons:"), TERM_YELLOW);
2499         }
2500         else if (have_flag(flgs, TR_SLAY_DEMON))
2501         {
2502                 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);
2503                 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);
2504                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("悪魔:", "Demons:"), TERM_YELLOW);
2505         }
2506
2507         if (have_flag(flgs, TR_KILL_ORC))
2508         {
2509                 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);
2510                 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);
2511                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("オーク:", "Orcs:"), TERM_YELLOW);
2512         }
2513         else if (have_flag(flgs, TR_SLAY_ORC))
2514         {
2515                 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);
2516                 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);
2517                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("オーク:", "Orcs:"), TERM_YELLOW);
2518         }
2519
2520         if (have_flag(flgs, TR_KILL_TROLL))
2521         {
2522                 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);
2523                 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);
2524                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("トロル:", "Trolls:"), TERM_YELLOW);
2525         }
2526         else if (have_flag(flgs, TR_SLAY_TROLL))
2527         {
2528                 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);
2529                 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);
2530                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("トロル:", "Trolls:"), TERM_YELLOW);
2531         }
2532
2533         if (have_flag(flgs, TR_KILL_GIANT))
2534         {
2535                 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);
2536                 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);
2537                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("巨人:", "Giants:"), TERM_YELLOW);
2538         }
2539         else if (have_flag(flgs, TR_SLAY_GIANT))
2540         {
2541                 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);
2542                 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);
2543                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("巨人:", "Giants:"), TERM_YELLOW);
2544         }
2545
2546         if (have_flag(flgs, TR_KILL_DRAGON))
2547         {
2548                 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);
2549                 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);
2550                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("竜:", "Dragons:"), TERM_YELLOW);
2551         }
2552         else if (have_flag(flgs, TR_SLAY_DRAGON))
2553         {
2554                 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);
2555                 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);
2556                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("竜:", "Dragons:"), TERM_YELLOW);
2557         }
2558
2559         if (have_flag(flgs, TR_BRAND_ACID))
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, _("酸属性:", "Acid:"), TERM_RED);
2564         }
2565
2566         if (have_flag(flgs, TR_BRAND_ELEC))
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, _("電属性:", "Elec:"), TERM_RED);
2571         }
2572
2573         if (have_flag(flgs, TR_BRAND_FIRE))
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, _("炎属性:", "Fire:"), TERM_RED);
2578         }
2579
2580         if (have_flag(flgs, TR_BRAND_COLD))
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, _("冷属性:", "Cold:"), TERM_RED);
2585         }
2586
2587         if (have_flag(flgs, TR_BRAND_POIS))
2588         {
2589                 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);
2590                 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);
2591                 show_weapon_dmg(r++, col, mindam, maxdam, blow, dmg_bonus, _("毒属性:", "Poison:"), TERM_RED);
2592         }
2593 }
2594
2595
2596 /*!
2597  * @brief 武器匠における武器一つ毎の完全情報を表示する。
2598  * @param player_type プレーヤーへの参照ポインタ
2599  * @param o_ptr オブジェクトの構造体の参照ポインタ。
2600  * @param row 表示する列の左端
2601  * @param col 表示する行の上端
2602  * @details
2603  * Displays all info about a weapon
2604  *
2605  * Only accurate for the current weapon, because it includes
2606  * various info about the player's +to_dam and number of blows.
2607  * @return なし
2608  */
2609 static void list_weapon(player_type *player_ptr, object_type *o_ptr, TERM_LEN row, TERM_LEN col)
2610 {
2611         GAME_TEXT o_name[MAX_NLEN];
2612         GAME_TEXT tmp_str[80];
2613
2614         DICE_NUMBER eff_dd = o_ptr->dd + player_ptr->to_dd[0];
2615         DICE_SID eff_ds = o_ptr->ds + player_ptr->to_ds[0];
2616         HIT_RELIABILITY reli = player_ptr->skill_thn + (player_ptr->to_h[0] + o_ptr->to_h) * BTH_PLUS_ADJ;
2617
2618         object_desc(player_ptr, o_name, o_ptr, OD_NAME_ONLY);
2619         c_put_str(TERM_YELLOW, o_name, row, col);
2620         sprintf(tmp_str, _("攻撃回数: %d", "Number of Blows: %d"), player_ptr->num_blow[0]);
2621         put_str(tmp_str, row + 1, col);
2622
2623         sprintf(tmp_str, _("命中率:  0  50 100 150 200 (敵のAC)", "To Hit:  0  50 100 150 200 (AC)"));
2624         put_str(tmp_str, row + 2, col);
2625         sprintf(tmp_str, "        %2d  %2d  %2d  %2d  %2d (%%)",
2626                 (int)hit_chance(player_ptr, reli, 0),
2627                 (int)hit_chance(player_ptr, reli, 50),
2628                 (int)hit_chance(player_ptr, reli, 100),
2629                 (int)hit_chance(player_ptr, reli, 150),
2630                 (int)hit_chance(player_ptr, reli, 200));
2631         put_str(tmp_str, row + 3, col);
2632         c_put_str(TERM_YELLOW, _("可能なダメージ:", "Possible Damage:"), row + 5, col);
2633
2634         sprintf(tmp_str, _("攻撃一回につき %d-%d", "One Strike: %d-%d damage"),
2635                 (int)(eff_dd + o_ptr->to_d + player_ptr->to_d[0]),
2636                 (int)(eff_ds * eff_dd + o_ptr->to_d + player_ptr->to_d[0]));
2637         put_str(tmp_str, row + 6, col + 1);
2638
2639         sprintf(tmp_str, _("1ターンにつき %d-%d", "One Attack: %d-%d damage"),
2640                 (int)(player_ptr->num_blow[0] * (eff_dd + o_ptr->to_d + player_ptr->to_d[0])),
2641                 (int)(player_ptr->num_blow[0] * (eff_ds * eff_dd + o_ptr->to_d + player_ptr->to_d[0])));
2642         put_str(tmp_str, row + 7, col + 1);
2643 }
2644
2645
2646 /*!
2647  * @brief 武器匠鑑定1回分(オブジェクト2種)の処理。/ Compare weapons
2648  * @details
2649  * Copies the weapons to compare into the weapon-slot and\n
2650  * compares the values for both weapons.\n
2651  * 武器1つだけで比較をしないなら費用は半額になる。
2652  * @param bcost 基本鑑定費用
2653  * @return 最終的にかかった費用
2654  */
2655 static PRICE compare_weapons(player_type *customer_ptr, PRICE bcost)
2656 {
2657         object_type *o_ptr[2];
2658         object_type orig_weapon;
2659         object_type *i_ptr;
2660         TERM_LEN row = 2;
2661         TERM_LEN wid = 38, mgn = 2;
2662         bool old_character_xtra = current_world_ptr->character_xtra;
2663         char ch;
2664         PRICE total = 0;
2665         PRICE cost = 0; /* First time no price */
2666
2667         screen_save();
2668         clear_bldg(0, 22);
2669         i_ptr = &customer_ptr->inventory_list[INVEN_RARM];
2670         object_copy(&orig_weapon, i_ptr);
2671
2672         item_tester_hook = item_tester_hook_orthodox_melee_weapons;
2673         concptr q = _("第一の武器は?", "What is your first weapon? ");
2674         concptr s = _("比べるものがありません。", "You have nothing to compare.");
2675
2676         OBJECT_IDX item;
2677         o_ptr[0] = choose_object(customer_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT), 0);
2678         if (!o_ptr[0])
2679         {
2680                 screen_load();
2681                 return 0;
2682         }
2683
2684         int n = 1;
2685         total = bcost;
2686
2687         while (TRUE)
2688         {
2689                 clear_bldg(0, 22);
2690                 item_tester_hook = item_tester_hook_orthodox_melee_weapons;
2691                 current_world_ptr->character_xtra = TRUE;
2692                 for (int i = 0; i < n; i++)
2693                 {
2694                         int col = (wid * i + mgn);
2695                         if (o_ptr[i] != i_ptr) object_copy(i_ptr, o_ptr[i]);
2696
2697                         customer_ptr->update |= PU_BONUS;
2698                         handle_stuff(customer_ptr);
2699
2700                         list_weapon(customer_ptr, o_ptr[i], row, col);
2701                         compare_weapon_aux(customer_ptr, o_ptr[i], col, row + 8);
2702                         object_copy(i_ptr, &orig_weapon);
2703                 }
2704
2705                 customer_ptr->update |= PU_BONUS;
2706                 handle_stuff(customer_ptr);
2707
2708                 current_world_ptr->character_xtra = old_character_xtra;
2709 #ifdef JP
2710                 put_str(format("[ 比較対象: 's'で変更 ($%d) ]", cost), 1, (wid + mgn));
2711                 put_str("(一番高いダメージが適用されます。複数の倍打効果は足し算されません。)", row + 4, 0);
2712                 prt("現在の技量から判断すると、あなたの武器は以下のような威力を発揮します:", 0, 0);
2713 #else
2714                 put_str(format("[ 's' Select secondary weapon($%d) ]", cost), 1, (wid + mgn));
2715                 put_str("(Only highest damage applies per monster. Special damage not cumulative.)", row + 4, 0);
2716                 prt("Based on your current abilities, here is what your weapons will do", 0, 0);
2717 #endif
2718
2719                 flush();
2720                 ch = inkey();
2721                 if (ch != 's') break;
2722
2723                 if (total + cost > customer_ptr->au)
2724                 {
2725                         msg_print(_("お金が足りません!", "You don't have enough money!"));
2726                         msg_print(NULL);
2727                         continue;
2728                 }
2729
2730                 q = _("第二の武器は?", "What is your second weapon? ");
2731                 s = _("比べるものがありません。", "You have nothing to compare.");
2732                 OBJECT_IDX item2;
2733                 o_ptr[1] = choose_object(customer_ptr, &item2, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT), 0);
2734                 if (!o_ptr[1]) continue;
2735
2736                 total += cost;
2737                 cost = bcost / 2;
2738                 n = 2;
2739         }
2740
2741         screen_load();
2742         return total;
2743 }
2744
2745
2746 /*!
2747  * @brief ACから回避率、ダメージ減少率を計算し表示する。 / Evaluate AC
2748  * @details
2749  * Calculate and display the dodge-rate and the protection-rate
2750  * based on AC
2751  * @param iAC プレイヤーのAC。
2752  * @return 常にTRUEを返す。
2753  */
2754 static bool eval_ac(ARMOUR_CLASS iAC)
2755 {
2756 #ifdef JP
2757         const char memo[] =
2758                 "ダメージ軽減率とは、敵の攻撃が当たった時そのダメージを\n"
2759                 "何パーセント軽減するかを示します。\n"
2760                 "ダメージ軽減は通常の直接攻撃(種類が「攻撃する」と「粉砕する」の物)\n"
2761                 "に対してのみ効果があります。\n \n"
2762                 "敵のレベルとは、その敵が通常何階に現れるかを示します。\n \n"
2763                 "回避率は敵の直接攻撃を何パーセントの確率で避けるかを示し、\n"
2764                 "敵のレベルとあなたのACによって決定されます。\n \n"
2765                 "ダメージ期待値とは、敵の100ポイントの通常攻撃に対し、\n"
2766                 "回避率とダメージ軽減率を考慮したダメージの期待値を示します。\n";
2767 #else
2768         const char memo[] =
2769                 "'Protection Rate' means how much damage is reduced by your armor.\n"
2770                 "Note that the Protection rate is effective only against normal "
2771                 "'attack' and 'shatter' type melee attacks, "
2772                 "and has no effect against any other types such as 'poison'.\n \n"
2773                 "'Dodge Rate' indicates the success rate on dodging the "
2774                 "monster's melee attacks.  "
2775                 "It is depend on the level of the monster and your AC.\n \n"
2776                 "'Average Damage' indicates the expected amount of damage "
2777                 "when you are attacked by normal melee attacks with power=100.";
2778 #endif
2779
2780         int protection;
2781         TERM_LEN col, row = 2;
2782         DEPTH lvl;
2783         char buf[80 * 20], *t;
2784
2785         if (iAC < 0) iAC = 0;
2786
2787         protection = 100 * MIN(iAC, 150) / 250;
2788         screen_save();
2789         clear_bldg(0, 22);
2790
2791         put_str(format(_("あなたの現在のAC: %3d", "Your current AC : %3d"), iAC), row++, 0);
2792         put_str(format(_("ダメージ軽減率  : %3d%%", "Protection rate : %3d%%"), protection), row++, 0);
2793         row++;
2794
2795         put_str(_("敵のレベル      :", "Level of Monster:"), row + 0, 0);
2796         put_str(_("回避率          :", "Dodge Rate      :"), row + 1, 0);
2797         put_str(_("ダメージ期待値  :", "Average Damage  :"), row + 2, 0);
2798
2799         for (col = 17 + 1, lvl = 0; lvl <= 100; lvl += 10, col += 5)
2800         {
2801                 int quality = 60 + lvl * 3; /* attack quality with power 60 */
2802                 int dodge;   /* 回避率(%) */
2803                 int average; /* ダメージ期待値 */
2804
2805                 put_str(format("%3d", lvl), row + 0, col);
2806
2807                 /* 回避率を計算 */
2808                 dodge = 5 + (MIN(100, 100 * (iAC * 3 / 4) / quality) * 9 + 5) / 10;
2809                 put_str(format("%3d%%", dodge), row + 1, col);
2810
2811                 /* 100点の攻撃に対してのダメージ期待値を計算 */
2812                 average = (100 - dodge) * (100 - protection) / 100;
2813                 put_str(format("%3d", average), row + 2, col);
2814         }
2815
2816         roff_to_buf(memo, 70, buf, sizeof(buf));
2817         for (t = buf; t[0]; t += strlen(t) + 1)
2818                 put_str(t, (row++) + 4, 4);
2819
2820         prt(_("現在のあなたの装備からすると、あなたの防御力はこれくらいです:", "Defense abilities from your current Armor Class are evaluated below."), 0, 0);
2821
2822         flush();
2823         (void)inkey();
2824         screen_load();
2825
2826         return TRUE;
2827 }
2828
2829
2830 /*!
2831  * @brief 修復材料のオブジェクトから修復対象に特性を移植する。
2832  * @param to_ptr 修復対象オブジェクトの構造体の参照ポインタ。
2833  * @param from_ptr 修復材料オブジェクトの構造体の参照ポインタ。
2834  * @return 修復対象になるならTRUEを返す。
2835  */
2836 static void give_one_ability_of_object(object_type *to_ptr, object_type *from_ptr)
2837 {
2838         BIT_FLAGS to_flgs[TR_FLAG_SIZE];
2839         BIT_FLAGS from_flgs[TR_FLAG_SIZE];
2840         object_flags(to_ptr, to_flgs);
2841         object_flags(from_ptr, from_flgs);
2842
2843         int n = 0;
2844         int cand[TR_FLAG_MAX];
2845         for (int i = 0; i < TR_FLAG_MAX; i++)
2846         {
2847                 switch (i)
2848                 {
2849                 case TR_IGNORE_ACID:
2850                 case TR_IGNORE_ELEC:
2851                 case TR_IGNORE_FIRE:
2852                 case TR_IGNORE_COLD:
2853                 case TR_ACTIVATE:
2854                 case TR_RIDING:
2855                 case TR_THROW:
2856                 case TR_SHOW_MODS:
2857                 case TR_HIDE_TYPE:
2858                 case TR_ES_ATTACK:
2859                 case TR_ES_AC:
2860                 case TR_FULL_NAME:
2861                 case TR_FIXED_FLAVOR:
2862                         break;
2863                 default:
2864                         if (have_flag(from_flgs, i) && !have_flag(to_flgs, i))
2865                         {
2866                                 if (!(is_pval_flag(i) && (from_ptr->pval < 1))) cand[n++] = i;
2867                         }
2868                 }
2869         }
2870
2871         if (n <= 0) return;
2872
2873         int tr_idx = cand[randint0(n)];
2874         add_flag(to_ptr->art_flags, tr_idx);
2875         if (is_pval_flag(tr_idx)) to_ptr->pval = MAX(to_ptr->pval, 1);
2876         int bmax = MIN(3, MAX(1, 40 / (to_ptr->dd * to_ptr->ds)));
2877         if (tr_idx == TR_BLOWS) to_ptr->pval = MIN(to_ptr->pval, bmax);
2878         if (tr_idx == TR_SPEED) to_ptr->pval = MIN(to_ptr->pval, 4);
2879 }
2880
2881
2882 /*!
2883  * @brief アイテム修復処理のメインルーチン / Repair broken weapon
2884  * @param player_ptr プレーヤーへの参照ポインタ
2885  * @param bcost 基本修復費用
2886  * @return 実際にかかった費用
2887  */
2888 static PRICE repair_broken_weapon_aux(player_type *player_ptr, PRICE bcost)
2889 {
2890         clear_bldg(0, 22);
2891         int row = 7;
2892         prt(_("修復には材料となるもう1つの武器が必要です。", "Hand one material weapon to repair a broken weapon."), row, 2);
2893         prt(_("材料に使用した武器はなくなります!", "The material weapon will disappear after repairing!!"), row + 1, 2);
2894
2895         concptr q = _("どの折れた武器を修復しますか?", "Repair which broken weapon? ");
2896         concptr s = _("修復できる折れた武器がありません。", "You have no broken weapon to repair.");
2897         item_tester_hook = item_tester_hook_broken_weapon;
2898
2899         OBJECT_IDX item;
2900         object_type *o_ptr;
2901         o_ptr = choose_object(player_ptr, &item, q, s, (USE_INVEN | USE_EQUIP), 0);
2902         if (!o_ptr) return 0;
2903
2904         if (!object_is_ego(o_ptr) && !object_is_artifact(o_ptr))
2905         {
2906                 msg_format(_("それは直してもしょうがないぜ。", "It is worthless to repair."));
2907                 return 0;
2908         }
2909
2910         if (o_ptr->number > 1)
2911         {
2912                 msg_format(_("一度に複数を修復することはできません!", "They are too many to repair at once!"));
2913                 return 0;
2914         }
2915
2916         char basenm[MAX_NLEN];
2917         object_desc(player_ptr, basenm, o_ptr, OD_NAME_ONLY);
2918         prt(format(_("修復する武器 : %s", "Repairing: %s"), basenm), row + 3, 2);
2919
2920         q = _("材料となる武器は?", "Which weapon for material? ");
2921         s = _("材料となる武器がありません。", "You have no material to repair.");
2922
2923         item_tester_hook = item_tester_hook_orthodox_melee_weapons;
2924         OBJECT_IDX mater;
2925         object_type *mo_ptr;
2926         mo_ptr = choose_object(player_ptr, &mater, q, s, (USE_INVEN | USE_EQUIP), 0);
2927         if (!mo_ptr) return 0;
2928         if (mater == item)
2929         {
2930                 msg_print(_("クラインの壷じゃない!", "This is not a klein bottle!"));
2931                 return 0;
2932         }
2933
2934         object_desc(player_ptr, basenm, mo_ptr, OD_NAME_ONLY);
2935         prt(format(_("材料とする武器: %s", "Material : %s"), basenm), row + 4, 2);
2936         PRICE cost = bcost + object_value_real(o_ptr) * 2;
2937         if (!get_check(format(_("$%dかかりますがよろしいですか? ", "Costs %d gold, okay? "), cost))) return 0;
2938
2939         if (player_ptr->au < cost)
2940         {
2941                 object_desc(player_ptr, basenm, o_ptr, OD_NAME_ONLY);
2942                 msg_format(_("%sを修復するだけのゴールドがありません!", "You do not have the gold to repair %s!"), basenm);
2943                 msg_print(NULL);
2944                 return 0;
2945         }
2946
2947         player_ptr->total_weight -= o_ptr->weight;
2948         KIND_OBJECT_IDX k_idx;
2949         if (o_ptr->sval == SV_BROKEN_DAGGER)
2950         {
2951                 int n = 1;
2952                 k_idx = 0;
2953                 for (KIND_OBJECT_IDX j = 1; j < max_k_idx; j++)
2954                 {
2955                         object_kind *k_aux_ptr = &k_info[j];
2956
2957                         if (k_aux_ptr->tval != TV_SWORD) continue;
2958                         if ((k_aux_ptr->sval == SV_BROKEN_DAGGER) ||
2959                                 (k_aux_ptr->sval == SV_BROKEN_SWORD) ||
2960                                 (k_aux_ptr->sval == SV_POISON_NEEDLE)) continue;
2961                         if (k_aux_ptr->weight > 99) continue;
2962
2963                         if (one_in_(n))
2964                         {
2965                                 k_idx = j;
2966                                 n++;
2967                         }
2968                 }
2969         }
2970         else
2971         {
2972                 OBJECT_TYPE_VALUE tval = (one_in_(5) ? mo_ptr->tval : TV_SWORD);
2973                 while (TRUE)
2974                 {
2975                         object_kind *ck_ptr;
2976                         k_idx = lookup_kind(tval, SV_ANY);
2977                         ck_ptr = &k_info[k_idx];
2978
2979                         if (tval == TV_SWORD)
2980                         {
2981                                 if ((ck_ptr->sval == SV_BROKEN_DAGGER) ||
2982                                         (ck_ptr->sval == SV_BROKEN_SWORD) ||
2983                                         (ck_ptr->sval == SV_DIAMOND_EDGE) ||
2984                                         (ck_ptr->sval == SV_POISON_NEEDLE)) continue;
2985                         }
2986                         if (tval == TV_POLEARM)
2987                         {
2988                                 if ((ck_ptr->sval == SV_DEATH_SCYTHE) ||
2989                                         (ck_ptr->sval == SV_TSURIZAO)) continue;
2990                         }
2991                         if (tval == TV_HAFTED)
2992                         {
2993                                 if ((ck_ptr->sval == SV_GROND) ||
2994                                         (ck_ptr->sval == SV_WIZSTAFF) ||
2995                                         (ck_ptr->sval == SV_NAMAKE_HAMMER)) continue;
2996                         }
2997
2998                         break;
2999                 }
3000         }
3001
3002         int dd_bonus = o_ptr->dd - k_info[o_ptr->k_idx].dd;
3003         int ds_bonus = o_ptr->ds - k_info[o_ptr->k_idx].ds;
3004         dd_bonus += mo_ptr->dd - k_info[mo_ptr->k_idx].dd;
3005         ds_bonus += mo_ptr->ds - k_info[mo_ptr->k_idx].ds;
3006
3007         object_kind *k_ptr;
3008         k_ptr = &k_info[k_idx];
3009         o_ptr->k_idx = k_idx;
3010         o_ptr->weight = k_ptr->weight;
3011         o_ptr->tval = k_ptr->tval;
3012         o_ptr->sval = k_ptr->sval;
3013         o_ptr->dd = k_ptr->dd;
3014         o_ptr->ds = k_ptr->ds;
3015
3016         for (int i = 0; i < TR_FLAG_SIZE; i++) o_ptr->art_flags[i] |= k_ptr->flags[i];
3017         if (k_ptr->pval) o_ptr->pval = MAX(o_ptr->pval, randint1(k_ptr->pval));
3018         if (have_flag(k_ptr->flags, TR_ACTIVATE)) o_ptr->xtra2 = (byte)k_ptr->act_idx;
3019
3020         if (dd_bonus > 0)
3021         {
3022                 o_ptr->dd++;
3023                 for (int i = 1; i < dd_bonus; i++)
3024                 {
3025                         if (one_in_(o_ptr->dd + i)) o_ptr->dd++;
3026                 }
3027         }
3028
3029         if (ds_bonus > 0)
3030         {
3031                 o_ptr->ds++;
3032                 for (int i = 1; i < ds_bonus; i++)
3033                 {
3034                         if (one_in_(o_ptr->ds + i)) o_ptr->ds++;
3035                 }
3036         }
3037
3038         if (have_flag(k_ptr->flags, TR_BLOWS))
3039         {
3040                 int bmax = MIN(3, MAX(1, 40 / (o_ptr->dd * o_ptr->ds)));
3041                 o_ptr->pval = MIN(o_ptr->pval, bmax);
3042         }
3043
3044         give_one_ability_of_object(o_ptr, mo_ptr);
3045         o_ptr->to_d += MAX(0, (mo_ptr->to_d / 3));
3046         o_ptr->to_h += MAX(0, (mo_ptr->to_h / 3));
3047         o_ptr->to_a += MAX(0, (mo_ptr->to_a));
3048
3049         if ((o_ptr->name1 == ART_NARSIL) ||
3050                 (object_is_random_artifact(o_ptr) && one_in_(1)) ||
3051                 (object_is_ego(o_ptr) && one_in_(7)))
3052         {
3053                 if (object_is_ego(o_ptr))
3054                 {
3055                         add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
3056                         add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
3057                 }
3058
3059                 give_one_ability_of_object(o_ptr, mo_ptr);
3060                 if (!activation_index(o_ptr)) one_activation(o_ptr);
3061
3062                 if (o_ptr->name1 == ART_NARSIL)
3063                 {
3064                         one_high_resistance(o_ptr);
3065                         one_ability(o_ptr);
3066                 }
3067
3068                 msg_print(_("これはかなりの業物だったようだ。", "This blade seems to be exceptional."));
3069         }
3070
3071         object_desc(player_ptr, basenm, o_ptr, OD_NAME_ONLY);
3072 #ifdef JP
3073         msg_format("$%dで%sに修復しました。", cost, basenm);
3074 #else
3075         msg_format("Repaired into %s for %d gold.", basenm, cost);
3076 #endif
3077         msg_print(NULL);
3078         o_ptr->ident &= ~(IDENT_BROKEN);
3079         o_ptr->discount = 99;
3080
3081         player_ptr->total_weight += o_ptr->weight;
3082         calc_android_exp(player_ptr);
3083         inven_item_increase(player_ptr, mater, -1);
3084         inven_item_optimize(player_ptr, mater);
3085
3086         player_ptr->update |= PU_BONUS;
3087         handle_stuff(player_ptr);
3088         return (cost);
3089 }
3090
3091
3092 /*!
3093  * @brief アイテム修復処理の過渡ルーチン / Repair broken weapon
3094  * @param player_ptr プレーヤーへの参照ポインタ
3095  * @param bcost 基本鑑定費用
3096  * @return 実際にかかった費用
3097  */
3098 static int repair_broken_weapon(player_type *player_ptr, PRICE bcost)
3099 {
3100         PRICE cost;
3101         screen_save();
3102         cost = repair_broken_weapon_aux(player_ptr, bcost);
3103         screen_load();
3104         return cost;
3105 }
3106
3107
3108 /*!
3109  * @brief アイテムの強化を行う。 / Enchant item
3110  * @param player_ptr プレーヤーへの参照ポインタ
3111  * @param cost 1回毎の費用
3112  * @param to_hit 命中をアップさせる量
3113  * @param to_dam ダメージをアップさせる量
3114  * @param to_ac ACをアップさせる量
3115  * @return 実際に行ったらTRUE
3116  */
3117 static bool enchant_item(player_type *player_ptr, PRICE cost, HIT_PROB to_hit, HIT_POINT to_dam, ARMOUR_CLASS to_ac)
3118 {
3119         clear_bldg(4, 18);
3120         int maxenchant = (player_ptr->lev / 5);
3121         prt(format(_("現在のあなたの技量だと、+%d まで改良できます。", "  Based on your skill, we can improve up to +%d."), maxenchant), 5, 0);
3122         prt(format(_(" 改良の料金は一個につき$%d です。", "  The price for the service is %d gold per item."), cost), 7, 0);
3123
3124         concptr q = _("どのアイテムを改良しますか?", "Improve which item? ");
3125         concptr s = _("改良できるものがありません。", "You have nothing to improve.");
3126
3127         OBJECT_IDX item;
3128         object_type *o_ptr;
3129         o_ptr = choose_object(player_ptr, &item, q, s, (USE_INVEN | USE_EQUIP | IGNORE_BOTHHAND_SLOT), item_tester_tval);
3130         if (!o_ptr) return FALSE;
3131
3132         char tmp_str[MAX_NLEN];
3133         if (player_ptr->au < (cost * o_ptr->number))
3134         {
3135                 object_desc(player_ptr, tmp_str, o_ptr, OD_NAME_ONLY);
3136                 msg_format(_("%sを改良するだけのゴールドがありません!", "You do not have the gold to improve %s!"), tmp_str);
3137                 return FALSE;
3138         }
3139
3140         bool okay = FALSE;
3141         for (int i = 0; i < to_hit; i++)
3142         {
3143                 if ((o_ptr->to_h < maxenchant) && enchant(player_ptr, o_ptr, 1, (ENCH_TOHIT | ENCH_FORCE)))
3144                 {
3145                         okay = TRUE;
3146                         break;
3147                 }
3148         }
3149
3150         for (int i = 0; i < to_dam; i++)
3151         {
3152                 if ((o_ptr->to_d < maxenchant) && enchant(player_ptr, o_ptr, 1, (ENCH_TODAM | ENCH_FORCE)))
3153                 {
3154                         okay = TRUE;
3155                         break;
3156                 }
3157         }
3158
3159         for (int i = 0; i < to_ac; i++)
3160         {
3161                 if ((o_ptr->to_a < maxenchant) && enchant(player_ptr, o_ptr, 1, (ENCH_TOAC | ENCH_FORCE)))
3162                 {
3163                         okay = TRUE;
3164                         break;
3165                 }
3166         }
3167
3168         if (!okay)
3169         {
3170                 if (flush_failure) flush();
3171                 msg_print(_("改良に失敗した。", "The improvement failed."));
3172                 return FALSE;
3173         }
3174
3175         object_desc(player_ptr, tmp_str, o_ptr, OD_NAME_AND_ENCHANT);
3176 #ifdef JP
3177         msg_format("$%dで%sに改良しました。", cost * o_ptr->number, tmp_str);
3178 #else
3179         msg_format("Improved into %s for %d gold.", tmp_str, cost * o_ptr->number);
3180 #endif
3181
3182         player_ptr->au -= (cost * o_ptr->number);
3183         if (item >= INVEN_RARM) calc_android_exp(player_ptr);
3184         return TRUE;
3185 }
3186
3187
3188 /*!
3189  * @brief 魔道具の使用回数を回復させる施設のメインルーチン / Recharge rods, wands and staffs
3190  * @details
3191  * The player can select the number of charges to add\n
3192  * (up to a limit), and the recharge never fails.\n
3193  *\n
3194  * The cost for rods depends on the level of the rod. The prices\n
3195  * for recharging wands and staffs are dependent on the cost of\n
3196  * the base-item.\n
3197  * @param player_ptr プレーヤーへの参照ポインタ
3198  * @return なし
3199  */
3200 static void building_recharge(player_type *player_ptr)
3201 {
3202         msg_flag = FALSE;
3203         clear_bldg(4, 18);
3204         prt(_("  再充填の費用はアイテムの種類によります。", "  The prices of recharge depend on the type."), 6, 0);
3205         item_tester_hook = item_tester_hook_recharge;
3206
3207         concptr q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
3208         concptr s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
3209
3210         OBJECT_IDX item;
3211         object_type *o_ptr;
3212         o_ptr = choose_object(player_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
3213         if (!o_ptr) return;
3214
3215         object_kind *k_ptr;
3216         k_ptr = &k_info[o_ptr->k_idx];
3217
3218         /*
3219          * We don't want to give the player free info about
3220          * the level of the item or the number of charges.
3221          */
3222          /* The item must be "known" */
3223         char tmp_str[MAX_NLEN];
3224         if (!object_is_known(o_ptr))
3225         {
3226                 msg_format(_("充填する前に鑑定されている必要があります!", "The item must be identified first!"));
3227                 msg_print(NULL);
3228
3229                 if ((player_ptr->au >= 50) &&
3230                         get_check(_("$50で鑑定しますか? ", "Identify for 50 gold? ")))
3231
3232                 {
3233                         player_ptr->au -= 50;
3234                         identify_item(player_ptr, o_ptr);
3235                         object_desc(player_ptr, tmp_str, o_ptr, 0);
3236                         msg_format(_("%s です。", "You have: %s."), tmp_str);
3237
3238                         autopick_alter_item(player_ptr, item, FALSE);
3239                         building_prt_gold(player_ptr);
3240                 }
3241
3242                 return;
3243         }
3244
3245         DEPTH lev = k_info[o_ptr->k_idx].level;
3246         PRICE price;
3247         if (o_ptr->tval == TV_ROD)
3248         {
3249                 if (o_ptr->timeout > 0)
3250                 {
3251                         price = (lev * 50 * o_ptr->timeout) / k_ptr->pval;
3252                 }
3253                 else
3254                 {
3255                         price = 0;
3256                         msg_format(_("それは再充填する必要はありません。", "That doesn't need to be recharged."));
3257                         return;
3258                 }
3259         }
3260         else if (o_ptr->tval == TV_STAFF)
3261         {
3262                 price = (k_info[o_ptr->k_idx].cost / 10) * o_ptr->number;
3263                 price = MAX(10, price);
3264         }
3265         else
3266         {
3267                 price = (k_info[o_ptr->k_idx].cost / 10);
3268                 price = MAX(10, price);
3269         }
3270
3271         if (o_ptr->tval == TV_WAND
3272                 && (o_ptr->pval / o_ptr->number >= k_ptr->pval))
3273         {
3274                 if (o_ptr->number > 1)
3275                 {
3276                         msg_print(_("この魔法棒はもう充分に充填されています。", "These wands are already fully charged."));
3277                 }
3278                 else
3279                 {
3280                         msg_print(_("この魔法棒はもう充分に充填されています。", "This wand is already fully charged."));
3281                 }
3282
3283                 return;
3284         }
3285         else if (o_ptr->tval == TV_STAFF && o_ptr->pval >= k_ptr->pval)
3286         {
3287                 if (o_ptr->number > 1)
3288                 {
3289                         msg_print(_("この杖はもう充分に充填されています。", "These staffs are already fully charged."));
3290                 }
3291                 else
3292                 {
3293                         msg_print(_("この杖はもう充分に充填されています。", "This staff is already fully charged."));
3294                 }
3295
3296                 return;
3297         }
3298
3299         if (player_ptr->au < price)
3300         {
3301                 object_desc(player_ptr, tmp_str, o_ptr, OD_NAME_ONLY);
3302 #ifdef JP
3303                 msg_format("%sを再充填するには$%d 必要です!", tmp_str, price);
3304 #else
3305                 msg_format("You need %d gold to recharge %s!", price, tmp_str);
3306 #endif
3307                 return;
3308         }
3309
3310         PARAMETER_VALUE charges;
3311         if (o_ptr->tval == TV_ROD)
3312         {
3313 #ifdef JP
3314                 if (get_check(format("そのロッドを$%d で再充填しますか?", price)))
3315 #else
3316                 if (get_check(format("Recharge the %s for %d gold? ",
3317                         ((o_ptr->number > 1) ? "rods" : "rod"), price)))
3318 #endif
3319
3320                 {
3321                         o_ptr->timeout = 0;
3322                 }
3323                 else
3324                 {
3325                         return;
3326                 }
3327         }
3328         else
3329         {
3330                 int max_charges;
3331                 if (o_ptr->tval == TV_STAFF)
3332                         max_charges = k_ptr->pval - o_ptr->pval;
3333                 else
3334                         max_charges = o_ptr->number * k_ptr->pval - o_ptr->pval;
3335
3336                 charges = (PARAMETER_VALUE)get_quantity(format(_("一回分$%d で何回分充填しますか?", "Add how many charges for %d gold? "), price),
3337                         MIN(player_ptr->au / price, max_charges));
3338
3339                 if (charges < 1) return;
3340
3341                 price *= charges;
3342                 o_ptr->pval += charges;
3343                 o_ptr->ident &= ~(IDENT_EMPTY);
3344         }
3345
3346         object_desc(player_ptr, tmp_str, o_ptr, 0);
3347 #ifdef JP
3348         msg_format("%sを$%d で再充填しました。", tmp_str, price);
3349 #else
3350         msg_format("%^s %s recharged for %d gold.", tmp_str, ((o_ptr->number > 1) ? "were" : "was"), price);
3351 #endif
3352         player_ptr->update |= (PU_COMBINE | PU_REORDER);
3353         player_ptr->window |= (PW_INVEN);
3354         player_ptr->au -= price;
3355 }
3356
3357
3358 /*!
3359  * @brief 魔道具の使用回数を回復させる施設の一括処理向けサブルーチン / Recharge rods, wands and staffs
3360  * @details
3361  * The player can select the number of charges to add\n
3362  * (up to a limit), and the recharge never fails.\n
3363  *\n
3364  * The cost for rods depends on the level of the rod. The prices\n
3365  * for recharging wands and staffs are dependent on the cost of\n
3366  * the base-item.\n
3367  * @param player_ptr プレーヤーへの参照ポインタ
3368  * @return なし
3369  */
3370 static void building_recharge_all(player_type *player_ptr)
3371 {
3372         msg_flag = FALSE;
3373         clear_bldg(4, 18);
3374         prt(_("  再充填の費用はアイテムの種類によります。", "  The prices of recharge depend on the type."), 6, 0);
3375
3376         PRICE price = 0;
3377         PRICE total_cost = 0;
3378         for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++)
3379         {
3380                 object_type *o_ptr;
3381                 o_ptr = &player_ptr->inventory_list[i];
3382
3383                 if (o_ptr->tval < TV_STAFF || o_ptr->tval > TV_ROD) continue;
3384                 if (!object_is_known(o_ptr)) total_cost += 50;
3385
3386                 DEPTH lev = k_info[o_ptr->k_idx].level;
3387                 object_kind *k_ptr;
3388                 k_ptr = &k_info[o_ptr->k_idx];
3389
3390                 switch (o_ptr->tval)
3391                 {
3392                 case TV_ROD:
3393                         price = (lev * 50 * o_ptr->timeout) / k_ptr->pval;
3394                         break;
3395
3396                 case TV_STAFF:
3397                         price = (k_info[o_ptr->k_idx].cost / 10) * o_ptr->number;
3398                         price = MAX(10, price);
3399                         price = (k_ptr->pval - o_ptr->pval) * price;
3400                         break;
3401
3402                 case TV_WAND:
3403                         price = (k_info[o_ptr->k_idx].cost / 10);
3404                         price = MAX(10, price);
3405                         price = (o_ptr->number * k_ptr->pval - o_ptr->pval) * price;
3406                         break;
3407                 }
3408
3409                 if (price > 0) total_cost += price;
3410         }
3411
3412         if (!total_cost)
3413         {
3414                 msg_print(_("充填する必要はありません。", "No need to recharge."));
3415                 msg_print(NULL);
3416                 return;
3417         }
3418
3419         if (player_ptr->au < total_cost)
3420         {
3421                 msg_format(_("すべてのアイテムを再充填するには$%d 必要です!", "You need %d gold to recharge all items!"), total_cost);
3422                 msg_print(NULL);
3423                 return;
3424         }
3425
3426         if (!get_check(format(_("すべてのアイテムを $%d で再充填しますか?", "Recharge all items for %d gold? "), total_cost))) return;
3427
3428         for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++)
3429         {
3430                 object_type *o_ptr;
3431                 o_ptr = &player_ptr->inventory_list[i];
3432                 object_kind *k_ptr;
3433                 k_ptr = &k_info[o_ptr->k_idx];
3434
3435                 if (o_ptr->tval < TV_STAFF || o_ptr->tval > TV_ROD) continue;
3436
3437                 if (!object_is_known(o_ptr))
3438                 {
3439                         identify_item(player_ptr, o_ptr);
3440                         autopick_alter_item(player_ptr, i, FALSE);
3441                 }
3442
3443                 switch (o_ptr->tval)
3444                 {
3445                 case TV_ROD:
3446                         o_ptr->timeout = 0;
3447                         break;
3448                 case TV_STAFF:
3449                         if (o_ptr->pval < k_ptr->pval) o_ptr->pval = k_ptr->pval;
3450
3451                         o_ptr->ident &= ~(IDENT_EMPTY);
3452                         break;
3453                 case TV_WAND:
3454                         if (o_ptr->pval < o_ptr->number * k_ptr->pval)
3455                                 o_ptr->pval = o_ptr->number * k_ptr->pval;
3456
3457                         o_ptr->ident &= ~(IDENT_EMPTY);
3458                         break;
3459                 }
3460         }
3461
3462         msg_format(_("$%d で再充填しました。", "You pay %d gold."), total_cost);
3463         msg_print(NULL);
3464         player_ptr->update |= (PU_COMBINE | PU_REORDER);
3465         player_ptr->window |= (PW_INVEN);
3466         player_ptr->au -= total_cost;
3467 }
3468
3469
3470 /*!
3471  * @brief 施設でモンスターの情報を知るメインルーチン / research_mon -KMW-
3472  * @param player_ptr プレーヤーへの参照ポインタ
3473  * @return 常にTRUEを返す。
3474  * @todo 返り値が意味不明なので直した方が良いかもしれない。
3475  */
3476 static bool research_mon(player_type *player_ptr)
3477 {
3478         char buf[128];
3479         bool notpicked;
3480         bool recall = FALSE;
3481         u16b why = 0;
3482         MONSTER_IDX *who;
3483
3484         bool all = FALSE;
3485         bool uniq = FALSE;
3486         bool norm = FALSE;
3487         char temp[80] = "";
3488
3489         static int old_sym = '\0';
3490         static IDX old_i = 0;
3491         screen_save();
3492
3493         char sym;
3494         if (!get_com(_("モンスターの文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^M名前):",
3495                 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE))
3496
3497         {
3498                 screen_load();
3499                 return FALSE;
3500         }
3501
3502         IDX i;
3503         for (i = 0; ident_info[i]; ++i)
3504         {
3505                 if (sym == ident_info[i][0]) break;
3506         }
3507
3508         /* XTRA HACK WHATSEARCH */
3509         if (sym == KTRL('A'))
3510         {
3511                 all = TRUE;
3512                 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
3513         }
3514         else if (sym == KTRL('U'))
3515         {
3516                 all = uniq = TRUE;
3517                 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
3518         }
3519         else if (sym == KTRL('N'))
3520         {
3521                 all = norm = TRUE;
3522                 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
3523         }
3524         else if (sym == KTRL('M'))
3525         {
3526                 all = TRUE;
3527                 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"), temp, 70))
3528                 {
3529                         temp[0] = 0;
3530                         screen_load();
3531
3532                         return FALSE;
3533                 }
3534
3535                 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""), temp);
3536         }
3537         else if (ident_info[i])
3538         {
3539                 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
3540         }
3541         else
3542         {
3543                 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
3544         }
3545
3546         /* Display the result */
3547         prt(buf, 16, 10);
3548
3549         /* Allocate the "who" array */
3550         C_MAKE(who, max_r_idx, MONRACE_IDX);
3551
3552         /* Collect matching monsters */
3553         int n = 0;
3554         for (i = 1; i < max_r_idx; i++)
3555         {
3556                 monster_race *r_ptr = &r_info[i];
3557
3558                 /* Empty monster */
3559                 if (!r_ptr->name) continue;
3560
3561                 /* XTRA HACK WHATSEARCH */
3562                 /* Require non-unique monsters if needed */
3563                 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
3564
3565                 /* Require unique monsters if needed */
3566                 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
3567
3568                 /* 名前検索 */
3569                 if (temp[0])
3570                 {
3571                         for (int xx = 0; temp[xx] && xx < 80; xx++)
3572                         {
3573 #ifdef JP
3574                                 if (iskanji(temp[xx]))
3575                                 {
3576                                         xx++;
3577                                         continue;
3578                                 }
3579 #endif
3580                                 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
3581                         }
3582
3583                         char temp2[80];
3584 #ifdef JP
3585                         strcpy(temp2, r_name + r_ptr->E_name);
3586 #else
3587                         strcpy(temp2, r_name + r_ptr->name);
3588 #endif
3589                         for (int xx = 0; temp2[xx] && xx < 80; xx++)
3590                         {
3591                                 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
3592                         }
3593
3594 #ifdef JP
3595                         if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
3596 #else
3597                         if (my_strstr(temp2, temp))
3598 #endif
3599                                 who[n++] = i;
3600                 }
3601                 else if (all || (r_ptr->d_char == sym))
3602                 {
3603                         who[n++] = i;
3604                 }
3605         }
3606
3607         if (n == 0)
3608         {
3609                 C_KILL(who, max_r_idx, MONRACE_IDX);
3610                 screen_load();
3611
3612                 return FALSE;
3613         }
3614
3615         why = 2;
3616         char query = 'y';
3617
3618         if (why)
3619         {
3620                 ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
3621         }
3622
3623         if (old_sym == sym && old_i < n) i = old_i;
3624         else i = n - 1;
3625
3626         notpicked = TRUE;
3627         MONRACE_IDX r_idx;
3628         while (notpicked)
3629         {
3630                 r_idx = who[i];
3631                 roff_top(r_idx);
3632                 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ' 'で続行, ESC]", " [(r)ecall, ESC, space to continue]"));
3633                 while (TRUE)
3634                 {
3635                         if (recall)
3636                         {
3637                                 lore_do_probe(player_ptr, r_idx);
3638                                 monster_race_track(player_ptr, r_idx);
3639                                 handle_stuff(player_ptr);
3640                                 screen_roff(player_ptr, r_idx, 0x01);
3641                                 notpicked = FALSE;
3642                                 old_sym = sym;
3643                                 old_i = i;
3644                         }
3645
3646                         query = inkey();
3647                         if (query != 'r') break;
3648
3649                         recall = !recall;
3650                 }
3651
3652                 if (query == ESCAPE) break;
3653
3654                 if (query == '-')
3655                 {
3656                         if (++i == n)
3657                         {
3658                                 i = 0;
3659                                 if (!expand_list) break;
3660                         }
3661
3662                         continue;
3663                 }
3664
3665                 if (i-- == 0)
3666                 {
3667                         i = n - 1;
3668                         if (!expand_list) break;
3669                 }
3670         }
3671
3672         C_KILL(who, max_r_idx, MONRACE_IDX);
3673         screen_load();
3674         return !notpicked;
3675 }
3676
3677
3678 /*!
3679  * @brief 施設の処理実行メインルーチン / Execute a building command
3680  * @param player_ptr プレーヤーへの参照ポインタ
3681  * @param bldg 施設構造体の参照ポインタ
3682  * @param i 実行したい施設のサービステーブルの添字
3683  * @return なし
3684  */
3685 static void bldg_process_command(player_type *player_ptr, building_type *bldg, int i)
3686 {
3687         msg_flag = FALSE;
3688         msg_erase();
3689
3690         PRICE bcost;
3691         if (is_owner(player_ptr, bldg))
3692                 bcost = bldg->member_costs[i];
3693         else
3694                 bcost = bldg->other_costs[i];
3695
3696         /* action restrictions */
3697         if (((bldg->action_restr[i] == 1) && !is_member(player_ptr, bldg)) ||
3698                 ((bldg->action_restr[i] == 2) && !is_owner(player_ptr, bldg)))
3699         {
3700                 msg_print(_("それを選択する権利はありません!", "You have no right to choose that!"));
3701                 return;
3702         }
3703
3704         BACT_IDX bact = bldg->actions[i];
3705         if ((bact != BACT_RECHARGE) &&
3706                 (((bldg->member_costs[i] > player_ptr->au) && is_owner(player_ptr, bldg)) ||
3707                 ((bldg->other_costs[i] > player_ptr->au) && !is_owner(player_ptr, bldg))))
3708         {
3709                 msg_print(_("お金が足りません!", "You do not have the gold!"));
3710                 return;
3711         }
3712
3713         bool paid = FALSE;
3714         switch (bact)
3715         {
3716         case BACT_NOTHING:
3717                 /* Do nothing */
3718                 break;
3719         case BACT_RESEARCH_ITEM:
3720                 paid = identify_fully(player_ptr, FALSE);
3721                 break;
3722         case BACT_TOWN_HISTORY:
3723                 town_history(player_ptr);
3724                 break;
3725         case BACT_RACE_LEGENDS:
3726                 race_legends(player_ptr);
3727                 break;
3728         case BACT_QUEST:
3729                 castle_quest(player_ptr);
3730                 break;
3731         case BACT_KING_LEGENDS:
3732         case BACT_ARENA_LEGENDS:
3733         case BACT_LEGENDS:
3734                 show_highclass(player_ptr);
3735                 break;
3736         case BACT_POSTER:
3737         case BACT_ARENA_RULES:
3738         case BACT_ARENA:
3739                 arena_comm(player_ptr, bact);
3740                 break;
3741         case BACT_IN_BETWEEN:
3742         case BACT_CRAPS:
3743         case BACT_SPIN_WHEEL:
3744         case BACT_DICE_SLOTS:
3745         case BACT_GAMBLE_RULES:
3746         case BACT_POKER:
3747                 gamble_comm(player_ptr, bact);
3748                 break;
3749         case BACT_REST:
3750         case BACT_RUMORS:
3751         case BACT_FOOD:
3752                 paid = inn_comm(player_ptr, bact);
3753                 break;
3754         case BACT_RESEARCH_MONSTER:
3755                 paid = research_mon(player_ptr);
3756                 break;
3757         case BACT_COMPARE_WEAPONS:
3758                 paid = TRUE;
3759                 bcost = compare_weapons(player_ptr, bcost);
3760                 break;
3761         case BACT_ENCHANT_WEAPON:
3762                 item_tester_hook = object_allow_enchant_melee_weapon;
3763                 enchant_item(player_ptr, bcost, 1, 1, 0);
3764                 break;
3765         case BACT_ENCHANT_ARMOR:
3766                 item_tester_hook = object_is_armour;
3767                 enchant_item(player_ptr, bcost, 0, 0, 1);
3768                 break;
3769         case BACT_RECHARGE:
3770                 building_recharge(player_ptr);
3771                 break;
3772         case BACT_RECHARGE_ALL:
3773                 building_recharge_all(player_ptr);
3774                 break;
3775         case BACT_IDENTS:
3776                 if (!get_check(_("持ち物を全て鑑定してよろしいですか?", "Do you pay for identify all your possession? "))) break;
3777                 identify_pack(player_ptr);
3778                 msg_print(_(" 持ち物全てが鑑定されました。", "Your possessions have been identified."));
3779                 paid = TRUE;
3780                 break;
3781         case BACT_IDENT_ONE:
3782                 paid = ident_spell(player_ptr, FALSE);
3783                 break;
3784         case BACT_LEARN:
3785                 do_cmd_study(player_ptr);
3786                 break;
3787         case BACT_HEALING:
3788                 paid = cure_critical_wounds(player_ptr, 200);
3789                 break;
3790         case BACT_RESTORE:
3791                 paid = restore_all_status(player_ptr);
3792                 break;
3793         case BACT_ENCHANT_ARROWS:
3794                 item_tester_hook = item_tester_hook_ammo;
3795                 enchant_item(player_ptr, bcost, 1, 1, 0);
3796                 break;
3797         case BACT_ENCHANT_BOW:
3798                 item_tester_tval = TV_BOW;
3799                 enchant_item(player_ptr, bcost, 1, 1, 0);
3800                 break;
3801
3802         case BACT_RECALL:
3803                 if (recall_player(player_ptr, 1)) paid = TRUE;
3804                 break;
3805
3806         case BACT_TELEPORT_LEVEL:
3807                 clear_bldg(4, 20);
3808                 paid = free_level_recall(player_ptr);
3809                 break;
3810
3811         case BACT_LOSE_MUTATION:
3812                 if (player_ptr->muta1 || player_ptr->muta2 || (player_ptr->muta3 & ~MUT3_GOOD_LUCK) ||
3813                         (player_ptr->pseikaku != SEIKAKU_LUCKY && (player_ptr->muta3 & MUT3_GOOD_LUCK)))
3814                 {
3815                         while (!lose_mutation(player_ptr, 0));
3816                         paid = TRUE;
3817                         break;
3818                 }
3819
3820                 msg_print(_("治すべき突然変異が無い。", "You have no mutations."));
3821                 msg_print(NULL);
3822                 break;
3823
3824         case BACT_BATTLE:
3825                 kakutoujou(player_ptr);
3826                 break;
3827
3828         case BACT_TSUCHINOKO:
3829                 tsuchinoko();
3830                 break;
3831
3832         case BACT_BOUNTY:
3833                 show_bounty();
3834                 break;
3835
3836         case BACT_TARGET:
3837                 today_target(player_ptr);
3838                 break;
3839
3840         case BACT_KANKIN:
3841                 kankin(player_ptr);
3842                 break;
3843
3844         case BACT_HEIKOUKA:
3845                 msg_print(_("平衡化の儀式を行なった。", "You received an equalization ritual."));
3846                 set_virtue(player_ptr, V_COMPASSION, 0);
3847                 set_virtue(player_ptr, V_HONOUR, 0);
3848                 set_virtue(player_ptr, V_JUSTICE, 0);
3849                 set_virtue(player_ptr, V_SACRIFICE, 0);
3850                 set_virtue(player_ptr, V_KNOWLEDGE, 0);
3851                 set_virtue(player_ptr, V_FAITH, 0);
3852                 set_virtue(player_ptr, V_ENLIGHTEN, 0);
3853                 set_virtue(player_ptr, V_ENCHANT, 0);
3854                 set_virtue(player_ptr, V_CHANCE, 0);
3855                 set_virtue(player_ptr, V_NATURE, 0);
3856                 set_virtue(player_ptr, V_HARMONY, 0);
3857                 set_virtue(player_ptr, V_VITALITY, 0);
3858                 set_virtue(player_ptr, V_UNLIFE, 0);
3859                 set_virtue(player_ptr, V_PATIENCE, 0);
3860                 set_virtue(player_ptr, V_TEMPERANCE, 0);
3861                 set_virtue(player_ptr, V_DILIGENCE, 0);
3862                 set_virtue(player_ptr, V_VALOUR, 0);
3863                 set_virtue(player_ptr, V_INDIVIDUALISM, 0);
3864                 get_virtues(player_ptr);
3865                 paid = TRUE;
3866                 break;
3867
3868         case BACT_TELE_TOWN:
3869                 paid = tele_town(player_ptr);
3870                 break;
3871
3872         case BACT_EVAL_AC:
3873                 paid = eval_ac(player_ptr->dis_ac + player_ptr->dis_to_a);
3874                 break;
3875
3876         case BACT_BROKEN_WEAPON:
3877                 paid = TRUE;
3878                 bcost = repair_broken_weapon(player_ptr, bcost);
3879                 break;
3880         }
3881
3882         if (paid) player_ptr->au -= bcost;
3883 }
3884
3885
3886 /*!
3887  * @brief 施設入り口にプレイヤーが乗った際の処理 / Do building commands
3888  * @param プレーヤーへの参照ポインタ
3889  * @return なし
3890  */
3891 void do_cmd_bldg(player_type *player_ptr)
3892 {
3893         if (player_ptr->wild_mode) return;
3894
3895         take_turn(player_ptr, 100);
3896
3897         if (!cave_have_flag_bold(player_ptr->current_floor_ptr, player_ptr->y, player_ptr->x, FF_BLDG))
3898         {
3899                 msg_print(_("ここには建物はない。", "You see no building here."));
3900                 return;
3901         }
3902
3903         int which = f_info[player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x].feat].subtype;
3904
3905         building_type *bldg;
3906         bldg = &building[which];
3907
3908         reinit_wilderness = FALSE;
3909
3910         if ((which == 2) && (player_ptr->arena_number < 0))
3911         {
3912                 msg_print(_("「敗者に用はない。」", "'There's no place here for a LOSER like you!'"));
3913                 return;
3914         }
3915         else if ((which == 2) && player_ptr->current_floor_ptr->inside_arena)
3916         {
3917                 if (!player_ptr->exit_bldg && player_ptr->current_floor_ptr->m_cnt > 0)
3918                 {
3919                         prt(_("ゲートは閉まっている。モンスターがあなたを待っている!", "The gates are closed.  The monster awaits!"), 0, 0);
3920                 }
3921                 else
3922                 {
3923                         prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS | CFM_NO_RETURN);
3924                         player_ptr->current_floor_ptr->inside_arena = FALSE;
3925                         player_ptr->leaving = TRUE;
3926                         command_new = SPECIAL_KEY_BUILDING;
3927                         free_turn(player_ptr);
3928                 }
3929
3930                 return;
3931         }
3932         else if (player_ptr->phase_out)
3933         {
3934                 prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS | CFM_NO_RETURN);
3935                 player_ptr->leaving = TRUE;
3936                 player_ptr->phase_out = FALSE;
3937                 command_new = SPECIAL_KEY_BUILDING;
3938                 free_turn(player_ptr);
3939                 return;
3940         }
3941         else
3942         {
3943                 player_ptr->oldpy = player_ptr->y;
3944                 player_ptr->oldpx = player_ptr->x;
3945         }
3946
3947         forget_lite(player_ptr->current_floor_ptr);
3948         forget_view(player_ptr->current_floor_ptr);
3949         current_world_ptr->character_icky++;
3950
3951         command_arg = 0;
3952         command_rep = 0;
3953         command_new = 0;
3954
3955         show_building(player_ptr, bldg);
3956         player_ptr->leave_bldg = FALSE;
3957         play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
3958
3959         bool validcmd;
3960         while (!player_ptr->leave_bldg)
3961         {
3962                 validcmd = FALSE;
3963                 prt("", 1, 0);
3964
3965                 building_prt_gold(player_ptr);
3966
3967                 char command = inkey();
3968
3969                 if (command == ESCAPE)
3970                 {
3971                         player_ptr->leave_bldg = TRUE;
3972                         player_ptr->current_floor_ptr->inside_arena = FALSE;
3973                         player_ptr->phase_out = FALSE;
3974                         break;
3975                 }
3976
3977                 int i;
3978                 for (i = 0; i < 8; i++)
3979                 {
3980                         if (bldg->letters[i] && (bldg->letters[i] == command))
3981                         {
3982                                 validcmd = TRUE;
3983                                 break;
3984                         }
3985                 }
3986
3987                 if (validcmd) bldg_process_command(player_ptr, bldg, i);
3988
3989                 handle_stuff(player_ptr);
3990         }
3991
3992         select_floor_music(player_ptr);
3993
3994         msg_flag = FALSE;
3995         msg_erase();
3996
3997         if (reinit_wilderness) player_ptr->leaving = TRUE;
3998
3999         current_world_ptr->character_icky--;
4000         Term_clear();
4001
4002         player_ptr->update |= (PU_VIEW | PU_MONSTERS | PU_BONUS | PU_LITE | PU_MON_LITE);
4003         player_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
4004         player_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4005 }
4006
4007
4008 /*!
4009  * @brief 今日の賞金首を確定する / Determine today's bounty monster
4010  * @param player_type プレーヤーへの参照ポインタ
4011  * @return なし
4012  * @note conv_old is used if loaded 0.0.3 or older save file
4013  */
4014 void determine_daily_bounty(player_type *player_ptr, bool conv_old)
4015 {
4016         int max_dl = 3, i;
4017         if (!conv_old)
4018         {
4019                 for (i = 0; i < current_world_ptr->max_d_idx; i++)
4020                 {
4021                         if (max_dlv[i] < d_info[i].mindepth) continue;
4022                         if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
4023                 }
4024         }
4025         else
4026         {
4027                 max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
4028         }
4029
4030         player_ptr->phase_out = TRUE;
4031         get_mon_num_prep(player_ptr, NULL, NULL);
4032
4033         while (TRUE)
4034         {
4035                 today_mon = get_mon_num(player_ptr, max_dl);
4036                 monster_race *r_ptr;
4037                 r_ptr = &r_info[today_mon];
4038
4039                 if (r_ptr->flags1 & RF1_UNIQUE) continue;
4040                 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
4041                 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
4042                 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
4043                 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
4044                 if (r_ptr->rarity > 10) continue;
4045                 break;
4046         }
4047
4048         player_ptr->today_mon = 0;
4049         bool old_inside_battle = player_ptr->phase_out;
4050         player_ptr->phase_out = old_inside_battle;
4051 }
4052
4053
4054 /*!
4055  * @brief 賞金首となるユニークを確定する / Determine bounty uniques
4056  * @param player_ptr プレーヤーへの参照ポインタ
4057  * @return なし
4058  */
4059 void determine_bounty_uniques(player_type *player_ptr)
4060 {
4061         get_mon_num_prep(player_ptr, NULL, NULL);
4062         for (int i = 0; i < MAX_BOUNTY; i++)
4063         {
4064                 while (TRUE)
4065                 {
4066                         current_world_ptr->bounty_r_idx[i] = get_mon_num(player_ptr, MAX_DEPTH - 1);
4067                         monster_race *r_ptr;
4068                         r_ptr = &r_info[current_world_ptr->bounty_r_idx[i]];
4069
4070                         if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
4071
4072                         if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)))
4073                                 continue;
4074
4075                         if (r_ptr->rarity > 100) continue;
4076
4077                         if (no_questor_or_bounty_uniques(current_world_ptr->bounty_r_idx[i]))
4078                                 continue;
4079
4080                         int j;
4081                         for (j = 0; j < i; j++)
4082                         {
4083                                 if (current_world_ptr->bounty_r_idx[i] == current_world_ptr->bounty_r_idx[j])
4084                                         break;
4085                         }
4086
4087                         if (j == i) break;
4088                 }
4089         }
4090
4091         for (int i = 0; i < MAX_BOUNTY - 1; i++)
4092         {
4093                 for (int j = i; j < MAX_BOUNTY; j++)
4094                 {
4095                         MONRACE_IDX tmp;
4096                         if (r_info[current_world_ptr->bounty_r_idx[i]].level > r_info[current_world_ptr->bounty_r_idx[j]].level)
4097                         {
4098                                 tmp = current_world_ptr->bounty_r_idx[i];
4099                                 current_world_ptr->bounty_r_idx[i] = current_world_ptr->bounty_r_idx[j];
4100                                 current_world_ptr->bounty_r_idx[j] = tmp;
4101                         }
4102                 }
4103         }
4104 }