OSDN Git Service

[Refactor] #3756 BaseitemKey::explain_activation() を定義し、ItemEntity::explain_activatio...
authorHourier <66951241+Hourier@users.noreply.github.com>
Sat, 2 Dec 2023 04:24:49 +0000 (13:24 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sat, 2 Dec 2023 05:32:54 +0000 (14:32 +0900)
src/system/baseitem-info.cpp
src/system/baseitem-info.h
src/system/item-entity.cpp

index 3f2ab34..0f94ff0 100644 (file)
@@ -517,6 +517,22 @@ bool BaseitemKey::refuse_enchant_weapon() const
     return *this == BaseitemKey(ItemKindType::SWORD, SV_POISON_NEEDLE);
 }
 
+/*!
+ * @brief ベースアイテムが発動効果を持つ時、その記述を生成する
+ * @return 発動効果
+ */
+std::string BaseitemKey::explain_activation() const
+{
+    switch (this->type_value) {
+    case ItemKindType::WHISTLE:
+        return _("ペット呼び寄せ : 100+d100ターン毎", "call pet every 100+d100 turns");
+    case ItemKindType::CAPTURE:
+        return _("モンスターを捕える、又は解放する。", "captures or releases a monster.");
+    default:
+        return _("何も起きない", "Nothing");
+    }
+}
+
 bool BaseitemKey::is_mushrooms() const
 {
     if (!this->subtype_value) {
index b736a56..f985edd 100644 (file)
@@ -72,6 +72,7 @@ public:
     bool is_armour() const;
     bool is_cross_bow() const;
     bool refuse_enchant_weapon() const;
+    std::string explain_activation() const;
 
 private:
     ItemKindType type_value;
index 7ddc744..591bda2 100644 (file)
@@ -907,16 +907,7 @@ std::string ItemEntity::explain_activation() const
         return this->build_activation_description();
     }
 
-    const auto tval = this->bi_key.tval();
-    if (tval == ItemKindType::WHISTLE) {
-        return _("ペット呼び寄せ : 100+d100ターン毎", "call pet every 100+d100 turns");
-    }
-
-    if (tval == ItemKindType::CAPTURE) {
-        return _("モンスターを捕える、又は解放する。", "captures or releases a monster.");
-    }
-
-    return _("何も起きない", "Nothing");
+    return this->bi_key.explain_activation();
 }
 
 std::string ItemEntity::build_timeout_description(const activation_type &act) const