OSDN Git Service

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