1 #include "player/player-skill.h"
2 #include "core/player-update-types.h"
3 #include "system/object-type-definition.h"
4 #include "system/player-type-definition.h"
5 #include "util/bit-flags-calculator.h"
7 /* Proficiency of weapons and misc. skills (except riding) */
8 constexpr SUB_EXP WEAPON_EXP_UNSKILLED = 0;
9 constexpr SUB_EXP WEAPON_EXP_BEGINNER = 4000;
10 constexpr SUB_EXP WEAPON_EXP_SKILLED = 6000;
11 constexpr SUB_EXP WEAPON_EXP_EXPERT = 7000;
12 constexpr SUB_EXP WEAPON_EXP_MASTER = 8000;
17 std::vector<skill_table> s_info;
22 const concptr exp_level_str[5] =
24 { "[初心者]", "[入門者]", "[熟練者]", "[エキスパート]", "[達人]" };
26 { "[Unskilled]", "[Beginner]", "[Skilled]", "[Expert]", "[Master]" };
29 PlayerSkill::PlayerSkill(player_type *player_ptr)
30 : player_ptr(player_ptr)
34 SUB_EXP PlayerSkill::weapon_exp_at(int level)
37 case EXP_LEVEL_UNSKILLED:
38 return WEAPON_EXP_UNSKILLED;
39 case EXP_LEVEL_BEGINNER:
40 return WEAPON_EXP_BEGINNER;
41 case EXP_LEVEL_SKILLED:
42 return WEAPON_EXP_SKILLED;
43 case EXP_LEVEL_EXPERT:
44 return WEAPON_EXP_EXPERT;
45 case EXP_LEVEL_MASTER:
46 return WEAPON_EXP_MASTER;
49 return WEAPON_EXP_UNSKILLED;
53 * @brief 武器や各種スキル(騎乗以外)の抽象的表現ランクを返す。 / Return proficiency level of weapons and misc. skills (except riding)
54 * @param weapon_exp 経験値
57 int PlayerSkill::weapon_exp_level(int weapon_exp)
59 if (weapon_exp < WEAPON_EXP_BEGINNER)
60 return EXP_LEVEL_UNSKILLED;
61 else if (weapon_exp < WEAPON_EXP_SKILLED)
62 return EXP_LEVEL_BEGINNER;
63 else if (weapon_exp < WEAPON_EXP_EXPERT)
64 return EXP_LEVEL_SKILLED;
65 else if (weapon_exp < WEAPON_EXP_MASTER)
66 return EXP_LEVEL_EXPERT;
68 return EXP_LEVEL_MASTER;
71 bool PlayerSkill::valid_weapon_exp(int weapon_exp)
73 return (WEAPON_EXP_UNSKILLED <= weapon_exp) && (weapon_exp <= WEAPON_EXP_MASTER);
76 void PlayerSkill::gain_melee_weapon_exp(const object_type *o_ptr)
78 auto now_exp = this->player_ptr->weapon_exp[o_ptr->tval][o_ptr->sval];
79 if (now_exp >= s_info[enum2i(this->player_ptr->pclass)].w_max[o_ptr->tval][o_ptr->sval])
83 if (now_exp < WEAPON_EXP_BEGINNER)
85 else if (now_exp < WEAPON_EXP_SKILLED)
87 else if ((now_exp < WEAPON_EXP_EXPERT) && (this->player_ptr->lev > 19))
89 else if ((player_ptr->lev > 34) && one_in_(2))
92 this->player_ptr->weapon_exp[o_ptr->tval][o_ptr->sval] += amount;
93 set_bits(this->player_ptr->update, PU_BONUS);
96 void PlayerSkill::gain_range_weapon_exp(const object_type *o_ptr)
98 auto now_exp = this->player_ptr->weapon_exp[o_ptr->tval][o_ptr->sval];
99 if (now_exp >= s_info[enum2i(this->player_ptr->pclass)].w_max[o_ptr->tval][o_ptr->sval])
103 if (now_exp < WEAPON_EXP_BEGINNER)
105 else if (now_exp < WEAPON_EXP_SKILLED)
107 else if ((now_exp < WEAPON_EXP_EXPERT) && (this->player_ptr->lev > 19))
109 else if (this->player_ptr->lev > 34)
112 this->player_ptr->weapon_exp[o_ptr->tval][o_ptr->sval] += amount;
113 set_bits(this->player_ptr->update, PU_BONUS);
116 void PlayerSkill::gain_martial_arts_skill_exp()
118 auto now_exp = this->player_ptr->skill_exp[SKILL_MARTIAL_ARTS];
119 if (now_exp >= s_info[enum2i(this->player_ptr->pclass)].s_max[SKILL_MARTIAL_ARTS])
123 if (now_exp < WEAPON_EXP_BEGINNER)
125 else if (now_exp < WEAPON_EXP_SKILLED)
127 else if ((now_exp < WEAPON_EXP_EXPERT) && (this->player_ptr->lev > 19))
129 else if ((this->player_ptr->lev > 34) && one_in_(3))
132 this->player_ptr->skill_exp[SKILL_MARTIAL_ARTS] += amount;
133 set_bits(this->player_ptr->update, PU_BONUS);
136 void PlayerSkill::gain_two_weapon_skill_exp()
138 auto now_exp = this->player_ptr->skill_exp[SKILL_TWO_WEAPON];
139 if (now_exp >= s_info[enum2i(this->player_ptr->pclass)].s_max[SKILL_TWO_WEAPON])
143 if (now_exp < WEAPON_EXP_BEGINNER)
145 else if (now_exp < WEAPON_EXP_SKILLED)
147 else if ((now_exp < WEAPON_EXP_EXPERT) && (this->player_ptr->lev > 19))
149 else if ((this->player_ptr->lev > 34) && one_in_(3))
152 this->player_ptr->skill_exp[SKILL_TWO_WEAPON] += amount;
153 set_bits(this->player_ptr->update, PU_BONUS);