2 * todo サブルーチン分割を行うと行数が膨れ上がりそう、再分割も検討すべし
3 * @brief 既知のモンスターに関する情報を表示する
8 #include "knowledge/knowledge-monsters.h"
9 #include "core/show-file.h"
10 #include "core/stuff-handler.h"
11 #include "game-option/cheat-options.h"
12 #include "game-option/special-options.h"
13 #include "io-dump/dump-util.h"
14 #include "io/input-key-acceptor.h"
15 #include "knowledge/monster-group-table.h"
16 #include "locale/english.h"
17 #include "monster-race/monster-race.h"
18 #include "monster-race/race-flags1.h"
19 #include "monster-race/race-flags3.h"
20 #include "monster-race/race-flags7.h"
21 #include "monster/monster-describer.h"
22 #include "monster/monster-description-types.h"
23 #include "monster/monster-info.h"
24 #include "monster/monster-status.h"
25 #include "monster/smart-learn-types.h"
26 #include "system/floor-type-definition.h"
27 #include "term/screen-processor.h"
28 #include "term/term-color-types.h"
29 #include "util/angband-files.h"
30 #include "util/int-char-converter.h"
31 #include "util/sort.h"
32 #include "util/string-processor.h"
33 #include "view/display-lore.h"
34 #include "view/display-monster-status.h"
35 #include "world/world.h"
39 * Build a list of monster indexes in the given group.
41 * mode & 0x01 : check for non-empty group
42 * mode & 0x02 : visual operation only
44 * @param creature_ptr プレーヤーへの参照ポインタ
46 * @param mon_idx[] ???
48 * @return The number of monsters in the group
50 static IDX collect_monsters(player_type *creature_ptr, IDX grp_cur, IDX mon_idx[], BIT_FLAGS8 mode)
52 concptr group_char = monster_group_char[grp_cur];
53 bool grp_unique = (monster_group_char[grp_cur] == (char *)-1L);
54 bool grp_riding = (monster_group_char[grp_cur] == (char *)-2L);
55 bool grp_wanted = (monster_group_char[grp_cur] == (char *)-3L);
56 bool grp_amberite = (monster_group_char[grp_cur] == (char *)-4L);
59 for (IDX i = 0; i < max_r_idx; i++) {
60 monster_race *r_ptr = &r_info[i];
63 if (!(mode & 0x02) && !cheat_know && !r_ptr->r_sights)
67 if (!(r_ptr->flags1 & RF1_UNIQUE))
69 } else if (grp_riding) {
70 if (!(r_ptr->flags7 & RF7_RIDING))
72 } else if (grp_wanted) {
74 for (int j = 0; j < MAX_BOUNTY; j++) {
75 if (current_world_ptr->bounty_r_idx[j] == i || current_world_ptr->bounty_r_idx[j] - 10000 == i
76 || (creature_ptr->today_mon && creature_ptr->today_mon == i)) {
84 } else if (grp_amberite) {
85 if (!(r_ptr->flags3 & RF3_AMBERITE))
88 if (!angband_strchr(group_char, r_ptr->d_char))
92 mon_idx[mon_cnt++] = i;
97 mon_idx[mon_cnt] = -1;
99 ang_sort(creature_ptr, mon_idx, &dummy_why, mon_cnt, ang_sort_comp_monster_level, ang_sort_swap_hook);
104 * @brief 現在のペットを表示するコマンドのメインルーチン /
105 * Display current pets
106 * @param creature_ptr プレーヤーへの参照ポインタ
109 void do_cmd_knowledge_pets(player_type *creature_ptr)
112 GAME_TEXT file_name[FILE_NAME_SIZE];
113 if (!open_temporary_file(&fff, file_name))
117 GAME_TEXT pet_name[MAX_NLEN];
119 for (int i = creature_ptr->current_floor_ptr->m_max - 1; i >= 1; i--) {
120 m_ptr = &creature_ptr->current_floor_ptr->m_list[i];
121 if (!monster_is_valid(m_ptr) || !is_pet(m_ptr))
125 monster_desc(creature_ptr, pet_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
126 fprintf(fff, "%s (%s)\n", pet_name, look_mon_desc(m_ptr, 0x00));
129 int show_upkeep = calculate_upkeep(creature_ptr);
131 fprintf(fff, "----------------------------------------------\n");
133 fprintf(fff, " 合計: %d 体のペット\n", t_friends);
135 fprintf(fff, " Total: %d pet%s.\n", t_friends, (t_friends == 1 ? "" : "s"));
137 fprintf(fff, _(" 維持コスト: %d%% MP\n", " Upkeep: %d%% mana.\n"), show_upkeep);
140 (void)show_file(creature_ptr, TRUE, file_name, _("現在のペット", "Current Pets"), 0, 0);
145 * @brief 現在までに倒したモンスターを表示するコマンドのメインルーチン /
146 * @param creature_ptr プレーヤーへの参照ポインタ
149 * @note the player ghosts are ignored.
151 void do_cmd_knowledge_kill_count(player_type *creature_ptr)
154 GAME_TEXT file_name[FILE_NAME_SIZE];
155 if (!open_temporary_file(&fff, file_name))
159 C_MAKE(who, max_r_idx, MONRACE_IDX);
161 for (int kk = 1; kk < max_r_idx; kk++) {
162 monster_race *r_ptr = &r_info[kk];
164 if (r_ptr->flags1 & (RF1_UNIQUE)) {
165 bool dead = (r_ptr->max_num == 0);
171 MONSTER_NUMBER this_monster = r_ptr->r_pkills;
173 if (this_monster > 0) {
174 total += this_monster;
180 fprintf(fff, _("あなたはまだ敵を倒していない。\n\n", "You have defeated no enemies yet.\n\n"));
183 fprintf(fff, "あなたは%ld体の敵を倒している。\n\n", (long int)total);
185 fprintf(fff, "You have defeated %ld %s.\n\n", (long int)total, (total == 1) ? "enemy" : "enemies");
190 for (MONRACE_IDX i = 1; i < max_r_idx; i++) {
191 monster_race *r_ptr = &r_info[i];
197 ang_sort(creature_ptr, who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
198 for (int k = 0; k < n; k++) {
199 monster_race *r_ptr = &r_info[who[k]];
200 if (r_ptr->flags1 & (RF1_UNIQUE)) {
201 bool dead = (r_ptr->max_num == 0);
203 fprintf(fff, " %s\n", (r_name + r_ptr->name));
210 MONSTER_NUMBER this_monster = r_ptr->r_pkills;
211 if (this_monster <= 0)
215 char *number_of_kills = angband_strchr("pt", r_ptr->d_char) ? "人" : "体";
216 fprintf(fff, " %3d %sの %s\n", (int)this_monster, number_of_kills, r_name + r_ptr->name);
218 if (this_monster < 2) {
219 if (angband_strstr(r_name + r_ptr->name, "coins")) {
220 fprintf(fff, " 1 pile of %s\n", (r_name + r_ptr->name));
222 fprintf(fff, " 1 %s\n", (r_name + r_ptr->name));
226 strcpy(ToPlural, (r_name + r_ptr->name));
227 plural_aux(ToPlural);
228 fprintf(fff, " %d %s\n", this_monster, ToPlural);
231 total += this_monster;
234 fprintf(fff, "----------------------------------------------\n");
236 fprintf(fff, " 合計: %lu 体を倒した。\n", (unsigned long int)total);
238 fprintf(fff, " Total: %lu creature%s killed.\n", (unsigned long int)total, (total == 1 ? "" : "s"));
241 C_KILL(who, max_r_idx, s16b);
243 (void)show_file(creature_ptr, TRUE, file_name, _("倒した敵の数", "Kill Count"), 0, 0);
248 * Display the monsters in a group.
250 static void display_monster_list(int col, int row, int per_page, s16b mon_idx[], int mon_cur, int mon_top, bool visual_only)
253 for (i = 0; i < per_page && (mon_idx[mon_top + i] >= 0); i++) {
255 MONRACE_IDX r_idx = mon_idx[mon_top + i];
256 monster_race *r_ptr = &r_info[r_idx];
257 attr = ((i + mon_top == mon_cur) ? TERM_L_BLUE : TERM_WHITE);
258 c_prt(attr, (r_name + r_ptr->name), row + i, col);
260 c_prt(attr, format("%02x/%02x", r_ptr->x_attr, r_ptr->x_char), row + i, (current_world_ptr->wizard || visual_only) ? 56 : 61);
262 if (current_world_ptr->wizard || visual_only)
263 c_prt(attr, format("%d", r_idx), row + i, 62);
265 term_erase(69, row + i, 255);
266 term_queue_bigchar(use_bigtile ? 69 : 70, row + i, r_ptr->x_attr, r_ptr->x_char, 0, 0);
268 if (!(r_ptr->flags1 & RF1_UNIQUE))
269 put_str(format("%5d", r_ptr->r_pkills), row + i, 73);
271 c_put_str((r_ptr->max_num == 0 ? TERM_L_DARK : TERM_WHITE), (r_ptr->max_num == 0 ? _("死亡", " dead") : _("生存", "alive")), row + i, 74);
275 for (; i < per_page; i++) {
276 term_erase(col, row + i, 255);
282 * Display known monsters.
283 * @param creature_ptr プレーヤーへの参照ポインタ
284 * @param need_redraw 画面の再描画が必要な時TRUE
285 * @param visual_only ???
286 * @param direct_r_idx モンスターID
289 void do_cmd_knowledge_monsters(player_type *creature_ptr, bool *need_redraw, bool visual_only, IDX direct_r_idx)
292 term_get_size(&wid, &hgt);
294 C_MAKE(mon_idx, max_r_idx, MONRACE_IDX);
300 bool visual_list = FALSE;
301 TERM_COLOR attr_top = 0;
304 int browser_rows = hgt - 8;
305 if (direct_r_idx < 0) {
306 mode = visual_only ? 0x03 : 0x01;
308 for (IDX i = 0; monster_group_text[i] != NULL; i++) {
309 len = strlen(monster_group_text[i]);
313 if ((monster_group_char[i] == ((char *)-1L)) || collect_monsters(creature_ptr, i, mon_idx, mode)) {
314 grp_idx[grp_cnt++] = i;
320 mon_idx[0] = direct_r_idx;
324 (void)visual_mode_command('v', &visual_list, browser_rows - 1, wid - (max + 3), &attr_top, &char_left, &r_info[direct_r_idx].x_attr,
325 &r_info[direct_r_idx].x_char, need_redraw);
328 grp_idx[grp_cnt] = -1;
329 mode = visual_only ? 0x02 : 0x00;
330 IDX old_grp_cur = -1;
341 prt(format(_("%s - モンスター", "%s - monsters"), !visual_only ? _("知識", "Knowledge") : _("表示", "Visuals")), 2, 0);
342 if (direct_r_idx < 0)
343 prt(_("グループ", "Group"), 4, 0);
344 prt(_("名前", "Name"), 4, max + 3);
345 if (current_world_ptr->wizard || visual_only)
347 prt(_("文字", "Sym"), 4, 67);
349 prt(_("殺害数", "Kills"), 4, 72);
351 for (IDX i = 0; i < 78; i++) {
352 term_putch(i, 5, TERM_WHITE, '=');
355 if (direct_r_idx < 0) {
356 for (IDX i = 0; i < browser_rows; i++) {
357 term_putch(max + 1, 6 + i, TERM_WHITE, '|');
364 if (direct_r_idx < 0) {
365 if (grp_cur < grp_top)
367 if (grp_cur >= grp_top + browser_rows)
368 grp_top = grp_cur - browser_rows + 1;
370 display_group_list(0, 6, max, browser_rows, grp_idx, monster_group_text, grp_cur, grp_top);
371 if (old_grp_cur != grp_cur) {
372 old_grp_cur = grp_cur;
373 mon_cnt = collect_monsters(creature_ptr, grp_idx[grp_cur], mon_idx, mode);
376 while (mon_cur < mon_top)
377 mon_top = MAX(0, mon_top - browser_rows / 2);
378 while (mon_cur >= mon_top + browser_rows)
379 mon_top = MIN(mon_cnt - browser_rows, mon_top + browser_rows / 2);
383 display_monster_list(max + 3, 6, browser_rows, mon_idx, mon_cur, mon_top, visual_only);
386 display_monster_list(max + 3, 6, 1, mon_idx, mon_cur, mon_top, visual_only);
387 display_visual_list(max + 3, 7, browser_rows - 1, wid - (max + 3), attr_top, char_left);
390 prt(format(_("<方向>%s%s%s, ESC", "<dir>%s%s%s, ESC"), (!visual_list && !visual_only) ? _(", 'r'で思い出を見る", ", 'r' to recall") : "",
391 visual_list ? _(", ENTERで決定", ", ENTER to accept") : _(", 'v'でシンボル変更", ", 'v' for visuals"),
392 (attr_idx || char_idx) ? _(", 'c', 'p'でペースト", ", 'c', 'p' to paste") : _(", 'c'でコピー", ", 'c' to copy")),
396 r_ptr = &r_info[mon_idx[mon_cur]];
400 monster_race_track(creature_ptr, mon_idx[mon_cur]);
401 handle_stuff(creature_ptr);
405 place_visual_list_cursor(max + 3, 7, r_ptr->x_attr, r_ptr->x_char, attr_top, char_left);
406 } else if (!column) {
407 term_gotoxy(0, 6 + (grp_cur - grp_top));
409 term_gotoxy(max + 3, 6 + (mon_cur - mon_top));
413 if (visual_mode_command(ch, &visual_list, browser_rows - 1, wid - (max + 3), &attr_top, &char_left, &r_ptr->x_attr, &r_ptr->x_char, need_redraw)) {
414 if (direct_r_idx >= 0) {
435 if (!visual_list && !visual_only && (mon_idx[mon_cur] > 0)) {
436 screen_roff(creature_ptr, mon_idx[mon_cur], 0);
447 browser_cursor(ch, &column, &grp_cur, grp_cnt, &mon_cur, mon_cnt);
454 C_KILL(mon_idx, max_r_idx, MONRACE_IDX);
458 * List wanted monsters
459 * @param creature_ptr プレーヤーへの参照ポインタ
462 void do_cmd_knowledge_bounty(player_type *creature_ptr)
465 GAME_TEXT file_name[FILE_NAME_SIZE];
466 if (!open_temporary_file(&fff, file_name))
469 fprintf(fff, _("今日のターゲット : %s\n", "Today's target : %s\n"),
470 (creature_ptr->today_mon ? r_name + r_info[creature_ptr->today_mon].name : _("不明", "unknown")));
472 fprintf(fff, _("賞金首リスト\n", "List of wanted monsters\n"));
473 fprintf(fff, "----------------------------------------------\n");
476 for (int i = 0; i < MAX_BOUNTY; i++) {
477 if (current_world_ptr->bounty_r_idx[i] <= 10000) {
478 fprintf(fff, "%s\n", r_name + r_info[current_world_ptr->bounty_r_idx[i]].name);
484 fprintf(fff, "\n%s\n", _("賞金首はもう残っていません。", "There are no more wanted monster."));
487 (void)show_file(creature_ptr, TRUE, file_name, _("賞金首の一覧", "Wanted monsters"), 0, 0);