OSDN Git Service

[Refactor] モンスターの攻撃後のテレポート処理
authorHabu <habu1010+github@gmail.com>
Fri, 31 May 2024 22:21:55 +0000 (07:21 +0900)
committerHabu <habu1010+github@gmail.com>
Fri, 31 May 2024 22:24:01 +0000 (07:24 +0900)
モンスターが金を盗むなどの攻撃をプレイヤーに行った後テレポートする処理は
どう考えてもSpellHexクラスのメソッドでやるべき内容ではないので、
MonsterAttackPlayerクラスに処理を移動する。

src/monster-attack/monster-attack-player.cpp
src/monster-attack/monster-attack-player.h
src/spell-realm/spells-hex.cpp
src/spell-realm/spells-hex.h

index 93129d5..3785ac8 100644 (file)
@@ -40,6 +40,7 @@
 #include "player/player-damage.h"
 #include "player/player-skill.h"
 #include "player/special-defense-types.h"
+#include "spell-kind/spells-teleport.h"
 #include "spell-realm/spells-hex.h"
 #include "status/action-setter.h"
 #include "status/bad-status-setter.h"
@@ -497,9 +498,7 @@ void MonsterAttackPlayer::postprocess_monster_blows()
     spell_hex.store_vengeful_damage(this->get_damage);
     spell_hex.eyes_on_eyes(this->m_idx, this->get_damage);
     musou_counterattack(this->player_ptr, this);
-    if (this->blinked && this->alive) {
-        spell_hex.thief_teleport(this->m_idx);
-    }
+    this->process_thief_teleport(spell_hex);
     auto *r_ptr = &this->m_ptr->get_monrace();
     if (this->player_ptr->is_dead && (r_ptr->r_deaths < MAX_SHORT) && !this->player_ptr->current_floor_ptr->inside_arena) {
         r_ptr->r_deaths++;
@@ -512,3 +511,17 @@ void MonsterAttackPlayer::postprocess_monster_blows()
 
     PlayerClass(this->player_ptr).break_samurai_stance({ SamuraiStanceType::IAI });
 }
+
+void MonsterAttackPlayer::process_thief_teleport(const SpellHex &spell_hex)
+{
+    if (!this->blinked || !this->alive || this->player_ptr->is_dead) {
+        return;
+    }
+
+    if (spell_hex.check_hex_barrier(this->m_idx, HEX_ANTI_TELE)) {
+        msg_print(_("泥棒は笑って逃げ...ようとしたがバリアに防がれた。", "The thief flees laughing...? But a magic barrier obstructs it."));
+    } else {
+        msg_print(_("泥棒は笑って逃げた!", "The thief flees laughing!"));
+        teleport_away(this->player_ptr, this->m_idx, MAX_PLAYER_SIGHT * 2 + 5, TELEPORT_SPONTANEOUS);
+    }
+}
index 5b55b50..4f71f26 100644 (file)
@@ -5,6 +5,7 @@
 enum class RaceBlowEffectType;
 enum class RaceBlowMethodType;
 class PlayerType;
+class SpellHex;
 class MonsterEntity;
 class ItemEntity;
 class MonsterAttackPlayer {
@@ -58,4 +59,5 @@ private:
     void gain_armor_exp();
     void increase_blow_type_seen(const int ap_cnt);
     void postprocess_monster_blows();
+    void process_thief_teleport(const SpellHex &spell_hex);
 };
index 2b77cdc..cf66a7b 100644 (file)
@@ -11,7 +11,6 @@
 #include "player/attack-defense-types.h"
 #include "player/player-skill.h"
 #include "realm/realm-hex-numbers.h"
-#include "spell-kind/spells-teleport.h"
 #include "spell-realm/spells-crusade.h"
 #include "spell-realm/spells-song.h"
 #include "spell/spell-info.h"
@@ -390,20 +389,6 @@ void SpellHex::eyes_on_eyes(MONSTER_IDX m_idx, int dam)
     }
 }
 
-void SpellHex::thief_teleport(MONSTER_IDX m_idx)
-{
-    if (this->player_ptr->is_dead) {
-        return;
-    }
-
-    if (this->check_hex_barrier(m_idx, HEX_ANTI_TELE)) {
-        msg_print(_("泥棒は笑って逃げ...ようとしたがバリアに防がれた。", "The thief flees laughing...? But a magic barrier obstructs it."));
-    } else {
-        msg_print(_("泥棒は笑って逃げた!", "The thief flees laughing!"));
-        teleport_away(this->player_ptr, m_idx, MAX_PLAYER_SIGHT * 2 + 5, TELEPORT_SPONTANEOUS);
-    }
-}
-
 void SpellHex::set_casting_flag(spell_hex_type type)
 {
     this->spell_hex_data->casting_spells.set(type);
index 48a9767..ec413a5 100644 (file)
@@ -30,7 +30,6 @@ public:
     bool is_spelling_any() const;
     void interrupt_spelling();
     void eyes_on_eyes(MONSTER_IDX, int dam);
-    void thief_teleport(MONSTER_IDX m_idx);
     void set_casting_flag(spell_hex_type type);
     void reset_casting_flag(spell_hex_type type);
     int32_t get_casting_num() const;