OSDN Git Service

Merge pull request #3532 from sikabane-works/release/3.0.0.87-alpha
[hengbandforosx/hengbandosx.git] / src / cmd-action / cmd-tunnel.cpp
1 #include "cmd-action/cmd-tunnel.h"
2 #include "action/tunnel-execution.h"
3 #include "cmd-action/cmd-attack.h"
4 #include "core/disturbance.h"
5 #include "floor/geometry.h"
6 #include "grid/grid.h"
7 #include "io/input-key-requester.h"
8 #include "player-base/player-class.h"
9 #include "player-info/samurai-data-type.h"
10 #include "player-status/player-energy.h"
11 #include "player/attack-defense-types.h"
12 #include "player/special-defense-types.h"
13 #include "status/action-setter.h"
14 #include "system/floor-type-definition.h"
15 #include "system/grid-type-definition.h"
16 #include "system/player-type-definition.h"
17 #include "system/redrawing-flags-updater.h"
18 #include "system/terrain-type-definition.h"
19 #include "target/target-getter.h"
20 #include "util/bit-flags-calculator.h"
21 #include "view/display-messages.h"
22
23 /*!
24  * @brief 「掘る」動作コマンドのメインルーチン /
25  * Tunnels through "walls" (including rubble and closed doors)
26  * @details
27  * <pre>
28  * Note that you must tunnel in order to hit invisible monsters
29  * in walls, though moving into walls still takes a turn anyway.
30  *
31  * Digging is very difficult without a "digger" weapon, but can be
32  * accomplished by strong players using heavy weapons.
33  * </pre>
34  */
35 void do_cmd_tunnel(PlayerType *player_ptr)
36 {
37     bool more = false;
38     PlayerClass(player_ptr).break_samurai_stance({ SamuraiStanceType::MUSOU });
39
40     if (command_arg) {
41         command_rep = command_arg - 1;
42         RedrawingFlagsUpdater::get_instance().set_flag(MainWindowRedrawingFlag::ACTION);
43         command_arg = 0;
44     }
45
46     DIRECTION dir;
47     if (!get_rep_dir(player_ptr, &dir)) {
48         if (!more) {
49             disturb(player_ptr, false, false);
50         }
51
52         return;
53     }
54
55     POSITION y = player_ptr->y + ddy[dir];
56     POSITION x = player_ptr->x + ddx[dir];
57     grid_type *g_ptr;
58     g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
59     FEAT_IDX feat = g_ptr->get_feat_mimic();
60     if (terrains_info[feat].flags.has(TerrainCharacteristics::DOOR)) {
61         msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
62     } else if (terrains_info[feat].flags.has_not(TerrainCharacteristics::TUNNEL)) {
63         msg_print(_("そこは掘れない。", "You can't tunnel through that."));
64     } else if (g_ptr->m_idx) {
65         PlayerEnergy(player_ptr).set_player_turn_energy(100);
66         msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
67         do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
68     } else {
69         more = exe_tunnel(player_ptr, y, x);
70     }
71
72     if (!more) {
73         disturb(player_ptr, false, false);
74     }
75 }