OSDN Git Service

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