OSDN Git Service

[Refactor] 乗馬スキルの上昇処理を PlayerSkill クラスに移設
[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-info/class-info.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 *player_ptr)
28 {
29     FILE *fff = nullptr;
30     GAME_TEXT file_name[FILE_NAME_SIZE];
31     if (!open_temporary_file(&fff, file_name))
32         return;
33
34     for (auto tval : {ItemKindType::SWORD, ItemKindType::POLEARM, ItemKindType::HAFTED, ItemKindType::DIGGING, ItemKindType::BOW}) {
35         for (int num = 0; num < 64; num++) {
36             char tmp[30];
37             for (const auto &k_ref : k_info) {
38                 if ((k_ref.tval != tval) || (k_ref.sval != num))
39                     continue;
40                 if ((k_ref.tval == ItemKindType::BOW) && (k_ref.sval == SV_CRIMSON || k_ref.sval == SV_HARP))
41                     continue;
42
43                 SUB_EXP weapon_exp = player_ptr->weapon_exp[tval][num];
44                 SUB_EXP weapon_max = s_info[enum2i(player_ptr->pclass)].w_max[tval][num];
45                 strip_name(tmp, k_ref.idx);
46                 fprintf(fff, "%-25s ", tmp);
47                 if (show_actual_value)
48                     fprintf(fff, "%4d/%4d ", std::min(weapon_exp, weapon_max), weapon_max);
49                 if (weapon_exp >= weapon_max)
50                     fprintf(fff, "!");
51                 else
52                     fprintf(fff, " ");
53                 fprintf(fff, "%s", exp_level_str[PlayerSkill::weapon_exp_level(weapon_exp)]);
54                 if (cheat_xtra)
55                     fprintf(fff, " %d", weapon_exp);
56                 fprintf(fff, "\n");
57                 break;
58             }
59         }
60     }
61
62     angband_fclose(fff);
63     (void)show_file(player_ptr, true, file_name, _("武器の経験値", "Weapon Proficiency"), 0, 0);
64     fd_kill(file_name);
65 }
66
67 /*!
68  * @brief 魔法の経験値を表示するコマンドのメインルーチン
69  * Display spell-exp
70  */
71 void do_cmd_knowledge_spell_exp(player_type *player_ptr)
72 {
73     FILE *fff = nullptr;
74     GAME_TEXT file_name[FILE_NAME_SIZE];
75     if (!open_temporary_file(&fff, file_name))
76         return;
77
78     if (player_ptr->realm1 != REALM_NONE) {
79         fprintf(fff, _("%sの魔法書\n", "%s Spellbook\n"), realm_names[player_ptr->realm1]);
80         for (SPELL_IDX i = 0; i < 32; i++) {
81             const magic_type *s_ptr;
82             if (!is_magic(player_ptr->realm1)) {
83                 s_ptr = &technic_info[player_ptr->realm1 - MIN_TECHNIC][i];
84             } else {
85                 s_ptr = &mp_ptr->info[player_ptr->realm1 - 1][i];
86             }
87
88             if (s_ptr->slevel >= 99)
89                 continue;
90             SUB_EXP spell_exp = player_ptr->spell_exp[i];
91             int exp_level = spell_exp_level(spell_exp);
92             fprintf(fff, "%-25s ", exe_spell(player_ptr, player_ptr->realm1, i, SPELL_NAME));
93             if (player_ptr->realm1 == REALM_HISSATSU) {
94                 if (show_actual_value)
95                     fprintf(fff, "----/---- ");
96                 fprintf(fff, "[--]");
97             } else {
98                 if (show_actual_value)
99                     fprintf(fff, "%4d/%4d ", std::min<short>(spell_exp, SPELL_EXP_MASTER), SPELL_EXP_MASTER);
100                 if (exp_level >= EXP_LEVEL_MASTER)
101                     fprintf(fff, "!");
102                 else
103                     fprintf(fff, " ");
104                 fprintf(fff, "%s", exp_level_str[exp_level]);
105             }
106
107             if (cheat_xtra)
108                 fprintf(fff, " %d", spell_exp);
109             fprintf(fff, "\n");
110         }
111     }
112
113     if (player_ptr->realm2 != REALM_NONE) {
114         fprintf(fff, _("%sの魔法書\n", "\n%s Spellbook\n"), realm_names[player_ptr->realm2]);
115         for (SPELL_IDX i = 0; i < 32; i++) {
116             const magic_type *s_ptr;
117             if (!is_magic(player_ptr->realm1)) {
118                 s_ptr = &technic_info[player_ptr->realm2 - MIN_TECHNIC][i];
119             } else {
120                 s_ptr = &mp_ptr->info[player_ptr->realm2 - 1][i];
121             }
122
123             if (s_ptr->slevel >= 99)
124                 continue;
125
126             SUB_EXP spell_exp = player_ptr->spell_exp[i + 32];
127             int exp_level = spell_exp_level(spell_exp);
128             fprintf(fff, "%-25s ", exe_spell(player_ptr, player_ptr->realm2, i, SPELL_NAME));
129             if (show_actual_value)
130                 fprintf(fff, "%4d/%4d ", std::min<short>(spell_exp, SPELL_EXP_MASTER), SPELL_EXP_MASTER);
131             if (exp_level >= EXP_LEVEL_EXPERT)
132                 fprintf(fff, "!");
133             else
134                 fprintf(fff, " ");
135             fprintf(fff, "%s", exp_level_str[exp_level]);
136             if (cheat_xtra)
137                 fprintf(fff, " %d", spell_exp);
138             fprintf(fff, "\n");
139         }
140     }
141
142     angband_fclose(fff);
143     (void)show_file(player_ptr, true, file_name, _("魔法の経験値", "Spell Proficiency"), 0, 0);
144     fd_kill(file_name);
145 }
146
147 /*!
148  * @brief スキル情報を表示するコマンドのメインルーチン /
149  * Display skill-exp
150  */
151 void do_cmd_knowledge_skill_exp(player_type *player_ptr)
152 {
153     const char *skill_name[SKILL_MAX] = { _("マーシャルアーツ", "Martial Arts    "), _("二刀流          ", "Dual Wielding   "),
154         _("乗馬            ", "Riding          "), _("盾              ", "Shield          ") };
155
156     FILE *fff = nullptr;
157     char file_name[FILE_NAME_SIZE];
158     if (!open_temporary_file(&fff, file_name))
159         return;
160
161     for (int i = 0; i < SKILL_MAX; i++) {
162         SUB_EXP skill_exp = player_ptr->skill_exp[i];
163         SUB_EXP skill_max = s_info[enum2i(player_ptr->pclass)].s_max[i];
164         fprintf(fff, "%-20s ", skill_name[i]);
165         if (show_actual_value)
166             fprintf(fff, "%4d/%4d ", std::min(skill_exp, skill_max), skill_max);
167         if (skill_exp >= skill_max)
168             fprintf(fff, "!");
169         else
170             fprintf(fff, " ");
171         fprintf(fff, "%s", exp_level_str[(i == SKILL_RIDING) ? PlayerSkill::riding_exp_level(skill_exp) : PlayerSkill::weapon_exp_level(skill_exp)]);
172         if (cheat_xtra)
173             fprintf(fff, " %d", skill_exp);
174         fprintf(fff, "\n");
175     }
176
177     angband_fclose(fff);
178     (void)show_file(player_ptr, true, file_name, _("技能の経験値", "Miscellaneous Proficiency"), 0, 0);
179     fd_kill(file_name);
180 }