OSDN Git Service

[Refactor] #2299 PlayerType::fearful を削除し、TimedEffects::Fear 側に処理を全て移した
authorHourier <66951241+Hourier@users.noreply.github.com>
Mon, 28 Feb 2022 12:59:12 +0000 (21:59 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Mon, 28 Feb 2022 12:59:12 +0000 (21:59 +0900)
src/cmd-action/cmd-attack.cpp
src/core/magic-effects-timeout-reducer.cpp
src/load/player-info-loader.cpp
src/mind/mind-samurai.cpp
src/player-info/self-info.cpp
src/save/player-writer.cpp
src/status/bad-status-setter.cpp
src/status/buff-setter.cpp
src/system/player-type-definition.cpp
src/system/player-type-definition.h
src/window/main-window-stat-poster.cpp

index 99d6854..3fb82d7 100644 (file)
@@ -52,6 +52,7 @@
 #include "system/object-type-definition.h"
 #include "system/player-type-definition.h"
 #include "timed-effect/player-confusion.h"
+#include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
 #include "timed-effect/player-stun.h"
 #include "timed-effect/timed-effects.h"
@@ -243,7 +244,7 @@ bool do_cmd_attack(PlayerType *player_ptr, POSITION y, POSITION x, combat_option
         }
     }
 
