OSDN Git Service

[Implement] ウサウサストライカー召喚処理を追加
[hengbandforosx/hengbandosx.git] / src / cmd-io / cmd-lore.cpp
1 #include "cmd-io/cmd-lore.h"
2 #include "core/asking-player.h"
3 #include "core/stuff-handler.h"
4 #include "game-option/cheat-options.h"
5 #include "game-option/game-play-options.h"
6 #include "io/input-key-acceptor.h"
7 #include "lore/lore-util.h"
8 #include "monster-race/monster-race.h"
9 #include "monster-race/race-flags1.h"
10 #include "monster-race/race-flags7.h"
11 #include "system/monster-race-info.h"
12 #include "system/player-type-definition.h"
13 #include "term/gameterm.h"
14 #include "term/screen-processor.h"
15 #include "term/term-color-types.h"
16 #include "term/z-form.h"
17 #include "util/int-char-converter.h"
18 #include "util/sort.h"
19 #include "util/string-processor.h"
20 #include "view/display-lore.h"
21
22 /*!
23  * @brief モンスターの思い出を見るコマンドのメインルーチン
24  * Identify a character, allow recall of monsters
25  * @param player_ptr プレイヤーへの参照ポインタ
26  * @details
27  * <pre>
28  * Several "special" responses recall "multiple" monsters:
29  *   ^A (all monsters)
30  *   ^U (all unique monsters)
31  *   ^N (all non-unique monsters)
32  *
33  * The responses may be sorted in several ways, see below.
34  *
35  * Note that the player ghosts are ignored.
36  * </pre>
37  */
38 void do_cmd_query_symbol(PlayerType *player_ptr)
39 {
40     bool all = false;
41     bool uniq = false;
42     bool norm = false;
43     bool ride = false;
44     bool recall = false;
45
46     uint16_t why = 0;
47
48     constexpr auto prompt = _("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
49         "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): ");
50     const auto symbol = input_command(prompt);
51     if (!symbol) {
52         return;
53     }
54
55     int ident_i;
56     for (ident_i = 0; ident_info[ident_i]; ++ident_i) {
57         if (symbol == ident_info[ident_i][0]) {
58             break;
59         }
60     }
61
62     std::string buf;
63     std::string monster_name("");
64     if (symbol == KTRL('A')) {
65         all = true;
66         buf = _("全モンスターのリスト", "Full monster list.");
67     } else if (symbol == KTRL('U')) {
68         all = uniq = true;
69         buf = _("ユニーク・モンスターのリスト", "Unique monster list.");
70     } else if (symbol == KTRL('N')) {
71         all = norm = true;
72         buf = _("ユニーク外モンスターのリスト", "Non-unique monster list.");
73     } else if (symbol == KTRL('R')) {
74         all = ride = true;
75         buf = _("乗馬可能モンスターのリスト", "Ridable monster list.");
76     } else if (symbol == KTRL('M')) {
77         all = true;
78         const auto monster_name_opt = input_string(_("名前(英語の場合小文字で可)", "Enter name:"), MAX_MONSTER_NAME);
79         if (!monster_name_opt) {
80             return;
81         }
82
83         monster_name = *monster_name_opt;
84         buf = format(_("名前:%sにマッチ", "Monsters' names with \"%s\""), monster_name.data());
85     } else if (ident_info[ident_i]) {
86         buf = format("%c - %s.", *symbol, ident_info[ident_i] + 2);
87     } else {
88         buf = format("%c - %s", *symbol, _("無効な文字", "Unknown Symbol"));
89     }
90
91     prt(buf, 0, 0);
92     std::vector<MonsterRaceId> monraces;
93     for (const auto &[monrace_id, monrace] : monraces_info) {
94         if (!cheat_know && !monrace.r_sights) {
95             continue;
96         }
97
98         if (norm && monrace.kind_flags.has(MonsterKindType::UNIQUE)) {
99             continue;
100         }
101
102         if (uniq && monrace.kind_flags.has_not(MonsterKindType::UNIQUE)) {
103             continue;
104         }
105
106         if (ride && monrace.misc_flags.has_not(MonsterMiscType::RIDING)) {
107             continue;
108         }
109
110         if (!monster_name.empty()) {
111             for (size_t xx = 0; xx < monster_name.length(); xx++) {
112 #ifdef JP
113                 if (iskanji(monster_name[xx])) {
114                     xx++;
115                     continue;
116                 }
117 #endif
118                 if (isupper(monster_name[xx])) {
119                     monster_name[xx] = (char)tolower(monster_name[xx]);
120                 }
121             }
122
123 #ifdef JP
124             auto temp2(monrace.E_name);
125 #else
126             auto temp2(monrace.name);
127 #endif
128             for (size_t xx = 0; xx < temp2.length(); xx++) {
129                 if (isupper(temp2[xx])) {
130                     temp2[xx] = (char)tolower(temp2[xx]);
131                 }
132             }
133
134 #ifdef JP
135             if (str_find(temp2, monster_name) || str_find(monrace.name, monster_name))
136 #else
137             if (str_find(temp2, monster_name))
138 #endif
139                 monraces.push_back(monrace_id);
140         }
141
142         else if (all || (monrace.d_char == symbol)) {
143             monraces.push_back(monrace_id);
144         }
145     }
146
147     if (monraces.empty()) {
148         return;
149     }
150
151     put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
152     auto query = inkey();
153     prt(buf, 0, 0);
154     why = 2;
155     ang_sort(player_ptr, monraces.data(), &why, monraces.size(), ang_sort_comp_hook, ang_sort_swap_hook);
156     if (query == 'k') {
157         why = 4;
158         query = 'y';
159     }
160
161     if (query != 'y') {
162         return;
163     }
164
165     if (why == 4) {
166         ang_sort(player_ptr, monraces.data(), &why, monraces.size(), ang_sort_comp_hook, ang_sort_swap_hook);
167     }
168
169     auto i = monraces.size() - 1;
170     while (true) {
171         auto r_idx = monraces[i];
172         monster_race_track(player_ptr, r_idx);
173         handle_stuff(player_ptr);
174         while (true) {
175             if (recall) {
176                 screen_save();
177                 screen_roff(player_ptr, monraces[i], MONSTER_LORE_NORMAL);
178             }
179
180             roff_top(r_idx);
181             term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
182             query = inkey();
183             if (recall) {
184                 screen_load();
185             }
186
187             if (query != 'r') {
188                 break;
189             }
190             recall = !recall;
191         }
192
193         if (query == ESCAPE) {
194             break;
195         }
196
197         if (query == '-') {
198             if (++i == monraces.size()) {
199                 i = 0;
200                 if (!expand_list) {
201                     break;
202                 }
203             }
204         } else {
205             if (i-- == 0) {
206                 i = monraces.size() - 1;
207                 if (!expand_list) {
208                     break;
209                 }
210             }
211         }
212     }
213
214     prt(buf, 0, 0);
215 }