OSDN Git Service

Merge pull request #2241 from sikabane-works/release/3.0.0Alpha53
[hengbandforosx/hengbandosx.git] / src / mutation / mutation-techniques.cpp
1 /*!
2  * @brief 突然変異でのみ得ることができる特殊能力処理
3  * @date 2020/07/04
4  * @author Hourier
5  */
6
7 #include "mutation/mutation-techniques.h"
8 #include "cmd-action/cmd-attack.h"
9 #include "floor/geometry.h"
10 #include "grid/feature.h"
11 #include "grid/grid.h"
12 #include "monster/monster-info.h"
13 #include "player/digestion-processor.h"
14 #include "player/player-move.h"
15 #include "player/player-status.h"
16 #include "system/floor-type-definition.h"
17 #include "system/grid-type-definition.h"
18 #include "system/monster-type-definition.h"
19 #include "system/player-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  * 岩石食い
26  * @param player_ptr プレイヤーへの参照ポインタ
27  * @return コマンドの入力方向に地形があればTRUE
28  */
29 bool eat_rock(PlayerType *player_ptr)
30 {
31     DIRECTION dir;
32     if (!get_direction(player_ptr, &dir, false, false))
33         return false;
34
35     POSITION y = player_ptr->y + ddy[dir];
36     POSITION x = player_ptr->x + ddx[dir];
37     grid_type *g_ptr;
38     g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
39     feature_type *f_ptr, *mimic_f_ptr;
40     f_ptr = &f_info[g_ptr->feat];
41     mimic_f_ptr = &f_info[g_ptr->get_feat_mimic()];
42
43     stop_mouth(player_ptr);
44     if (mimic_f_ptr->flags.has_not(FloorFeatureType::HURT_ROCK)) {
45         msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
46     } else if (f_ptr->flags.has(FloorFeatureType::PERMANENT)) {
47         msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch!  This %s is harder than your teeth!"), mimic_f_ptr->name.c_str());
48     } else if (g_ptr->m_idx) {
49         auto *m_ptr = &player_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
50         msg_print(_("何かが邪魔しています!", "There's something in the way!"));
51
52         if (!m_ptr->ml || !is_pet(m_ptr))
53             do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
54     } else if (f_ptr->flags.has(FloorFeatureType::TREE)) {
55         msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
56     } else if (f_ptr->flags.has(FloorFeatureType::GLASS)) {
57         msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
58     } else if (f_ptr->flags.has(FloorFeatureType::DOOR) || f_ptr->flags.has(FloorFeatureType::CAN_DIG)) {
59         (void)set_food(player_ptr, player_ptr->food + 3000);
60     } else if (f_ptr->flags.has(FloorFeatureType::MAY_HAVE_GOLD) || f_ptr->flags.has(FloorFeatureType::HAS_GOLD)) {
61         (void)set_food(player_ptr, player_ptr->food + 5000);
62     } else {
63         msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), mimic_f_ptr->name.c_str());
64         (void)set_food(player_ptr, player_ptr->food + 10000);
65     }
66
67     cave_alter_feat(player_ptr, y, x, FloorFeatureType::HURT_ROCK);
68     (void)move_player_effect(player_ptr, y, x, MPE_DONT_PICKUP);
69     return true;
70 }