diff --git a/src/MaaCore/Common/AsstTypes.h b/src/MaaCore/Common/AsstTypes.h index 17db0c1eaa..17465ade2c 100644 --- a/src/MaaCore/Common/AsstTypes.h +++ b/src/MaaCore/Common/AsstTypes.h @@ -421,7 +421,4 @@ namespace asst }; inline static const std::string UploadDataSource = "MeoAssistant"; - inline static constexpr std::string_view RoguelikePhantomThemeName = "Phantom"; - inline static constexpr std::string_view RoguelikeMizukiThemeName = "Mizuki"; - inline static constexpr std::string_view RoguelikeSamiThemeName = "Sami"; } // namespace asst diff --git a/src/MaaCore/Task/Interface/RoguelikeTask.cpp b/src/MaaCore/Task/Interface/RoguelikeTask.cpp index e2a1922be3..00bdc5dae1 100644 --- a/src/MaaCore/Task/Interface/RoguelikeTask.cpp +++ b/src/MaaCore/Task/Interface/RoguelikeTask.cpp @@ -74,13 +74,8 @@ bool asst::RoguelikeTask::set_params(const json::value& params) { LogTraceFunction; - std::string theme = params.get("theme", std::string(RoguelikePhantomThemeName)); - static constexpr std::array all_themes = { - RoguelikePhantomThemeName, - RoguelikeMizukiThemeName, - RoguelikeSamiThemeName, - }; - if (ranges::find(all_themes, theme) == all_themes.end()) { + std::string theme = params.get("theme", std::string(RoguelikeTheme::Phantom)); + if (RoguelikeConfig::is_valid_theme(theme)) { m_roguelike_task_ptr->set_tasks({ "Stop" }); Log.error("Unknown roguelike theme", theme); return false; diff --git a/src/MaaCore/Task/Roguelike/RoguelikeConfig.h b/src/MaaCore/Task/Roguelike/RoguelikeConfig.h index 4009820922..a75a2a8413 100644 --- a/src/MaaCore/Task/Roguelike/RoguelikeConfig.h +++ b/src/MaaCore/Task/Roguelike/RoguelikeConfig.h @@ -16,8 +16,21 @@ namespace asst Collectible = 4, }; + class RoguelikeTheme + { + public: + static constexpr std::string_view Phantom = "Phantom"; + static constexpr std::string_view Mizuki = "Mizuki"; + static constexpr std::string_view Sami = "Sami"; + }; + class RoguelikeConfig { + public: + static constexpr bool is_valid_theme(std::string_view theme) + { + return theme == RoguelikeTheme::Phantom || theme == RoguelikeTheme::Mizuki || theme == RoguelikeTheme::Sami; + } public: // 清理缓存的肉鸽数据 void clear();