OSDN Git Service

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