OSDN Git Service

[Refactor] #1578 Separated process_cut_effect() from cut()
authorHourier <66951241+Hourier@users.noreply.github.com>
Wed, 22 Sep 2021 12:42:22 +0000 (21:42 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Thu, 23 Sep 2021 07:26:40 +0000 (16:26 +0900)
src/status/bad-status-setter.cpp
src/status/bad-status-setter.h

index 3333432..cf61612 100644 (file)
@@ -494,7 +494,6 @@ bool BadStatusSetter::stun(const TIME_EFFECT tmp_v)
  */
 bool BadStatusSetter::cut(const TIME_EFFECT tmp_v)
 {
-    auto notice = false;
     auto v = std::clamp<short>(tmp_v, 0, 10000);
     if (this->player_ptr->is_dead) {
         return false;
@@ -504,17 +503,7 @@ bool BadStatusSetter::cut(const TIME_EFFECT tmp_v)
         v = 0;
     }
 
-    auto player_cut = this->player_ptr->effects()->cut();
-    auto old_aux = player_cut->get_rank();
-    auto new_aux = player_cut->get_rank(v);
-    if (new_aux > old_aux) {
-        this->decrease_charisma(new_aux, v);
-        notice = true;
-    } else if (new_aux < old_aux) {
-        this->stop_blooding(new_aux);
-        notice = true;
-    }
-
+    auto notice = this->process_cut_effect(v);
     this->player_ptr->cut = v;
     if (!notice) {
         return false;
@@ -530,6 +519,24 @@ bool BadStatusSetter::cut(const TIME_EFFECT tmp_v)
     return true;
 }
 
+bool BadStatusSetter::process_cut_effect(const short v)
+{
+    auto player_cut = this->player_ptr->effects()->cut();
+    auto old_aux = player_cut->get_rank();
+    auto new_aux = player_cut->get_rank(v);
+    if (new_aux > old_aux) {
+        this->decrease_charisma(new_aux, v);
+        return true;
+    }
+    
+    if (new_aux < old_aux) {
+        this->stop_blooding(new_aux);
+        return true;
+    }
+
+    return false;
+}
+
 void BadStatusSetter::decrease_charisma(const PlayerCutRank new_aux, const short v)
 {
     auto player_cut = this->player_ptr->effects()->cut();
index ecb5f6c..a0cb3b2 100644 (file)
@@ -26,6 +26,7 @@ public:
 private:
     player_type *player_ptr;
 
+    bool process_cut_effect(const short v);
     void decrease_charisma(const PlayerCutRank new_aux, const short v);
     void stop_blooding(const PlayerCutRank new_aux);
 };