OSDN Git Service

[Refactor] #3947 エルドリッチホラーのセービングスローをPlayerType::try_resist_eldritch_horror() にまとめた
authorHourier <66951241+Hourier@users.noreply.github.com>
Fri, 21 Jun 2024 10:05:50 +0000 (19:05 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Fri, 21 Jun 2024 14:17:15 +0000 (23:17 +0900)
src/player/eldritch-horror.cpp
src/system/player-type-definition.cpp
src/system/player-type-definition.h

index eceaca9..3983114 100644 (file)
@@ -265,11 +265,11 @@ void sanity_blast(PlayerType *player_ptr, MonsterEntity *m_ptr, bool necro)
 
         do {
             (void)do_dec_stat(player_ptr, A_INT);
-        } while (randint0(100) > player_ptr->skill_sav && one_in_(2));
+        } while (!player_ptr->try_resist_eldritch_horror());
 
         do {
             (void)do_dec_stat(player_ptr, A_WIS);
-        } while (randint0(100) > player_ptr->skill_sav && one_in_(2));
+        } while (!player_ptr->try_resist_eldritch_horror());
 
         break;
     }
index 2ce4302..a85cea0 100644 (file)
@@ -153,3 +153,8 @@ int PlayerType::calc_life_rating() const
 
     return actual_hp * 100 / expected_hp;
 }
+
+bool PlayerType::try_resist_eldritch_horror() const
+{
+    return magik(this->skill_sav) || one_in_(2);
+}
index fbfa366..b1bb47c 100644 (file)
@@ -395,6 +395,7 @@ public:
     bool is_located_at(const Pos2D &pos) const;
     bool in_saved_floor() const;
     int calc_life_rating() const;
+    bool try_resist_eldritch_horror() const;
 
 private:
     std::shared_ptr<TimedEffects> timed_effects;