OSDN Git Service

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