OSDN Git Service

[Refactor] #2830 TV_WEAPON_BEGIN/TV_WEAPON_END 定数を廃止した
authorHourier <66951241+Hourier@users.noreply.github.com>
Fri, 25 Nov 2022 10:47:51 +0000 (19:47 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sat, 26 Nov 2022 02:52:40 +0000 (11:52 +0900)
src/object/tval-types.h
src/system/baseitem-info.cpp
src/system/baseitem-info.h
src/system/item-entity.cpp

index a70b4a1..cca98a2 100644 (file)
@@ -76,8 +76,6 @@ enum class ItemKindType : short {
 
 #define TV_EQUIP_BEGIN ItemKindType::SHOT
 #define TV_EQUIP_END ItemKindType::CARD
-#define TV_WEAPON_BEGIN ItemKindType::BOW
-#define TV_WEAPON_END ItemKindType::SWORD
 
 constexpr auto TV_WEARABLE_RANGE = EnumRange(ItemKindType::BOW, ItemKindType::CARD);
 constexpr auto TV_WEAPON_RANGE = EnumRange(ItemKindType::BOW, ItemKindType::SWORD);
index eb84752..9277775 100644 (file)
@@ -252,6 +252,20 @@ bool BaseitemKey::is_wearable() const
     }
 }
 
+bool BaseitemKey::is_weapon() const
+{
+    switch (this->type_value) {
+    case ItemKindType::BOW:
+    case ItemKindType::DIGGING:
+    case ItemKindType::HAFTED:
+    case ItemKindType::POLEARM:
+    case ItemKindType::SWORD:
+        return true;
+    default:
+        return false;
+    }
+}
+
 bool BaseitemKey::is_mushrooms() const
 {
     if (!this->subtype_value.has_value()) {
index 67899fd..8592cf7 100644 (file)
@@ -49,6 +49,7 @@ public:
     bool is_protector() const;
     bool can_be_aura_protector() const;
     bool is_wearable() const;
+    bool is_weapon() const;
 
 private:
     ItemKindType type_value;
index 62971ff..46d2941 100644 (file)
@@ -113,7 +113,7 @@ void ItemEntity::prep(short new_bi_id)
  */
 bool ItemEntity::is_weapon() const
 {
-    return (TV_WEAPON_BEGIN <= this->tval) && (this->tval <= TV_WEAPON_END);
+    return BaseitemKey(this->tval).is_weapon();
 }
 
 /*!