OSDN Git Service

[Refactor] #1578 Separated process_stun_status() from stun()
authorHourier <66951241+Hourier@users.noreply.github.com>
Wed, 22 Sep 2021 13:01:34 +0000 (22:01 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Thu, 23 Sep 2021 07:26:41 +0000 (16:26 +0900)
src/status/bad-status-setter.cpp
src/status/bad-status-setter.h

index d91fca0..9436bfb 100644 (file)
@@ -413,8 +413,7 @@ bool BadStatusSetter::stun(const TIME_EFFECT tmp_v)
         return false;
     }
 
-    PlayerClass player_class(this->player_ptr);
-    if (PlayerRace(this->player_ptr).equals(player_race_type::GOLEM) || player_class.can_resist_stun()) {
+    if (PlayerRace(this->player_ptr).equals(player_race_type::GOLEM) || PlayerClass(this->player_ptr).can_resist_stun()) {
         v = 0;
     }
 
@@ -422,22 +421,7 @@ bool BadStatusSetter::stun(const TIME_EFFECT tmp_v)
     auto old_aux = player_stun->get_rank();
     auto new_aux = PlayerStun::get_rank(v);
     if (new_aux > old_aux) {
-        auto stun_mes = PlayerStun::get_stun_mes(new_aux);
-        msg_print(stun_mes.data());
-        this->decrease_int_wis(v);
-        if (player_class.lose_balance()) {
-            msg_print(_("型が崩れた。", "You lose your stance."));
-        }
-
-        if (this->player_ptr->concent) {
-            reset_concentration(this->player_ptr, true);
-        }
-
-        SpellHex spell_hex(this->player_ptr);
-        if (spell_hex.is_spelling_any()) {
-            (void)spell_hex.stop_all_spells();
-        }
-
+        this->process_stun_status(new_aux, v);
         notice = true;
     } else if (new_aux < old_aux) {
         if (new_aux == PlayerStunRank::NONE) {
@@ -499,6 +483,25 @@ bool BadStatusSetter::cut(const TIME_EFFECT tmp_v)
     return true;
 }
 
+void BadStatusSetter::process_stun_status(const PlayerStunRank new_aux, const short v)
+{
+    auto stun_mes = PlayerStun::get_stun_mes(new_aux);
+    msg_print(stun_mes.data());
+    this->decrease_int_wis(v);
+    if (PlayerClass(this->player_ptr).lose_balance()) {
+        msg_print(_("型が崩れた。", "You lose your stance."));
+    }
+
+    if (this->player_ptr->concent) {
+        reset_concentration(this->player_ptr, true);
+    }
+
+    SpellHex spell_hex(this->player_ptr);
+    if (spell_hex.is_spelling_any()) {
+        (void)spell_hex.stop_all_spells();
+    }
+}
+
 /*!
  * @todo 後で知能と賢さが両方減る確率を減らす.
  */
index 818e111..09f6c04 100644 (file)
@@ -7,6 +7,7 @@
  * @todo TIME_EFFECT型の引数はplayer_typeの時限ステータスをTimedEffectsクラスへ入れる時にshortへ差し替えること.
  */
 enum class PlayerCutRank;
+enum class PlayerStunRank;
 struct player_type;
 class BadStatusSetter {
 public:
@@ -26,6 +27,7 @@ public:
 private:
     player_type *player_ptr;
 
+    void process_stun_status(const PlayerStunRank new_aux, const short v);
     void decrease_int_wis(const short v);
     bool process_cut_effect(const short v);
     void decrease_charisma(const PlayerCutRank new_aux, const short v);