OSDN Git Service

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