OSDN Git Service

[Refactor] #2683 Rebamed k_idx to bi_id (Kind index to Baseitem ID)
[hengbandforosx/hengbandosx.git] / src / cmd-action / cmd-open-close.cpp
index a434ba1..71300a7 100644 (file)
 #include "status/experience.h"
 #include "system/floor-type-definition.h"
 #include "system/grid-type-definition.h"
-#include "system/object-type-definition.h"
+#include "system/item-entity.h"
 #include "system/player-type-definition.h"
+#include "system/terrain-type-definition.h"
 #include "target/target-getter.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"
@@ -51,11 +54,12 @@ static bool exe_open_chest(PlayerType *player_ptr, POSITION y, POSITION x, OBJEC
     if (o_ptr->pval > 0) {
         flag = false;
         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->effects()->confusion()->is_confused() || player_ptr->hallucinated) {
+        if (effects->confusion()->is_confused() || effects->hallucination()->is_hallucinated()) {
             i = i / 10;
         }
 
@@ -130,7 +134,7 @@ void do_cmd_open(PlayerType *player_ptr)
         g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
         feat = g_ptr->get_feat_mimic();
         o_idx = chest_check(player_ptr->current_floor_ptr, y, x, false);
-        if (f_info[feat].flags.has_not(FloorFeatureType::OPEN) && !o_idx) {
+        if (terrains_info[feat].flags.has_not(TerrainCharacteristics::OPEN) && !o_idx) {
             msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
         } else if (g_ptr->m_idx && player_ptr->riding != g_ptr->m_idx) {
             PlayerEnergy(player_ptr).set_player_turn_energy(100);
@@ -182,7 +186,7 @@ void do_cmd_close(PlayerType *player_ptr)
         x = player_ptr->x + ddx[dir];
         g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
         feat = g_ptr->get_feat_mimic();
-        if (f_info[feat].flags.has_not(FloorFeatureType::CLOSE)) {
+        if (terrains_info[feat].flags.has_not(TerrainCharacteristics::CLOSE)) {
             msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
         } else if (g_ptr->m_idx) {
             PlayerEnergy(player_ptr).set_player_turn_energy(100);
@@ -297,7 +301,7 @@ void do_cmd_bash(PlayerType *player_ptr)
         x = player_ptr->x + ddx[dir];
         g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
         feat = g_ptr->get_feat_mimic();
-        if (f_info[feat].flags.has_not(FloorFeatureType::BASH)) {
+        if (terrains_info[feat].flags.has_not(TerrainCharacteristics::BASH)) {
             msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
         } else if (g_ptr->m_idx) {
             PlayerEnergy(player_ptr).set_player_turn_energy(100);
@@ -327,7 +331,7 @@ static bool get_spike(PlayerType *player_ptr, INVENTORY_IDX *ip)
 {
     for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++) {
         auto *o_ptr = &player_ptr->inventory_list[i];
-        if (!o_ptr->k_idx) {
+        if (!o_ptr->bi_id) {
             continue;
         }
 
@@ -368,7 +372,7 @@ void do_cmd_spike(PlayerType *player_ptr)
     g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
     FEAT_IDX feat = g_ptr->get_feat_mimic();
     INVENTORY_IDX item;
-    if (f_info[feat].flags.has_not(FloorFeatureType::SPIKE)) {
+    if (terrains_info[feat].flags.has_not(TerrainCharacteristics::SPIKE)) {
         msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
     } else if (!get_spike(player_ptr, &item)) {
         msg_print(_("くさびを持っていない!", "You have no spikes!"));
@@ -378,8 +382,8 @@ void do_cmd_spike(PlayerType *player_ptr)
         do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
     } else {
         PlayerEnergy(player_ptr).set_player_turn_energy(100);
-        msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_info[feat].name.c_str());
-        cave_alter_feat(player_ptr, y, x, FloorFeatureType::SPIKE);
+        msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), terrains_info[feat].name.data());
+        cave_alter_feat(player_ptr, y, x, TerrainCharacteristics::SPIKE);
         vary_item(player_ptr, item, -1);
     }
 }