OSDN Git Service

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