OSDN Git Service

[Refactor] 技能の定義を enum class にする
[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 constexpr auto PLAYER_SKILL_KIND_TYPE_RANGE = EnumRange(PlayerSkillKindType::MARTIAL_ARTS, PlayerSkillKindType::SHIELD);
21
22 /* Proficiency level */
23 #define EXP_LEVEL_UNSKILLED 0
24 #define EXP_LEVEL_BEGINNER 1
25 #define EXP_LEVEL_SKILLED 2
26 #define EXP_LEVEL_EXPERT 3
27 #define EXP_LEVEL_MASTER 4
28
29 extern const concptr exp_level_str[5];
30
31 enum class ItemKindType : short;
32
33 /*
34  * Information about "skill"
35  */
36 typedef struct skill_table {
37     std::map<ItemKindType, std::array<SUB_EXP, 64>> w_start{}; /* start weapon exp */
38     std::map<ItemKindType, std::array<SUB_EXP, 64>> w_max{}; /* max weapon exp */
39     std::map<PlayerSkillKindType, SUB_EXP> s_start{}; /* start skill */
40     std::map<PlayerSkillKindType, SUB_EXP> s_max{}; /* max skill */
41 } skill_table;
42
43 extern std::vector<skill_table> s_info;
44
45 struct monster_race;
46 struct object_type;
47 struct player_type;
48
49 class PlayerSkill {
50 public:
51     PlayerSkill(player_type *player_ptr);
52
53     static SUB_EXP weapon_exp_at(int level);
54     static SUB_EXP spell_exp_at(int level);
55     static bool valid_weapon_exp(int weapon_exp);
56     static int weapon_exp_level(int weapon_exp);
57     static int riding_exp_level(int riding_exp);
58     static int spell_exp_level(int spell_exp);
59     static concptr skill_name(PlayerSkillKindType skill);
60
61     void gain_melee_weapon_exp(const object_type *o_ptr);
62     void gain_range_weapon_exp(const object_type *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     int gain_spell_skill_exp_over_learning(int spell_idx);
71
72     EXP exp_of_spell(int realm, int spell_idx) const;
73
74 private:
75     player_type *player_ptr;
76 };