From ca0fdf2ac9dc5f590145aa99cfde3ac9e78dd3df Mon Sep 17 00:00:00 2001 From: Hourier <66951241+Hourier@users.noreply.github.com> Date: Thu, 10 Mar 2022 19:35:13 +0900 Subject: [PATCH] [Refactor] #1642 Separated sleep() from influence() --- src/object-use/quaff/quaff-effects.cpp | 35 +++++++++++++++++++--------------- src/object-use/quaff/quaff-effects.h | 1 + 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/object-use/quaff/quaff-effects.cpp b/src/object-use/quaff/quaff-effects.cpp index d7f177478..7589293e4 100644 --- a/src/object-use/quaff/quaff-effects.cpp +++ b/src/object-use/quaff/quaff-effects.cpp @@ -96,21 +96,7 @@ bool QuaffEffects::influence(const ObjectType &o_ref) ident = this->booze(); break; case SV_POTION_SLEEP: - if (this->player_ptr->free_act) { - break; - } - - msg_print(_("あなたは眠ってしまった。", "You fall asleep.")); - if (ironman_nightmare) { - msg_print(_("恐ろしい光景が頭に浮かんできた。", "A horrible vision enters your mind.")); - sanity_blast(this->player_ptr, nullptr, false); - } - - if (BadStatusSetter(this->player_ptr).mod_paralysis(randint0(4) + 4)) { - ident = true; - } - - break; + return this->sleep(); case SV_POTION_LOSE_MEMORIES: if (this->player_ptr->hold_exp || (this->player_ptr->exp <= 0)) { break; @@ -548,6 +534,25 @@ bool QuaffEffects::booze() } /*! + * @brief 眠りの薬 + * @return 麻痺したか否か + */ +bool QuaffEffects::sleep() +{ + if (this->player_ptr->free_act) { + return false; + } + + msg_print(_("あなたは眠ってしまった。", "You fall asleep.")); + if (ironman_nightmare) { + msg_print(_("恐ろしい光景が頭に浮かんできた。", "A horrible vision enters your mind.")); + sanity_blast(this->player_ptr, nullptr, false); + } + + return BadStatusSetter(this->player_ptr).mod_paralysis(randint0(4) + 4); +} + +/*! * @brief 爆発の薬 / Fumble ramble * @return 常にTRUE */ diff --git a/src/object-use/quaff/quaff-effects.h b/src/object-use/quaff/quaff-effects.h index 8191f524a..a369213bd 100644 --- a/src/object-use/quaff/quaff-effects.h +++ b/src/object-use/quaff/quaff-effects.h @@ -13,5 +13,6 @@ private: bool salt_water(); bool booze(); + bool sleep(); bool detonation(); }; -- 2.11.0