OSDN Git Service

Merge pull request #1866 from sikabane-works/release/3.0.0Alpha46
[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 "core/player-redraw-types.h"
6 #include "floor/geometry.h"
7 #include "grid/feature.h"
8 #include "grid/grid.h"
9 #include "io/input-key-requester.h"
10 #include "player-base/player-class.h"
11 #include "player-info/samurai-data-type.h"
12 #include "player-status/player-energy.h"
13 #include "player/attack-defense-types.h"
14 #include "player/special-defense-types.h"
15 #include "status/action-setter.h"
16 #include "system/floor-type-definition.h"
17 #include "system/grid-type-definition.h"
18 #include "system/player-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         player_ptr->redraw |= PR_STATE;
43         command_arg = 0;
44     }
45
46     DIRECTION dir;
47     if (!get_rep_dir(player_ptr, &dir, false)) {
48         if (!more)
49             disturb(player_ptr, false, false);
50
51         return;
52     }
53
54     POSITION y = player_ptr->y + ddy[dir];
55     POSITION x = player_ptr->x + ddx[dir];
56     grid_type *g_ptr;
57     g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
58     FEAT_IDX feat = g_ptr->get_feat_mimic();
59     if (f_info[feat].flags.has(FloorFeatureType::DOOR))
60         msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
61     else if (f_info[feat].flags.has_not(FloorFeatureType::TUNNEL))
62         msg_print(_("そこは掘れない。", "You can't tunnel through that."));
63     else if (g_ptr->m_idx) {
64         PlayerEnergy(player_ptr).set_player_turn_energy(100);
65         msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
66         do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
67     } else
68         more = exe_tunnel(player_ptr, y, x);
69
70     if (!more)
71         disturb(player_ptr, false, false);
72 }