OSDN Git Service

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