OSDN Git Service

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