OSDN Git Service

[Refactor] #2403 Separated strengthen() from apply_magic()
authorHourier <66951241+Hourier@users.noreply.github.com>
Fri, 11 Mar 2022 13:07:22 +0000 (22:07 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sun, 13 Mar 2022 14:15:04 +0000 (23:15 +0900)
src/object-enchant/weapon/apply-magic-sword.cpp
src/object-enchant/weapon/apply-magic-sword.h

index 4e61e05..14115e0 100644 (file)
@@ -40,24 +40,7 @@ void SwordEnchanter::apply_magic()
     }
 
     if (this->power > 1) {
-        if ((this->power > 2) || one_in_(40)) {
-            become_random_artifact(this->player_ptr, this->o_ptr, false);
-            return;
-        }
-
-        this->give_ego_index();
-        if (this->o_ptr->art_name > 0) {
-            return;
-        }
-
-        while (one_in_(10 * this->o_ptr->dd * this->o_ptr->ds)) {
-            this->o_ptr->dd++;
-        }
-
-        if (this->o_ptr->dd > 9) {
-            this->o_ptr->dd = 9;
-        }
-
+        this->strengthen();
         return;
     }
 
@@ -124,3 +107,24 @@ void SwordEnchanter::give_cursed()
         continue;
     }
 }
+
+void SwordEnchanter::strengthen()
+{
+    if ((this->power > 2) || one_in_(40)) {
+        become_random_artifact(this->player_ptr, this->o_ptr, false);
+        return;
+    }
+
+    this->give_ego_index();
+    if (this->o_ptr->art_name > 0) {
+        return;
+    }
+
+    while (one_in_(10 * this->o_ptr->dd * this->o_ptr->ds)) {
+        this->o_ptr->dd++;
+    }
+
+    if (this->o_ptr->dd > 9) {
+        this->o_ptr->dd = 9;
+    }
+}
index 3e0b0a7..5d77fd2 100644 (file)
@@ -18,4 +18,6 @@ protected:
 
 private:
     PlayerType *player_ptr;
+
+    void strengthen();
 };