mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 02:10:21 +08:00
feat.新增支持刷理智时崩溃自动重开游戏并继续上一次战斗。还重构了一些有的没的
https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/720 https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/115 https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/766
This commit is contained in:
@@ -836,6 +836,10 @@
|
||||
1,
|
||||
255
|
||||
],
|
||||
"reduceOtherTimes": [
|
||||
"StartButton1",
|
||||
"StartButton2"
|
||||
],
|
||||
"next": [
|
||||
"GameStart",
|
||||
"StartToWakeUp",
|
||||
@@ -1238,10 +1242,10 @@
|
||||
"PRTS",
|
||||
"PRTS2",
|
||||
"EndOfAction",
|
||||
"ClickCornerAfterPRTS1"
|
||||
"ClickCornerAfterPRTS_1"
|
||||
]
|
||||
},
|
||||
"ClickCornerAfterPRTS1": {
|
||||
"ClickCornerAfterPRTS_1": {
|
||||
"ClickCorner_Doc": "点击屏幕右边,不会点到掉落物品,且不会关掉关卡选择的一块区域",
|
||||
"algorithm": "JustReturn",
|
||||
"action": "ClickRect",
|
||||
@@ -1259,10 +1263,10 @@
|
||||
"UseMedicine",
|
||||
"UseStone",
|
||||
"NoStone",
|
||||
"ClickCornerAfterPRTS2"
|
||||
"ClickCornerAfterPRTS_2"
|
||||
]
|
||||
},
|
||||
"ClickCornerAfterPRTS2": {
|
||||
"ClickCornerAfterPRTS_2": {
|
||||
"ClickCorner_Doc": "点击屏幕右边,不会点到掉落物品,且不会关掉关卡选择的一块区域",
|
||||
"algorithm": "JustReturn",
|
||||
"action": "ClickRect",
|
||||
@@ -1279,7 +1283,39 @@
|
||||
"StartButton2",
|
||||
"UseMedicine",
|
||||
"UseStone",
|
||||
"NoStone"
|
||||
"NoStone",
|
||||
"MaybeCrashAndRestartGame"
|
||||
]
|
||||
},
|
||||
"MaybeCrashAndRestartGame": {
|
||||
"ClickCorner_Doc": "一般能点这么多下还不行的,多半是游戏崩了,所以重启游戏试试",
|
||||
"Doc": "本任务注册了插件 GameCrashRestartTaskPlugin",
|
||||
"algorithm": "JustReturn",
|
||||
"action": "ClickRect",
|
||||
"specificRect": [
|
||||
1000,
|
||||
120,
|
||||
270,
|
||||
10
|
||||
],
|
||||
"rearDelay": 3000,
|
||||
"next": [
|
||||
"EndOfAction",
|
||||
"StartButton1",
|
||||
"StartButton2",
|
||||
"UseMedicine",
|
||||
"UseStone",
|
||||
"NoStone",
|
||||
"GameStart",
|
||||
"StartToWakeUp",
|
||||
"StartUpConnectingFlag",
|
||||
"StartLoginBServer",
|
||||
"Terminal",
|
||||
"CloseAnno",
|
||||
"TodaysSupplies",
|
||||
"ReturnToTerminal",
|
||||
"OfflineConfirm",
|
||||
"StageSNFlag"
|
||||
]
|
||||
},
|
||||
"EndOfAction": {
|
||||
|
||||
@@ -321,6 +321,6 @@ void asst::Assistant::append_callback(AsstMsg msg, json::value detail)
|
||||
|
||||
void Assistant::clear_cache()
|
||||
{
|
||||
m_status->clear_data();
|
||||
m_status->clear_number();
|
||||
//Task.clear_cache();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "ProcessTask.h"
|
||||
#include "StageDropsTaskPlugin.h"
|
||||
#include "GameCrashRestartTaskPlugin.h"
|
||||
|
||||
asst::FightTask::FightTask(AsstCallback callback, void* callback_arg)
|
||||
: PackageTask(std::move(callback), callback_arg, TaskType),
|
||||
@@ -39,6 +40,8 @@ asst::FightTask::FightTask(AsstCallback callback, void* callback_arg)
|
||||
.set_times_limit("StartButton2", INT_MAX);
|
||||
m_stage_drops_plugin_ptr = m_fight_task_ptr->regiseter_plugin<StageDropsTaskPlugin>();
|
||||
m_stage_drops_plugin_ptr->set_retry_times(0);
|
||||
m_game_restart_plugin_ptr = m_fight_task_ptr->regiseter_plugin<GameCrashRestartTaskPlugin>();
|
||||
m_game_restart_plugin_ptr->set_retry_times(0);
|
||||
|
||||
m_subtasks.emplace_back(m_start_up_task_ptr);
|
||||
m_subtasks.emplace_back(m_stage_task_ptr);
|
||||
@@ -54,6 +57,7 @@ bool asst::FightTask::set_params(const json::value& params)
|
||||
bool enable_penguid = params.get("report_to_penguin", false);
|
||||
std::string penguin_id = params.get("penguin_id", "");
|
||||
std::string server = params.get("server", "CN");
|
||||
std::string client_type = params.get("client_type", std::string());
|
||||
|
||||
if (params.contains("drops")) {
|
||||
std::unordered_map<std::string, int> drops;
|
||||
@@ -81,6 +85,9 @@ bool asst::FightTask::set_params(const json::value& params)
|
||||
.set_times_limit("StartButton2", times);
|
||||
m_stage_drops_plugin_ptr->set_enable_penguid(enable_penguid);
|
||||
m_stage_drops_plugin_ptr->set_penguin_id(std::move(penguin_id));
|
||||
if (!client_type.empty()) {
|
||||
m_game_restart_plugin_ptr->set_client_type(client_type);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace asst
|
||||
{
|
||||
class ProcessTask;
|
||||
class StageDropsTaskPlugin;
|
||||
class GameCrashRestartTaskPlugin;
|
||||
|
||||
class FightTask final : public PackageTask
|
||||
{
|
||||
@@ -23,5 +24,6 @@ namespace asst
|
||||
std::shared_ptr<ProcessTask> m_stage_task_ptr = nullptr;
|
||||
std::shared_ptr<ProcessTask> m_fight_task_ptr = nullptr;
|
||||
std::shared_ptr<StageDropsTaskPlugin> m_stage_drops_plugin_ptr = nullptr;
|
||||
std::shared_ptr<GameCrashRestartTaskPlugin> m_game_restart_plugin_ptr = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
16
src/MeoAssistant/GameCrashRestartTaskPlugin.cpp
Normal file
16
src/MeoAssistant/GameCrashRestartTaskPlugin.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "GameCrashRestartTaskPlugin.h"
|
||||
|
||||
bool asst::GameCrashRestartTaskPlugin::verify(AsstMsg msg, const json::value& details) const
|
||||
{
|
||||
if (msg != AsstMsg::SubTaskCompleted
|
||||
|| details.get("subtask", std::string()) != "ProcessTask") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (details.at("details").at("task").as_string() == "MaybeCrashAndRestartGame") {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
14
src/MeoAssistant/GameCrashRestartTaskPlugin.h
Normal file
14
src/MeoAssistant/GameCrashRestartTaskPlugin.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "StartGameTaskPlugin.h"
|
||||
|
||||
namespace asst
|
||||
{
|
||||
class GameCrashRestartTaskPlugin : public StartGameTaskPlugin
|
||||
{
|
||||
public:
|
||||
using StartGameTaskPlugin::StartGameTaskPlugin;
|
||||
virtual ~GameCrashRestartTaskPlugin() noexcept = default;
|
||||
|
||||
virtual bool verify(AsstMsg msg, const json::value& details) const override;
|
||||
};
|
||||
}
|
||||
@@ -20,7 +20,7 @@ bool asst::InfrastInfoTask::_run()
|
||||
for (auto&& [name, res] : analyzer.get_result()) {
|
||||
std::string key = "NumOf" + name;
|
||||
//int size = static_cast<int>(res.size());
|
||||
m_status->set_data(key, res.size());
|
||||
m_status->set_number(key, res.size());
|
||||
Log.trace("InfrastInfoTask | ", key, res.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -319,7 +319,7 @@ bool asst::InfrastProductionTask::optimal_calc()
|
||||
// 条件判断,不符合的直接过滤掉
|
||||
bool meet_condition = true;
|
||||
for (const auto& [cond, cond_value] : group.conditions) {
|
||||
auto cond_opt = m_status->get_data(cond);
|
||||
auto cond_opt = m_status->get_number(cond);
|
||||
if (!cond_opt) {
|
||||
continue;
|
||||
}
|
||||
@@ -614,7 +614,7 @@ asst::InfrastProductionTask::efficient_regex_calc(
|
||||
// TODO 报错!
|
||||
}
|
||||
std::string status_key = cur_formula.substr(pos + 1, rp_pos - pos - 1);
|
||||
auto status_opt = m_status->get_data(status_key);
|
||||
auto status_opt = m_status->get_number(status_key);
|
||||
const int64_t status_value = status_opt ? status_opt.value() : 0;
|
||||
cur_formula.replace(pos, rp_pos - pos + 1, std::to_string(status_value));
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<ClInclude Include="BattleFormationTask.h" />
|
||||
<ClInclude Include="BattleImageAnalyzer.h" />
|
||||
<ClInclude Include="BattleProcessTask.h" />
|
||||
<ClInclude Include="GameCrashRestartTaskPlugin.h" />
|
||||
<ClInclude Include="RoguelikeRecruitConfiger.h" />
|
||||
<ClInclude Include="CopilotTask.h" />
|
||||
<ClInclude Include="DebugTask.h" />
|
||||
@@ -86,7 +87,7 @@
|
||||
<ClInclude Include="StageDropsConfiger.h" />
|
||||
<ClInclude Include="StageDropsImageAnalyzer.h" />
|
||||
<ClInclude Include="StageDropsTaskPlugin.h" />
|
||||
<ClInclude Include="StartGameTask.h" />
|
||||
<ClInclude Include="StartGameTaskPlugin.h" />
|
||||
<ClInclude Include="StartUpTask.h" />
|
||||
<ClInclude Include="TaskData.h" />
|
||||
<ClInclude Include="MatchImageAnalyzer.h" />
|
||||
@@ -108,6 +109,7 @@
|
||||
<ClCompile Include="BattleFormationTask.cpp" />
|
||||
<ClCompile Include="BattleImageAnalyzer.cpp" />
|
||||
<ClCompile Include="BattleProcessTask.cpp" />
|
||||
<ClCompile Include="GameCrashRestartTaskPlugin.cpp" />
|
||||
<ClCompile Include="RoguelikeRecruitConfiger.cpp" />
|
||||
<ClCompile Include="CopilotTask.cpp" />
|
||||
<ClCompile Include="DebugTask.cpp" />
|
||||
@@ -166,7 +168,7 @@
|
||||
<ClCompile Include="StageDropsConfiger.cpp" />
|
||||
<ClCompile Include="StageDropsImageAnalyzer.cpp" />
|
||||
<ClCompile Include="StageDropsTaskPlugin.cpp" />
|
||||
<ClCompile Include="StartGameTask.cpp" />
|
||||
<ClCompile Include="StartGameTaskPlugin.cpp" />
|
||||
<ClCompile Include="StartUpTask.cpp" />
|
||||
<ClCompile Include="TaskData.cpp" />
|
||||
<ClCompile Include="MatchImageAnalyzer.cpp" />
|
||||
@@ -336,4 +338,4 @@
|
||||
<UserProperties _1_1_4_1_1_4resource_4config_1json__JsonSchema="" _1_1_4_1_1_4resource_4tasks_1json__JsonSchema="../docs/maa_tasks_schema.json" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -240,9 +240,6 @@
|
||||
<ClInclude Include="RecruitCalcTask.h">
|
||||
<Filter>头文件\Task\Sub</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StartGameTask.h">
|
||||
<Filter>头文件\Task\Sub</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BattleImageAnalyzer.h">
|
||||
<Filter>头文件\ImageAnalyzer\Final</Filter>
|
||||
</ClInclude>
|
||||
@@ -336,6 +333,12 @@
|
||||
<ClInclude Include="RoguelikeRecruitImageAnalyzer.h">
|
||||
<Filter>头文件\ImageAnalyzer\Final</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StartGameTaskPlugin.h">
|
||||
<Filter>头文件\Task\Plugin</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GameCrashRestartTaskPlugin.h">
|
||||
<Filter>头文件\Task\Plugin</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Controller.cpp">
|
||||
@@ -476,9 +479,6 @@
|
||||
<ClCompile Include="ProcessTask.cpp">
|
||||
<Filter>源文件\Task\Sub</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StartGameTask.cpp">
|
||||
<Filter>源文件\Task\Sub</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="BattleImageAnalyzer.cpp">
|
||||
<Filter>源文件\ImageAnalyzer\Final</Filter>
|
||||
</ClCompile>
|
||||
@@ -569,6 +569,12 @@
|
||||
<ClCompile Include="RoguelikeRecruitImageAnalyzer.cpp">
|
||||
<Filter>源文件\ImageAnalyzer\Final</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StartGameTaskPlugin.cpp">
|
||||
<Filter>源文件\Task\Plugin</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GameCrashRestartTaskPlugin.cpp">
|
||||
<Filter>源文件\Task\Plugin</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\resource\config.json">
|
||||
@@ -584,4 +590,4 @@
|
||||
<Filter>资源文件</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -205,7 +205,7 @@ bool ProcessTask::_run()
|
||||
break;
|
||||
}
|
||||
|
||||
m_status->set_data("Last" + cur_name, time(nullptr));
|
||||
m_status->set_number("Last" + cur_name, time(nullptr));
|
||||
|
||||
// 减少其他任务的执行次数
|
||||
// 例如,进入吃理智药的界面了,相当于上一次点蓝色开始行动没生效
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
asst::ProcessTaskImageAnalyzer::ProcessTaskImageAnalyzer(const cv::Mat& image, std::vector<std::string> tasks_name)
|
||||
: AbstractImageAnalyzer(image),
|
||||
m_tasks_name(std::move(tasks_name))
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
asst::ProcessTaskImageAnalyzer::~ProcessTaskImageAnalyzer() = default;
|
||||
|
||||
@@ -26,7 +25,7 @@ bool asst::ProcessTaskImageAnalyzer::match_analyze(const std::shared_ptr<TaskInf
|
||||
const auto match_task_ptr = std::dynamic_pointer_cast<MatchTaskInfo>(task_ptr);
|
||||
m_match_analyzer->set_region_of_appeared(Rect());
|
||||
m_match_analyzer->set_task_info(match_task_ptr);
|
||||
auto region_opt = m_status->get_region(match_task_ptr->name);
|
||||
auto region_opt = m_status->get_rect(match_task_ptr->name);
|
||||
if (region_opt) {
|
||||
m_match_analyzer->set_region_of_appeared(region_opt.value());
|
||||
}
|
||||
@@ -34,7 +33,7 @@ bool asst::ProcessTaskImageAnalyzer::match_analyze(const std::shared_ptr<TaskInf
|
||||
if (m_match_analyzer->analyze()) {
|
||||
m_result = match_task_ptr;
|
||||
m_result_rect = m_match_analyzer->get_result().rect;
|
||||
m_status->set_region(match_task_ptr->name, m_result_rect);
|
||||
m_status->set_rect(match_task_ptr->name, m_result_rect);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -75,7 +74,7 @@ bool asst::ProcessTaskImageAnalyzer::ocr_analyze(const std::shared_ptr<TaskInfo>
|
||||
}
|
||||
m_ocr_analyzer->set_region_of_appeared(Rect());
|
||||
m_ocr_analyzer->set_task_info(ocr_task_ptr);
|
||||
auto region_opt = m_status->get_region(ocr_task_ptr->name);
|
||||
auto region_opt = m_status->get_rect(ocr_task_ptr->name);
|
||||
if (region_opt) {
|
||||
m_ocr_analyzer->set_region_of_appeared(region_opt.value());
|
||||
}
|
||||
@@ -88,7 +87,7 @@ bool asst::ProcessTaskImageAnalyzer::ocr_analyze(const std::shared_ptr<TaskInfo>
|
||||
auto& res = ocr_result.front();
|
||||
m_result = ocr_task_ptr;
|
||||
m_result_rect = res.rect;
|
||||
m_status->set_region(ocr_task_ptr->name, m_result_rect);
|
||||
m_status->set_rect(ocr_task_ptr->name, m_result_rect);
|
||||
//m_ocr_cache.insert(m_ocr_cache.end(), ocr_result.begin(), ocr_result.end());
|
||||
Log.trace("ProcessTaskImageAnalyzer::ocr_analyze | found", res.to_string());
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ void asst::RoguelikeBattleTaskPlugin::clear()
|
||||
m_used_tiles.clear();
|
||||
|
||||
for (auto& [key, status] : m_restore_status) {
|
||||
m_status->set_data(key, status);
|
||||
m_status->set_number(key, status);
|
||||
}
|
||||
m_restore_status.clear();
|
||||
}
|
||||
@@ -389,7 +389,7 @@ bool asst::RoguelikeBattleTaskPlugin::try_possible_skill(const cv::Mat& image)
|
||||
for (auto& [loc, name] : m_used_tiles) {
|
||||
std::string status_key = "RoguelikeSkillUsage-" + name;
|
||||
auto usage = BattleSkillUsage::Possibly;
|
||||
auto usage_opt = m_status->get_data(status_key);
|
||||
auto usage_opt = m_status->get_number(status_key);
|
||||
if (usage_opt) {
|
||||
usage = static_cast<BattleSkillUsage>(usage_opt.value());
|
||||
}
|
||||
@@ -408,7 +408,7 @@ bool asst::RoguelikeBattleTaskPlugin::try_possible_skill(const cv::Mat& image)
|
||||
m_ctrler->click(pos_rect);
|
||||
used |= ProcessTask(*this, { "BattleSkillReadyOnClick" }).set_task_delay(0).run();
|
||||
if (usage == BattleSkillUsage::Once) {
|
||||
m_status->set_data(status_key, static_cast<int64_t>(BattleSkillUsage::OnceUsed));
|
||||
m_status->set_number(status_key, static_cast<int64_t>(BattleSkillUsage::OnceUsed));
|
||||
m_restore_status[status_key] = static_cast<int64_t>(BattleSkillUsage::Once);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ bool asst::RoguelikeSkillSelectionTaskPlugin::_run()
|
||||
Log.info(__FUNCTION__, name, " select skill:", index + 1);
|
||||
m_ctrler->click(skill_vec.at(index));
|
||||
}
|
||||
m_status->set_data("RoguelikeSkillUsage-" + name, static_cast<int>(usage));
|
||||
m_status->set_number("RoguelikeSkillUsage-" + name, static_cast<int>(usage));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "RuntimeStatus.h"
|
||||
|
||||
std::optional<int64_t> asst::RuntimeStatus::get_data(const std::string& key) const noexcept
|
||||
std::optional<int64_t> asst::RuntimeStatus::get_number(const std::string& key) const noexcept
|
||||
{
|
||||
if (auto iter = m_data.find(key);
|
||||
iter != m_data.cend()) {
|
||||
if (auto iter = m_number.find(key);
|
||||
iter != m_number.cend()) {
|
||||
return iter->second;
|
||||
}
|
||||
else {
|
||||
@@ -11,20 +11,20 @@ std::optional<int64_t> asst::RuntimeStatus::get_data(const std::string& key) con
|
||||
}
|
||||
}
|
||||
|
||||
void asst::RuntimeStatus::set_data(std::string key, int64_t value)
|
||||
void asst::RuntimeStatus::set_number(std::string key, int64_t value)
|
||||
{
|
||||
m_data[std::move(key)] = value;
|
||||
m_number.insert_or_assign(std::move(key), value);
|
||||
}
|
||||
|
||||
void asst::RuntimeStatus::clear_data() noexcept
|
||||
void asst::RuntimeStatus::clear_number() noexcept
|
||||
{
|
||||
m_data.clear();
|
||||
m_number.clear();
|
||||
}
|
||||
|
||||
std::optional<asst::Rect> asst::RuntimeStatus::get_region(const std::string& key) const noexcept
|
||||
std::optional<asst::Rect> asst::RuntimeStatus::get_rect(const std::string& key) const noexcept
|
||||
{
|
||||
if (auto iter = m_region_of_appeared.find(key);
|
||||
iter != m_region_of_appeared.cend()) {
|
||||
if (auto iter = m_rect.find(key);
|
||||
iter != m_rect.cend()) {
|
||||
return iter->second;
|
||||
}
|
||||
else {
|
||||
@@ -32,12 +32,33 @@ std::optional<asst::Rect> asst::RuntimeStatus::get_region(const std::string& key
|
||||
}
|
||||
}
|
||||
|
||||
void asst::RuntimeStatus::set_region(std::string key, Rect rect)
|
||||
void asst::RuntimeStatus::set_rect(std::string key, Rect rect)
|
||||
{
|
||||
m_region_of_appeared[std::move(key)] = rect;
|
||||
m_rect.insert_or_assign(std::move(key), rect);
|
||||
}
|
||||
|
||||
void asst::RuntimeStatus::clear_region() noexcept
|
||||
void asst::RuntimeStatus::clear_rect() noexcept
|
||||
{
|
||||
m_region_of_appeared.clear();
|
||||
m_rect.clear();
|
||||
}
|
||||
|
||||
std::optional<std::string> asst::RuntimeStatus::get_str(const std::string& key) const noexcept
|
||||
{
|
||||
if (auto iter = m_string.find(key);
|
||||
iter != m_string.cend()) {
|
||||
return iter->second;
|
||||
}
|
||||
else {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
void asst::RuntimeStatus::set_str(std::string key, std::string value)
|
||||
{
|
||||
m_string.insert_or_assign(std::move(key), std::move(value));
|
||||
}
|
||||
|
||||
void asst::RuntimeStatus::clear_str() noexcept
|
||||
{
|
||||
m_string.clear();
|
||||
}
|
||||
|
||||
@@ -17,20 +17,25 @@ namespace asst
|
||||
RuntimeStatus(RuntimeStatus&& rhs) noexcept = delete;
|
||||
~RuntimeStatus() = default;
|
||||
|
||||
std::optional<int64_t> get_data(const std::string& key) const noexcept;
|
||||
void set_data(std::string key, int64_t value);
|
||||
void clear_data() noexcept;
|
||||
std::optional<int64_t> get_number(const std::string& key) const noexcept;
|
||||
void set_number(std::string key, int64_t value);
|
||||
void clear_number() noexcept;
|
||||
|
||||
std::optional<Rect> get_region(const std::string& key) const noexcept;
|
||||
void set_region(std::string key, Rect rect);
|
||||
void clear_region() noexcept;
|
||||
std::optional<Rect> get_rect(const std::string& key) const noexcept;
|
||||
void set_rect(std::string key, Rect rect);
|
||||
void clear_rect() noexcept;
|
||||
|
||||
std::optional<std::string> get_str(const std::string& key) const noexcept;
|
||||
void set_str(std::string key, std::string value);
|
||||
void clear_str() noexcept;
|
||||
|
||||
RuntimeStatus& operator=(const RuntimeStatus& rhs) = delete;
|
||||
RuntimeStatus& operator=(RuntimeStatus&& rhs) noexcept = delete;
|
||||
|
||||
private:
|
||||
|
||||
std::unordered_map<std::string, int64_t> m_data;
|
||||
std::unordered_map<std::string, Rect> m_region_of_appeared;
|
||||
std::unordered_map<std::string, int64_t> m_number;
|
||||
std::unordered_map<std::string, Rect> m_rect;
|
||||
std::unordered_map<std::string, std::string> m_string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ bool asst::StageDropsTaskPlugin::verify(AsstMsg msg, const json::value& details)
|
||||
}
|
||||
|
||||
if (details.at("details").at("task").as_string() == "EndOfAction") {
|
||||
auto pre_time_opt = m_status->get_data("LastStartButton2");
|
||||
auto pre_time_opt = m_status->get_number("LastStartButton2");
|
||||
int64_t pre_start_time = pre_time_opt ? pre_time_opt.value() : 0;
|
||||
auto pre_reg_time_opt = m_status->get_data("LastRecognizeDrops");
|
||||
auto pre_reg_time_opt = m_status->get_number("LastRecognizeDrops");
|
||||
int64_t pre_recognize_time = pre_reg_time_opt ? pre_reg_time_opt.value() : 0;
|
||||
if (pre_start_time + RecognizationTimeOffset == pre_recognize_time) {
|
||||
Log.info("Recognization time too close, pass", pre_start_time, pre_recognize_time);
|
||||
@@ -119,9 +119,9 @@ bool asst::StageDropsTaskPlugin::recognize_drops()
|
||||
m_stars = analyzer.get_stars();
|
||||
m_cur_drops = analyzer.get_drops();
|
||||
|
||||
auto last_time_opt = m_status->get_data("LastStartButton2");
|
||||
auto last_time_opt = m_status->get_number("LastStartButton2");
|
||||
auto last_time = last_time_opt ? last_time_opt.value() : 0;
|
||||
m_status->set_data("LastRecognizeDrops", last_time + RecognizationTimeOffset);
|
||||
m_status->set_number("LastRecognizeDrops", last_time + RecognizationTimeOffset);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ void asst::StageDropsTaskPlugin::set_startbutton_delay()
|
||||
LogTraceFunction;
|
||||
|
||||
if (!m_startbutton_delay_setted) {
|
||||
auto last_time_opt = m_status->get_data("LastStartButton2");
|
||||
auto last_time_opt = m_status->get_number("LastStartButton2");
|
||||
int64_t pre_start_time = last_time_opt ? last_time_opt.value() : 0;
|
||||
|
||||
if (pre_start_time > 0) {
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AbstractTask.h"
|
||||
#include "AsstTypes.h"
|
||||
|
||||
namespace asst
|
||||
{
|
||||
class StartGameTask : public AbstractTask
|
||||
{
|
||||
public:
|
||||
using AbstractTask::AbstractTask;
|
||||
~StartGameTask() override = default;
|
||||
|
||||
StartGameTask& set_param(std::string client_type) noexcept;
|
||||
|
||||
protected:
|
||||
bool _run() override;
|
||||
|
||||
std::string m_client_type = "";
|
||||
};
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "StartGameTask.h"
|
||||
#include "StartGameTaskPlugin.h"
|
||||
|
||||
#include "Controller.h"
|
||||
|
||||
using namespace asst;
|
||||
|
||||
bool StartGameTask::_run()
|
||||
bool StartGameTaskPlugin::_run()
|
||||
{
|
||||
if (m_client_type.empty()) {
|
||||
return false;
|
||||
@@ -12,7 +12,7 @@ bool StartGameTask::_run()
|
||||
return m_ctrler->start_game(m_client_type).has_value();
|
||||
}
|
||||
|
||||
StartGameTask& StartGameTask::set_param(std::string client_type) noexcept
|
||||
StartGameTaskPlugin& StartGameTaskPlugin::set_client_type(std::string client_type) noexcept
|
||||
{
|
||||
m_client_type = std::move(client_type);
|
||||
return *this;
|
||||
28
src/MeoAssistant/StartGameTaskPlugin.h
Normal file
28
src/MeoAssistant/StartGameTaskPlugin.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "AbstractTaskPlugin.h"
|
||||
#include "AsstTypes.h"
|
||||
|
||||
namespace asst
|
||||
{
|
||||
inline static const std::string ClientTypeKey = "client_type";
|
||||
|
||||
class StartGameTaskPlugin : public AbstractTaskPlugin
|
||||
{
|
||||
public:
|
||||
using AbstractTaskPlugin::AbstractTaskPlugin;
|
||||
virtual ~StartGameTaskPlugin() noexcept = default;
|
||||
|
||||
virtual bool verify(AsstMsg msg, const json::value& details) const override
|
||||
{
|
||||
std::ignore = msg; std::ignore = details; return true;
|
||||
};
|
||||
|
||||
StartGameTaskPlugin& set_client_type(std::string client_type) noexcept;
|
||||
|
||||
protected:
|
||||
bool _run() override;
|
||||
|
||||
std::string m_client_type = "";
|
||||
};
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
asst::StartUpTask::StartUpTask(AsstCallback callback, void* callback_arg)
|
||||
: PackageTask(std::move(callback), callback_arg, TaskType),
|
||||
m_start_game_task_ptr(std::make_shared<StartGameTask>(m_callback, m_callback_arg, TaskType)),
|
||||
m_start_game_task_ptr(std::make_shared<StartGameTaskPlugin>(m_callback, m_callback_arg, TaskType)),
|
||||
m_start_up_task_ptr(std::make_shared<ProcessTask>(m_callback, m_callback_arg, TaskType))
|
||||
{
|
||||
m_start_up_task_ptr->set_tasks({ "StartUp" })
|
||||
@@ -18,7 +18,7 @@ asst::StartUpTask::StartUpTask(AsstCallback callback, void* callback_arg)
|
||||
|
||||
bool asst::StartUpTask::set_params(const json::value& params)
|
||||
{
|
||||
m_start_game_task_ptr->set_param(params.get("client_type", ""))
|
||||
m_start_game_task_ptr->set_client_type(params.get("client_type", ""))
|
||||
.set_enable(params.get("start_game_enable", false));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "PackageTask.h"
|
||||
#include "StartGameTask.h"
|
||||
#include "StartGameTaskPlugin.h"
|
||||
|
||||
namespace asst
|
||||
{
|
||||
@@ -16,7 +16,7 @@ namespace asst
|
||||
|
||||
static constexpr const char* TaskType = "StartUp";
|
||||
private:
|
||||
std::shared_ptr<StartGameTask> m_start_game_task_ptr = nullptr;
|
||||
std::shared_ptr<StartGameTaskPlugin> m_start_game_task_ptr = nullptr;
|
||||
std::shared_ptr<ProcessTask> m_start_up_task_ptr = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -264,8 +264,8 @@ namespace MeoAsstGui
|
||||
|
||||
switch (subTask)
|
||||
{
|
||||
case "StartGameTask":
|
||||
mainModel.AddLog("打开客户端失败,请\n检查配置文件", "darkred");
|
||||
case "StartGameTaskPlugin":
|
||||
mainModel.AddLog("打开客户端失败,请检查配置文件", "darkred");
|
||||
break;
|
||||
|
||||
case "AutoRecruitTask":
|
||||
@@ -382,6 +382,14 @@ namespace MeoAsstGui
|
||||
case "Roguelike1StageTraderInvestSystemFull":
|
||||
mainModel.AddLog("投资达到上限", "darkcyan");
|
||||
break;
|
||||
|
||||
case "MaybeCrashAndRestartGame":
|
||||
mainModel.AddLog("游戏崩溃,重新启动");
|
||||
break;
|
||||
|
||||
case "OfflineConfirm":
|
||||
mainModel.AddLog("游戏掉线,重新连接");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -690,6 +698,7 @@ namespace MeoAsstGui
|
||||
task_params["drops"][drops_item_id] = drops_item_quantity;
|
||||
}
|
||||
var settings = _container.Get<SettingsViewModel>();
|
||||
task_params["client_type"] = settings.ClientType;
|
||||
task_params["penguin_id"] = settings.PenguinId;
|
||||
task_params["server"] = "CN";
|
||||
return AsstAppendTaskWithEncoding("Fight", task_params);
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace MeoAsstGui
|
||||
new CombData { Display = "刷源石锭投资,投资过后退出", Value = "2" }
|
||||
};
|
||||
|
||||
ServerTypeList = new List<CombData>
|
||||
ClientTypeList = new List<CombData>
|
||||
{
|
||||
new CombData { Display = "官服", Value = "Official" },
|
||||
new CombData { Display = "Bilibili服", Value = "Bilibili" }
|
||||
@@ -166,15 +166,15 @@ namespace MeoAsstGui
|
||||
}
|
||||
}
|
||||
|
||||
private string _serverType = ViewStatusStorage.Get("Start.ServerType", "Official");
|
||||
private string _clientType = ViewStatusStorage.Get("Start.ClientType", "Official");
|
||||
|
||||
public string ServerType
|
||||
public string ClientType
|
||||
{
|
||||
get { return _serverType; }
|
||||
get { return _clientType; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _serverType, value);
|
||||
ViewStatusStorage.Set("Start.ServerType", value);
|
||||
SetAndNotify(ref _clientType, value);
|
||||
ViewStatusStorage.Set("Start.ClientType", value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace MeoAsstGui
|
||||
|
||||
public List<CombData> UsesOfDronesList { get; set; }
|
||||
public List<CombData> RoguelikeModeList { get; set; }
|
||||
public List<CombData> ServerTypeList { get; set; }
|
||||
public List<CombData> ClientTypeList { get; set; }
|
||||
public List<CombData> ConnectConfigList { get; set; }
|
||||
|
||||
private int _dormThreshold = Convert.ToInt32(ViewStatusStorage.Get("Infrast.DormThreshold", "30"));
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace MeoAsstGui
|
||||
{
|
||||
new CombData { Display = "当前关卡", Value = string.Empty },
|
||||
new CombData { Display = "上次作战", Value = "LastBattle" },
|
||||
|
||||
|
||||
// “覆潮之下” 活动关卡 //复刻活动,结束后直接删除
|
||||
new CombData { Display = "SV-9", Value = "SV-9" },
|
||||
new CombData { Display = "SV-8", Value = "SV-8" },
|
||||
@@ -350,11 +350,11 @@ namespace MeoAsstGui
|
||||
{
|
||||
var settings = _container.Get<SettingsViewModel>();
|
||||
var asstProxy = _container.Get<AsstProxy>();
|
||||
var mode = settings.ServerType;
|
||||
var mode = settings.ClientType;
|
||||
var enable = settings.StartGameEnable;
|
||||
return asstProxy.AsstAppendStartUp(mode, enable);
|
||||
}
|
||||
|
||||
|
||||
private bool appendFight()
|
||||
{
|
||||
int medicine = 0;
|
||||
@@ -373,14 +373,14 @@ namespace MeoAsstGui
|
||||
stone = 0;
|
||||
}
|
||||
}
|
||||
int times = int.MaxValue;
|
||||
if (IsSpecifiedDrops)
|
||||
{
|
||||
if (!int.TryParse(DropsQuantity, out times))
|
||||
{
|
||||
times = 0;
|
||||
}
|
||||
}
|
||||
//int times = int.MaxValue;
|
||||
//if (IsSpecifiedDrops)
|
||||
//{
|
||||
// if (!int.TryParse(DropsQuantity, out times))
|
||||
// {
|
||||
// times = 0;
|
||||
// }
|
||||
//}
|
||||
int drops_quantity = 0;
|
||||
if (IsSpecifiedDrops)
|
||||
{
|
||||
@@ -391,7 +391,7 @@ namespace MeoAsstGui
|
||||
}
|
||||
|
||||
var asstProxy = _container.Get<AsstProxy>();
|
||||
return asstProxy.AsstAppendFight(Stage, medicine, stone, times, DropsItemId, drops_quantity);
|
||||
return asstProxy.AsstAppendFight(Stage, medicine, stone, int.MaxValue, DropsItemId, drops_quantity);
|
||||
}
|
||||
|
||||
private bool appendInfrast()
|
||||
|
||||
Reference in New Issue
Block a user