OSDN Git Service

[Refactor] #40413 Separated display-messages.c/h from util.c/h
[hengband/hengband.git] / src / market / building-quest.c
1 #include "market/building-quest.h"
2 #include "info-reader/fixed-map-parser.h"
3 #include "dungeon/quest.h"
4 #include "floor/floor.h"
5 #include "market/building-util.h"
6 #include "monster-race/race-flags1.h"
7 #include "monster/monster-list.h"
8 #include "system/system-variables.h"
9 #include "term/term-color-types.h"
10 #include "view/display-messages.h"
11
12 /*!
13  * @brief クエスト情報を表示しつつ処理する。/ Display quest information
14  * @param player_ptr プレーヤーへの参照ポインタ
15  * @param questnum クエストのID
16  * @param do_init クエストの開始処理(TRUE)、結果処理か(FALSE)
17  * @return なし
18  */
19 static void get_questinfo(player_type *player_ptr, IDX questnum, bool do_init)
20 {
21     for (int i = 0; i < 10; i++) {
22         quest_text[i][0] = '\0';
23     }
24
25     quest_text_line = 0;
26
27     floor_type *floor_ptr = player_ptr->current_floor_ptr;
28     QUEST_IDX old_quest = floor_ptr->inside_quest;
29     floor_ptr->inside_quest = questnum;
30
31     init_flags = INIT_SHOW_TEXT;
32     if (do_init)
33         init_flags |= INIT_ASSIGN;
34
35     parse_fixed_map(player_ptr, "q_info.txt", 0, 0, 0, 0);
36     floor_ptr->inside_quest = old_quest;
37
38     GAME_TEXT tmp_str[80];
39     sprintf(tmp_str, _("クエスト情報 (危険度: %d 階相当)", "Quest Information (Danger level: %d)"), (int)quest[questnum].level);
40     prt(tmp_str, 5, 0);
41     prt(quest[questnum].name, 7, 0);
42
43     for (int i = 0; i < 10; i++) {
44         c_put_str(TERM_YELLOW, quest_text[i], i + 8, 0);
45     }
46 }
47
48 /*!
49  * @brief クエスト処理のメインルーチン / Request a quest from the Lord.
50  * @param player_ptr プレーヤーへの参照ポインタ
51  * @return なし
52  */
53 void castle_quest(player_type *player_ptr)
54 {
55     clear_bldg(4, 18);
56     QUEST_IDX q_index = player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x].special;
57
58     if (!q_index) {
59         put_str(_("今のところクエストはありません。", "I don't have a quest for you at the moment."), 8, 0);
60         return;
61     }
62
63     quest_type *q_ptr;
64     q_ptr = &quest[q_index];
65     if (q_ptr->status == QUEST_STATUS_COMPLETED) {
66         q_ptr->status = QUEST_STATUS_REWARDED;
67         get_questinfo(player_ptr, q_index, FALSE);
68         reinit_wilderness = TRUE;
69         return;
70     }
71
72     if (q_ptr->status == QUEST_STATUS_FAILED) {
73         get_questinfo(player_ptr, q_index, FALSE);
74         q_ptr->status = QUEST_STATUS_FAILED_DONE;
75         reinit_wilderness = TRUE;
76         return;
77     }
78
79     if (q_ptr->status == QUEST_STATUS_TAKEN) {
80         put_str(_("あなたは現在のクエストを終了させていません!", "You have not completed your current quest yet!"), 8, 0);
81         put_str(_("CTRL-Qを使えばクエストの状態がチェックできます。", "Use CTRL-Q to check the status of your quest."), 9, 0);
82         put_str(_("クエストを終わらせたら戻って来て下さい。", "Return when you have completed your quest."), 12, 0);
83         return;
84     }
85
86     if (q_ptr->status != QUEST_STATUS_UNTAKEN)
87         return;
88
89     q_ptr->status = QUEST_STATUS_TAKEN;
90     reinit_wilderness = TRUE;
91     if (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL) {
92         get_questinfo(player_ptr, q_index, TRUE);
93         return;
94     }
95
96     if (q_ptr->r_idx == 0) {
97         q_ptr->r_idx = get_mon_num(player_ptr, q_ptr->level + 4 + randint1(6), 0);
98     }
99
100     monster_race *r_ptr;
101     r_ptr = &r_info[q_ptr->r_idx];
102     while ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->rarity != 1)) {
103         q_ptr->r_idx = get_mon_num(player_ptr, q_ptr->level + 4 + randint1(6), 0);
104         r_ptr = &r_info[q_ptr->r_idx];
105     }
106
107     if (q_ptr->max_num == 0) {
108         if (randint1(10) > 7)
109             q_ptr->max_num = 1;
110         else
111             q_ptr->max_num = randint1(3) + 1;
112     }
113
114     q_ptr->cur_num = 0;
115     concptr name = (r_name + r_ptr->name);
116 #ifdef JP
117     msg_format("クエスト: %sを %d体倒す", name, q_ptr->max_num);
118 #else
119     msg_format("Your quest: kill %d %s", q_ptr->max_num, name);
120 #endif
121     get_questinfo(player_ptr, q_index, TRUE);
122 }