OSDN Git Service

[Refactor] #2666 is_teleport_level_ineffective() をFloorType のメソッドcan_teleport_level...
authorHourier <66951241+Hourier@users.noreply.github.com>
Wed, 11 Oct 2023 12:07:24 +0000 (21:07 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sun, 29 Oct 2023 08:59:28 +0000 (17:59 +0900)
src/melee/melee-spell-flags-checker.cpp
src/mspell/mspell-attack.cpp
src/spell-kind/spells-world.cpp
src/spell-kind/spells-world.h
src/system/floor-type-definition.cpp
src/system/floor-type-definition.h

index c819d19..6f94c62 100644 (file)
@@ -346,7 +346,8 @@ static void check_smart(PlayerType *player_ptr, melee_spell_type *ms_ptr)
         ms_ptr->ability_flags &= RF_ABILITY_INT_MASK;
     }
 
-    if (ms_ptr->ability_flags.has(MonsterAbilityType::TELE_LEVEL) && is_teleport_level_ineffective(player_ptr, (ms_ptr->target_idx == player_ptr->riding) ? 0 : ms_ptr->target_idx)) {
+    const auto &floor = *player_ptr->current_floor_ptr;
+    if (ms_ptr->ability_flags.has(MonsterAbilityType::TELE_LEVEL) && floor.can_teleport_level((ms_ptr->target_idx != player_ptr->riding) ? ms_ptr->target_idx != 0 : false)) {
         ms_ptr->ability_flags.reset(MonsterAbilityType::TELE_LEVEL);
     }
 }
index 991c62d..90b323b 100644 (file)
@@ -69,7 +69,7 @@ static void check_mspell_stupid(PlayerType *player_ptr, msa_type *msa_ptr)
     msa_ptr->ability_flags &= RF_ABILITY_NOMAGIC_MASK;
 }
 
-static void check_mspell_smart(PlayerType *player_ptr, msa_type *msa_ptr)
+static void check_mspell_smart(const FloorType &floor, msa_type *msa_ptr)
 {
     if (msa_ptr->r_ptr->behavior_flags.has_not(MonsterBehaviorType::SMART)) {
         return;
@@ -79,7 +79,7 @@ static void check_mspell_smart(PlayerType *player_ptr, msa_type *msa_ptr)
         msa_ptr->ability_flags &= RF_ABILITY_INT_MASK;
     }
 
-    if (msa_ptr->ability_flags.has(MonsterAbilityType::TELE_LEVEL) && is_teleport_level_ineffective(player_ptr, 0)) {
+    if (msa_ptr->ability_flags.has(MonsterAbilityType::TELE_LEVEL) && floor.can_teleport_level()) {
         msa_ptr->ability_flags.reset(MonsterAbilityType::TELE_LEVEL);
     }
 }
@@ -337,7 +337,7 @@ bool make_attack_spell(PlayerType *player_ptr, MONSTER_IDX m_idx)
     set_no_magic_mask(msa_ptr);
     decide_lite_area(player_ptr, msa_ptr);
     check_mspell_stupid(player_ptr, msa_ptr);
-    check_mspell_smart(player_ptr, msa_ptr);
+    check_mspell_smart(*player_ptr->current_floor_ptr, msa_ptr);
     if (!check_mspell_continuation(player_ptr, msa_ptr)) {
         return false;
     }
index 109b53a..52d8f17 100644 (file)
 #include <algorithm>
 
 /*!
- * @brief テレポート・レベルが効かないモンスターであるかどうかを判定する
- * @param player_ptr プレイヤーへの参照ポインタ
- * @param idx テレポート・レベル対象のモンスター
- * @todo 変数名が実態と合っているかどうかは要確認
- */
-bool is_teleport_level_ineffective(PlayerType *player_ptr, MONSTER_IDX idx)
-{
-    const auto &floor = *player_ptr->current_floor_ptr;
-    auto is_special_floor = floor.inside_arena;
-    is_special_floor |= AngbandSystem::get_instance().is_watching();
-    is_special_floor |= floor.is_in_quest() && !inside_quest(floor.get_random_quest_id());
-    auto is_invalid_floor = idx <= 0;
-    is_invalid_floor &= inside_quest(floor.get_quest_id()) || (floor.dun_level >= floor.get_dungeon_definition().maxdepth);
-    is_invalid_floor &= floor.dun_level >= 1;
-    is_invalid_floor &= ironman_downward;
-    return is_special_floor || is_invalid_floor;
-}
-
-/*!
  * @brief プレイヤー及びモンスターをレベルテレポートさせる /
  * Teleport the player one level up or down (random when legal)
  * @param player_ptr プレイヤーへの参照ポインタ
@@ -83,7 +64,7 @@ void teleport_level(PlayerType *player_ptr, MONSTER_IDX m_idx)
         see_m = is_seen(player_ptr, m_ptr);
     }
 
-    if (is_teleport_level_ineffective(player_ptr, m_idx)) {
+    if (floor.can_teleport_level(m_idx != 0)) {
         if (see_m) {
             msg_print(_("効果がなかった。", "There is no effect."));
         }
index 2038095..5e44612 100644 (file)
@@ -7,7 +7,6 @@ void teleport_level(PlayerType *player_ptr, MONSTER_IDX m_idx);
 bool teleport_level_other(PlayerType *player_ptr);
 bool tele_town(PlayerType *player_ptr);
 void reserve_alter_reality(PlayerType *player_ptr, TIME_EFFECT turns);
-bool is_teleport_level_ineffective(PlayerType *player_ptr, MONSTER_IDX idx);
 bool recall_player(PlayerType *player_ptr, TIME_EFFECT turns);
 bool free_level_recall(PlayerType *player_ptr);
 bool reset_recall(PlayerType *player_ptr);
index efcfacc..a7c7d3d 100644 (file)
@@ -1,5 +1,6 @@
 #include "system/floor-type-definition.h"
 #include "dungeon/quest.h"
+#include "game-option/birth-options.h"
 #include "system/angband-system.h"
 #include "system/dungeon-info.h"
 #include "system/grid-type-definition.h"
@@ -127,3 +128,17 @@ bool FloorType::is_special() const
     is_in_fixed_quest &= !inside_quest(this->get_random_quest_id());
     return is_in_fixed_quest || this->inside_arena || AngbandSystem::get_instance().is_watching();
 }
+
+/*!
+ * @brief テレポート・レベル無効フロアの判定
+ * @param to_player プレイヤーを対象としているか否か
+ * @return テレポート・レベルが不可能ならばtrue
+ */
+bool FloorType::can_teleport_level(bool to_player) const
+{
+    auto is_invalid_floor = to_player;
+    is_invalid_floor &= inside_quest(this->get_quest_id()) || (this->dun_level >= this->get_dungeon_definition().maxdepth);
+    is_invalid_floor &= this->dun_level >= 1;
+    is_invalid_floor &= ironman_downward;
+    return this->is_special() || is_invalid_floor;
+}
index 2e51fcb..d1deea5 100644 (file)
@@ -96,4 +96,5 @@ public:
     QuestId get_quest_id(const int bonus = 0) const;
     bool has_los(const Pos2D pos) const;
     bool is_special() const;
+    bool can_teleport_level(bool to_player = false) const;
 };