OSDN Git Service

[Refactor] check_arena_record() をArenaEntryList のオブジェクトメソッドに繰り込んだ
authorHourier <66951241+Hourier@users.noreply.github.com>
Mon, 10 Jun 2024 10:07:12 +0000 (19:07 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sat, 15 Jun 2024 00:49:25 +0000 (09:49 +0900)
src/market/arena-entry.cpp
src/market/arena-entry.h
src/market/arena.cpp

index fc4aad4..19c0eee 100644 (file)
@@ -128,6 +128,24 @@ const MonsterRaceInfo &ArenaEntryList::get_monrace() const
     return MonraceList::get_instance().get_monrace(ARENA_ENTRIES.at(this->current_entry).monrace_id);
 }
 
+/*!
+ * @brief 対戦相手の確認
+ * @return 最後に倒した対戦相手 (鳳凰以下は一律で鳳凰)
+ */
+ArenaRecord ArenaEntryList::check_arena_record() const
+{
+    const auto max_entries = this->get_max_entries();
+    if (this->current_entry <= max_entries) {
+        return ArenaRecord::FENGFUANG;
+    }
+
+    if (this->current_entry < max_entries + 2) {
+        return ArenaRecord::POWER_WYRM;
+    }
+
+    return ArenaRecord::METAL_BABBLE;
+}
+
 void ArenaEntryList::increment_entry()
 {
     this->current_entry++;
index 60aad50..638745c 100644 (file)
@@ -3,6 +3,12 @@
 #include <optional>
 #include <vector>
 
+enum class ArenaRecord {
+    FENGFUANG,
+    POWER_WYRM,
+    METAL_BABBLE,
+};
+
 class BaseitemKey;
 class MonsterRaceInfo;
 class ArenaEntryList {
@@ -22,6 +28,7 @@ public:
     const BaseitemKey &get_bi_key() const;
     MonsterRaceInfo &get_monrace();
     const MonsterRaceInfo &get_monrace() const;
+    ArenaRecord check_arena_record() const;
     void increment_entry();
     void reset_entry();
     void set_defeated_entry();
index 56fdca0..88d04c9 100644 (file)
 #include <numeric>
 #include <optional>
 
-namespace {
-enum class ArenaRecord {
-    FENGFUANG,
-    POWER_WYRM,
-    METAL_BABBLE,
-};
-}
-
 /*!
  * @brief 優勝時のメッセージを表示し、賞金を与える
  * @param player_ptr プレイヤーへの参照ポインタ
@@ -68,26 +60,6 @@ static std::optional<int> process_ostensible_arena_victory()
     return 1000000;
 }
 
-/*!
- * @brief 対戦相手の確認
- * @param player_ptr プレイヤーへの参照ポインタ
- * @return 最後に倒した対戦相手 (鳳凰以下は一律で鳳凰)
- */
-static ArenaRecord check_arena_record()
-{
-    const auto &entries = ArenaEntryList::get_instance();
-    const auto max_entries = entries.get_max_entries();
-    if (entries.get_current_entry() <= max_entries) {
-        return ArenaRecord::FENGFUANG;
-    }
-
-    if (entries.get_current_entry() < max_entries + 2) {
-        return ArenaRecord::POWER_WYRM;
-    }
-
-    return ArenaRecord::METAL_BABBLE;
-}
-
 static bool check_battle_metal_babble(PlayerType *player_ptr)
 {
     msg_print(_("君のために最強の挑戦者を用意しておいた。", "The strongest challenger is waiting for you."));
@@ -121,7 +93,7 @@ static bool go_to_arena(PlayerType *player_ptr)
         return false;
     }
 
-    const auto arena_record = check_arena_record();
+    const auto arena_record = ArenaEntryList::get_instance().check_arena_record();
     if (arena_record == ArenaRecord::METAL_BABBLE) {
         msg_print(_("あなたはアリーナに入り、しばらくの間栄光にひたった。", "You enter the arena briefly and bask in your glory."));
         msg_print(nullptr);