OSDN Git Service

Merge remote-tracking branch 'remotes/origin/For2.2.2-Fix-Hourier' into For2.2.2...
[hengband/hengband.git] / src / knowledge / knowledge-experiences.c
1 /*!
2  * @brief 技能の経験を表示する
3  * @date 2020/04/23
4  * @author Hourier
5  */
6
7 #include "angband.h"
8 #include "knowledge-experiences.h"
9 #include "cmd/dump-util.h"
10 #include "core/show-file.h"
11 #include "object-flavor.h"
12 #include "object/object-kind.h"
13 #include "player-skill.h"
14 #include "spell/technic-info-table.h"
15 #include "spell/spells-util.h"
16 #include "spell/spells-execution.h"
17
18 /*
19  * Display weapon-exp
20  */
21 void do_cmd_knowledge_weapon_exp(player_type *creature_ptr)
22 {
23         FILE *fff = NULL;
24         GAME_TEXT file_name[FILE_NAME_SIZE];
25         if (!open_temporary_file(&fff, file_name)) return;
26
27         for (int i = 0; i < 5; i++)
28         {
29                 for (int num = 0; num < 64; num++)
30                 {
31                         SUB_EXP weapon_exp;
32                         char tmp[30];
33                         for (KIND_OBJECT_IDX j = 0; j < max_k_idx; j++)
34                         {
35                                 object_kind *k_ptr = &k_info[j];
36
37                                 if ((k_ptr->tval != TV_SWORD - i) || (k_ptr->sval != num)) continue;
38                                 if ((k_ptr->tval == TV_BOW) && (k_ptr->sval == SV_CRIMSON || k_ptr->sval == SV_HARP)) continue;
39
40                                 weapon_exp = creature_ptr->weapon_exp[4 - i][num];
41                                 strip_name(tmp, j);
42                                 fprintf(fff, "%-25s ", tmp);
43                                 if (weapon_exp >= s_info[creature_ptr->pclass].w_max[4 - i][num]) fprintf(fff, "!");
44                                 else fprintf(fff, " ");
45                                 fprintf(fff, "%s", exp_level_str[weapon_exp_level(weapon_exp)]);
46                                 if (cheat_xtra) fprintf(fff, " %d", weapon_exp);
47                                 fprintf(fff, "\n");
48                                 break;
49                         }
50                 }
51         }
52
53         my_fclose(fff);
54         (void)show_file(creature_ptr, TRUE, file_name, _("武器の経験値", "Weapon Proficiency"), 0, 0);
55         fd_kill(file_name);
56 }
57
58
59 /*!
60  * @brief 魔法の経験値を表示するコマンドのメインルーチン
61  * Display spell-exp
62  * @return なし
63  */
64 void do_cmd_knowledge_spell_exp(player_type *creature_ptr)
65 {
66         FILE *fff = NULL;
67         GAME_TEXT file_name[FILE_NAME_SIZE];
68         if (!open_temporary_file(&fff, file_name)) return;
69
70         if (creature_ptr->realm1 != REALM_NONE)
71         {
72                 fprintf(fff, _("%sの魔法書\n", "%s Spellbook\n"), realm_names[creature_ptr->realm1]);
73                 for (SPELL_IDX i = 0; i < 32; i++)
74                 {
75                         const magic_type *s_ptr;
76                         if (!is_magic(creature_ptr->realm1))
77                         {
78                                 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][i];
79                         }
80                         else
81                         {
82                                 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][i];
83                         }
84
85                         if (s_ptr->slevel >= 99) continue;
86                         SUB_EXP spell_exp = creature_ptr->spell_exp[i];
87                         int exp_level = spell_exp_level(spell_exp);
88                         fprintf(fff, "%-25s ", exe_spell(creature_ptr, creature_ptr->realm1, i, SPELL_NAME));
89                         if (creature_ptr->realm1 == REALM_HISSATSU)
90                                 fprintf(fff, "[--]");
91                         else
92                         {
93                                 if (exp_level >= EXP_LEVEL_MASTER) fprintf(fff, "!");
94                                 else fprintf(fff, " ");
95                                 fprintf(fff, "%s", exp_level_str[exp_level]);
96                         }
97
98                         if (cheat_xtra) fprintf(fff, " %d", spell_exp);
99                         fprintf(fff, "\n");
100                 }
101         }
102
103         if (creature_ptr->realm2 != REALM_NONE)
104         {
105                 fprintf(fff, _("%sの魔法書\n", "\n%s Spellbook\n"), realm_names[creature_ptr->realm2]);
106                 for (SPELL_IDX i = 0; i < 32; i++)
107                 {
108                         const magic_type *s_ptr;
109                         if (!is_magic(creature_ptr->realm1))
110                         {
111                                 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][i];
112                         }
113                         else
114                         {
115                                 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][i];
116                         }
117
118                         if (s_ptr->slevel >= 99) continue;
119
120                         SUB_EXP spell_exp = creature_ptr->spell_exp[i + 32];
121                         int exp_level = spell_exp_level(spell_exp);
122                         fprintf(fff, "%-25s ", exe_spell(creature_ptr, creature_ptr->realm2, i, SPELL_NAME));
123                         if (exp_level >= EXP_LEVEL_EXPERT) fprintf(fff, "!");
124                         else fprintf(fff, " ");
125                         fprintf(fff, "%s", exp_level_str[exp_level]);
126                         if (cheat_xtra) fprintf(fff, " %d", spell_exp);
127                         fprintf(fff, "\n");
128                 }
129         }
130
131         my_fclose(fff);
132         (void)show_file(creature_ptr, TRUE, file_name, _("魔法の経験値", "Spell Proficiency"), 0, 0);
133         fd_kill(file_name);
134 }
135
136
137 /*!
138  * @brief スキル情報を表示するコマンドのメインルーチン /
139  * Display skill-exp
140  * @return なし
141  */
142 void do_cmd_knowledge_skill_exp(player_type *creature_ptr)
143 {
144         char skill_name[GINOU_TEMPMAX][20] =
145         {
146                 _("マーシャルアーツ", "Martial Arts    "),
147                 _("二刀流          ", "Dual Wielding   "),
148                 _("乗馬            ", "Riding          "),
149                 _("盾              ", "Shield          ")
150         };
151
152         FILE *fff = NULL;
153         char file_name[FILE_NAME_SIZE];
154         if (!open_temporary_file(&fff, file_name)) return;
155
156         for (int i = 0; i < GINOU_TEMPMAX; i++)
157         {
158                 int skill_exp = creature_ptr->skill_exp[i];
159                 fprintf(fff, "%-20s ", skill_name[i]);
160                 if (skill_exp >= s_info[creature_ptr->pclass].s_max[i]) fprintf(fff, "!");
161                 else fprintf(fff, " ");
162                 fprintf(fff, "%s", exp_level_str[(i == GINOU_RIDING) ? riding_exp_level(skill_exp) : weapon_exp_level(skill_exp)]);
163                 if (cheat_xtra) fprintf(fff, " %d", skill_exp);
164                 fprintf(fff, "\n");
165         }
166
167         my_fclose(fff);
168         (void)show_file(creature_ptr, TRUE, file_name, _("技能の経験値", "Miscellaneous Proficiency"), 0, 0);
169         fd_kill(file_name);
170 }