OSDN Git Service

[Refactor] #2523 PlayerType::blind をPlayerBlindnessの呼び出しに差し替えた
[hengbandforosx/hengbandosx.git] / src / action / open-close-execution.cpp
index 514193b..65c92fb 100644 (file)
@@ -16,6 +16,7 @@
 #include "main/sound-definitions-table.h"
 #include "main/sound-of-music.h"
 #include "perception/object-perception.h"
+#include "player-base/player-class.h"
 #include "player-status/player-energy.h"
 #include "player/player-status-table.h"
 #include "specific-object/chest.h"
 #include "system/object-type-definition.h"
 #include "system/player-type-definition.h"
 #include "term/screen-processor.h"
+#include "timed-effect/player-blindness.h"
+#include "timed-effect/player-confusion.h"
+#include "timed-effect/player-hallucination.h"
+#include "timed-effect/timed-effects.h"
 #include "util/bit-flags-calculator.h"
 #include "view/display-messages.h"
 
@@ -38,8 +43,8 @@
  */
 bool exe_open(PlayerType *player_ptr, POSITION y, POSITION x)
 {
-    grid_type *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
-    feature_type *f_ptr = &f_info[g_ptr->feat];
+    auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
+    auto *f_ptr = &f_info[g_ptr->feat];
     PlayerEnergy(player_ptr).set_player_turn_energy(100);
     if (f_ptr->flags.has_not(FloorFeatureType::OPEN)) {
         msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_info[g_ptr->get_feat_mimic()].name.c_str());
@@ -53,20 +58,25 @@ bool exe_open(PlayerType *player_ptr, POSITION y, POSITION x)
     }
 
     int i = player_ptr->skill_dis;
-    if (player_ptr->blind || no_lite(player_ptr))
+    const auto effects = player_ptr->effects();
+    if (effects->blindness()->is_blind() || no_lite(player_ptr)) {
         i = i / 10;
+    }
 
-    if (player_ptr->confused || player_ptr->hallucinated)
+    if (effects->confusion()->is_confused() || effects->hallucination()->is_hallucinated()) {
         i = i / 10;
+    }
 
     int j = f_ptr->power;
     j = i - (j * 4);
