OSDN Git Service

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