OSDN Git Service

Merge branch 'master' of git.osdn.net:/gitroot/hengband/hengband
[hengband/hengband.git] / src / dungeon / dungeon.c
1 #include "dungeon/dungeon.h"
2 #include "game-option/birth-options.h"
3 #include "io/input-key-acceptor.h"
4 #include "main/sound-of-music.h"
5 #include "monster-race/monster-race.h"
6 #include "term/screen-processor.h"
7 #include "util/int-char-converter.h"
8 #include "view/display-messages.h"
9 #include "world/world.h"
10
11 /*
12  * The dungeon arrays
13  */
14 dungeon_type *d_info;
15 char *d_name;
16 char *d_text;
17
18 /*
19  * Maximum number of dungeon in d_info.txt
20  */
21 DEPTH *max_dlv;
22
23
24 /*!
25  * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
26  * @param note ダンジョンに施す処理記述
27  * @param y コンソールY座標
28  * @param x コンソールX座標
29  * @return 選択されたダンジョンID
30  */
31 DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x)
32 {
33         DUNGEON_IDX select_dungeon;
34         DUNGEON_IDX i;
35         int num = 0;
36         DUNGEON_IDX *dun;
37
38         /* Hack -- No need to choose dungeon in some case */
39         if (lite_town || vanilla_town || ironman_downward)
40         {
41                 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
42                 else
43                 {
44                         msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
45                         msg_print(NULL);
46                         return 0;
47                 }
48         }
49
50         /* Allocate the "dun" array */
51         C_MAKE(dun, current_world_ptr->max_d_idx, DUNGEON_IDX);
52
53         screen_save();
54         for (i = 1; i < current_world_ptr->max_d_idx; i++)
55         {
56                 char buf[80];
57                 bool seiha = FALSE;
58
59                 if (!d_info[i].maxdepth) continue;
60                 if (!max_dlv[i]) continue;
61                 if (d_info[i].final_guardian)
62                 {
63                         if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
64                 }
65                 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
66
67                 sprintf(buf, _("      %c) %c%-12s : 最大 %d 階", "      %c) %c%-16s : Max level %d"),
68                         'a' + num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
69                 prt(buf, y + num, x);
70                 dun[num++] = i;
71         }
72
73         if (!num)
74         {
75                 prt(_("      選べるダンジョンがない。", "      No dungeon is available."), y, x);
76         }
77
78         prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
79         while (TRUE)
80         {
81                 i = inkey();
82                 if ((i == ESCAPE) || !num)
83                 {
84                         /* Free the "dun" array */
85                         C_KILL(dun, current_world_ptr->max_d_idx, DUNGEON_IDX);
86
87                         screen_load();
88                         return 0;
89                 }
90                 if (i >= 'a' && i < ('a' + num))
91                 {
92                         select_dungeon = dun[i - 'a'];
93                         break;
94                 }
95                 else bell();
96         }
97         screen_load();
98
99         /* Free the "dun" array */
100         C_KILL(dun, current_world_ptr->max_d_idx, DUNGEON_IDX);
101
102         return select_dungeon;
103 }
104