OSDN Git Service

[Refactor] #2520 PlayerType::fast をPlayerAccelerationの呼び出しに変更し、fast値を増減させている箇所はmod_ac...
[hengbandforosx/hengbandosx.git] / src / status / buff-setter.cpp
index d79dbb5..1393d47 100644 (file)
@@ -19,6 +19,7 @@
 #include "status/buff-setter.h"
 #include "status/element-resistance.h"
 #include "system/player-type-definition.h"
+#include "timed-effect/player-acceleration.h"
 #include "timed-effect/player-confusion.h"
 #include "timed-effect/player-cut.h"
 #include "timed-effect/player-fear.h"
@@ -34,7 +35,7 @@
 void reset_tim_flags(PlayerType *player_ptr)
 {
     auto effects = player_ptr->effects();
-    player_ptr->fast = 0; /* Timed -- Fast */
+    effects->acceleration()->reset();
     player_ptr->lightspeed = 0;
     player_ptr->slow = 0; /* Timed -- Slow */
     player_ptr->blind = 0; /* Timed -- Blindness */
@@ -126,9 +127,10 @@ bool set_fast(PlayerType *player_ptr, TIME_EFFECT v, bool do_dec)
         return false;
     }
 
+    auto acceleration = player_ptr->effects()->acceleration();
     if (v) {
-        if (player_ptr->fast && !do_dec) {
-            if (player_ptr->fast > v) {
+        if (acceleration->is_fast() && !do_dec) {
+            if (acceleration->current() > v) {
                 return false;
             }
         } else if (!is_fast(player_ptr) && !player_ptr->lightspeed) {
@@ -138,13 +140,13 @@ bool set_fast(PlayerType *player_ptr, TIME_EFFECT v, bool do_dec)
             chg_virtue(player_ptr, V_DILIGENCE, 1);
         }
     } else {
-        if (player_ptr->fast && !player_ptr->lightspeed && !music_singing(player_ptr, MUSIC_SPEED) && !music_singing(player_ptr, MUSIC_SHERO)) {
+        if (acceleration->is_fast() && !player_ptr->lightspeed && !music_singing(player_ptr, MUSIC_SPEED) && !music_singing(player_ptr, MUSIC_SHERO)) {
             msg_print(_("動きの素早さがなくなったようだ。", "You feel yourself slow down."));
             notice = true;
         }
     }
 
-    player_ptr->fast = v;
+    acceleration->set(v);
     if (!notice) {
         return false;
     }
@@ -157,6 +159,11 @@ bool set_fast(PlayerType *player_ptr, TIME_EFFECT v, bool do_dec)
     return true;
 }
 
+bool mod_acceleration(PlayerType *player_ptr, const TIME_EFFECT v, const bool do_dec)
+{
+    return set_fast(player_ptr, player_ptr->effects()->acceleration()->current() + v, do_dec);
+}
+
 /*!
  * @brief 肌石化の継続時間をセットする / Set "shield", notice observable changes
  * @param v 継続時間