OSDN Git Service

[Refactor] feature_flag_type の enum class 化
[hengbandforosx/hengbandosx.git] / src / action / tunnel-execution.cpp
index 4765ce6..2db9a06 100644 (file)
@@ -1,13 +1,21 @@
-#include "action/tunnel-execution.h"
+/*!
+ * @file tunnel-execution.cpp
+ * @brief 掘削処理実装
+ */
+
+#include "action/tunnel-execution.h"
+#include "avatar/avatar.h"
 #include "core/player-update-types.h"
 #include "floor/cave.h"
 #include "grid/feature.h"
 #include "grid/grid.h"
 #include "main/sound-definitions-table.h"
 #include "main/sound-of-music.h"
-#include "player-info/avatar.h"
+#include "player-status/player-energy.h"
 #include "player/player-move.h"
 #include "system/floor-type-definition.h"
+#include "system/grid-type-definition.h"
+#include "system/player-type-definition.h"
 #include "util/bit-flags-calculator.h"
 #include "view/display-messages.h"
 
 static bool do_cmd_tunnel_test(floor_type *floor_ptr, POSITION y, POSITION x)
 {
     grid_type *g_ptr = &floor_ptr->grid_array[y][x];
-    if (!(g_ptr->info & CAVE_MARK)) {
+    if (!g_ptr->is_mark()) {
         msg_print(_("そこには何も見当たらない。", "You see nothing there."));
-        return FALSE;
+        return false;
     }
 
-    if (!cave_has_flag_grid(g_ptr, FF_TUNNEL)) {
+    if (!g_ptr->cave_has_flag(FF::TUNNEL)) {
         msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
-        return FALSE;
+        return false;
     }
 
-    return TRUE;
+    return true;
 }
 
 /*!
@@ -51,33 +59,33 @@ bool exe_tunnel(player_type *creature_ptr, POSITION y, POSITION x)
     feature_type *f_ptr, *mimic_f_ptr;
     int power;
     concptr name;
-    bool more = FALSE;
+    bool more = false;
     if (!do_cmd_tunnel_test(creature_ptr->current_floor_ptr, y, x))
-        return FALSE;
+        return false;
 
-    take_turn(creature_ptr, 100);
+    PlayerEnergy(creature_ptr).set_player_turn_energy(100);
     g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
     f_ptr = &f_info[g_ptr->feat];
     power = f_ptr->power;
-    mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
-    name = f_name + mimic_f_ptr->name;
+    mimic_f_ptr = &f_info[g_ptr->get_feat_mimic()];
+    name = mimic_f_ptr->name.c_str();
     sound(SOUND_DIG);
-    if (has_flag(f_ptr->flags, FF_PERMANENT)) {
-        if (has_flag(mimic_f_ptr->flags, FF_PERMANENT))
+    if (f_ptr->flags.has(FF::PERMANENT)) {
+        if (mimic_f_ptr->flags.has(FF::PERMANENT))
             msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
         else
             msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
-    } else if (has_flag(f_ptr->flags, FF_CAN_DIG)) {
+    } else if (f_ptr->flags.has(FF::CAN_DIG)) {
         if (creature_ptr->skill_dig > randint0(20 * power)) {
             msg_format(_("%sをくずした。", "You have removed the %s."), name);
-            cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
+            cave_alter_feat(creature_ptr, y, x, FF::TUNNEL);
             creature_ptr->update |= PU_FLOW;
         } else {
             msg_format(_("%sをくずしている。", "You dig into the %s."), name);
-            more = TRUE;
+            more = true;
         }
     } else {
-        bool tree = has_flag(mimic_f_ptr->flags, FF_TREE);
+        bool tree = mimic_f_ptr->flags.has(FF::TREE);
         if (creature_ptr->skill_dig > power + randint0(40 * power)) {
             if (tree)
                 msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
@@ -86,10 +94,10 @@ bool exe_tunnel(player_type *creature_ptr, POSITION y, POSITION x)
                 creature_ptr->update |= (PU_FLOW);
             }
 
-            if (has_flag(f_ptr->flags, FF_GLASS))
+            if (f_ptr->flags.has(FF::GLASS))
                 sound(SOUND_GLASS);
 
-            cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
+            cave_alter_feat(creature_ptr, y, x, FF::TUNNEL);
             chg_virtue(creature_ptr, V_DILIGENCE, 1);
             chg_virtue(creature_ptr, V_NATURE, -1);
         } else {
@@ -101,7 +109,7 @@ bool exe_tunnel(player_type *creature_ptr, POSITION y, POSITION x)
                 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
             }
 
-            more = TRUE;
+            more = true;
         }
     }