OSDN Git Service

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