OSDN Git Service

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