From: Hourier <66951241+Hourier@users.noreply.github.com> Date: Thu, 10 Mar 2022 10:38:49 +0000 (+0900) Subject: [Refactor] #1642 Separated polymorph() from influence() X-Git-Tag: 3.0.0Alpha57^2~28^2~15 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4a1ad54f9caf1e20f42a3326a32093e095f76659;p=hengbandforosx%2Fhengbandosx.git [Refactor] #1642 Separated polymorph() from influence() --- diff --git a/src/object-use/quaff/quaff-effects.cpp b/src/object-use/quaff/quaff-effects.cpp index 7589293e4..96d41a1de 100644 --- a/src/object-use/quaff/quaff-effects.cpp +++ b/src/object-use/quaff/quaff-effects.cpp @@ -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; +} diff --git a/src/object-use/quaff/quaff-effects.h b/src/object-use/quaff/quaff-effects.h index a369213bd..0829b5bb8 100644 --- a/src/object-use/quaff/quaff-effects.h +++ b/src/object-use/quaff/quaff-effects.h @@ -15,4 +15,5 @@ private: bool booze(); bool sleep(); bool detonation(); + bool polymorph(); };