OSDN Git Service

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