-    if (player_ptr->fearful) {
+    if (effects->fear()->is_fearful()) {
         if (m_ptr->ml) {
             msg_format(_("恐くて%sを攻撃できない!", "You are too fearful to attack %s!"), m_name);
         } else {
index 808f8b8..d82730f 100644 (file)
@@ -19,6 +19,7 @@
 #include "system/player-type-definition.h"
 #include "timed-effect/player-confusion.h"
 #include "timed-effect/player-cut.h"
+#include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
 #include "timed-effect/player-paralysis.h"
 #include "timed-effect/player-stun.h"
@@ -138,7 +139,7 @@ void reduce_magic_effects_timeout(PlayerType *player_ptr)
         (void)bss.mod_confusion(-1);
     }
 
-    if (player_ptr->fearful) {
+    if (effects->fear()->is_fearful()) {
         (void)bss.mod_afraidness(-1);
     }
 
index 492a796..07a042a 100644 (file)
@@ -25,6 +25,7 @@
 #include "system/player-type-definition.h"
 #include "timed-effect/player-confusion.h"
 #include "timed-effect/player-cut.h"
+#include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
 #include "timed-effect/player-paralysis.h"
 #include "timed-effect/player-stun.h"
@@ -348,7 +349,7 @@ static void rd_status(PlayerType *player_ptr)
     auto effects = player_ptr->effects();
     player_ptr->fast = rd_s16b();
     player_ptr->slow = rd_s16b();
-    player_ptr->fearful = rd_s16b();
+    effects->fear()->set(rd_s16b());
     effects->cut()->set(rd_s16b());
     effects->stun()->set(rd_s16b());
     player_ptr->poisoned = rd_s16b();
index b5e1a6a..ced12d1 100644 (file)
@@ -37,6 +37,7 @@
 #include "system/player-type-definition.h"
 #include "term/screen-processor.h"
 #include "timed-effect/player-cut.h"
+#include "timed-effect/player-fear.h"
 #include "timed-effect/player-stun.h"
 #include "timed-effect/timed-effects.h"
 #include "util/bit-flags-calculator.h"
@@ -386,7 +387,7 @@ bool choose_samurai_stance(PlayerType *player_ptr)
         return false;
     }
 
-    if (player_ptr->fearful) {
+    if (effects->fear()->is_fearful()) {
         msg_print(_("体が震えて構えられない!", "You are trembling with fear!"));
         return false;
     }
index ca7de18..e1d81e9 100644 (file)
@@ -30,6 +30,7 @@
 #include "term/screen-processor.h"
 #include "timed-effect/player-confusion.h"
 #include "timed-effect/player-cut.h"
+#include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
 #include "timed-effect/player-stun.h"
 #include "timed-effect/timed-effects.h"
@@ -46,7 +47,7 @@ static void set_bad_status_info(PlayerType *player_ptr, self_info_type *self_ptr
         self_ptr->info[self_ptr->line++] = _("あなたは混乱している。", "You are confused.");
     }
 
-    if (player_ptr->fearful) {
+    if (effects->fear()->is_fearful()) {
         self_ptr->info[self_ptr->line++] = _("あなたは恐怖に侵されている。", "You are terrified.");
     }
 
@@ -329,8 +330,8 @@ void report_magics(PlayerType *player_ptr)
         info[i++] = _("あなたは混乱している", "You are confused");
     }
 
-    if (player_ptr->fearful) {
-        info2[i] = report_magics_aux(player_ptr->fearful);
+    if (effects->fear()->is_fearful()) {
+        info2[i] = report_magics_aux(effects->fear()->current());
         info[i++] = _("あなたは恐怖に侵されている", "You are terrified");
     }
 
index d1976b5..c231f13 100644 (file)
@@ -12,6 +12,7 @@
 #include "system/player-type-definition.h"
 #include "timed-effect/player-confusion.h"
 #include "timed-effect/player-cut.h"
+#include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
 #include "timed-effect/player-paralysis.h"
 #include "timed-effect/player-stun.h"
@@ -164,7 +165,7 @@ void wr_player(PlayerType *player_ptr)
     wr_s16b(player_ptr->enchant_energy_need);
     wr_s16b(player_ptr->fast);
     wr_s16b(player_ptr->slow);
-    wr_s16b(player_ptr->fearful);
+    wr_s16b(effects->fear()->current());
     wr_s16b(effects->cut()->current());
     wr_s16b(effects->stun()->current());
     wr_s16b(player_ptr->poisoned);
index 548822b..cb274d9 100644 (file)
@@ -21,6 +21,7 @@
 #include "system/player-type-definition.h"
 #include "timed-effect/player-confusion.h"
 #include "timed-effect/player-cut.h"
+#include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
 #include "timed-effect/player-paralysis.h"
 #include "timed-effect/player-stun.h"
@@ -231,8 +232,9 @@ bool BadStatusSetter::afraidness(const TIME_EFFECT tmp_v)
         return false;
     }
 
+    auto fear = this->player_ptr->effects()->fear();
     if (v > 0) {
-        if (!this->player_ptr->fearful) {
+        if (!fear->is_fearful()) {
             msg_print(_("何もかも恐くなってきた!", "You are terrified!"));
             if (PlayerClass(this->player_ptr).lose_balance()) {
                 msg_print(_("型が崩れた。", "You lose your stance."));
@@ -243,13 +245,13 @@ bool BadStatusSetter::afraidness(const TIME_EFFECT tmp_v)
             chg_virtue(this->player_ptr, V_VALOUR, -1);
         }
     } else {
-        if (this->player_ptr->fearful) {
+        if (fear->is_fearful()) {
             msg_print(_("やっと恐怖を振り払った。", "You feel bolder now."));
             notice = true;
         }
     }
 
-    this->player_ptr->fearful = v;
+    fear->set(v);
     this->player_ptr->redraw |= PR_STATUS;
     if (!notice) {
         return false;
@@ -265,7 +267,7 @@ bool BadStatusSetter::afraidness(const TIME_EFFECT tmp_v)
 
 bool BadStatusSetter::mod_afraidness(const TIME_EFFECT tmp_v)
 {
-    return this->afraidness(this->player_ptr->fearful + tmp_v);
+    return this->afraidness(this->player_ptr->effects()->fear()->current() + tmp_v);
 }
 
 /*!
index 70914b5..d79dbb5 100644 (file)
@@ -21,6 +21,7 @@
 #include "system/player-type-definition.h"
 #include "timed-effect/player-confusion.h"
 #include "timed-effect/player-cut.h"
+#include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
 #include "timed-effect/player-paralysis.h"
 #include "timed-effect/player-stun.h"
@@ -39,7 +40,7 @@ void reset_tim_flags(PlayerType *player_ptr)
     player_ptr->blind = 0; /* Timed -- Blindness */
     effects->paralysis()->reset();
     effects->confusion()->reset();
-    player_ptr->fearful = 0; /* Timed -- Fear */
+    effects->fear()->reset();
     effects->hallucination()->reset();
     player_ptr->poisoned = 0; /* Timed -- Poisoned */
     effects->cut()->reset();
index 400a97f..26df859 100644 (file)
@@ -2,6 +2,7 @@
 #include "market/arena-info-table.h"
 #include "timed-effect/player-confusion.h"
 #include "timed-effect/player-cut.h"
+#include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
 #include "timed-effect/player-paralysis.h"
 #include "timed-effect/player-stun.h"
@@ -46,7 +47,7 @@ bool PlayerType::is_fully_healthy() const
     is_fully_healthy &= !this->blind;
     is_fully_healthy &= !effects->confusion()->is_confused();
     is_fully_healthy &= !this->poisoned;
-    is_fully_healthy &= !this->fearful;
+    is_fully_healthy &= !effects->fear()->is_fearful();
     is_fully_healthy &= !effects->stun()->is_stunned();
     is_fully_healthy &= !effects->cut()->is_cut();
     is_fully_healthy &= !this->slow;
index cabf4a4..891b461 100644 (file)
@@ -96,7 +96,6 @@ public:
     TIME_EFFECT fast{}; /* Timed -- Fast */
     TIME_EFFECT slow{}; /* Timed -- Slow */
     TIME_EFFECT blind{}; /* Timed -- Blindness */
-    TIME_EFFECT fearful{}; /* Timed -- Fear */
     TIME_EFFECT poisoned{}; /* Timed -- Poisoned */
 
     TIME_EFFECT protevil{}; /* Timed -- Protection */
index d077d5b..786736e 100644 (file)
@@ -24,6 +24,7 @@
 #include "term/term-color-types.h"
 #include "timed-effect/player-confusion.h"
 #include "timed-effect/player-cut.h"
+#include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
 #include "timed-effect/player-paralysis.h"
 #include "timed-effect/player-stun.h"
@@ -596,7 +597,7 @@ void print_status(PlayerType *player_ptr)
         ADD_BAR_FLAG(BAR_ALTER);
     }
 
-    if (player_ptr->fearful) {
+    if (effects->fear()->is_fearful()) {
         ADD_BAR_FLAG(BAR_AFRAID);
     }