OSDN Git Service

[Refactor] object_is_ammo() を object_type のメンバ関数化
authorHabu <habu1010+github@gmail.com>
Thu, 2 Sep 2021 16:33:15 +0000 (01:33 +0900)
committerHabu <habu1010+github@gmail.com>
Thu, 2 Sep 2021 16:33:15 +0000 (01:33 +0900)
src/autopick/autopick-entry.cpp
src/autopick/autopick-matcher.cpp
src/cmd-building/cmd-building.cpp
src/object-hook/hook-bow.cpp
src/object-hook/hook-bow.h
src/system/object-type-definition.cpp
src/system/object-type-definition.h

index 4c112f4..fb64cc1 100644 (file)
@@ -418,7 +418,7 @@ void autopick_entry_from_object(player_type *player_ptr, autopick_type *entry, o
     if (o_ptr->tval >= TV_LIFE_BOOK && 3 == o_ptr->sval)
         ADD_FLG(FLG_FOURTH);
 
-    if (object_is_ammo(o_ptr))
+    if (o_ptr->is_ammo())
         ADD_FLG(FLG_MISSILES);
     else if (o_ptr->tval == TV_SCROLL || o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND || o_ptr->tval == TV_ROD)
         ADD_FLG(FLG_DEVICES);
index bb52d2b..88595a5 100644 (file)
@@ -213,7 +213,7 @@ bool is_autopick_match(player_type *player_ptr, object_type *o_ptr, autopick_typ
         if (!o_ptr->is_armour())
             return false;
     } else if (IS_FLG(FLG_MISSILES)) {
-        if (!object_is_ammo(o_ptr))
+        if (!o_ptr->is_ammo())
             return false;
     } else if (IS_FLG(FLG_DEVICES)) {
         switch (o_ptr->tval) {
index d08acba..a946ec5 100644 (file)
@@ -198,7 +198,7 @@ static void bldg_process_command(player_type *player_ptr, building_type *bldg, i
         paid = restore_all_status(player_ptr);
         break;
     case BACT_ENCHANT_ARROWS:
-        enchant_item(player_ptr, bcost, 1, 1, 0, FuncItemTester(object_is_ammo));
+        enchant_item(player_ptr, bcost, 1, 1, 0, FuncItemTester(&object_type::is_ammo));
         break;
     case BACT_ENCHANT_BOW:
         enchant_item(player_ptr, bcost, 1, 1, 0, TvalItemTester(TV_BOW));
index acdb97f..ee342bd 100644 (file)
@@ -17,16 +17,3 @@ bool object_is_convertible(const object_type *o_ptr)
         return true;
     return false;
 }
-
-/*!
- * @brief オブジェクトが矢弾として使用できるかどうかを返す / Check if an object is ammo
- * @param o_ptr 対象のオブジェクト構造体ポインタ
- * @return 矢弾として使えるならばTRUEを返す
- */
-bool object_is_ammo(const object_type *o_ptr)
-{
-    if (TV_MISSILE_BEGIN <= o_ptr->tval && o_ptr->tval <= TV_MISSILE_END)
-        return true;
-
-    return false;
-}
index 8aa47fb..d557bd4 100644 (file)
@@ -3,4 +3,3 @@
 typedef struct object_type object_type;
 typedef struct player_type player_type;
 bool object_is_convertible(const object_type *o_ptr);
-bool object_is_ammo(const object_type *o_ptr);
index 606d5c5..d234b2e 100644 (file)
@@ -232,6 +232,16 @@ bool object_type::allow_two_hands_wielding() const
     return this->is_melee_weapon() && ((this->weight > 99) || (this->tval == TV_POLEARM));
 }
 
+/*!
+ * @brief オブジェクトが矢弾として使用できるかどうかを返す / Check if an object is ammo
+ * @return 矢弾として使えるならばtrueを返す
+ */
+bool object_type::is_ammo() const
+{
+    return (TV_MISSILE_BEGIN <= this->tval) && (this->tval <= TV_MISSILE_END);
+}
+
+
 bool object_type::is_lance() const
 {
     auto is_lance = this->tval == TV_POLEARM;
index 6a4d990..0d1bc8e 100644 (file)
@@ -71,6 +71,7 @@ typedef struct object_type {
     bool allow_enchant_weapon() const;
     bool allow_enchant_melee_weapon() const;
     bool allow_two_hands_wielding() const;
+    bool is_ammo() const;
     bool is_lance() const;
     bool is_armour() const;
 } object_type;