OSDN Git Service

[Refactor] #40236 アンデッド種族で宿屋に泊まった場合のメッセージを拡張した (日本語のみ)
[hengband/hengband.git] / src / cmd / cmd-inn.c
1 #include "angband.h"
2 #include "cmd/cmd-inn.h"
3 #include "cmd/cmd-magiceat.h"
4 #include "io/write-diary.h"
5 #include "world.h"
6 #include "player-effects.h"
7 #include "core.h" // 暫定、後で消す.
8 #include "rumor.h"
9
10 /*!
11  * @brief 宿屋で食事を摂る
12  * @param customer_ptr プレーヤーへの参照ポインタ
13  * @return 満腹ならFALSE、そうでないならTRUE
14  */
15 static bool buy_food(player_type *customer_ptr)
16 {
17         if (customer_ptr->food >= PY_FOOD_FULL)
18         {
19                 msg_print(_("今は満腹だ。", "You are full now."));
20                 return FALSE;
21         }
22
23         msg_print(_("バーテンはいくらかの食べ物とビールをくれた。", "The barkeep gives you some gruel and a beer."));
24         (void)set_food(customer_ptr, PY_FOOD_MAX - 1);
25         return TRUE;
26 }
27
28
29 /*!
30  * @brief 健康体しか宿屋に泊めない処理
31  * @param customer_ptr プレーヤーへの参照ポインタ
32  * @return 毒でも切り傷でもないならTRUE、そうでないならFALSE
33  */
34 static bool is_healthy_stay(player_type *customer_ptr)
35 {
36         if (!customer_ptr->poisoned && !customer_ptr->cut) return TRUE;
37
38         msg_print(_("あなたに必要なのは部屋ではなく、治療者です。", "You need a healer, not a room."));
39         msg_print(NULL);
40         msg_print(_("すみません、でもうちで誰かに死なれちゃ困りますんで。", "Sorry, but don't want anyone dying in here."));
41         return FALSE;
42 }
43
44
45 static bool is_player_undead(player_type *customer_ptr)
46 {
47         bool is_player_undead = PRACE_IS_(customer_ptr, RACE_SKELETON) ||
48                 PRACE_IS_(customer_ptr, RACE_ZOMBIE) ||
49                 PRACE_IS_(customer_ptr, RACE_VAMPIRE) ||
50                 PRACE_IS_(customer_ptr, RACE_SPECTRE);
51         return is_player_undead;
52 }
53
54
55 /*!
56  * @brief 宿屋に泊まったことを日記に残す
57  * @param customer_ptr プレーヤーへの参照ポインタ
58  * @param prev_hour 宿屋に入った直後のゲーム内時刻
59  * @return なし
60  */
61 static void write_diary_stay_inn(player_type *customer_ptr, int prev_hour)
62 {
63         if ((prev_hour >= 6) && (prev_hour < 18))
64         {
65                 concptr stay_message_jp = is_player_undead(customer_ptr) ? "宿屋に泊まった。" : "日が暮れるまで宿屋で過ごした。";
66                 exe_write_diary(customer_ptr, DIARY_DESCRIPTION, 0, _(stay_message_jp, "stayed during the day at the inn."));
67                 return;
68         }
69
70         concptr stay_message_jp = is_player_undead(customer_ptr) ? "夜が明けるまで宿屋で過ごした。" : "宿屋に泊まった。";
71         exe_write_diary(customer_ptr, DIARY_DESCRIPTION, 0, _(stay_message_jp, "stayed overnight at the inn."));
72 }
73
74
75 /*!
76  * @brief 宿泊によってゲーム内ターンを経過させる
77  * @param なし
78  * @return なし
79  */
80 static void pass_game_turn_by_stay(void)
81 {
82         s32b oldturn = current_world_ptr->game_turn;
83         current_world_ptr->game_turn =
84                 (current_world_ptr->game_turn / (TURNS_PER_TICK * TOWN_DAWN / 2) + 1) *
85                 (TURNS_PER_TICK * TOWN_DAWN / 2);
86         if (current_world_ptr->dungeon_turn >= current_world_ptr->dungeon_turn_limit)
87                 return;
88
89         current_world_ptr->dungeon_turn += MIN((current_world_ptr->game_turn - oldturn), TURNS_PER_TICK * 250) * INN_DUNGEON_TURN_ADJ;
90         if (current_world_ptr->dungeon_turn > current_world_ptr->dungeon_turn_limit)
91                 current_world_ptr->dungeon_turn = current_world_ptr->dungeon_turn_limit;
92 }
93
94
95 /*!
96  * @brief 悪夢モードなら悪夢を見せる
97  * @param customer_ptr プレーヤーへの参照ポインタ
98  * @return 悪夢モードならばTRUE
99  */
100 static bool have_a_nightmare(player_type *customer_ptr)
101 {
102         if (!ironman_nightmare) return FALSE;
103
104         msg_print(_("眠りに就くと恐ろしい光景が心をよぎった。", "Horrible visions flit through your mind as you sleep."));
105
106         while (TRUE)
107         {
108                 sanity_blast(customer_ptr, NULL, FALSE);
109                 if (!one_in_(3)) break;
110         }
111
112         msg_print(_("あなたは絶叫して目を覚ました。", "You awake screaming."));
113         exe_write_diary(customer_ptr, DIARY_DESCRIPTION, 0, _("悪夢にうなされてよく眠れなかった。", "had a nightmare."));
114         return TRUE;
115 }
116
117
118 /*!
119  * @brief 体調を元に戻す
120  * @param customer_ptr プレーヤーへの参照ポインタ
121  * @return なし
122  */
123 static void back_to_health(player_type *customer_ptr)
124 {
125         set_blind(customer_ptr, 0);
126         set_confused(customer_ptr, 0);
127         customer_ptr->stun = 0;
128         customer_ptr->chp = customer_ptr->mhp;
129         customer_ptr->csp = customer_ptr->msp;
130 }
131
132
133 /*!
134  * @brief 魔力喰いの残り回数回復(本当? 要調査)
135  * @param customer_ptr プレーヤーへの参照ポインタ
136  * @return なし
137  */
138 static void charge_magic_eating_energy(player_type *customer_ptr)
139 {
140         if (customer_ptr->pclass != CLASS_MAGIC_EATER)
141                 return;
142
143         int i;
144         for (i = 0; i < 72; i++)
145         {
146                 customer_ptr->magic_num1[i] = customer_ptr->magic_num2[i] * EATER_CHARGE;
147         }
148
149         for (; i < 108; i++)
150         {
151                 customer_ptr->magic_num1[i] = 0;
152         }
153 }
154
155
156 /*!
157  * @brief リフレッシュ結果を画面に表示する
158  * @param customer_ptr プレーヤーへの参照ポインタ
159  * @param prev_hour 宿屋に入った直後のゲーム内時刻
160  */
161 static void display_stay_result(player_type *customer_ptr, int prev_hour)
162 {
163         if ((prev_hour >= 6) && (prev_hour < 18))
164         {
165                 char refresh_message_jp[50];
166                 sprintf(refresh_message_jp, "%s%s%s", "あなたはリフレッシュして目覚め、", is_player_undead(customer_ptr) ? "夜" : "夕方", "を迎えた。");
167                 msg_print(_(refresh_message_jp, "You awake refreshed for the evening."));
168                 concptr awake_message_jp = is_player_undead(customer_ptr) ? "すがすがしい夜を迎えた。" : "夕方を迎えた。";
169                 exe_write_diary(customer_ptr, DIARY_DESCRIPTION, 0, _(awake_message_jp, "awoke refreshed."));
170                 return;
171         }
172
173         msg_print(_("あなたはリフレッシュして目覚め、新たな日を迎えた。", "You awake refreshed for the new day."));
174         concptr awake_message_jp = is_player_undead(customer_ptr) ? "すがすがしい朝を迎えた。" : "朝を迎えた。";
175         exe_write_diary(customer_ptr, DIARY_DESCRIPTION, 0, _(awake_message_jp, "awoke refreshed."));
176 }
177
178
179 /*!
180  * @brief 宿屋への宿泊実行処理
181  * @param customer_ptr プレーヤーへの参照ポインタ
182  * @return 泊まれたらTRUE
183  */
184 static bool stay_inn(player_type *customer_ptr)
185 {
186         if (!is_healthy_stay(customer_ptr)) return FALSE;
187
188         int prev_day, prev_hour, prev_min;
189         extract_day_hour_min(customer_ptr, &prev_day, &prev_hour, &prev_min);
190         write_diary_stay_inn(customer_ptr, prev_hour);
191
192         pass_game_turn_by_stay();
193         prevent_turn_overflow(customer_ptr);
194
195         if ((prev_hour >= 18) && (prev_hour <= 23))
196                 exe_write_diary(customer_ptr, DIARY_DIALY, 0, NULL);
197
198         customer_ptr->chp = customer_ptr->mhp;
199         if (have_a_nightmare(customer_ptr)) return TRUE;
200
201         back_to_health(customer_ptr);
202         charge_magic_eating_energy(customer_ptr);
203
204         display_stay_result(customer_ptr, prev_hour);
205         return TRUE;
206 }
207
208
209 /*!
210  * todo 悪夢を見る前後に全回復しているが、何か意図がある?
211  * @brief 宿屋を利用する
212  * @param customer_ptr プレーヤーへの参照ポインタ
213  * @param cmd 宿屋の利用施設ID
214  * @return 施設の利用が実際に行われたらTRUE
215  * @details inn commands
216  * Note that resting for the night was a perfect way to avoid player
217  * ghosts in the town *if* you could only make it to the inn in time (-:
218  * Now that the ghosts are temporarily disabled in 2.8.X, this function
219  * will not be that useful.  I will keep it in the hopes the player
220  * ghost code does become a reality again. Does help to avoid filthy urchins.
221  * Resting at night is also a quick way to restock stores -KMW-
222  */
223 bool inn_comm(player_type *customer_ptr, int cmd)
224 {
225         switch (cmd)
226         {
227         case BACT_FOOD:
228                 return buy_food(customer_ptr);
229         case BACT_REST:
230                 return stay_inn(customer_ptr);
231         case BACT_RUMORS:
232                 display_rumor(customer_ptr, TRUE);
233                 return TRUE;
234         default:
235                 // todo リファクタリング前のコードもTRUEだった、FALSEにすべきでは.
236                 return TRUE;
237         }
238 }