7 #include "knowledge-quests.h"
8 #include "core/show-file.h"
10 #include "dungeon/dungeon.h"
11 #include "dungeon/quest.h"
12 #include "floor/floor.h"
13 #include "info-reader/fixed-map-parser.h"
14 #include "io-dump/dump-util.h"
15 #include "locale/english.h"
16 #include "object-enchant/artifact.h"
17 #include "object-enchant/special-object-flags.h"
18 #include "object/object-flavor.h"
19 #include "object/object-generator.h"
20 #include "object/object-kind-hook.h"
21 #include "system/system-variables.h" // 暫定、init_flagsのため。後で消すかも.
22 #include "term/screen-processor.h"
23 #include "util/angband-files.h"
24 #include "world/world.h"
27 * Check on the status of an active quest
28 * @param creature_ptr プレーヤーへの参照ポインタ
31 void do_cmd_checkquest(player_type *creature_ptr)
34 do_cmd_knowledge_quests(creature_ptr);
40 * todo player_typeではなくQUEST_IDXを引数にすべきかもしれない
41 * Print all active quests
42 * @param creature_ptr プレーヤーへの参照ポインタ
45 static void do_cmd_knowledge_quests_current(player_type *creature_ptr, FILE *fff)
48 char rand_tmp_str[120] = "\0";
49 GAME_TEXT name[MAX_NLEN];
54 fprintf(fff, _("《遂行中のクエスト》\n", "< Current Quest >\n"));
56 for (QUEST_IDX i = 1; i < max_q_idx; i++)
58 bool is_print = quest[i].status == QUEST_STATUS_TAKEN;
59 is_print |= (quest[i].status == QUEST_STATUS_STAGE_COMPLETED) && (quest[i].type == QUEST_TYPE_TOWER);
60 is_print |= quest[i].status == QUEST_STATUS_COMPLETED;
64 QUEST_IDX old_quest = creature_ptr->current_floor_ptr->inside_quest;
65 for (int j = 0; j < 10; j++)
66 quest_text[j][0] = '\0';
69 creature_ptr->current_floor_ptr->inside_quest = i;
70 init_flags = INIT_SHOW_TEXT;
71 parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
72 creature_ptr->current_floor_ptr->inside_quest = old_quest;
73 if (quest[i].flags & QUEST_FLAG_SILENT) continue;
76 if (quest[i].type != QUEST_TYPE_RANDOM)
80 if (quest[i].status == QUEST_STATUS_TAKEN || quest[i].status == QUEST_STATUS_STAGE_COMPLETED)
82 switch (quest[i].type)
84 case QUEST_TYPE_KILL_LEVEL:
85 case QUEST_TYPE_KILL_ANY_LEVEL:
86 r_ptr = &r_info[quest[i].r_idx];
87 strcpy(name, r_name + r_ptr->name);
88 if (quest[i].max_num > 1)
91 sprintf(note, " - %d 体の%sを倒す。(あと %d 体)",
92 (int)quest[i].max_num, name, (int)(quest[i].max_num - quest[i].cur_num));
95 sprintf(note, " - kill %d %s, have killed %d.",
96 (int)quest[i].max_num, name, (int)quest[i].cur_num);
100 sprintf(note, _(" - %sを倒す。", " - kill %s."), name);
103 case QUEST_TYPE_FIND_ARTIFACT:
106 artifact_type *a_ptr = &a_info[quest[i].k_idx];
108 object_type *q_ptr = &forge;
109 KIND_OBJECT_IDX k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
110 object_prep(q_ptr, k_idx);
111 q_ptr->name1 = quest[i].k_idx;
112 q_ptr->ident = IDENT_STORE;
113 object_desc(creature_ptr, name, q_ptr, OD_NAME_ONLY);
115 sprintf(note, _("\n - %sを見つけ出す。", "\n - Find %s."), name);
117 case QUEST_TYPE_FIND_EXIT:
118 sprintf(note, _(" - 出口に到達する。", " - Reach exit."));
121 case QUEST_TYPE_KILL_NUMBER:
123 sprintf(note, " - %d 体のモンスターを倒す。(あと %d 体)",
124 (int)quest[i].max_num, (int)(quest[i].max_num - quest[i].cur_num));
126 sprintf(note, " - Kill %d monsters, have killed %d.",
127 (int)quest[i].max_num, (int)quest[i].cur_num);
131 case QUEST_TYPE_KILL_ALL:
132 case QUEST_TYPE_TOWER:
133 sprintf(note, _(" - 全てのモンスターを倒す。", " - Kill all monsters."));
138 sprintf(tmp_str, _(" %s (危険度:%d階相当)%s\n", " %s (Danger level: %d)%s\n"),
139 quest[i].name, (int)quest[i].level, note);
141 if (quest[i].status == QUEST_STATUS_COMPLETED)
143 sprintf(tmp_str, _(" クエスト達成 - まだ報酬を受けとってない。\n", " Quest Completed - Unrewarded\n"));
149 while (quest_text[k][0] && k < 10)
151 fprintf(fff, " %s\n", quest_text[k]);
158 if (quest[i].level >= rand_level)
161 rand_level = quest[i].level;
162 if (max_dlv[DUNGEON_ANGBAND] < rand_level) continue;
164 r_ptr = &r_info[quest[i].r_idx];
165 strcpy(name, r_name + r_ptr->name);
166 if (quest[i].max_num <= 1)
168 sprintf(rand_tmp_str, _(" %s (%d 階) - %sを倒す。\n", " %s (Dungeon level: %d)\n Kill %s.\n"),
169 quest[i].name, (int)quest[i].level, name);
174 sprintf(rand_tmp_str, " %s (%d 階) - %d 体の%sを倒す。(あと %d 体)\n",
175 quest[i].name, (int)quest[i].level,
176 (int)quest[i].max_num, name, (int)(quest[i].max_num - quest[i].cur_num));
180 sprintf(rand_tmp_str, " %s (Dungeon level: %d)\n Kill %d %s, have killed %d.\n",
181 quest[i].name, (int)quest[i].level,
182 (int)quest[i].max_num, name, (int)quest[i].cur_num);
186 if (rand_tmp_str[0]) fputs(rand_tmp_str, fff);
188 if (!total) fprintf(fff, _(" なし\n", " Nothing.\n"));
192 static bool do_cmd_knowledge_quests_aux(player_type *player_ptr, FILE *fff, IDX q_idx)
195 char playtime_str[16];
196 quest_type* const q_ptr = &quest[q_idx];
198 floor_type *floor_ptr = player_ptr->current_floor_ptr;
199 if (is_fixed_quest_idx(q_idx))
201 IDX old_quest = floor_ptr->inside_quest;
202 floor_ptr->inside_quest = q_idx;
203 init_flags = INIT_NAME_ONLY;
204 parse_fixed_map(player_ptr, "q_info.txt", 0, 0, 0, 0);
205 floor_ptr->inside_quest = old_quest;
206 if (q_ptr->flags & QUEST_FLAG_SILENT) return FALSE;
209 strnfmt(playtime_str, sizeof(playtime_str), "%02d:%02d:%02d",
210 q_ptr->comptime / (60 * 60), (q_ptr->comptime / 60) % 60, q_ptr->comptime % 60);
212 if (is_fixed_quest_idx(q_idx) || (q_ptr->r_idx == 0))
215 _(" %-35s (危険度:%3d階相当) - レベル%2d - %s\n",
216 " %-35s (Danger level: %3d) - level %2d - %s\n"),
217 q_ptr->name, (int)q_ptr->level, q_ptr->complev, playtime_str);
222 if (q_ptr->complev == 0)
225 _(" %-35s (%3d階) - 不戦勝 - %s\n",
226 " %-35s (Dungeon level: %3d) - Unearned - %s\n"),
227 r_name + r_info[q_ptr->r_idx].name,
228 (int)q_ptr->level, playtime_str);
234 _(" %-35s (%3d階) - レベル%2d - %s\n",
235 " %-35s (Dungeon level: %3d) - level %2d - %s\n"),
236 r_name + r_info[q_ptr->r_idx].name,
246 * Print all finished quests
247 * @param creature_ptr プレーヤーへの参照ポインタ
248 * @param fff セーブファイル (展開済?)
249 * @param quest_num[] 受注したことのあるクエスト群
252 void do_cmd_knowledge_quests_completed(player_type *creature_ptr, FILE *fff, QUEST_IDX quest_num[])
254 fprintf(fff, _("《達成したクエスト》\n", "< Completed Quest >\n"));
256 for (QUEST_IDX i = 1; i < max_q_idx; i++)
258 QUEST_IDX q_idx = quest_num[i];
259 quest_type* const q_ptr = &quest[q_idx];
261 if (q_ptr->status == QUEST_STATUS_FINISHED && do_cmd_knowledge_quests_aux(creature_ptr, fff, q_idx))
267 if (!total) fprintf(fff, _(" なし\n", " Nothing.\n"));
272 * Print all failed quests
273 * @param creature_ptr プレーヤーへの参照ポインタ
274 * @param fff セーブファイル (展開済?)
275 * @param quest_num[] 受注したことのあるクエスト群
278 void do_cmd_knowledge_quests_failed(player_type *creature_ptr, FILE *fff, QUEST_IDX quest_num[])
280 fprintf(fff, _("《失敗したクエスト》\n", "< Failed Quest >\n"));
282 for (QUEST_IDX i = 1; i < max_q_idx; i++)
284 QUEST_IDX q_idx = quest_num[i];
285 quest_type* const q_ptr = &quest[q_idx];
287 if (((q_ptr->status == QUEST_STATUS_FAILED_DONE) || (q_ptr->status == QUEST_STATUS_FAILED)) &&
288 do_cmd_knowledge_quests_aux(creature_ptr, fff, q_idx))
294 if (!total) fprintf(fff, _(" なし\n", " Nothing.\n"));
299 * Print all random quests
301 static void do_cmd_knowledge_quests_wiz_random(FILE *fff)
303 fprintf(fff, _("《残りのランダムクエスト》\n", "< Remaining Random Quest >\n"));
304 GAME_TEXT tmp_str[120];
306 for (QUEST_IDX i = 1; i < max_q_idx; i++)
308 if (quest[i].flags & QUEST_FLAG_SILENT) continue;
310 if ((quest[i].type == QUEST_TYPE_RANDOM) && (quest[i].status == QUEST_STATUS_TAKEN))
313 sprintf(tmp_str, _(" %s (%d階, %s)\n", " %s (%d, %s)\n"),
314 quest[i].name, (int)quest[i].level, r_name + r_info[quest[i].r_idx].name);
319 if (!total) fprintf(fff, _(" なし\n", " Nothing.\n"));
323 * Print quest status of all active quests
324 * @param creature_ptr プレーヤーへの参照ポインタ
327 void do_cmd_knowledge_quests(player_type *creature_ptr)
330 GAME_TEXT file_name[FILE_NAME_SIZE];
331 if (!open_temporary_file(&fff, file_name)) return;
334 C_MAKE(quest_num, max_q_idx, QUEST_IDX);
336 for (IDX i = 1; i < max_q_idx; i++)
340 ang_sort(quest_num, &dummy, max_q_idx, ang_sort_comp_quest_num, ang_sort_swap_quest_num);
342 do_cmd_knowledge_quests_current(creature_ptr, fff);
344 do_cmd_knowledge_quests_completed(creature_ptr, fff, quest_num);
346 do_cmd_knowledge_quests_failed(creature_ptr, fff, quest_num);
347 if (current_world_ptr->wizard)
350 do_cmd_knowledge_quests_wiz_random(fff);
354 (void)show_file(creature_ptr, TRUE, file_name, _("クエスト達成状況", "Quest status"), 0, 0);
356 C_KILL(quest_num, max_q_idx, QUEST_IDX);