-    if (j < 2)
+    if (j < 2) {
         j = 2;
+    }
 
     if (randint0(100) >= j) {
-        if (flush_failure)
+        if (flush_failure) {
             flush();
+        }
 
         msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
         return true;
@@ -93,12 +103,13 @@ bool exe_open(PlayerType *player_ptr, POSITION y, POSITION x)
  */
 bool exe_close(PlayerType *player_ptr, POSITION y, POSITION x)
 {
-    grid_type *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
+    auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
     FEAT_IDX old_feat = g_ptr->feat;
     bool more = false;
     PlayerEnergy(player_ptr).set_player_turn_energy(100);
-    if (f_info[old_feat].flags.has_not(FloorFeatureType::CLOSE))
+    if (f_info[old_feat].flags.has_not(FloorFeatureType::CLOSE)) {
         return more;
+    }
 
     int16_t closed_feat = feat_state(player_ptr->current_floor_ptr, old_feat, FloorFeatureType::CLOSE);
     if ((!g_ptr->o_idx_list.empty() || g_ptr->is_object()) && (closed_feat != old_feat) && f_info[closed_feat].flags.has_not(FloorFeatureType::DROP)) {
@@ -133,25 +144,30 @@ bool exe_close(PlayerType *player_ptr, POSITION y, POSITION x)
 bool easy_open_door(PlayerType *player_ptr, POSITION y, POSITION x)
 {
     int i, j;
-    grid_type *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
-    feature_type *f_ptr = &f_info[g_ptr->feat];
-    if (!is_closed_door(player_ptr, g_ptr->feat))
+    auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
+    auto *f_ptr = &f_info[g_ptr->feat];
+    if (!is_closed_door(player_ptr, g_ptr->feat)) {
         return false;
+    }
 
     if (f_ptr->flags.has_not(FloorFeatureType::OPEN)) {
         msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_info[g_ptr->get_feat_mimic()].name.c_str());
     } else if (f_ptr->power) {
         i = player_ptr->skill_dis;
-        if (player_ptr->blind || no_lite(player_ptr))
+        const auto effects = player_ptr->effects();
+        if (effects->blindness()->is_blind() || no_lite(player_ptr)) {
             i = i / 10;
+        }
 
-        if (player_ptr->confused || player_ptr->hallucinated)
+        if (effects->confusion()->is_confused() || effects->hallucination()->is_hallucinated()) {
             i = i / 10;
+        }
 
         j = f_ptr->power;
         j = i - (j * 4);
-        if (j < 2)
+        if (j < 2) {
             j = 2;
+        }
 
         if (randint0(100) < j) {
             msg_print(_("鍵をはずした。", "You have picked the lock."));
@@ -159,8 +175,9 @@ bool easy_open_door(PlayerType *player_ptr, POSITION y, POSITION x)
             sound(SOUND_OPENDOOR);
             gain_exp(player_ptr, 1);
         } else {
-            if (flush_failure)
+            if (flush_failure) {
                 flush();
+            }
 
             msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
         }
@@ -189,18 +206,22 @@ bool easy_open_door(PlayerType *player_ptr, POSITION y, POSITION x)
 bool exe_disarm_chest(PlayerType *player_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
 {
     bool more = false;
-    object_type *o_ptr = &player_ptr->current_floor_ptr->o_list[o_idx];
+    auto *o_ptr = &player_ptr->current_floor_ptr->o_list[o_idx];
     PlayerEnergy(player_ptr).set_player_turn_energy(100);
     int i = player_ptr->skill_dis;
-    if (player_ptr->blind || no_lite(player_ptr))
+    const auto effects = player_ptr->effects();
+    if (effects->blindness()->is_blind() || no_lite(player_ptr)) {
         i = i / 10;
+    }
 
-    if (player_ptr->confused || player_ptr->hallucinated)
+    if (effects->confusion()->is_confused() || effects->hallucination()->is_hallucinated()) {
         i = i / 10;
+    }
 
     int j = i - o_ptr->pval;
-    if (j < 2)
+    if (j < 2) {
         j = 2;
+    }
 
     if (!o_ptr->is_known()) {
         msg_print(_("トラップが見あたらない。", "I don't see any traps."));
@@ -214,8 +235,9 @@ bool exe_disarm_chest(PlayerType *player_ptr, POSITION y, POSITION x, OBJECT_IDX
         o_ptr->pval = (0 - o_ptr->pval);
     } else if ((i > 5) && (randint1(i) > 5)) {
         more = true;
-        if (flush_failure)
+        if (flush_failure) {
             flush();
+        }
 
         msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
     } else {
@@ -244,22 +266,26 @@ bool exe_disarm_chest(PlayerType *player_ptr, POSITION y, POSITION x, OBJECT_IDX
 
 bool exe_disarm(PlayerType *player_ptr, POSITION y, POSITION x, DIRECTION dir)
 {
-    grid_type *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
-    feature_type *f_ptr = &f_info[g_ptr->feat];
+    auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
+    auto *f_ptr = &f_info[g_ptr->feat];
     concptr name = f_ptr->name.c_str();
     int power = f_ptr->power;
     bool more = false;
     int i = player_ptr->skill_dis;
     PlayerEnergy(player_ptr).set_player_turn_energy(100);
-    if (player_ptr->blind || no_lite(player_ptr))
+    auto effects = player_ptr->effects();
+    if (effects->blindness()->is_blind() || no_lite(player_ptr)) {
         i = i / 10;
+    }
 
-    if (player_ptr->confused || player_ptr->hallucinated)
+    if (effects->confusion()->is_confused() || effects->hallucination()->is_hallucinated()) {
         i = i / 10;
+    }
 
     int j = i - power;
-    if (j < 2)
+    if (j < 2) {
         j = 2;
+    }
 
     if (randint0(100) < j) {
         msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
@@ -267,8 +293,9 @@ bool exe_disarm(PlayerType *player_ptr, POSITION y, POSITION x, DIRECTION dir)
         cave_alter_feat(player_ptr, y, x, FloorFeatureType::DISARM);
         exe_movement(player_ptr, dir, easy_disarm, false);
     } else if ((i > 5) && (randint1(i) > 5)) {
-        if (flush_failure)
+        if (flush_failure) {
             flush();
+        }
 
         msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
         more = true;
@@ -296,8 +323,8 @@ bool exe_disarm(PlayerType *player_ptr, POSITION y, POSITION x, DIRECTION dir)
  */
 bool exe_bash(PlayerType *player_ptr, POSITION y, POSITION x, DIRECTION dir)
 {
-    grid_type *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
-    feature_type *f_ptr = &f_info[g_ptr->feat];
+    auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
+    auto *f_ptr = &f_info[g_ptr->feat];
     int bash = adj_str_blow[player_ptr->stat_index[A_STR]];
     int temp = f_ptr->power;
     bool more = false;
@@ -305,11 +332,13 @@ bool exe_bash(PlayerType *player_ptr, POSITION y, POSITION x, DIRECTION dir)
     PlayerEnergy(player_ptr).set_player_turn_energy(100);
     msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
     temp = (bash - (temp * 10));
-    if (player_ptr->pclass == PlayerClassType::BERSERKER)
+    if (PlayerClass(player_ptr).equals(PlayerClassType::BERSERKER)) {
         temp *= 2;
+    }
 
-    if (temp < 1)
+    if (temp < 1) {
         temp = 1;
+    }
 
     if (randint0(100) < temp) {
         msg_format(_("%sを壊した!", "The %s crashes open!"), name);