OSDN Git Service

[Refactor] #3627 MonraceList::defeat_separated_uniques() を定義し、wipe_monsters_list...
authorHourier <66951241+Hourier@users.noreply.github.com>
Wed, 27 Sep 2023 03:10:33 +0000 (12:10 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sun, 15 Oct 2023 13:33:06 +0000 (22:33 +0900)
src/monster-floor/monster-remover.cpp
src/system/monster-race-info.cpp
src/system/monster-race-info.h

index 50872be..4e06986 100644 (file)
@@ -105,34 +105,13 @@ void delete_monster_idx(PlayerType *player_ptr, MONSTER_IDX i)
 }
 
 /*!
- * @brief プレイヤーのフロア離脱に伴う全モンスター配列の消去 / Delete/Remove all the monsters when the player leaves the level
+ * @brief プレイヤーのフロア離脱に伴う全モンスター配列の消去
  * @param player_ptr プレイヤーへの参照ポインタ
- * @details
- * This is an efficient method of simulating multiple calls to the
- * "delete_monster()" function, with no visual effects.
+ * @details 視覚効果なしでdelete_monster() をフロア全体に対して呼び出す.
  */
 void wipe_monsters_list(PlayerType *player_ptr)
 {
-    if (!monraces_info[MonsterRaceId::BANORLUPART].max_num) {
-        if (monraces_info[MonsterRaceId::BANOR].max_num) {
-            monraces_info[MonsterRaceId::BANOR].max_num = 0;
-            monraces_info[MonsterRaceId::BANOR].r_pkills++;
-            monraces_info[MonsterRaceId::BANOR].r_akills++;
-            if (monraces_info[MonsterRaceId::BANOR].r_tkills < MAX_SHORT) {
-                monraces_info[MonsterRaceId::BANOR].r_tkills++;
-            }
-        }
-
-        if (monraces_info[MonsterRaceId::LUPART].max_num) {
-            monraces_info[MonsterRaceId::LUPART].max_num = 0;
-            monraces_info[MonsterRaceId::LUPART].r_pkills++;
-            monraces_info[MonsterRaceId::LUPART].r_akills++;
-            if (monraces_info[MonsterRaceId::LUPART].r_tkills < MAX_SHORT) {
-                monraces_info[MonsterRaceId::LUPART].r_tkills++;
-            }
-        }
-    }
-
+    MonraceList::get_instance().defeat_separated_uniques();
     auto *floor_ptr = player_ptr->current_floor_ptr;
     for (int i = floor_ptr->m_max - 1; i >= 1; i--) {
         auto *m_ptr = &floor_ptr->m_list[i];
index 62c0185..eb5f976 100644 (file)
@@ -134,3 +134,29 @@ bool MonraceList::is_selectable(const MonsterRaceId r_idx) const
 
     return std::all_of(it->second.begin(), it->second.end(), [](const auto x) { return monraces_info[x].cur_num == 0; });
 }
+
+/*!
+ * @brief 合体ユニークが撃破済の状態でフロアから離脱した時に、各分離ユニークも撃破済状態へと変更する
+ */
+void MonraceList::defeat_separated_uniques()
+{
+    for (const auto &[unified_unique, separates] : unified_uniques) {
+        if (monraces_info[unified_unique].max_num > 0) {
+            continue;
+        }
+
+        for (const auto separate : separates) {
+            auto &monrace = monraces_info[separate];
+            if (monrace.max_num == 0) {
+                continue;
+            }
+
+            monrace.max_num = 0;
+            monrace.r_pkills++;
+            monrace.r_akills++;
+            if (monrace.r_tkills < MAX_SHORT) {
+                monrace.r_tkills++;
+            }
+        }
+    }
+}
index 59d6adf..c24f6fd 100644 (file)
@@ -155,6 +155,7 @@ public:
     bool can_unify_separate(const MonsterRaceId r_idx) const;
     void kill_unified_unique(const MonsterRaceId r_idx);
     bool is_selectable(const MonsterRaceId r_idx) const;
+    void defeat_separated_uniques();
 
 private:
     MonraceList() = default;