OSDN Git Service

[Refactor] #40413 Renamed my_f*() to angband_f*() in util.c/h; propably f means fuxk...
[hengband/hengband.git] / src / cmd-io / cmd-lore.c
1 #include "cmd-io/cmd-lore.h"
2 #include "core/sort.h"
3 #include "core/stuff-handler.h"
4 #include "game-option/game-play-options.h"
5 #include "game-option/cheat-options.h"
6 #include "monster-race/race-flags1.h"
7 #include "monster-race/race-flags7.h"
8 #include "term/gameterm.h"
9 #include "term/term-color-types.h"
10 #include "view/display-main-window.h"
11 #include "view/display-lore.h"
12
13 /*!
14  * @brief モンスターの思い出を見るコマンドのメインルーチン
15  * Identify a character, allow recall of monsters
16  * @param player_ptr プレーヤーへの参照ポインタ
17  * @return なし
18  * @details
19  * <pre>
20  * Several "special" responses recall "multiple" monsters:
21  *   ^A (all monsters)
22  *   ^U (all unique monsters)
23  *   ^N (all non-unique monsters)
24  *
25  * The responses may be sorted in several ways, see below.
26  *
27  * Note that the player ghosts are ignored.
28  * </pre>
29  */
30 void do_cmd_query_symbol(player_type *creature_ptr)
31 {
32     IDX i;
33     int n;
34     MONRACE_IDX r_idx;
35     char sym, query;
36     char buf[128];
37
38     bool all = FALSE;
39     bool uniq = FALSE;
40     bool norm = FALSE;
41     bool ride = FALSE;
42     char temp[80] = "";
43
44     bool recall = FALSE;
45
46     u16b why = 0;
47     MONRACE_IDX *who;
48
49     if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
50                      "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "),
51             &sym, FALSE))
52         return;
53
54     for (i = 0; ident_info[i]; ++i) {
55         if (sym == ident_info[i][0])
56             break;
57     }
58
59     if (sym == KTRL('A')) {
60         all = TRUE;
61         strcpy(buf, _("全モンスターのリスト", "Full monster list."));
62     } else if (sym == KTRL('U')) {
63         all = uniq = TRUE;
64         strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
65     } else if (sym == KTRL('N')) {
66         all = norm = TRUE;
67         strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
68     } else if (sym == KTRL('R')) {
69         all = ride = TRUE;
70         strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
71     } else if (sym == KTRL('M')) {
72         all = TRUE;
73         if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"), temp, 70)) {
74             temp[0] = 0;
75             return;
76         }
77         sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""), temp);
78     } else if (ident_info[i]) {
79         sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
80     } else {
81         sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
82     }
83
84     prt(buf, 0, 0);
85     C_MAKE(who, max_r_idx, MONRACE_IDX);
86     for (n = 0, i = 1; i < max_r_idx; i++) {
87         monster_race *r_ptr = &r_info[i];
88         if (!cheat_know && !r_ptr->r_sights)
89             continue;
90
91         if (norm && (r_ptr->flags1 & (RF1_UNIQUE)))
92             continue;
93
94         if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE)))
95             continue;
96
97         if (ride && !(r_ptr->flags7 & (RF7_RIDING)))
98             continue;
99
100         if (temp[0]) {
101             TERM_LEN xx;
102             char temp2[80];
103
104             for (xx = 0; temp[xx] && xx < 80; xx++) {
105 #ifdef JP
106                 if (iskanji(temp[xx])) {
107                     xx++;
108                     continue;
109                 }
110 #endif
111                 if (isupper(temp[xx]))
112                     temp[xx] = (char)tolower(temp[xx]);
113             }
114
115 #ifdef JP
116             strcpy(temp2, r_name + r_ptr->E_name);
117 #else
118             strcpy(temp2, r_name + r_ptr->name);
119 #endif
120             for (xx = 0; temp2[xx] && xx < 80; xx++)
121                 if (isupper(temp2[xx]))
122                     temp2[xx] = (char)tolower(temp2[xx]);
123
124 #ifdef JP
125             if (angband_strstr(temp2, temp) || angband_strstr(r_name + r_ptr->name, temp))
126 #else
127             if (angband_strstr(temp2, temp))
128 #endif
129                 who[n++] = i;
130         }
131
132         else if (all || (r_ptr->d_char == sym))
133             who[n++] = i;
134     }
135
136     if (!n) {
137         C_KILL(who, max_r_idx, MONRACE_IDX);
138         return;
139     }
140
141     put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
142     query = inkey();
143     prt(buf, 0, 0);
144     why = 2;
145     ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
146     if (query == 'k') {
147         why = 4;
148         query = 'y';
149     }
150
151     if (query != 'y') {
152         C_KILL(who, max_r_idx, MONRACE_IDX);
153         return;
154     }
155
156     if (why == 4) {
157         ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
158     }
159
160     i = n - 1;
161     while (TRUE) {
162         r_idx = who[i];
163         monster_race_track(creature_ptr, r_idx);
164         handle_stuff(creature_ptr);
165         while (TRUE) {
166             if (recall) {
167                 screen_save();
168                 screen_roff(creature_ptr, who[i], 0);
169             }
170
171             roff_top(r_idx);
172             Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
173             query = inkey();
174             if (recall) {
175                 screen_load();
176             }
177
178             if (query != 'r')
179                 break;
180             recall = !recall;
181         }
182
183         if (query == ESCAPE)
184             break;
185
186         if (query == '-') {
187             if (++i == n) {
188                 i = 0;
189                 if (!expand_list)
190                     break;
191             }
192         } else {
193             if (i-- == 0) {
194                 i = n - 1;
195                 if (!expand_list)
196                     break;
197             }
198         }
199     }
200
201     C_KILL(who, max_r_idx, IDX);
202     prt(buf, 0, 0);
203 }