refactor: 迁移肉鸽模式

This commit is contained in:
status102
2023-11-03 21:56:12 +08:00
parent 7f5c7c44c3
commit bdbcf4e24d
10 changed files with 42 additions and 32 deletions

View File

@@ -52,7 +52,6 @@ namespace asst
static inline const std::string RoguelikeRecruitmentStartsComplete = "RoguelikeRecruitmentStartsComplete";
static inline const std::string RoguelikeRecruitmentTeamComplete = "RoguelikeRecruitmentTeamComplete";
static inline const std::string RoguelikeRecruitmentCount = "RoguelikeRecruitmentCount";
static inline const std::string RoguelikeMode = "RoguelikeMode";
static inline const std::string RoguelikeDifficulty = "RoguelikeDifficulty";
static inline const std::string RoguelikeFoldartalOverview = "RoguelikeFoldartalOverview";

View File

@@ -92,24 +92,19 @@ bool asst::RoguelikeTask::set_params(const json::value& params)
m_roguelike_config_ptr->set_theme(theme);
m_roguelike_task_ptr->set_tasks({ theme + "@Roguelike@Begin" });
// 0 - 刷经验,尽可能稳定地打更多层数,不期而遇采用激进策略
// 1 - 刷源石锭,第一层投资完就退出,不期而遇采用保守策略
// 2 - 【已移除】两者兼顾,投资过后再退出,没有投资就继续往后打
// 3 - 尝试通关激进策略TODO
// 4 - 刷开局藏品,以获得热水壶或者演讲稿开局,不期而遇采用保守策略
int mode = params.get("mode", 0);
if (mode != 0 && mode != 1 && mode != 4) {
auto mode = static_cast<RoguelikeMode>(params.get("mode", 0));
m_roguelike_config_ptr->set_mode(mode);
if (mode != RoguelikeMode::Exp && mode != RoguelikeMode::Investment && mode != RoguelikeMode::Collectible) {
m_roguelike_task_ptr->set_tasks({ "Stop" });
Log.error(__FUNCTION__, "| Unknown mode", mode);
Log.error(__FUNCTION__, "| Unknown mode", static_cast<int>(mode));
return false;
}
m_debug_plugin_ptr->set_enable(mode != 1);
m_debug_plugin_ptr->set_enable(mode != RoguelikeMode::Investment);
// 是否凹指定干员开局直升
bool start_with_elite_two = params.get("start_with_elite_two", false);
status()->set_properties(Status::RoguelikeMode, std::to_string(mode));
status()->set_properties(Status::RoguelikeDifficulty, "0");
status()->set_properties(Status::RoguelikeStartWithEliteTwo, std::to_string(start_with_elite_two));
@@ -117,10 +112,10 @@ bool asst::RoguelikeTask::set_params(const json::value& params)
{
Task.set_task_base(theme + "@Roguelike@Stages", theme + "@Roguelike@Stages_default");
std::string strategy_task = theme + "@Roguelike@StrategyChange";
std::string strategy_task_with_mode = strategy_task + "_mode" + std::to_string(mode);
std::string strategy_task_with_mode = strategy_task + "_mode" + std::to_string(static_cast<int>(mode));
if (Task.get(strategy_task_with_mode) == nullptr) {
strategy_task_with_mode = "#none"; // 没有对应的层数选点策略,使用默认策略(避战)
Log.warn(__FUNCTION__, "No strategy for mode", mode);
Log.warn(__FUNCTION__, "No strategy for mode", static_cast<int>(mode));
}
Task.set_task_base(strategy_task, strategy_task_with_mode);
}
@@ -132,7 +127,7 @@ bool asst::RoguelikeTask::set_params(const json::value& params)
Task.set_task_base("Roguelike@LastReward4", "Roguelike@LastReward_default");
Task.set_task_base("Roguelike@LastRewardRand", "Roguelike@LastReward_default");
if (mode == 1) {
if (mode == RoguelikeMode::Investment) {
// 战斗后奖励只拿钱
Task.set_task_base(theme + "@Roguelike@DropsFlag", theme + "@Roguelike@DropsFlag_mode1");
// 刷源石锭模式是否进入第二层

View File

@@ -1,3 +1,5 @@
#include "RoguelikeConfig.h"
void asst::RoguelikeConfig::clear() {}
void asst::RoguelikeConfig::clear() {
}

View File

@@ -3,17 +3,34 @@
namespace asst
{
enum class RoguelikeMode
{
// 0 - 刷经验,尽可能稳定地打更多层数,不期而遇采用激进策略
Exp = 0,
// 1 - 刷源石锭,第一层投资完就退出,不期而遇采用保守策略
Investment = 1,
// 2 - 【已移除】两者兼顾,投资过后再退出,没有投资就继续往后打
// 3 - 尝试通关激进策略TODO
// 4 - 刷开局藏品,以获得热水壶或者演讲稿开局,不期而遇采用保守策略
Collectible = 4,
};
class RoguelikeConfig
{
public:
// 清理缓存的肉鸽数据
void clear();
public:
void set_theme(std::string roguelike_theme) { m_theme = std::move(roguelike_theme); }
void set_theme(std::string theme) { m_theme = std::move(theme); }
std::string get_theme() { return m_theme; }
void set_mode(RoguelikeMode mode) { m_mode = mode; }
RoguelikeMode get_mode() { return m_mode; }
protected:
// 肉鸽主题
std::string m_theme;
RoguelikeMode m_mode = RoguelikeMode::Exp;
};
}

View File

@@ -32,12 +32,12 @@ bool asst::RoguelikeDifficultySelectionTaskPlugin::_run()
{
LogTraceFunction;
std::string mode = status()->get_properties(Status::RoguelikeMode).value();
auto mode = m_config->get_mode();
// todo:以后可以根据传入的难度值选择难度?
// 当前难度
std::string difficulty = status()->get_properties(Status::RoguelikeDifficulty).value();
if (m_config->get_theme() != "Phantom" && mode == "4") {
if (m_config->get_theme() != "Phantom" && mode == RoguelikeMode::Collectible) {
if (difficulty == "max") {
ProcessTask(*this, { m_config->get_theme() + "@Roguelike@ChooseDifficulty_Hardest" }).run();
}

View File

@@ -57,8 +57,6 @@ bool asst::RoguelikeFoldartalGainTaskPlugin::_run()
LogTraceFunction;
std::string theme = m_config->get_theme();
std::string mode = status()->get_properties(Status::RoguelikeMode).value();
auto image = ctrler()->get_image();
OCRer analyzer(image);

View File

@@ -21,7 +21,7 @@ bool asst::RoguelikeFoldartalUseTaskPlugin::verify(AsstMsg msg, const json::valu
if (m_config->get_theme() != "Sami") {
return false;
}
std::string mode = status()->get_properties(Status::RoguelikeMode).value();
auto mode = m_config->get_mode();
std::string task_name_pre = m_config->get_theme() + "@Roguelike@Stage";
const std::string& task = details.get("details", "task", "");
std::string_view task_view = task;
@@ -39,28 +39,28 @@ bool asst::RoguelikeFoldartalUseTaskPlugin::verify(AsstMsg msg, const json::valu
task_view.remove_suffix(task_name_suf.length());
}
if (task_view == "CombatDps" || task_view == "EmergencyDps" || task_view == "FerociousPresage") {
if (mode == "1" || mode == "4") {
if (mode == RoguelikeMode::Investment || mode == RoguelikeMode::Collectible) {
m_stage = "SkipBattle";
}
else if (mode == "0") {
else if (mode == RoguelikeMode::Exp) {
m_stage = "Battle";
}
return true;
}
if (task_view == "DreadfulFoe-5" && mode == "0") {
if (task_view == "DreadfulFoe-5" && mode == RoguelikeMode::Exp) {
m_stage = "Boss";
return true;
}
if (task_view == "Trader" && mode == "0") {
if (task_view == "Trader" && mode == RoguelikeMode::Exp) {
m_stage = "Trader";
return true;
}
if (task_view == "Encounter" && mode == "0") {
if (task_view == "Encounter" && mode == RoguelikeMode::Exp) {
m_stage = "Encounter";
return true;
}
if ((task_view == "Gambling" || task_view == "EmergencyTransportation" || task_view == "WindAndRain") &&
mode == "0") {
mode == RoguelikeMode::Exp) {
m_stage = "Gambling";
return true;
}

View File

@@ -44,7 +44,7 @@ bool asst::RoguelikeLastRewardTaskPlugin::_run()
{
LogTraceFunction;
std::string mode = status()->get_properties(Status::RoguelikeMode).value();
auto mode = m_config->get_mode();
std::string stages_task_name = m_config->get_theme() + "@Roguelike@Stages";
std::string strategy_task_name = stages_task_name + "_default";
@@ -59,7 +59,7 @@ bool asst::RoguelikeLastRewardTaskPlugin::_run()
// 需要开局凹直升
bool start_with_elite_two =
status()->get_properties(Status::RoguelikeStartWithEliteTwo).value() == std::to_string(true);
if (m_config->get_theme() != "Phantom" && mode == "4") {
if (m_config->get_theme() != "Phantom" && mode == RoguelikeMode::Collectible) {
if (m_is_next_hardest) {
status()->set_properties(Status::RoguelikeDifficulty, "max");
// 获得热水壶和演讲时停止肉鸽(凹直升则继续),获得其他奖励时重开

View File

@@ -38,10 +38,10 @@ bool asst::RoguelikeStageEncounterTaskPlugin::_run()
{
LogTraceFunction;
std::string rogue_mode = status()->get_properties(Status::RoguelikeMode).value();
auto mode = m_config->get_mode();
std::vector<RoguelikeEvent> events = RoguelikeStageEncounter.get_events(m_config->get_theme());
// 刷源石锭模式和烧水模式
if (rogue_mode == "1" || rogue_mode == "4") {
if (mode == RoguelikeMode::Investment || mode == RoguelikeMode::Collectible) {
events = RoguelikeStageEncounter.get_events(m_config->get_theme() + "_deposit");
}
std::vector<std::string> event_names;

View File

@@ -36,7 +36,6 @@ bool asst::RoguelikeStrategyChangeTaskPlugin::_run()
LogTraceFunction;
std::string theme = m_config->get_theme();
std::string mode = status()->get_properties(Status::RoguelikeMode).value();
// TODO: 这段识别有点冗余,要是 plugin 能获取识别结果就好了
std::string task_name = theme + "@Roguelike@StrategyChange";