OSDN Git Service

English: fix typo in smithing menus ("gauntlets of Genji")
[hengbandforosx/hengbandosx.git] / src / smith / smith-info.h
1 #pragma once
2
3 #include "system/angband.h"
4
5 #include "object-enchant/tr-flags.h"
6
7 #include <optional>
8 #include <vector>
9
10 enum class SmithEffectType : int16_t;
11 enum class SmithCategoryType;
12 enum class SmithEssenceType : int16_t;
13 enum class RandomArtActType : short;
14
15 class PlayerType;
16 class ObjectType;
17
18 /*!
19  * @brief 鍛冶効果の情報の基底クラス
20  */
21 class ISmithInfo {
22 public:
23     virtual ~ISmithInfo() = default;
24
25     /*!
26      * @brief 鍛冶効果を付与する
27      *
28      * @param o_ptr 鍛冶効果の付与を行うアイテム構造体へのポインタ
29      * @param number 付与を行うエッセンスの個数
30      * @return 鍛冶効果の付与に成功した場合は true、失敗した場合は false
31      */
32     virtual bool add_essence(PlayerType *player_ptr, ObjectType *o_ptr, int number) const = 0;
33
34     /*!
35      * @brief 鍛冶効果を消去する
36      *
37      * @param o_ptr 鍛冶効果の消去を行うアイテム構造体へのポインタ
38      */
39     virtual void erase_essence(ObjectType *o_ptr) const = 0;
40
41     /*!
42      * @brief 鍛冶効果により与えられる特性フラグ(tr_type)のFlagGroupオブジェクトを取得する
43      * 基底クラスは空のFlagGroupオブジェクトを返す。派生クラスで必要に応じて鍛冶効果で与えられる特性フラグを返すようオーバーライドする。
44      *
45      * @return TrFlags 鍛冶効果により与えられる特性フラグ(tr_type)のFlagGroupオブジェクト
46      */
47     virtual TrFlags tr_flags() const;
48
49     /*!
50      * @brief 鍛冶を行えるアイテムかどうかを調べる
51      *
52      * @param o_ptr 鍛冶を行うアイテム構造体へのポインタ
53      * @return 鍛冶を行えるなら true、そうでなければ false
54      */
55     virtual bool can_give_smith_effect(const ObjectType *o_ptr) const = 0;
56
57     SmithEffectType effect; //!< 鍛冶で与える効果の種類
58     concptr name; //!< 鍛冶で与える能力の名称
59     SmithCategoryType category; //!< 鍛冶で与える能力が所属するグループ
60     std::vector<SmithEssenceType> need_essences; //!< 能力を与えるのに必要なエッセンスのリスト
61     int consumption; //!< 能力を与えるのに必要な消費量(need_essencesに含まれるエッセンスそれぞれについてこの量を消費)
62
63 protected:
64     ISmithInfo(SmithEffectType effect, concptr name, SmithCategoryType category, std::vector<SmithEssenceType> need_essences, int consumption);
65 };
66
67 /*!
68  * @brief 基本的な鍛冶効果の情報クラス
69  * 多くの鍛冶効果が該当する、指定した特性フラグを与える鍛冶の情報を扱う
70  */
71 class BasicSmithInfo : public ISmithInfo {
72 public:
73     BasicSmithInfo(SmithEffectType effect, concptr name, SmithCategoryType category, std::vector<SmithEssenceType> need_essences, int consumption, TrFlags add_flags);
74     virtual bool add_essence(PlayerType *player_ptr, ObjectType *o_ptr, int number) const override;
75     virtual void erase_essence(ObjectType *o_ptr) const override;
76     virtual TrFlags tr_flags() const override;
77     virtual bool can_give_smith_effect(const ObjectType *o_ptr) const final override;
78
79 private:
80     virtual bool can_give_smith_effect_impl(const ObjectType *o_ptr) const;
81     TrFlags add_flags; //!< 鍛冶で能力を与えることにより付与されるアイテム特性フラグ
82 };
83
84 /*!
85  * @brief 発動効果を付与する鍛冶効果の情報クラス
86  * 発動効果を付与する鍛冶の情報を扱う
87  */
88 class ActivationSmithInfo : public ISmithInfo {
89 public:
90     ActivationSmithInfo(SmithEffectType effect, concptr name, SmithCategoryType category, std::vector<SmithEssenceType> need_essences, int consumption, RandomArtActType act_idx);
91     virtual bool add_essence(PlayerType *player_ptr, ObjectType *o_ptr, int number) const override;
92     virtual void erase_essence(ObjectType *) const override;
93     virtual bool can_give_smith_effect(const ObjectType *o_ptr) const override;
94
95 private:
96     RandomArtActType act_idx; //!< 発動能力ID
97 };
98
99 /*!
100  * @brief 武器強化を行う鍛冶情報のクラス
101  * 武器の命中/ダメージ修正を強化する。鍛冶効果とは別枠で行うので鍛冶師の銘付きにはならない。
102  */
103 class EnchantWeaponSmithInfo : public ISmithInfo {
104 public:
105     EnchantWeaponSmithInfo(SmithEffectType effect, concptr name, SmithCategoryType category, std::vector<SmithEssenceType> need_essences, int consumption);
106     virtual bool add_essence(PlayerType *player_ptr, ObjectType *o_ptr, int number) const override;
107     virtual void erase_essence(ObjectType *) const override {}
108     virtual bool can_give_smith_effect(const ObjectType *o_ptr) const override;
109 };
110
111 /*!
112  * @brief 防具強化を行う鍛冶情報のクラス
113  * 防具のAC修正を強化する。鍛冶効果とは別枠で行うので鍛冶師の銘付きにはならない。
114  */
115 class EnchantArmourSmithInfo : public ISmithInfo {
116 public:
117     EnchantArmourSmithInfo(SmithEffectType effect, concptr name, SmithCategoryType category, std::vector<SmithEssenceType> need_essences, int consumption);
118     virtual bool add_essence(PlayerType *player_ptr, ObjectType *o_ptr, int number) const override;
119     virtual void erase_essence(ObjectType *) const override {}
120     virtual bool can_give_smith_effect(const ObjectType *o_ptr) const override;
121 };
122
123 /*!
124  * @brief 装備保持を行う鍛冶情報のクラス
125  * 四元素属性で破壊されないフラグを付与する。鍛冶効果とは別枠で行うので鍛冶師の銘付きにはならない。
126  */
127 class SustainSmithInfo : public ISmithInfo {
128 public:
129     SustainSmithInfo(SmithEffectType effect, concptr name, SmithCategoryType category, std::vector<SmithEssenceType> need_essences, int consumption);
130     virtual bool add_essence(PlayerType *player_ptr, ObjectType *o_ptr, int number) const override;
131     virtual void erase_essence(ObjectType *) const override {}
132     virtual bool can_give_smith_effect(const ObjectType *o_ptr) const override;
133 };
134
135 /*!
136  * @brief 殺戮の小手を作成する鍛冶情報のクラス
137  * 小手に殺戮修正を付ける。(もともと殺戮修正のある小手は修正をさらに強化する)
138  */
139 class SlayingGlovesSmithInfo : public BasicSmithInfo {
140 public:
141     SlayingGlovesSmithInfo(SmithEffectType effect, concptr name, SmithCategoryType category, std::vector<SmithEssenceType> need_essences, int consumption);
142     virtual bool add_essence(PlayerType *player_ptr, ObjectType *o_ptr, int number) const override;
143     virtual void erase_essence(ObjectType *) const override;
144
145 private:
146     virtual bool can_give_smith_effect_impl(const ObjectType *o_ptr) const override;
147 };