OSDN Git Service

[Refactor] #1599 Defined mod_blindness() and replaced the calls
authorHourier <66951241+Hourier@users.noreply.github.com>
Fri, 24 Sep 2021 01:02:48 +0000 (10:02 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Fri, 24 Sep 2021 01:02:48 +0000 (10:02 +0900)
13 files changed:
src/cmd-item/cmd-eat.cpp
src/cmd-item/cmd-usestaff.cpp
src/core/magic-effects-timeout-reducer.cpp
src/effect/effect-player-resist-hurt.cpp
src/effect/effect-player-spirit.cpp
src/grid/trap.cpp
src/monster-attack/monster-attack-status.cpp
src/object-use/quaff-execution.cpp
src/object-use/read-execution.cpp
src/spell-kind/spells-floor.cpp
src/spell/spells-status.cpp
src/status/bad-status-setter.cpp
src/status/bad-status-setter.h

index c6bd64d..8f124d0 100644 (file)
@@ -66,7 +66,7 @@ bool exe_eat_food_type_object(player_type *player_ptr, object_type *o_ptr)
     case SV_FOOD_POISON:
         return (!(has_resist_pois(player_ptr) || is_oppose_pois(player_ptr))) && bss.poison(player_ptr->poisoned + randint0(10) + 10);
     case SV_FOOD_BLINDNESS:
-        return !has_resist_blind(player_ptr) && bss.blindness(player_ptr->blind + randint0(200) + 200);
+        return !has_resist_blind(player_ptr) && bss.mod_blindness(randint0(200) + 200);
     case SV_FOOD_PARANOIA:
         return !has_resist_fear(player_ptr) && bss.afraidness(player_ptr->afraid + randint0(10) + 10);
     case SV_FOOD_CONFUSION:
index 705dd2c..fbbff2c 100644 (file)
@@ -75,7 +75,7 @@ int staff_effect(player_type *player_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use_c
     switch (sval) {
     case SV_STAFF_DARKNESS:
         if (!has_resist_blind(player_ptr) && !has_resist_dark(player_ptr)) {
-            if (bss.blindness(player_ptr->blind + 3 + randint1(5))) {
+            if (bss.mod_blindness(3 + randint1(5))) {
                 ident = true;
             }
         }
index 7ccdb78..74e886b 100644 (file)
@@ -39,7 +39,7 @@ void reduce_magic_effects_timeout(player_type *player_ptr)
     }
 
     if (player_ptr->blind) {
-        (void)bss.blindness(player_ptr->blind - dec_count);
+        (void)bss.mod_blindness(-dec_count);
     }
 
     if (player_ptr->tim_invis) {
index 4b621b1..64007ea 100644 (file)
@@ -390,7 +390,7 @@ void effect_player_lite(player_type *player_ptr, effect_player_type *ep_ptr)
     if (player_ptr->blind)
         msg_print(_("何かで攻撃された!", "You are hit by something!"));
     if (!player_ptr->blind && !has_resist_lite(player_ptr) && !has_resist_blind(player_ptr) && !check_multishadow(player_ptr)) {
-        (void)BadStatusSetter(player_ptr).blindness(player_ptr->blind + randint1(5) + 2);
+        (void)BadStatusSetter(player_ptr).mod_blindness(randint1(5) + 2);
     }
 
     ep_ptr->dam = ep_ptr->dam * calc_lite_damage_rate(player_ptr, CALC_RAND) / 100;
@@ -421,7 +421,7 @@ void effect_player_dark(player_type *player_ptr, effect_player_type *ep_ptr)
     ep_ptr->dam = ep_ptr->dam * calc_dark_damage_rate(player_ptr, CALC_RAND) / 100;
 
     if (!player_ptr->blind && !has_resist_dark(player_ptr) && !has_resist_blind(player_ptr) && !check_multishadow(player_ptr)) {
-        (void)BadStatusSetter(player_ptr).blindness(player_ptr->blind + randint1(5) + 2);
+        (void)BadStatusSetter(player_ptr).mod_blindness(randint1(5) + 2);
     }
 
     ep_ptr->get_damage = take_hit(player_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer);
index 1db5c70..ffe1f30 100644 (file)
@@ -119,7 +119,7 @@ void effect_player_brain_smash(player_type *player_ptr, effect_player_type *ep_p
 
     BadStatusSetter bss(player_ptr);
     if (!has_resist_blind(player_ptr)) {
-        (void)bss.blindness(player_ptr->blind + 8 + randint0(8));
+        (void)bss.mod_blindness(8 + randint0(8));
     }
 
     if (!has_resist_conf(player_ptr)) {
index eecfa0e..5f15eda 100644 (file)
@@ -499,7 +499,7 @@ void hit_trap(player_type *player_ptr, bool break_trap)
     case TRAP_BLIND:
         msg_print(_("黒いガスに包み込まれた!", "A black gas surrounds you!"));
         if (has_resist_blind(player_ptr) == 0) {
-            (void)BadStatusSetter(player_ptr).blindness(player_ptr->blind + (TIME_EFFECT)randint0(50) + 25);
+            (void)BadStatusSetter(player_ptr).mod_blindness(randint0(50) + 25);
         }
 
         break;
index a6dbb07..8ce2939 100644 (file)
@@ -35,7 +35,7 @@ void process_blind_attack(player_type *player_ptr, monap_type *monap_ptr)
         return;
     }
 
-    if (!BadStatusSetter(player_ptr).blindness(player_ptr->blind + 10 + randint1(monap_ptr->rlev))) {
+    if (!BadStatusSetter(player_ptr).mod_blindness(10 + randint1(monap_ptr->rlev))) {
         return;
     }
 
index f71ef88..e9e6164 100644 (file)
@@ -207,7 +207,7 @@ void exe_quaff_potion(player_type *player_ptr, INVENTORY_IDX item)
 
         case SV_POTION_BLINDNESS:
             if (!has_resist_blind(player_ptr)) {
-                if (BadStatusSetter(player_ptr).blindness(player_ptr->blind + randint0(100) + 100)) {
+                if (BadStatusSetter(player_ptr).mod_blindness(randint0(100) + 100)) {
                     ident = true;
                 }
             }
index 9e8614f..86811ce 100644 (file)
@@ -107,7 +107,7 @@ void exe_read(player_type *player_ptr, INVENTORY_IDX item, bool known)
         switch (o_ptr->sval) {
         case SV_SCROLL_DARKNESS: {
             if (!has_resist_blind(player_ptr) && !has_resist_dark(player_ptr))
-                (void)BadStatusSetter(player_ptr).blindness(player_ptr->blind + 3 + randint1(5));
+                (void)BadStatusSetter(player_ptr).mod_blindness(3 + randint1(5));
 
             if (unlite_area(player_ptr, 10, 3))
                 ident = true;
index e004d0b..14a316d 100644 (file)
@@ -444,7 +444,7 @@ bool destroy_area(player_type *player_ptr, POSITION y1, POSITION x1, POSITION r,
     if (flag) {
         msg_print(_("燃えるような閃光が発生した!", "There is a searing blast of light!"));
         if (!has_resist_blind(player_ptr) && !has_resist_lite(player_ptr)) {
-            (void)BadStatusSetter(player_ptr).blindness(player_ptr->blind + 10 + randint1(10));
+            (void)BadStatusSetter(player_ptr).mod_blindness(10 + randint1(10));
         }
     }
 
index 3bbf88d..02ab732 100644 (file)
@@ -571,9 +571,9 @@ bool cosmic_cast_off(player_type *player_ptr, object_type **o_ptr_ptr)
 
     /* Get effects */
     msg_print(_("「燃え上がれ俺の小宇宙!」", "You say, 'Burn up my cosmo!"));
-    int t = 20 + randint1(20);
+    TIME_EFFECT t = 20 + randint1(20);
     BadStatusSetter bss(player_ptr);
-    (void)bss.blindness(player_ptr->blind + t);
+    (void)bss.mod_blindness(t);
     (void)bss.afraidness(0);
     (void)set_tim_esp(player_ptr, player_ptr->tim_esp + t, false);
     (void)set_tim_regen(player_ptr, player_ptr->tim_regen + t, false);
index a45822b..0274e93 100644 (file)
@@ -86,6 +86,11 @@ bool BadStatusSetter::blindness(const TIME_EFFECT tmp_v)
     return true;
 }
 
+bool BadStatusSetter::mod_blindness(const TIME_EFFECT tmp_v)
+{
+    return this->blindness(this->player_ptr->blind + tmp_v);
+}
+
 /*!
  * @brief 混乱の継続時間をセットする / Set "confused", notice observable changes
  * @param v 継続時間
index cde15b2..57878c7 100644 (file)
@@ -15,6 +15,7 @@ public:
     virtual ~BadStatusSetter() = default;
     
     bool blindness(const TIME_EFFECT tmp_v);
+    bool mod_blindness(const TIME_EFFECT tmp_v);
     bool confusion(const TIME_EFFECT tmp_v);
     bool poison(const TIME_EFFECT tmp_v);
     bool afraidness(const TIME_EFFECT tmp_v);