OSDN Git Service

365714e72d16919df590619e97531a77d63c9cc7
[hengbandforosx/hengbandosx.git] / src / player / player-skill.h
1 #pragma once
2
3 #include "system/angband.h"
4
5 #include "util/enum-range.h"
6
7 #include <array>
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 enum class PlayerSkillKindType {
13     MARTIAL_ARTS = 0,
14     TWO_WEAPON = 1,
15     RIDING = 2,
16     SHIELD = 3,
17     MAX,
18 };
19
20 enum class PlayerSkillRank {
21     UNSKILLED = 0,
22     BEGINNER = 1,
23     SKILLED = 2,
24     EXPERT = 3,
25     MASTER = 4,
26 };
27
28 constexpr auto PLAYER_SKILL_KIND_TYPE_RANGE = EnumRange(PlayerSkillKindType::MARTIAL_ARTS, PlayerSkillKindType::SHIELD);
29
30 enum class ItemKindType : short;
31
32 /*
33  * Information about "skill"
34  */
35 struct skill_table {
36     std::map<ItemKindType, std::array<SUB_EXP, 64>> w_start{}; /* start weapon exp */
37     std::map<ItemKindType, std::array<SUB_EXP, 64>> w_max{}; /* max weapon exp */
38     std::map<PlayerSkillKindType, SUB_EXP> s_start{}; /* start skill */
39     std::map<PlayerSkillKindType, SUB_EXP> s_max{}; /* max skill */
40 };
41
42 extern std::vector<skill_table> s_info;
43
44 struct monster_race;
45 class ObjectType;
46 class PlayerType;
47
48 class PlayerSkill {
49 public:
50     PlayerSkill(PlayerType *player_ptr);
51
52     static SUB_EXP weapon_exp_at(PlayerSkillRank rank);
53     static SUB_EXP spell_exp_at(PlayerSkillRank rank);
54     static bool valid_weapon_exp(int weapon_exp);
55     static PlayerSkillRank weapon_skill_rank(int weapon_exp);
56     static PlayerSkillRank riding_skill_rank(int riding_exp);
57     static PlayerSkillRank spell_skill_rank(int spell_exp);
58     static concptr skill_name(PlayerSkillKindType skill);
59     static concptr skill_rank_str(PlayerSkillRank rank);
60
61     void gain_melee_weapon_exp(const ObjectType *o_ptr);
62     void gain_range_weapon_exp(const ObjectType *o_ptr);
63     void gain_martial_arts_skill_exp();
64     void gain_two_weapon_skill_exp();
65     void gain_riding_skill_exp_on_melee_attack(const monster_race *r_ptr);
66     void gain_riding_skill_exp_on_range_attack();
67     void gain_riding_skill_exp_on_fall_off_check(HIT_POINT dam);
68     void gain_spell_skill_exp(int realm, int spell_idx);
69     void gain_continuous_spell_skill_exp(int realm, int spell_idx);
70     PlayerSkillRank gain_spell_skill_exp_over_learning(int spell_idx);
71
72     EXP exp_of_spell(int realm, int spell_idx) const;
73
74     void apply_special_weapon_skill_max_values();
75     void limit_weapon_skills_by_max_value();
76
77 private:
78     PlayerType *player_ptr;
79 };