OSDN Git Service

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