OSDN Git Service

Merge pull request #716 from sikabane-works/release/3.0.0Alpha16
[hengbandforosx/hengbandosx.git] / src / player-info / self-info.cpp
1 /*!
2  * @brief 自己分析処理/ Self knowledge
3  * @date 2018/09/07
4  * @author deskull
5  * <pre>
6  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
7  * This software may be copied and distributed for educational, research,
8  * and not for profit purposes provided that this copyright and statement
9  * are included in all such copies.  Other copyrights may also apply.
10  * </pre>
11  */
12
13 #include "player-info/self-info.h"
14 #include "io/input-key-acceptor.h"
15 #include "object-enchant/trc-types.h"
16 #include "player-info/avatar.h"
17 #include "player-info/base-status-info.h"
18 #include "player-info/body-improvement-info.h"
19 #include "player-info/class-ability-info.h"
20 #include "player-info/mutation-info.h"
21 #include "player-info/race-ability-info.h"
22 #include "player-info/resistance-info.h"
23 #include "player-info/self-info-util.h"
24 #include "player-info/weapon-effect-info.h"
25 #include "player/attack-defense-types.h"
26 #include "player/player-status-flags.h"
27 #include "term/screen-processor.h"
28 #include "view/display-self-info.h"
29
30 static void set_bad_status_info(player_type *creature_ptr, self_info_type *self_ptr)
31 {
32     if (creature_ptr->blind)
33         self_ptr->info[self_ptr->line++] = _("あなたは目が見えない。", "You cannot see.");
34
35     if (creature_ptr->confused)
36         self_ptr->info[self_ptr->line++] = _("あなたは混乱している。", "You are confused.");
37
38     if (creature_ptr->afraid)
39         self_ptr->info[self_ptr->line++] = _("あなたは恐怖に侵されている。", "You are terrified.");
40
41     if (creature_ptr->cut)
42         self_ptr->info[self_ptr->line++] = _("あなたは出血している。", "You are bleeding.");
43
44     if (creature_ptr->stun)
45         self_ptr->info[self_ptr->line++] = _("あなたはもうろうとしている。", "You are stunned.");
46
47     if (creature_ptr->poisoned)
48         self_ptr->info[self_ptr->line++] = _("あなたは毒に侵されている。", "You are poisoned.");
49
50     if (creature_ptr->image)
51         self_ptr->info[self_ptr->line++] = _("あなたは幻覚を見ている。", "You are hallucinating.");
52 }
53
54 static void set_curse_info(player_type *creature_ptr, self_info_type *self_ptr)
55 {
56     if (creature_ptr->cursed & TRC_TY_CURSE)
57         self_ptr->info[self_ptr->line++] = _("あなたは邪悪な怨念に包まれている。", "You carry an ancient foul curse.");
58
59     if (has_aggravate(creature_ptr))
60         self_ptr->info[self_ptr->line++] = _("あなたはモンスターを怒らせている。", "You aggravate monsters.");
61
62     if (creature_ptr->cursed & TRC_DRAIN_EXP)
63         self_ptr->info[self_ptr->line++] = _("あなたは経験値を吸われている。", "You occasionally lose experience for no reason.");
64
65     if (creature_ptr->cursed & TRC_SLOW_REGEN)
66         self_ptr->info[self_ptr->line++] = _("あなたの回復力は非常に遅い。", "You regenerate slowly.");
67
68     if (creature_ptr->cursed & TRC_ADD_L_CURSE)
69         self_ptr->info[self_ptr->line++] = _("あなたの弱い呪いは増える。", "Your weak curses multiply."); /* 暫定的 -- henkma */
70
71     if (creature_ptr->cursed & TRC_ADD_H_CURSE)
72         self_ptr->info[self_ptr->line++] = _("あなたの強い呪いは増える。", "Your heavy curses multiply."); /* 暫定的 -- henkma */
73
74     if (creature_ptr->cursed & TRC_CALL_ANIMAL)
75         self_ptr->info[self_ptr->line++] = _("あなたは動物に狙われている。", "You attract animals.");
76
77     if (creature_ptr->cursed & TRC_CALL_DEMON)
78         self_ptr->info[self_ptr->line++] = _("あなたは悪魔に狙われている。", "You attract demons.");
79
80     if (creature_ptr->cursed & TRC_CALL_DRAGON)
81         self_ptr->info[self_ptr->line++] = _("あなたはドラゴンに狙われている。", "You attract dragons.");
82
83     if (creature_ptr->cursed & TRC_COWARDICE)
84         self_ptr->info[self_ptr->line++] = _("あなたは時々臆病になる。", "You are subject to cowardice.");
85
86     if (creature_ptr->cursed & TRC_TELEPORT)
87         self_ptr->info[self_ptr->line++] = _("あなたの位置はひじょうに不安定だ。", "Your position is very uncertain.");
88
89     if (creature_ptr->cursed & TRC_LOW_MELEE)
90         self_ptr->info[self_ptr->line++] = _("あなたの武器は攻撃を外しやすい。", "Your weapon causes you to miss blows.");
91
92     if (creature_ptr->cursed & TRC_LOW_AC)
93         self_ptr->info[self_ptr->line++] = _("あなたは攻撃を受けやすい。", "You are subject to be hit.");
94
95     if (creature_ptr->cursed & TRC_LOW_MAGIC)
96         self_ptr->info[self_ptr->line++] = _("あなたは魔法を失敗しやすい。", "Your spells fail more frequently.");
97
98     if (creature_ptr->cursed & TRC_FAST_DIGEST)
99         self_ptr->info[self_ptr->line++] = _("あなたはすぐお腹がへる。", "You have a good appetite.");
100
101     if (creature_ptr->cursed & TRC_DRAIN_HP)
102         self_ptr->info[self_ptr->line++] = _("あなたは体力を吸われている。", "You occasionally lose hit points for no reason.");
103
104     if (creature_ptr->cursed & TRC_DRAIN_MANA)
105         self_ptr->info[self_ptr->line++] = _("あなたは魔力を吸われている。", "You occasionally lose spell points for no reason.");
106 }
107
108 static void set_special_attack_info(player_type *creature_ptr, self_info_type *self_ptr)
109 {
110     if (creature_ptr->special_attack & ATTACK_CONFUSE)
111         self_ptr->info[self_ptr->line++] = _("あなたの手は赤く輝いている。", "Your hands are glowing dull red.");
112
113     if (creature_ptr->special_attack & ATTACK_FIRE)
114         self_ptr->info[self_ptr->line++] = _("あなたの手は火炎に覆われている。", "You can strike the enemy with flame.");
115
116     if (creature_ptr->special_attack & ATTACK_COLD)
117         self_ptr->info[self_ptr->line++] = _("あなたの手は冷気に覆われている。", "You can strike the enemy with cold.");
118
119     if (creature_ptr->special_attack & ATTACK_ACID)
120         self_ptr->info[self_ptr->line++] = _("あなたの手は酸に覆われている。", "You can strike the enemy with acid.");
121
122     if (creature_ptr->special_attack & ATTACK_ELEC)
123         self_ptr->info[self_ptr->line++] = _("あなたの手は電撃に覆われている。", "You can strike the enemy with electoric shock.");
124
125     if (creature_ptr->special_attack & ATTACK_POIS)
126         self_ptr->info[self_ptr->line++] = _("あなたの手は毒に覆われている。", "You can strike the enemy with poison.");
127 }
128
129 static void set_esp_info(player_type *creature_ptr, self_info_type *self_ptr)
130 {
131     if (creature_ptr->telepathy)
132         self_ptr->info[self_ptr->line++] = _("あなたはテレパシー能力を持っている。", "You have ESP.");
133
134     if (creature_ptr->esp_animal)
135         self_ptr->info[self_ptr->line++] = _("あなたは自然界の生物の存在を感じる能力を持っている。", "You sense natural creatures.");
136
137     if (creature_ptr->esp_undead)
138         self_ptr->info[self_ptr->line++] = _("あなたはアンデッドの存在を感じる能力を持っている。", "You sense undead.");
139
140     if (creature_ptr->esp_demon)
141         self_ptr->info[self_ptr->line++] = _("あなたは悪魔の存在を感じる能力を持っている。", "You sense demons.");
142
143     if (creature_ptr->esp_orc)
144         self_ptr->info[self_ptr->line++] = _("あなたはオークの存在を感じる能力を持っている。", "You sense orcs.");
145
146     if (creature_ptr->esp_troll)
147         self_ptr->info[self_ptr->line++] = _("あなたはトロルの存在を感じる能力を持っている。", "You sense trolls.");
148
149     if (creature_ptr->esp_giant)
150         self_ptr->info[self_ptr->line++] = _("あなたは巨人の存在を感じる能力を持っている。", "You sense giants.");
151
152     if (creature_ptr->esp_dragon)
153         self_ptr->info[self_ptr->line++] = _("あなたはドラゴンの存在を感じる能力を持っている。", "You sense dragons.");
154
155     if (creature_ptr->esp_human)
156         self_ptr->info[self_ptr->line++] = _("あなたは人間の存在を感じる能力を持っている。", "You sense humans.");
157
158     if (creature_ptr->esp_evil)
159         self_ptr->info[self_ptr->line++] = _("あなたは邪悪な生き物の存在を感じる能力を持っている。", "You sense evil creatures.");
160
161     if (creature_ptr->esp_good)
162         self_ptr->info[self_ptr->line++] = _("あなたは善良な生き物の存在を感じる能力を持っている。", "You sense good creatures.");
163
164     if (creature_ptr->esp_nonliving)
165         self_ptr->info[self_ptr->line++] = _("あなたは活動する無生物体の存在を感じる能力を持っている。", "You sense non-living creatures.");
166
167     if (creature_ptr->esp_unique)
168         self_ptr->info[self_ptr->line++] = _("あなたは特別な強敵の存在を感じる能力を持っている。", "You sense unique monsters.");
169 }
170
171 /*!
172  * @brief 自己分析処理(Nethackからのアイデア) / self-knowledge... idea from nethack.
173  * @return なし
174  * @details
175  * <pre>
176  * Useful for determining powers and
177  * resistences of items.  It saves the screen, clears it, then starts listing
178  * attributes, a screenful at a time.  (There are a LOT of attributes to
179  * list.  It will probably take 2 or 3 screens for a powerful character whose
180  * using several artifacts...) -CFT
181  *
182  * It is now a lot more efficient. -BEN-
183  *
184  * See also "identify_fully()".
185  *
186  * Use the "show_file()" method, perhaps.
187  * </pre>
188  */
189 void self_knowledge(player_type *creature_ptr)
190 {
191     self_info_type tmp_si;
192     self_info_type *self_ptr = initialize_self_info_type(&tmp_si);
193     display_life_rating(creature_ptr, self_ptr);
194     chg_virtue(creature_ptr, V_KNOWLEDGE, 1);
195     chg_virtue(creature_ptr, V_ENLIGHTEN, 1);
196     display_max_base_status(creature_ptr, self_ptr);
197     display_virtue(creature_ptr, self_ptr);
198     self_ptr->info[self_ptr->line++] = "";
199     if (creature_ptr->mimic_form)
200         display_mimic_race_ability(creature_ptr, self_ptr);
201     else
202         set_race_ability_info(creature_ptr, self_ptr);
203
204     set_class_ability_info(creature_ptr, self_ptr);
205     set_mutation_info(creature_ptr, self_ptr);
206     set_bad_status_info(creature_ptr, self_ptr);
207     set_curse_info(creature_ptr, self_ptr);
208     set_body_improvement_info_1(creature_ptr, self_ptr);
209     set_special_attack_info(creature_ptr, self_ptr);
210     switch (creature_ptr->action) {
211     case ACTION_SEARCH:
212         self_ptr->info[self_ptr->line++] = _("あなたはひじょうに注意深く周囲を見渡している。", "You are looking around very carefully.");
213         break;
214     }
215
216     set_body_improvement_info_2(creature_ptr, self_ptr);
217     set_esp_info(creature_ptr, self_ptr);
218     set_body_improvement_info_3(creature_ptr, self_ptr);
219     set_element_resistance_info(creature_ptr, self_ptr);
220     set_high_resistance_info(creature_ptr, self_ptr);
221     set_body_improvement_info_4(creature_ptr, self_ptr);
222     set_status_sustain_info(creature_ptr, self_ptr);
223     set_equipment_influence(creature_ptr, self_ptr);
224     set_weapon_effect_info(creature_ptr, self_ptr);
225     display_self_info(self_ptr);
226 }
227
228 /*!
229  * @brief 魔法効果時間のターン数に基づいて表現IDを返す。
230  * @param dur 効果ターン数
231  * @return 効果時間の表現ID
232  */
233 static int report_magics_aux(int dur)
234 {
235     if (dur <= 5) {
236         return 0;
237     } else if (dur <= 10) {
238         return 1;
239     } else if (dur <= 20) {
240         return 2;
241     } else if (dur <= 50) {
242         return 3;
243     } else if (dur <= 100) {
244         return 4;
245     } else if (dur <= 200) {
246         return 5;
247     } else {
248         return 6;
249     }
250 }
251
252 static concptr report_magic_durations[] = { _("ごく短い間", "for a short time"), _("少しの間", "for a little while"), _("しばらくの間", "for a while"),
253     _("多少長い間", "for a long while"), _("長い間", "for a long time"), _("非常に長い間", "for a very long time"),
254     _("信じ難いほど長い間", "for an incredibly long time"), _("モンスターを攻撃するまで", "until you hit a monster") };
255
256 /*!
257  * @brief 現在の一時的効果一覧を返す / Report all currently active magical effects.
258  * @return なし
259  */
260 void report_magics(player_type *creature_ptr)
261 {
262     int i = 0;
263     concptr info[128];
264     int info2[128];
265     if (creature_ptr->blind) {
266         info2[i] = report_magics_aux(creature_ptr->blind);
267         info[i++] = _("あなたは目が見えない", "You cannot see");
268     }
269
270     if (creature_ptr->confused) {
271         info2[i] = report_magics_aux(creature_ptr->confused);
272         info[i++] = _("あなたは混乱している", "You are confused");
273     }
274
275     if (creature_ptr->afraid) {
276         info2[i] = report_magics_aux(creature_ptr->afraid);
277         info[i++] = _("あなたは恐怖に侵されている", "You are terrified");
278     }
279
280     if (creature_ptr->poisoned) {
281         info2[i] = report_magics_aux(creature_ptr->poisoned);
282         info[i++] = _("あなたは毒に侵されている", "You are poisoned");
283     }
284
285     if (creature_ptr->image) {
286         info2[i] = report_magics_aux(creature_ptr->image);
287         info[i++] = _("あなたは幻覚を見ている", "You are hallucinating");
288     }
289
290     if (creature_ptr->blessed) {
291         info2[i] = report_magics_aux(creature_ptr->blessed);
292         info[i++] = _("あなたは高潔さを感じている", "You feel rightous");
293     }
294
295     if (creature_ptr->hero) {
296         info2[i] = report_magics_aux(creature_ptr->hero);
297         info[i++] = _("あなたはヒーロー気分だ", "You feel heroic");
298     }
299
300     if (is_shero(creature_ptr)) {
301         info2[i] = report_magics_aux(creature_ptr->shero);
302         info[i++] = _("あなたは戦闘狂だ", "You are in a battle rage");
303     }
304
305     if (creature_ptr->protevil) {
306         info2[i] = report_magics_aux(creature_ptr->protevil);
307         info[i++] = _("あなたは邪悪なる存在から守られている", "You are protected from evil");
308     }
309
310     if (creature_ptr->shield) {
311         info2[i] = report_magics_aux(creature_ptr->shield);
312         info[i++] = _("あなたは神秘のシールドで守られている", "You are protected by a mystic shield");
313     }
314
315     if (creature_ptr->invuln) {
316         info2[i] = report_magics_aux(creature_ptr->invuln);
317         info[i++] = _("あなたは無敵だ", "You are invulnerable");
318     }
319
320     if (creature_ptr->wraith_form) {
321         info2[i] = report_magics_aux(creature_ptr->wraith_form);
322         info[i++] = _("あなたは幽体化している", "You are incorporeal");
323     }
324
325     if (creature_ptr->special_attack & ATTACK_CONFUSE) {
326         info2[i] = 7;
327         info[i++] = _("あなたの手は赤く輝いている", "Your hands are glowing dull red.");
328     }
329
330     if (creature_ptr->word_recall) {
331         info2[i] = report_magics_aux(creature_ptr->word_recall);
332         info[i++] = _("この後帰還の詔が発動する", "You are waiting to be recalled");
333     }
334
335     if (creature_ptr->alter_reality) {
336         info2[i] = report_magics_aux(creature_ptr->alter_reality);
337         info[i++] = _("この後現実変容が発動する", "You waiting to be altered");
338     }
339
340     if (creature_ptr->oppose_acid) {
341         info2[i] = report_magics_aux(creature_ptr->oppose_acid);
342         info[i++] = _("あなたは酸への耐性を持っている", "You are resistant to acid");
343     }
344
345     if (creature_ptr->oppose_elec) {
346         info2[i] = report_magics_aux(creature_ptr->oppose_elec);
347         info[i++] = _("あなたは電撃への耐性を持っている", "You are resistant to lightning");
348     }
349
350     if (creature_ptr->oppose_fire) {
351         info2[i] = report_magics_aux(creature_ptr->oppose_fire);
352         info[i++] = _("あなたは火への耐性を持っている", "You are resistant to fire");
353     }
354
355     if (creature_ptr->oppose_cold) {
356         info2[i] = report_magics_aux(creature_ptr->oppose_cold);
357         info[i++] = _("あなたは冷気への耐性を持っている", "You are resistant to cold");
358     }
359
360     if (creature_ptr->oppose_pois) {
361         info2[i] = report_magics_aux(creature_ptr->oppose_pois);
362         info[i++] = _("あなたは毒への耐性を持っている", "You are resistant to poison");
363     }
364
365     screen_save();
366
367     /* Erase the screen */
368     for (int k = 1; k < 24; k++)
369         prt("", k, 13);
370
371     prt(_("    現在かかっている魔法     :", "     Your Current Magic:"), 1, 15);
372     int k = 2;
373     char buf[80];
374     for (int j = 0; j < i; j++) {
375         sprintf(buf, _("%-28s : 期間 - %s ", "%s %s."), info[j], report_magic_durations[info2[j]]);
376         prt(buf, k++, 15);
377
378         /* Every 20 entries (lines 2 to 21), start over */
379         if ((k == 22) && (j + 1 < i)) {
380             prt(_("-- 続く --", "-- more --"), k, 15);
381             inkey();
382             for (; k > 2; k--)
383                 prt("", k, 15);
384         }
385     }
386
387     prt(_("[何かキーを押すとゲームに戻ります]", "[Press any key to continue]"), k, 13);
388     inkey();
389     screen_load();
390 }