OSDN Git Service

[Refactor] #1558 Replaced set_paralyzed() to paralysis() and transferred it into...
authorHourier <66951241+Hourier@users.noreply.github.com>
Mon, 20 Sep 2021 06:14:47 +0000 (15:14 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Wed, 22 Sep 2021 11:37:03 +0000 (20:37 +0900)
22 files changed:
src/action/open-close-execution.cpp
src/cmd-action/cmd-mind.cpp
src/cmd-action/cmd-spell.cpp
src/cmd-item/cmd-eat.cpp
src/core/magic-effects-timeout-reducer.cpp
src/effect/effect-monster-psi.cpp
src/effect/effect-player-oldies.cpp
src/effect/effect-player-spirit.cpp
src/grid/trap.cpp
src/mind/mind-blue-mage.cpp
src/mind/mind-elementalist.cpp
src/monster-attack/monster-attack-status.cpp
src/mspell/mspell-status.cpp
src/object-use/quaff-execution.cpp
src/player/digestion-processor.cpp
src/player/eldritch-horror.cpp
src/specific-object/chest.cpp
src/spell-kind/spells-random.cpp
src/spell/spells-object.cpp
src/spell/spells-status.cpp
src/status/bad-status-setter.cpp
src/status/bad-status-setter.h

index 2a9562d..dbdef1a 100644 (file)
@@ -326,7 +326,7 @@ bool exe_bash(player_type *player_ptr, POSITION y, POSITION x, DIRECTION dir)
         more = true;
     } else {
         msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
-        (void)set_paralyzed(player_ptr, player_ptr->paralyzed + 2 + randint0(2));
+        (void)BadStatusSetter(player_ptr).paralysis(player_ptr->paralyzed + 2 + randint0(2));
     }
 
     return more;
index c089ef5..4297fc7 100644 (file)
@@ -336,7 +336,7 @@ static void mind_reflection(player_type *player_ptr, cm_type *cm_ptr)
 
     player_ptr->csp = MAX(0, player_ptr->csp - cm_ptr->mana_cost);
     msg_format(_("%sを集中しすぎて気を失ってしまった!", "You faint from the effort!"), cm_ptr->mind_explanation);
-    (void)set_paralyzed(player_ptr, player_ptr->paralyzed + randint1(5 * oops + 1));
+    (void)BadStatusSetter(player_ptr).paralysis(player_ptr->paralyzed + randint1(5 * oops + 1));
     if (randint0(100) >= 50)
         return;
 
