* @param effect 情報を得る鍛冶効果
* @return 鍛冶情報構造体へのポインタを保持する std::optional オブジェクトを返す
*/
-std::optional<const smith_info_base *> Smith::find_smith_info(SmithEffect effect)
+std::optional<const ISmithInfo *> Smith::find_smith_info(SmithEffect effect)
{
// 何度も呼ぶので線形探索を避けるため鍛冶効果から鍛冶情報のテーブルを引けるmapを作成しておく。
- static std::unordered_map<SmithEffect, const smith_info_base *> search_map;
+ static std::unordered_map<SmithEffect, const ISmithInfo *> search_map;
if (search_map.empty()) {
for (const auto &info : smith_info_table) {
search_map.emplace(info->effect, info.get());
struct object_type;
struct player_type;
-class smith_info_base;
+class ISmithInfo;
struct essence_drain_type;
class ItemTester;
int get_addable_count(SmithEffect smith_effect, int item_number) const;
private:
- static std::optional<const smith_info_base *> find_smith_info(SmithEffect effect);
+ static std::optional<const ISmithInfo *> find_smith_info(SmithEffect effect);
static const std::vector<SmithEssence> essence_list_order;
static const std::unordered_map<SmithEssence, concptr> essence_to_name;
static const std::vector<essence_drain_type> essence_drain_info_table;
- static const std::vector<std::shared_ptr<smith_info_base>> smith_info_table;
+ static const std::vector<std::shared_ptr<ISmithInfo>> smith_info_table;
player_type *player_ptr;
};
#include "system/object-type-definition.h"
#include "system/player-type-definition.h"
-smith_info_base::smith_info_base(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption)
+ISmithInfo::ISmithInfo(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption)
: effect(effect)
, name(name)
, category(category)
{
}
-TrFlags smith_info_base::tr_flags() const
+TrFlags ISmithInfo::tr_flags() const
{
return {};
}
-std::optional<random_art_activation_type> smith_info_base::activation_index() const
+std::optional<random_art_activation_type> ISmithInfo::activation_index() const
{
return std::nullopt;
}
-basic_smith_info::basic_smith_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption, TrFlags add_flags)
- : smith_info_base(effect, name, category, std::move(need_essences), consumption)
+BasicSmithInfo::BasicSmithInfo(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption, TrFlags add_flags)
+ : ISmithInfo(effect, name, category, std::move(need_essences), consumption)
, add_flags(add_flags)
{
}
-bool basic_smith_info::add_essence(player_type *, object_type *o_ptr, int) const
+bool BasicSmithInfo::add_essence(player_type *, object_type *o_ptr, int) const
{
o_ptr->xtra3 = static_cast<decltype(o_ptr->xtra3)>(effect);
return true;
}
-void basic_smith_info::erase_essence(object_type *o_ptr) const
+void BasicSmithInfo::erase_essence(object_type *o_ptr) const
{
o_ptr->xtra3 = 0;
auto flgs = object_flags(o_ptr);
o_ptr->pval = 0;
}
-TrFlags basic_smith_info::tr_flags() const
+TrFlags BasicSmithInfo::tr_flags() const
{
return this->add_flags;
}
-activation_smith_info::activation_smith_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption, TrFlags add_flags, random_art_activation_type act_idx)
- : basic_smith_info(effect, name, category, std::move(need_essences), consumption, std::move(add_flags))
+ActivationSmithInfo::ActivationSmithInfo(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption, TrFlags add_flags, random_art_activation_type act_idx)
+ : BasicSmithInfo(effect, name, category, std::move(need_essences), consumption, std::move(add_flags))
, act_idx(act_idx)
{
}
-TrFlags activation_smith_info::tr_flags() const
+TrFlags ActivationSmithInfo::tr_flags() const
{
- return basic_smith_info::tr_flags().set(TR_ACTIVATE);
+ return BasicSmithInfo::tr_flags().set(TR_ACTIVATE);
}
-std::optional<random_art_activation_type> activation_smith_info::activation_index() const
+std::optional<random_art_activation_type> ActivationSmithInfo::activation_index() const
{
return this->act_idx;
}
-enchant_weapon_smith_info::enchant_weapon_smith_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption)
- : smith_info_base(effect, name, category, std::move(need_essences), consumption)
+EnchantWeaponSmithInfo::EnchantWeaponSmithInfo(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption)
+ : ISmithInfo(effect, name, category, std::move(need_essences), consumption)
{
}
-bool enchant_weapon_smith_info::add_essence(player_type *player_ptr, object_type *o_ptr, int) const
+bool EnchantWeaponSmithInfo::add_essence(player_type *player_ptr, object_type *o_ptr, int) const
{
const auto max_val = player_ptr->lev / 5 + 5;
if ((o_ptr->to_h >= max_val) && (o_ptr->to_d >= max_val)) {
return true;
}
-enchant_armour_smith_info::enchant_armour_smith_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption)
- : smith_info_base(effect, name, category, std::move(need_essences), consumption)
+EnchantArmourSmithInfo::EnchantArmourSmithInfo(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption)
+ : ISmithInfo(effect, name, category, std::move(need_essences), consumption)
{
}
-bool enchant_armour_smith_info::add_essence(player_type *player_ptr, object_type *o_ptr, int) const
+bool EnchantArmourSmithInfo::add_essence(player_type *player_ptr, object_type *o_ptr, int) const
{
const auto max_val = player_ptr->lev / 5 + 5;
if (o_ptr->to_a >= max_val) {
return true;
}
-sustain_smith_info::sustain_smith_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption)
- : smith_info_base(effect, name, category, std::move(need_essences), consumption)
+SustainSmithInfo::SustainSmithInfo(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption)
+ : ISmithInfo(effect, name, category, std::move(need_essences), consumption)
{
}
-bool sustain_smith_info::add_essence(player_type *, object_type *o_ptr, int) const
+bool SustainSmithInfo::add_essence(player_type *, object_type *o_ptr, int) const
{
o_ptr->art_flags.set(TR_IGNORE_ACID);
o_ptr->art_flags.set(TR_IGNORE_ELEC);
return true;
}
-slaying_gloves_smith_info::slaying_gloves_smith_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption)
- : basic_smith_info(effect, name, category, std::move(need_essences), consumption, {})
+SlayingGlovesSmithInfo::SlayingGlovesSmithInfo(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption)
+ : BasicSmithInfo(effect, name, category, std::move(need_essences), consumption, {})
{
}
-bool slaying_gloves_smith_info::add_essence(player_type *player_ptr, object_type *o_ptr, int number) const
+bool SlayingGlovesSmithInfo::add_essence(player_type *player_ptr, object_type *o_ptr, int number) const
{
- basic_smith_info::add_essence(player_ptr, o_ptr, number);
+ BasicSmithInfo::add_essence(player_ptr, o_ptr, number);
HIT_PROB get_to_h = ((number + 1) / 2 + randint0(number / 2 + 1));
HIT_POINT get_to_d = ((number + 1) / 2 + randint0(number / 2 + 1));
return true;
}
-void slaying_gloves_smith_info::erase_essence(object_type *o_ptr) const
+void SlayingGlovesSmithInfo::erase_essence(object_type *o_ptr) const
{
- basic_smith_info::erase_essence(o_ptr);
+ BasicSmithInfo::erase_essence(o_ptr);
o_ptr->to_h -= (o_ptr->xtra4 >> 8);
o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
/*!
* @brief 鍛冶効果の情報の基底クラス
*/
-class smith_info_base {
+class ISmithInfo {
public:
- virtual ~smith_info_base() = default;
+ virtual ~ISmithInfo() = default;
/*!
* @brief 鍛冶効果を付与する
int consumption; //!< 能力を与えるのに必要な消費量(need_essencesに含まれるエッセンスそれぞれについてこの量を消費)
protected:
- smith_info_base(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption);
+ ISmithInfo(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption);
};
/*!
* @brief 基本的な鍛冶効果の情報クラス
* 多くの鍛冶効果が該当する、指定した特性フラグを与える鍛冶の情報を扱う
*/
-class basic_smith_info : public smith_info_base {
+class BasicSmithInfo : public ISmithInfo {
public:
- basic_smith_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption, TrFlags add_flags);
+ BasicSmithInfo(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption, TrFlags add_flags);
virtual bool add_essence(player_type *player_ptr, object_type *o_ptr, int number) const override;
virtual void erase_essence(object_type *o_ptr) const override;
virtual TrFlags tr_flags() const override;
* @brief 発動効果を付与する鍛冶効果の情報クラス
* 発動効果を付与する(かつ、特性フラグを与える場合もある)鍛冶の情報を扱う
*/
-class activation_smith_info : public basic_smith_info {
+class ActivationSmithInfo : public BasicSmithInfo {
public:
- activation_smith_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption, TrFlags add_flags, random_art_activation_type act_idx);
+ ActivationSmithInfo(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption, TrFlags add_flags, random_art_activation_type act_idx);
virtual TrFlags tr_flags() const override;
virtual std::optional<random_art_activation_type> activation_index() const override;
* @brief 武器強化を行う鍛冶情報のクラス
* 武器の命中/ダメージ修正を強化する。鍛冶効果とは別枠で行うので鍛冶師の銘付きにはならない。
*/
-class enchant_weapon_smith_info : public smith_info_base {
+class EnchantWeaponSmithInfo : public ISmithInfo {
public:
- enchant_weapon_smith_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption);
+ EnchantWeaponSmithInfo(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption);
virtual bool add_essence(player_type *player_ptr, object_type *o_ptr, int number) const override;
virtual void erase_essence(object_type *) const override {}
};
* @brief 防具強化を行う鍛冶情報のクラス
* 防具のAC修正を強化する。鍛冶効果とは別枠で行うので鍛冶師の銘付きにはならない。
*/
-class enchant_armour_smith_info : public smith_info_base {
+class EnchantArmourSmithInfo : public ISmithInfo {
public:
- enchant_armour_smith_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption);
+ EnchantArmourSmithInfo(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption);
virtual bool add_essence(player_type *player_ptr, object_type *o_ptr, int number) const override;
virtual void erase_essence(object_type *) const override {}
};
* @brief 装備保持を行う鍛冶情報のクラス
* 四元素属性で破壊されないフラグを付与する。鍛冶効果とは別枠で行うので鍛冶師の銘付きにはならない。
*/
-class sustain_smith_info : public smith_info_base {
+class SustainSmithInfo : public ISmithInfo {
public:
- sustain_smith_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption);
+ SustainSmithInfo(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption);
virtual bool add_essence(player_type *player_ptr, object_type *o_ptr, int number) const override;
virtual void erase_essence(object_type *) const override {}
};
* @brief 殺戮の小手を作成する鍛冶情報のクラス
* 小手に殺戮修正を付ける。(もともと殺戮修正のある小手は修正をさらに強化する)
*/
-class slaying_gloves_smith_info : public basic_smith_info {
+class SlayingGlovesSmithInfo : public BasicSmithInfo {
public:
- slaying_gloves_smith_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption);
+ SlayingGlovesSmithInfo(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption);
virtual bool add_essence(player_type *player_ptr, object_type *o_ptr, int number) const override;
virtual void erase_essence(object_type *) const override;
};
namespace {
template <typename T, typename... Args>
-std::shared_ptr<smith_info_base> make_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption, Args&&... args)
+std::shared_ptr<ISmithInfo> make_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption, Args&&... args)
{
return std::make_shared<T>(effect, name, category, std::move(need_essences), consumption, std::forward<Args>(args)...);
}
-std::shared_ptr<smith_info_base> make_basic_smith_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption, TrFlags add_flags)
+std::shared_ptr<ISmithInfo> make_basic_smith_info(SmithEffect effect, concptr name, SmithCategory category, std::vector<SmithEssence> need_essences, int consumption, TrFlags add_flags)
{
- return make_info<basic_smith_info>(effect, name, category, std::move(need_essences), consumption, std::move(add_flags));
+ return make_info<BasicSmithInfo>(effect, name, category, std::move(need_essences), consumption, std::move(add_flags));
}
}
/*!
* @brief 鍛冶情報テーブル
*/
-const std::vector<std::shared_ptr<smith_info_base>> Smith::smith_info_table = {
+const std::vector<std::shared_ptr<ISmithInfo>> Smith::smith_info_table = {
make_basic_smith_info(SmithEffect::NONE, _("なし", "None"), SmithCategory::NONE, std::vector<SmithEssence>{ SmithEssence::NONE }, 0, {}),
make_basic_smith_info(SmithEffect::STR, _("腕力", "strength"), SmithCategory::PVAL, { SmithEssence::STR }, 20, { TR_STR }),
make_basic_smith_info(SmithEffect::ESP_DRAGON, _("竜ESP", "sense dragon"), SmithCategory::ESP, { SmithEssence::SLAY_DRAGON }, 40, { TR_ESP_DRAGON }),
make_basic_smith_info(SmithEffect::ESP_HUMAN, _("人間ESP", "sense human"), SmithCategory::ESP, { SmithEssence::SLAY_HUMAN }, 40, { TR_ESP_HUMAN }),
- make_info<activation_smith_info>(SmithEffect::EARTHQUAKE, _("地震発動", "quake activation"), SmithCategory::ETC, { SmithEssence::EATHQUAKE }, 15, TrFlags{ TR_EARTHQUAKE }, ACT_QUAKE),
- make_info<activation_smith_info>(SmithEffect::TMP_RES_ACID, _("酸耐性発動", "resist acid activation"), SmithCategory::ETC, { SmithEssence::RES_ACID }, 50, TrFlags{ TR_RES_ACID }, ACT_RESIST_ACID),
- make_info<activation_smith_info>(SmithEffect::TMP_RES_ELEC, _("電撃耐性発動", "resist electricity activation"), SmithCategory::ETC, { SmithEssence::RES_ELEC }, 50, TrFlags{ TR_RES_ELEC }, ACT_RESIST_ELEC),
- make_info<activation_smith_info>(SmithEffect::TMP_RES_FIRE, _("火炎耐性発動", "resist fire activation"), SmithCategory::ETC, { SmithEssence::RES_FIRE }, 50, TrFlags{ TR_RES_FIRE }, ACT_RESIST_FIRE),
- make_info<activation_smith_info>(SmithEffect::TMP_RES_COLD, _("冷気耐性発動", "resist cold activation"), SmithCategory::ETC, { SmithEssence::RES_COLD }, 50, TrFlags{ TR_RES_COLD }, ACT_RESIST_COLD),
+ make_info<ActivationSmithInfo>(SmithEffect::EARTHQUAKE, _("地震発動", "quake activation"), SmithCategory::ETC, { SmithEssence::EATHQUAKE }, 15, TrFlags{ TR_EARTHQUAKE }, ACT_QUAKE),
+ make_info<ActivationSmithInfo>(SmithEffect::TMP_RES_ACID, _("酸耐性発動", "resist acid activation"), SmithCategory::ETC, { SmithEssence::RES_ACID }, 50, TrFlags{ TR_RES_ACID }, ACT_RESIST_ACID),
+ make_info<ActivationSmithInfo>(SmithEffect::TMP_RES_ELEC, _("電撃耐性発動", "resist electricity activation"), SmithCategory::ETC, { SmithEssence::RES_ELEC }, 50, TrFlags{ TR_RES_ELEC }, ACT_RESIST_ELEC),
+ make_info<ActivationSmithInfo>(SmithEffect::TMP_RES_FIRE, _("火炎耐性発動", "resist fire activation"), SmithCategory::ETC, { SmithEssence::RES_FIRE }, 50, TrFlags{ TR_RES_FIRE }, ACT_RESIST_FIRE),
+ make_info<ActivationSmithInfo>(SmithEffect::TMP_RES_COLD, _("冷気耐性発動", "resist cold activation"), SmithCategory::ETC, { SmithEssence::RES_COLD }, 50, TrFlags{ TR_RES_COLD }, ACT_RESIST_COLD),
make_basic_smith_info(SmithEffect::SH_FIRE, _("火炎オーラ", "fiery sheath"), SmithCategory::ETC, { SmithEssence::RES_FIRE, SmithEssence::BRAND_FIRE }, 50, { TR_RES_FIRE, TR_SH_FIRE }),
make_basic_smith_info(SmithEffect::SH_ELEC, _("電撃オーラ", "electric sheath"), SmithCategory::ETC, { SmithEssence::RES_ELEC, SmithEssence::BRAND_ELEC }, 50, { TR_RES_ELEC, TR_SH_ELEC }),
make_basic_smith_info(SmithEffect::SH_COLD, _("冷気オーラ", "sheath of coldness"), SmithCategory::ETC, { SmithEssence::RES_COLD, SmithEssence::BRAND_COLD }, 50, { TR_RES_COLD, TR_SH_COLD }),
make_basic_smith_info(SmithEffect::RESISTANCE, _("全耐性", "resistance"), SmithCategory::RESISTANCE, { SmithEssence::RES_ACID, SmithEssence::RES_ELEC, SmithEssence::RES_FIRE, SmithEssence::RES_COLD }, 150, { TR_RES_ACID, TR_RES_ELEC, TR_RES_FIRE, TR_RES_COLD }),
- make_info<slaying_gloves_smith_info>(SmithEffect::SLAY_GLOVE, _("殺戮の小手", "gauntlets of slaying"), SmithCategory::WEAPON_ATTR, { SmithEssence::ATTACK }, 200),
+ make_info<SlayingGlovesSmithInfo>(SmithEffect::SLAY_GLOVE, _("殺戮の小手", "gauntlets of slaying"), SmithCategory::WEAPON_ATTR, { SmithEssence::ATTACK }, 200),
- make_info<enchant_weapon_smith_info>(SmithEffect::ATTACK, _("攻撃", "weapon enchant"), SmithCategory::ENCHANT, { SmithEssence::ATTACK }, 30),
- make_info<enchant_armour_smith_info>(SmithEffect::AC, _("防御", "armor enchant"), SmithCategory::ENCHANT, { SmithEssence::AC }, 15),
- make_info<sustain_smith_info>(SmithEffect::SUSTAIN, _("装備保持", "elements proof"), SmithCategory::ENCHANT, { SmithEssence::RES_ACID, SmithEssence::RES_ELEC, SmithEssence::RES_FIRE, SmithEssence::RES_COLD }, 10),
+ make_info<EnchantWeaponSmithInfo>(SmithEffect::ATTACK, _("攻撃", "weapon enchant"), SmithCategory::ENCHANT, { SmithEssence::ATTACK }, 30),
+ make_info<EnchantArmourSmithInfo>(SmithEffect::AC, _("防御", "armor enchant"), SmithCategory::ENCHANT, { SmithEssence::AC }, 15),
+ make_info<SustainSmithInfo>(SmithEffect::SUSTAIN, _("装備保持", "elements proof"), SmithCategory::ENCHANT, { SmithEssence::RES_ACID, SmithEssence::RES_ELEC, SmithEssence::RES_FIRE, SmithEssence::RES_COLD }, 10),
};