From b0f9572b05886f64b5b461221827703a4c63ce1d Mon Sep 17 00:00:00 2001 From: Hourier Date: Sat, 4 Jul 2020 14:03:08 +0900 Subject: [PATCH] [Refactor] #40482 Separated mutation-techniques.c/h from spells3.c/h --- Hengband/Hengband/Hengband.vcxproj | 2 + Hengband/Hengband/Hengband.vcxproj.filters | 6 +++ src/Makefile.am | 1 + src/mutation/mutation-techniques.c | 65 ++++++++++++++++++++++++++++++ src/mutation/mutation-techniques.h | 5 +++ src/mutation/mutation.c | 2 +- src/spell/spells3.c | 47 --------------------- src/spell/spells3.h | 1 - 8 files changed, 80 insertions(+), 49 deletions(-) create mode 100644 src/mutation/mutation-techniques.c create mode 100644 src/mutation/mutation-techniques.h diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index 88c276dbb..e1c7cb7ee 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -225,6 +225,7 @@ + @@ -677,6 +678,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index e2faae7a0..1c111be87 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -1583,6 +1583,9 @@ spell-kind + + mutation + @@ -3463,6 +3466,9 @@ spell-kind + + mutation + diff --git a/src/Makefile.am b/src/Makefile.am index c1354c8fe..f6db765ef 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -407,6 +407,7 @@ hengband_SOURCES = \ mutation/mutation.c mutation/mutation.h \ mutation/mutation-flag-types.h \ mutation/mutation-processor.c mutation/mutation-processor.h \ + mutation/mutation-techniques.c mutation/mutation-techniques.h \ \ object/item-tester-hooker.c object/item-tester-hooker.h \ object/object-broken.c object/object-broken.h \ diff --git a/src/mutation/mutation-techniques.c b/src/mutation/mutation-techniques.c new file mode 100644 index 000000000..bc3e35100 --- /dev/null +++ b/src/mutation/mutation-techniques.c @@ -0,0 +1,65 @@ +/*! + * @brief 突然変異でのみ得ることができる特殊能力処理 + * @date 2020/07/04 + * @author Hourier + */ + +#include "mutation/mutation-techniques.h" +#include "cmd-action/cmd-attack.h" +#include "floor/floor.h" +#include "grid/feature.h" +#include "grid/grid.h" +#include "io/targeting.h" +#include "monster/monster-info.h" +#include "player/digestion-processor.h" +#include "player/player-move.h" +#include "util/bit-flags-calculator.h" +#include "view/display-messages.h" + +/*! + * 岩石食い + * @param caster_ptr プレーヤーへの参照ポインタ + * @return コマンドの入力方向に地形があればTRUE + */ +bool eat_rock(player_type *caster_ptr) +{ + DIRECTION dir; + if (!get_direction(caster_ptr, &dir, FALSE, FALSE)) + return FALSE; + + POSITION y = caster_ptr->y + ddy[dir]; + POSITION x = caster_ptr->x + ddx[dir]; + grid_type *g_ptr; + g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x]; + feature_type *f_ptr, *mimic_f_ptr; + f_ptr = &f_info[g_ptr->feat]; + mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)]; + + stop_mouth(caster_ptr); + if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK)) { + msg_print(_("この地形は食べられない。", "You cannot eat this feature.")); + } else if (have_flag(f_ptr->flags, FF_PERMANENT)) { + msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch! This %s is harder than your teeth!"), f_name + mimic_f_ptr->name); + } else if (g_ptr->m_idx) { + monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx]; + msg_print(_("何かが邪魔しています!", "There's something in the way!")); + + if (!m_ptr->ml || !is_pet(m_ptr)) + do_cmd_attack(caster_ptr, y, x, 0); + } else if (have_flag(f_ptr->flags, FF_TREE)) { + msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!")); + } else if (have_flag(f_ptr->flags, FF_GLASS)) { + msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!")); + } else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG)) { + (void)set_food(caster_ptr, caster_ptr->food + 3000); + } else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD)) { + (void)set_food(caster_ptr, caster_ptr->food + 5000); + } else { + msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name); + (void)set_food(caster_ptr, caster_ptr->food + 10000); + } + + cave_alter_feat(caster_ptr, y, x, FF_HURT_ROCK); + (void)move_player_effect(caster_ptr, y, x, MPE_DONT_PICKUP); + return TRUE; +} diff --git a/src/mutation/mutation-techniques.h b/src/mutation/mutation-techniques.h new file mode 100644 index 000000000..012e94fdc --- /dev/null +++ b/src/mutation/mutation-techniques.h @@ -0,0 +1,5 @@ +#pragma once + +#include "system/angband.h" + +bool eat_rock(player_type *caster_ptr); diff --git a/src/mutation/mutation.c b/src/mutation/mutation.c index c5f4426ba..4995e1877 100644 --- a/src/mutation/mutation.c +++ b/src/mutation/mutation.c @@ -39,6 +39,7 @@ #include "monster/monster-info.h" #include "monster/smart-learn-types.h" #include "mutation/mutation-flag-types.h" +#include "mutation/mutation-techniques.h" #include "object-enchant/item-feeling.h" #include "object-hook/hook-checker.h" #include "player/avatar.h" @@ -60,7 +61,6 @@ #include "spell/spells-status.h" #include "spell/spells-summon.h" #include "spell/spell-types.h" -#include "spell/spells3.h" #include "status/element-resistance.h" #include "status/shape-changer.h" #include "system/object-type-definition.h" diff --git a/src/spell/spells3.c b/src/spell/spells3.c index e2beb1fea..cfed3552b 100644 --- a/src/spell/spells3.c +++ b/src/spell/spells3.c @@ -473,53 +473,6 @@ void massacre(player_type *caster_ptr) } } -/*! - * 岩石食い - * @param caster_ptr プレーヤーへの参照ポインタ - * @return コマンドの入力方向に地形があればTRUE - */ -bool eat_rock(player_type *caster_ptr) -{ - DIRECTION dir; - if (!get_direction(caster_ptr, &dir, FALSE, FALSE)) - return FALSE; - POSITION y = caster_ptr->y + ddy[dir]; - POSITION x = caster_ptr->x + ddx[dir]; - grid_type *g_ptr; - g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x]; - feature_type *f_ptr, *mimic_f_ptr; - f_ptr = &f_info[g_ptr->feat]; - mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)]; - - stop_mouth(caster_ptr); - if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK)) { - msg_print(_("この地形は食べられない。", "You cannot eat this feature.")); - } else if (have_flag(f_ptr->flags, FF_PERMANENT)) { - msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch! This %s is harder than your teeth!"), f_name + mimic_f_ptr->name); - } else if (g_ptr->m_idx) { - monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx]; - msg_print(_("何かが邪魔しています!", "There's something in the way!")); - - if (!m_ptr->ml || !is_pet(m_ptr)) - do_cmd_attack(caster_ptr, y, x, 0); - } else if (have_flag(f_ptr->flags, FF_TREE)) { - msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!")); - } else if (have_flag(f_ptr->flags, FF_GLASS)) { - msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!")); - } else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG)) { - (void)set_food(caster_ptr, caster_ptr->food + 3000); - } else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD)) { - (void)set_food(caster_ptr, caster_ptr->food + 5000); - } else { - msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name); - (void)set_food(caster_ptr, caster_ptr->food + 10000); - } - - cave_alter_feat(caster_ptr, y, x, FF_HURT_ROCK); - (void)move_player_effect(caster_ptr, y, x, MPE_DONT_PICKUP); - return TRUE; -} - bool shock_power(player_type *caster_ptr) { int boost = get_current_ki(caster_ptr); diff --git a/src/spell/spells3.h b/src/spell/spells3.h index 63e942383..6d2157f28 100644 --- a/src/spell/spells3.h +++ b/src/spell/spells3.h @@ -7,7 +7,6 @@ bool artifact_scroll(player_type* caster_ptr); bool mundane_spell(player_type* ownner_ptr, bool only_equip); bool recharge(player_type* caster_ptr, int power); void massacre(player_type* caster_ptr); -bool eat_rock(player_type* caster_ptr); bool shock_power(player_type* caster_ptr); bool booze(player_type* creature_ptr); bool detonation(player_type* creature_ptr); -- 2.11.0