OSDN Git Service

[Refactor] #40574 Separated neutralize_base_status() from gain_mutation()
authorHourier <hourier@users.sourceforge.jp>
Sat, 1 Aug 2020 02:16:48 +0000 (11:16 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 1 Aug 2020 02:16:48 +0000 (11:16 +0900)
src/mutation/mutation.c

index 4fb751f..edfb76d 100644 (file)
@@ -109,6 +109,118 @@ static void race_dependent_mutation(player_type *creature_ptr, gm_type *gm_ptr)
     }
 }
 
+static void neutralize_base_status(player_type *creature_ptr, gm_type *gm_ptr)
+{
+    if (gm_ptr->muta_which == MUT3_PUNY) {
+        if (creature_ptr->muta3 & MUT3_HYPER_STR) {
+            msg_print(_("あなたはもう超人的に強くはない!", "You no longer feel super-strong!"));
+            creature_ptr->muta3 &= ~(MUT3_HYPER_STR);
+        }
+
+        return;
+    }
+    
+    if (gm_ptr->muta_which == MUT3_HYPER_STR) {
+        if (creature_ptr->muta3 & MUT3_PUNY) {
+            msg_print(_("あなたはもう虚弱ではない!", "You no longer feel puny!"));
+            creature_ptr->muta3 &= ~(MUT3_PUNY);
+        }
+
+        return;
+    }
+    
+    if (gm_ptr->muta_which == MUT3_MORONIC) {
+        if (creature_ptr->muta3 & MUT3_HYPER_INT) {
+            msg_print(_("あなたの脳はもう生体コンピュータではない。", "Your brain is no longer a living computer."));
+            creature_ptr->muta3 &= ~(MUT3_HYPER_INT);
+        }
+
+        return;
+    }
+    
+    if (gm_ptr->muta_which == MUT3_HYPER_INT) {
+        if (creature_ptr->muta3 & MUT3_MORONIC) {
+            msg_print(_("あなたはもう精神薄弱ではない。", "You are no longer moronic."));
+            creature_ptr->muta3 &= ~(MUT3_MORONIC);
+        }
+
+        return;
+    }
+    
+    if (gm_ptr->muta_which == MUT3_IRON_SKIN) {
+        if (creature_ptr->muta3 & MUT3_SCALES) {
+            msg_print(_("鱗がなくなった。", "You lose your scales."));
+            creature_ptr->muta3 &= ~(MUT3_SCALES);
+        }
+
+        if (creature_ptr->muta3 & MUT3_FLESH_ROT) {
+            msg_print(_("肉体が腐乱しなくなった。", "Your flesh rots no longer."));
+            creature_ptr->muta3 &= ~(MUT3_FLESH_ROT);
+        }
+
+        if (creature_ptr->muta3 & MUT3_WART_SKIN) {
+            msg_print(_("肌のイボイボがなくなった。", "You lose your warts."));
+            creature_ptr->muta3 &= ~(MUT3_WART_SKIN);
+        }
+
+        return;
+    }
+    
+    if (gm_ptr->muta_which == MUT3_WART_SKIN || gm_ptr->muta_which == MUT3_SCALES || gm_ptr->muta_which == MUT3_FLESH_ROT) {
+        if (creature_ptr->muta3 & MUT3_IRON_SKIN) {
+            msg_print(_("あなたの肌はもう鉄ではない。", "Your skin is no longer made of steel."));
+            creature_ptr->muta3 &= ~(MUT3_IRON_SKIN);
+        }
+
+        return;
+    }
+    
+    if (gm_ptr->muta_which == MUT3_FEARLESS) {
+        if (creature_ptr->muta2 & MUT2_COWARDICE) {
+            msg_print(_("臆病でなくなった。", "You are no longer cowardly."));
+            creature_ptr->muta2 &= ~(MUT2_COWARDICE);
+        }
+
+        return;
+    }
+    
+    if (gm_ptr->muta_which == MUT3_FLESH_ROT) {
+        if (creature_ptr->muta3 & MUT3_REGEN) {
+            msg_print(_("急速に回復しなくなった。", "You stop regenerating."));
+            creature_ptr->muta3 &= ~(MUT3_REGEN);
+        }
+
+        return;
+    }
+    
+    if (gm_ptr->muta_which == MUT3_REGEN) {
+        if (creature_ptr->muta3 & MUT3_FLESH_ROT) {
+            msg_print(_("肉体が腐乱しなくなった。", "Your flesh stops rotting."));
+            creature_ptr->muta3 &= ~(MUT3_FLESH_ROT);
+        }
+
+        return;
+    }
+    
+    if (gm_ptr->muta_which == MUT3_LIMBER) {
+        if (creature_ptr->muta3 & MUT3_ARTHRITIS) {
+            msg_print(_("関節が痛くなくなった。", "Your joints stop hurting."));
+            creature_ptr->muta3 &= ~(MUT3_ARTHRITIS);
+        }
+
+        return;
+    }
+    
+    if (gm_ptr->muta_which == MUT3_ARTHRITIS) {
+        if (creature_ptr->muta3 & MUT3_LIMBER) {
+            msg_print(_("あなたはしなやかでなくなった。", "You no longer feel limber."));
+            creature_ptr->muta3 &= ~(MUT3_LIMBER);
+        }
+
+        return;
+    }
+}
+
 /*!
  * @brief プレイヤーに突然変異を与える
  * @param choose_mut 与えたい突然変異のID、0ならばランダムに選択
@@ -140,72 +252,11 @@ bool gain_mutation(player_type *creature_ptr, MUTATION_IDX choose_mut)
     race_dependent_mutation(creature_ptr, gm_ptr);
     msg_print(_("突然変異した!", "You mutate!"));
     msg_print(gm_ptr->muta_desc);
-    *gm_ptr->muta_class |= gm_ptr->muta_which;
+    if (gm_ptr->muta_class != NULL)
+        *gm_ptr->muta_class |= gm_ptr->muta_which;
+
     if (gm_ptr->muta_class == &(creature_ptr->muta3)) {
-        if (gm_ptr->muta_which == MUT3_PUNY) {
-            if (creature_ptr->muta3 & MUT3_HYPER_STR) {
-                msg_print(_("あなたはもう超人的に強くはない!", "You no longer feel super-strong!"));
-                creature_ptr->muta3 &= ~(MUT3_HYPER_STR);
-            }
-        } else if (gm_ptr->muta_which == MUT3_HYPER_STR) {
-            if (creature_ptr->muta3 & MUT3_PUNY) {
-                msg_print(_("あなたはもう虚弱ではない!", "You no longer feel puny!"));
-                creature_ptr->muta3 &= ~(MUT3_PUNY);
-            }
-        } else if (gm_ptr->muta_which == MUT3_MORONIC) {
-            if (creature_ptr->muta3 & MUT3_HYPER_INT) {
-                msg_print(_("あなたの脳はもう生体コンピュータではない。", "Your brain is no longer a living computer."));
-                creature_ptr->muta3 &= ~(MUT3_HYPER_INT);
-            }
-        } else if (gm_ptr->muta_which == MUT3_HYPER_INT) {
-            if (creature_ptr->muta3 & MUT3_MORONIC) {
-                msg_print(_("あなたはもう精神薄弱ではない。", "You are no longer moronic."));
-                creature_ptr->muta3 &= ~(MUT3_MORONIC);
-            }
-        } else if (gm_ptr->muta_which == MUT3_IRON_SKIN) {
-            if (creature_ptr->muta3 & MUT3_SCALES) {
-                msg_print(_("鱗がなくなった。", "You lose your scales."));
-                creature_ptr->muta3 &= ~(MUT3_SCALES);
-            }
-            if (creature_ptr->muta3 & MUT3_FLESH_ROT) {
-                msg_print(_("肉体が腐乱しなくなった。", "Your flesh rots no longer."));
-                creature_ptr->muta3 &= ~(MUT3_FLESH_ROT);
-            }
-            if (creature_ptr->muta3 & MUT3_WART_SKIN) {
-                msg_print(_("肌のイボイボがなくなった。", "You lose your warts."));
-                creature_ptr->muta3 &= ~(MUT3_WART_SKIN);
-            }
-        } else if (gm_ptr->muta_which == MUT3_WART_SKIN || gm_ptr->muta_which == MUT3_SCALES || gm_ptr->muta_which == MUT3_FLESH_ROT) {
-            if (creature_ptr->muta3 & MUT3_IRON_SKIN) {
-                msg_print(_("あなたの肌はもう鉄ではない。", "Your skin is no longer made of steel."));
-                creature_ptr->muta3 &= ~(MUT3_IRON_SKIN);
-            }
-        } else if (gm_ptr->muta_which == MUT3_FEARLESS) {
-            if (creature_ptr->muta2 & MUT2_COWARDICE) {
-                msg_print(_("臆病でなくなった。", "You are no longer cowardly."));
-                creature_ptr->muta2 &= ~(MUT2_COWARDICE);
-            }
-        } else if (gm_ptr->muta_which == MUT3_FLESH_ROT) {
-            if (creature_ptr->muta3 & MUT3_REGEN) {
-                msg_print(_("急速に回復しなくなった。", "You stop regenerating."));
-                creature_ptr->muta3 &= ~(MUT3_REGEN);
-            }
-        } else if (gm_ptr->muta_which == MUT3_REGEN) {
-            if (creature_ptr->muta3 & MUT3_FLESH_ROT) {
-                msg_print(_("肉体が腐乱しなくなった。", "Your flesh stops rotting."));
-                creature_ptr->muta3 &= ~(MUT3_FLESH_ROT);
-            }
-        } else if (gm_ptr->muta_which == MUT3_LIMBER) {
-            if (creature_ptr->muta3 & MUT3_ARTHRITIS) {
-                msg_print(_("関節が痛くなくなった。", "Your joints stop hurting."));
-                creature_ptr->muta3 &= ~(MUT3_ARTHRITIS);
-            }
-        } else if (gm_ptr->muta_which == MUT3_ARTHRITIS) {
-            if (creature_ptr->muta3 & MUT3_LIMBER) {
-                msg_print(_("あなたはしなやかでなくなった。", "You no longer feel limber."));
-                creature_ptr->muta3 &= ~(MUT3_LIMBER);
-            }
-        }
+        neutralize_base_status(creature_ptr, gm_ptr);
     } else if (gm_ptr->muta_class == &(creature_ptr->muta2)) {
         if (gm_ptr->muta_which == MUT2_COWARDICE) {
             if (creature_ptr->muta3 & MUT3_FEARLESS) {