OSDN Git Service

[Refactor] #1642 Separated lose_memories() from influence()
authorHourier <66951241+Hourier@users.noreply.github.com>
Thu, 10 Mar 2022 10:46:59 +0000 (19:46 +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 c0bd800..fb48475 100644 (file)
@@ -98,15 +98,7 @@ bool QuaffEffects::influence(const ObjectType &o_ref)
     case SV_POTION_SLEEP:
         return this->sleep();
     case SV_POTION_LOSE_MEMORIES:
-        if (this->player_ptr->hold_exp || (this->player_ptr->exp <= 0)) {
-            break;
-        }
-
-        msg_print(_("過去の記憶が薄れていく気がする。", "You feel your memories fade."));
-        chg_virtue(this->player_ptr, V_KNOWLEDGE, -5);
-        lose_exp(this->player_ptr, this->player_ptr->exp / 4);
-        ident = true;
-        break;
+        return this->lose_memories();
     case SV_POTION_RUINATION:
         msg_print(_("身も心も弱ってきて、精気が抜けていくようだ。", "Your nerves and muscles feel weak and lifeless!"));
         take_hit(this->player_ptr, DAMAGE_LOSELIFE, damroll(10, 10), _("破滅の薬", "a potion of Ruination"));
@@ -515,6 +507,22 @@ bool QuaffEffects::sleep()
 }
 
 /*!
+ * @brief 記憶喪失の薬
+ * @return 経験値が下がったか
+ */
+bool QuaffEffects::lose_memories()
+{
+    if (this->player_ptr->hold_exp || (this->player_ptr->exp <= 0)) {
+        return false;
+    }
+
+    msg_print(_("過去の記憶が薄れていく気がする。", "You feel your memories fade."));
+    chg_virtue(this->player_ptr, V_KNOWLEDGE, -5);
+    lose_exp(this->player_ptr, this->player_ptr->exp / 4);
+    return true;
+}
+
+/*!
  * @brief 爆発の薬 / Fumble ramble
  * @return 常にTRUE
  */
index 436ffe1..c54ce0a 100644 (file)
@@ -14,6 +14,7 @@ private:
     bool salt_water();
     bool booze();
     bool sleep();
+    bool lose_memories();
     bool detonation();
     bool augmentation();
     bool polymorph();