index 6e4ea0b..743b6d2 100644 (file)
@@ -1350,16 +1350,10 @@ bool do_cmd_cast(player_type *player_ptr)
     /* Over-exert the player */
     if (over_exerted) {
         int oops = need_mana;
-
-        /* No mana left */
         player_ptr->csp = 0;
         player_ptr->csp_frac = 0;
-
         msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
-
-        /* Hack -- Bypass free action */
-        (void)set_paralyzed(player_ptr, player_ptr->paralyzed + randint1(5 * oops + 1));
-
+        (void)BadStatusSetter(player_ptr).paralysis(player_ptr->paralyzed + randint1(5 * oops + 1));
         switch (realm) {
         case REALM_LIFE:
             chg_virtue(player_ptr, V_VITALITY, -10);
index 3e95342..c625862 100644 (file)
@@ -74,7 +74,7 @@ bool exe_eat_food_type_object(player_type *player_ptr, object_type *o_ptr)
     case SV_FOOD_HALLUCINATION:
         return !has_resist_chaos(player_ptr) && set_image(player_ptr, player_ptr->image + randint0(250) + 250);
     case SV_FOOD_PARALYSIS:
-        return !player_ptr->free_act && set_paralyzed(player_ptr, player_ptr->paralyzed + randint0(10) + 10);
+        return !player_ptr->free_act && bss.paralysis(player_ptr->paralyzed + randint0(10) + 10);
     case SV_FOOD_WEAKNESS:
         take_hit(player_ptr, DAMAGE_NOESCAPE, damroll(6, 6), _("毒入り食料", "poisonous food"));
         (void)do_dec_stat(player_ptr, A_STR);
index 9a7be6e..0436437 100644 (file)
@@ -126,7 +126,7 @@ void reduce_magic_effects_timeout(player_type *player_ptr)
     }
 
     if (player_ptr->paralyzed) {
-        (void)set_paralyzed(player_ptr, player_ptr->paralyzed - dec_count);
+        (void)bss.paralysis(player_ptr->paralyzed - dec_count);
     }
 
     if (player_ptr->confused) {
index 739bfb2..d98e57a 100644 (file)
@@ -119,7 +119,7 @@ static void effect_monster_psi_reflect_extra_effect(player_type *player_ptr, eff
         return;
     default:
         if (!player_ptr->free_act) {
-            (void)set_paralyzed(player_ptr, player_ptr->paralyzed + randint1(em_ptr->dam));
+            (void)bss.paralysis(player_ptr->paralyzed + randint1(em_ptr->dam));
         }
 
         return;
index bb8be96..579c361 100644 (file)
@@ -50,6 +50,6 @@ void effect_player_old_sleep(player_type *player_ptr, effect_player_type *ep_ptr
         sanity_blast(player_ptr, nullptr, false);
     }
 
-    set_paralyzed(player_ptr, player_ptr->paralyzed + ep_ptr->dam);
+    (void)BadStatusSetter(player_ptr).paralysis(player_ptr->paralyzed + ep_ptr->dam);
     ep_ptr->dam = 0;
 }
index 06c24d3..4ca89db 100644 (file)
@@ -127,7 +127,7 @@ void effect_player_brain_smash(player_type *player_ptr, effect_player_type *ep_p
     }
 
     if (!player_ptr->free_act) {
-        (void)set_paralyzed(player_ptr, player_ptr->paralyzed + randint0(4) + 4);
+        (void)bss.paralysis(player_ptr->paralyzed + randint0(4) + 4);
     }
 
     (void)set_slow(player_ptr, player_ptr->slow + randint0(4) + 4, false);
index 09aa413..516cd39 100644 (file)
@@ -519,17 +519,17 @@ void hit_trap(player_type *player_ptr, bool break_trap)
 
     case TRAP_SLEEP: {
         msg_print(_("奇妙な白い霧に包まれた!", "A strange white mist surrounds you!"));
-        if (!player_ptr->free_act) {
-            msg_print(_("あなたは眠りに就いた。", "You fall asleep."));
-
-            if (ironman_nightmare) {
-                msg_print(_("身の毛もよだつ光景が頭に浮かんだ。", "A horrible vision enters your mind."));
+        if (player_ptr->free_act) {
+            break;
+        }
 
-                /* Have some nightmares */
-                sanity_blast(player_ptr, nullptr, false);
-            }
-            (void)set_paralyzed(player_ptr, player_ptr->paralyzed + randint0(10) + 5);
+        msg_print(_("あなたは眠りに就いた。", "You fall asleep."));
+        if (ironman_nightmare) {
+            msg_print(_("身の毛もよだつ光景が頭に浮かんだ。", "A horrible vision enters your mind."));
+            sanity_blast(player_ptr, nullptr, false);
         }
+
+        (void)BadStatusSetter(player_ptr).paralysis(player_ptr->paralyzed + randint0(10) + 5);
         break;
     }
 
index 9552e10..e244f18 100644 (file)
@@ -102,7 +102,7 @@ bool do_cmd_cast_learned(player_type *player_ptr)
         player_ptr->csp = 0;
         player_ptr->csp_frac = 0;
         msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
-        (void)set_paralyzed(player_ptr, player_ptr->paralyzed + randint1(5 * oops + 1));
+        (void)BadStatusSetter(player_ptr).paralysis(player_ptr->paralyzed + randint1(5 * oops + 1));
         chg_virtue(player_ptr, V_KNOWLEDGE, -10);
         if (randint0(100) < 50) {
             bool perm = (randint0(100) < 25);
index 8cb5f31..d78de91 100644 (file)
@@ -918,7 +918,7 @@ void do_cmd_element(player_type *player_ptr)
         player_ptr->csp = 0;
         player_ptr->csp_frac = 0;
         msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
-        (void)set_paralyzed(player_ptr, player_ptr->paralyzed + randint1(5 * oops + 1));
+        (void)BadStatusSetter(player_ptr).paralysis(player_ptr->paralyzed + randint1(5 * oops + 1));
         chg_virtue(player_ptr, V_KNOWLEDGE, -10);
         if (randint0(100) < 50) {
             bool perm = (randint0(100) < 25);
index a2b913f..87864e2 100644 (file)
@@ -89,7 +89,7 @@ void process_paralyze_attack(player_type *player_ptr, monap_type *monap_ptr)
         return;
     }
 
-    if (!player_ptr->paralyzed && set_paralyzed(player_ptr, 3 + randint1(monap_ptr->rlev))) {
+    if (!player_ptr->paralyzed && BadStatusSetter(player_ptr).paralysis(3 + randint1(monap_ptr->rlev))) {
         monap_ptr->obvious = true;
     }
 }
index 35b01d0..b0ee446 100644 (file)
@@ -403,7 +403,7 @@ MonsterSpellResult spell_RF5_HOLD(MONSTER_IDX m_idx, player_type *player_ptr, MO
             _("しかし効力を跳ね返した!", "You resist the effects!"), (bool)resist, saving_throw, TARGET_TYPE);
 
         if (!resist && !saving_throw) {
-            (void)set_paralyzed(player_ptr, player_ptr->paralyzed + randint0(4) + 4);
+            (void)BadStatusSetter(player_ptr).paralysis(player_ptr->paralyzed + randint0(4) + 4);
         }
 
         update_smart_learn(player_ptr, m_idx, DRS_FREE);
index 59eaf57..52e7d44 100644 (file)
@@ -177,7 +177,6 @@ void exe_quaff_potion(player_type *player_ptr, INVENTORY_IDX item)
 
         case SV_POTION_SALT_WATER: {
             msg_print(_("うぇ!思わず吐いてしまった。", "The potion makes you vomit!"));
-
             switch (player_race_food(player_ptr)) {
             case PlayerRaceFood::RATION:
             case PlayerRaceFood::WATER:
@@ -190,7 +189,7 @@ void exe_quaff_potion(player_type *player_ptr, INVENTORY_IDX item)
 
             BadStatusSetter bss(player_ptr);
             (void)bss.poison(0);
-            (void)set_paralyzed(player_ptr, player_ptr->paralyzed + 4);
+            (void)bss.paralysis(player_ptr->paralyzed + 4);
             ident = true;
             break;
         }
@@ -215,21 +214,21 @@ void exe_quaff_potion(player_type *player_ptr, INVENTORY_IDX item)
             break;
 
         case SV_POTION_SLEEP:
-            if (!player_ptr->free_act) {
-                msg_print(_("あなたは眠ってしまった。", "You fall asleep."));
+            if (player_ptr->free_act) {
+                break;
+            }
 
-                if (ironman_nightmare) {
-                    msg_print(_("恐ろしい光景が頭に浮かんできた。", "A horrible vision enters your mind."));
+            msg_print(_("あなたは眠ってしまった。", "You fall asleep."));
+            if (ironman_nightmare) {
+                msg_print(_("恐ろしい光景が頭に浮かんできた。", "A horrible vision enters your mind."));
+                sanity_blast(player_ptr, nullptr, false);
+            }
 
-                    /* Have some nightmares */
-                    sanity_blast(player_ptr, nullptr, false);
-                }
-                if (set_paralyzed(player_ptr, player_ptr->paralyzed + randint0(4) + 4)) {
-                    ident = true;
-                }
+            if (BadStatusSetter(player_ptr).paralysis(player_ptr->paralyzed + randint0(4) + 4)) {
+                ident = true;
             }
-            break;
 
+            break;
         case SV_POTION_LOSE_MEMORIES:
             if (!player_ptr->hold_exp && (player_ptr->exp > 0)) {
                 msg_print(_("過去の記憶が薄れていく気がする。", "You feel your memories fade."));
index 16b1c38..c48a3b4 100644 (file)
@@ -55,7 +55,7 @@ void starve_player(player_type *player_ptr)
     if (!player_ptr->paralyzed && (randint0(100) < 10)) {
         msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
         disturb(player_ptr, true, true);
-        (void)set_paralyzed(player_ptr, player_ptr->paralyzed + 1 + randint0(5));
+        (void)BadStatusSetter(player_ptr).paralysis(player_ptr->paralyzed + 1 + randint0(5));
     }
 
     if (player_ptr->food < PY_FOOD_STARVE) {
index e9d3bb5..cf924fc 100644 (file)
@@ -281,7 +281,7 @@ void sanity_blast(player_type *player_ptr, monster_type *m_ptr, bool necro)
             (void)bss.confusion(player_ptr->confused + randint0(4) + 4);
         }
         if (!player_ptr->free_act) {
-            (void)set_paralyzed(player_ptr, player_ptr->paralyzed + randint0(4) + 4);
+            (void)bss.paralysis(player_ptr->paralyzed + randint0(4) + 4);
         }
         if (!has_resist_chaos(player_ptr)) {
             (void)set_image(player_ptr, player_ptr->image + randint0(250) + 150);
index f065805..384c543 100644 (file)
@@ -191,7 +191,7 @@ void chest_trap(player_type *player_ptr, POSITION y, POSITION x, OBJECT_IDX o_id
     if (trap & (CHEST_PARALYZE)) {
         msg_print(_("突如吹き出した黄色いガスに包み込まれた!", "A puff of yellow gas surrounds you!"));
         if (!player_ptr->free_act) {
-            (void)set_paralyzed(player_ptr, player_ptr->paralyzed + 10 + randint1(20));
+            (void)BadStatusSetter(player_ptr).paralysis(player_ptr->paralyzed + 10 + randint1(20));
         }
     }
 
@@ -279,8 +279,9 @@ void chest_trap(player_type *player_ptr, POSITION y, POSITION x, OBJECT_IDX o_id
                     (void)set_cut(player_ptr, player_ptr->cut + 200);
                 else if (one_in_(4)) {
                     auto effects = player_ptr->effects(); // @todo paralyzed と共通化の予定あり.
+                    BadStatusSetter bss(player_ptr);
                     if (!player_ptr->free_act) {
-                        (void)set_paralyzed(player_ptr, player_ptr->paralyzed + 2 + randint0(6));
+                        (void)bss.paralysis(player_ptr->paralyzed + 2 + randint0(6));
                     } else {
                         (void)set_stun(player_ptr, effects->stun()->current() + 10 + randint0(100));
                     }
index 3fd7836..0efc19f 100644 (file)
@@ -178,20 +178,19 @@ bool activate_ty_curse(player_type *player_ptr, bool stop_ty, int *count)
         case 15:
         case 19:
         case 20: {
-            bool is_statue = stop_ty;
+            auto is_statue = stop_ty;
             is_statue |= player_ptr->free_act && (randint1(125) < player_ptr->skill_sav);
             is_statue |= player_ptr->pclass == CLASS_BERSERKER;
             if (!is_statue) {
                 msg_print(_("彫像になった気分だ!", "You feel like a statue!"));
-                if (player_ptr->free_act)
-                    set_paralyzed(player_ptr, player_ptr->paralyzed + randint1(3));
-                else
-                    set_paralyzed(player_ptr, player_ptr->paralyzed + randint1(13));
+                auto turns = player_ptr->free_act ? randint1(3) : randint1(13);
+                (void)BadStatusSetter(player_ptr).paralysis(player_ptr->paralyzed + turns);
                 stop_ty = true;
             }
 
-            if (!one_in_(6))
+            if (!one_in_(6)) {
                 break;
+            }
         }
             /* Fall through */
         case 21:
index b816e5d..abb4ac9 100644 (file)
@@ -372,17 +372,14 @@ bool perilous_secrets(player_type *player_ptr)
 
     BadStatusSetter bss(player_ptr);
     if (player_ptr->msp > 0) {
-        if (20 <= player_ptr->csp)
+        if (20 <= player_ptr->csp) {
             player_ptr->csp -= 20;
-        else {
-            int oops = 20 - player_ptr->csp;
-
+        } else {
+            auto oops = 20 - player_ptr->csp;
             player_ptr->csp = 0;
             player_ptr->csp_frac = 0;
-
             msg_print(_("石を制御できない!", "You are too weak to control the stone!"));
-
-            (void)set_paralyzed(player_ptr, player_ptr->paralyzed + randint1(5 * oops + 1));
+            (void)bss.paralysis(player_ptr->paralyzed + randint1(5 * oops + 1));
             (void)bss.confusion(player_ptr->confused + randint1(5 * oops + 1));
         }
 
index 2087185..d1a0aac 100644 (file)
@@ -288,7 +288,7 @@ bool life_stream(player_type *player_ptr, bool message, bool virtue_change)
     (void)set_image(player_ptr, 0);
     (void)set_stun(player_ptr, 0);
     (void)set_cut(player_ptr, 0);
-    (void)set_paralyzed(player_ptr, 0);
+    (void)bss.paralysis(0);
     (void)restore_all_status(player_ptr);
     (void)set_shero(player_ptr, 0, true);
     handle_stuff(player_ptr);
index 75cf791..ce70481 100644 (file)
@@ -256,45 +256,49 @@ bool BadStatusSetter::afraidness(TIME_EFFECT v)
  * @param v 継続時間
  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
  */
-bool set_paralyzed(player_type *player_ptr, TIME_EFFECT v)
+bool BadStatusSetter::paralysis(TIME_EFFECT v)
 {
-    bool notice = false;
+    auto notice = false;
     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
 
-    if (player_ptr->is_dead)
+    if (this->player_ptr->is_dead) {
         return false;
+    }
 
     if (v) {
-        if (!player_ptr->paralyzed) {
+        if (!this->player_ptr->paralyzed) {
             msg_print(_("体が麻痺してしまった!", "You are paralyzed!"));
-            if (player_ptr->concent)
-                reset_concentration(player_ptr, true);
+            if (this->player_ptr->concent) {
+                reset_concentration(this->player_ptr, true);
+            }
 
-            SpellHex spell_hex(player_ptr);
+            SpellHex spell_hex(this->player_ptr);
             if (spell_hex.is_spelling_any()) {
                 (void)spell_hex.stop_all_spells();
             }
 
-            player_ptr->counter = false;
+            this->player_ptr->counter = false;
             notice = true;
         }
     } else {
-        if (player_ptr->paralyzed) {
+        if (this->player_ptr->paralyzed) {
             msg_print(_("やっと動けるようになった。", "You can move again."));
             notice = true;
         }
     }
 
-    player_ptr->paralyzed = v;
-    player_ptr->redraw |= (PR_STATUS);
-
-    if (!notice)
+    this->player_ptr->paralyzed = v;
+    this->player_ptr->redraw |= PR_STATUS;
+    if (!notice) {
         return false;
+    }
 
-    if (disturb_state)
-        disturb(player_ptr, false, false);
-    player_ptr->redraw |= (PR_STATE);
-    handle_stuff(player_ptr);
+    if (disturb_state) {
+        disturb(this->player_ptr, false, false);
+    }
+
+    this->player_ptr->redraw |= PR_STATE;
+    handle_stuff(this->player_ptr);
     return true;
 }
 
index 5c967bc..20f2980 100644 (file)
@@ -13,12 +13,12 @@ public:
     bool confusion(TIME_EFFECT v);
     bool poison(TIME_EFFECT v);
     bool afraidness(TIME_EFFECT v);
+    bool paralysis(TIME_EFFECT v);
 
 private:
     player_type *player_ptr;
 };
 
-bool set_paralyzed(player_type *player_ptr, TIME_EFFECT v);
 bool set_image(player_type *player_ptr, TIME_EFFECT v);
 bool set_slow(player_type *player_ptr, TIME_EFFECT v, bool do_dec);
 bool set_stun(player_type *player_ptr, TIME_EFFECT v);