OSDN Git Service

[Refactor] #1642 Separated polymorph() from influence()
authorHourier <66951241+Hourier@users.noreply.github.com>
Thu, 10 Mar 2022 10:38:49 +0000 (19:38 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Fri, 11 Mar 2022 11:47:14 +0000 (20:47 +0900)
src/object-use/quaff/quaff-effects.cpp
src/object-use/quaff/quaff-effects.h

index 7589293..96d41a1 100644 (file)
@@ -445,21 +445,7 @@ bool QuaffEffects::influence(const ObjectType &o_ref)
         ident = true;
         break;
     case SV_POTION_POLYMORPH:
-        if (this->player_ptr->muta.any() && one_in_(23)) {
-            lose_all_mutations(this->player_ptr);
-            break;
-        }
-
-        do {
-            if (one_in_(2)) {
-                if (gain_mutation(this->player_ptr, 0)) {
-                    ident = true;
-                }
-            } else if (lose_mutation(this->player_ptr, 0)) {
-                ident = true;
-            }
-        } while (!ident || one_in_(2));
-        break;
+        return this->polymorph();
     }
 
     return ident;
@@ -565,3 +551,27 @@ bool QuaffEffects::detonation()
     (void)bss.mod_cut(5000);
     return true;
 }
+
+/*!
+ * @brief 自己変容の薬
+ * @return 突然変異を得たか失ったらtrue、そのままならfalse
+ */
+bool QuaffEffects::polymorph()
+{
+    if (this->player_ptr->muta.any() && one_in_(23)) {
+        lose_all_mutations(this->player_ptr);
+        return false;
+    }
+
+    auto ident = false;
+    do {
+        if (one_in_(2)) {
+            if (gain_mutation(this->player_ptr, 0)) {
+                ident = true;
+            }
+        } else if (lose_mutation(this->player_ptr, 0)) {
+            ident = true;
+        }
+    } while (!ident || one_in_(2));
+    return ident;
+}
index a369213..0829b5b 100644 (file)
@@ -15,4 +15,5 @@ private:
     bool booze();
     bool sleep();
     bool detonation();
+    bool polymorph();
 };