OSDN Git Service

Merge pull request #3532 from sikabane-works/release/3.0.0.87-alpha
[hengbandforosx/hengbandosx.git] / src / smith / object-smith.h
1 #pragma once
2
3 #include "system/system-variables.h"
4
5 #include "object-enchant/tr-flags.h"
6
7 #include <memory>
8 #include <optional>
9 #include <unordered_map>
10
11 class ItemEntity;
12 class PlayerType;
13 class ISmithInfo;
14 struct essence_drain_type;
15 class ItemTester;
16 struct smith_data_type;
17
18 enum class SmithEffectType : int16_t;
19 enum class SmithCategoryType;
20 enum class SmithEssenceType : int16_t;
21 enum class RandomArtActType : short;
22
23 /*!
24  * @brief 鍛冶クラス
25  */
26 class Smith {
27 public:
28     //! エッセンスとその抽出量を表すタプルのリスト
29     using DrainEssenceResult = std::vector<std::tuple<SmithEssenceType, int>>;
30
31     Smith(PlayerType *player_ptr);
32
33     static const std::vector<SmithEssenceType> &get_essence_list();
34     static concptr get_essence_name(SmithEssenceType essence);
35     static std::vector<SmithEffectType> get_effect_list(SmithCategoryType category);
36     static concptr get_effect_name(SmithEffectType effect);
37     static std::string get_need_essences_desc(SmithEffectType effect);
38     static std::vector<SmithEssenceType> get_need_essences(SmithEffectType effect);
39     static int get_essence_consumption(SmithEffectType effect, const ItemEntity *o_ptr = nullptr);
40     static std::unique_ptr<ItemTester> get_item_tester(SmithEffectType effect);
41     static TrFlags get_effect_tr_flags(SmithEffectType effect);
42     static std::optional<RandomArtActType> object_activation(const ItemEntity *o_ptr);
43     static std::optional<SmithEffectType> object_effect(const ItemEntity *o_ptr);
44
45     int get_essence_num_of_posessions(SmithEssenceType essence) const;
46     DrainEssenceResult drain_essence(ItemEntity *o_ptr);
47     bool add_essence(SmithEffectType effect, ItemEntity *o_ptr, int consumption);
48     void erase_essence(ItemEntity *o_ptr) const;
49     int get_addable_count(SmithEffectType smith_effect, const ItemEntity *o_ptr = nullptr) const;
50
51     static constexpr int ESSENCE_AMOUNT_MAX = 20000;
52
53 private:
54     static std::optional<const ISmithInfo *> find_smith_info(SmithEffectType effect);
55
56     static const std::vector<SmithEssenceType> essence_list_order;
57     static const std::unordered_map<SmithEssenceType, concptr> essence_to_name;
58     static const std::vector<essence_drain_type> essence_drain_info_table;
59     static const std::vector<std::shared_ptr<ISmithInfo>> smith_info_table;
60
61     PlayerType *player_ptr;
62     std::shared_ptr<smith_data_type> smith_data;
63 };