mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
fix: sln
This commit is contained in:
@@ -90,9 +90,6 @@
|
||||
<ClInclude Include="Task\Reclamation\ReclamationConfig.h" />
|
||||
<ClInclude Include="Task\Reclamation\AbstractReclamationTaskPlugin.h" />
|
||||
<ClInclude Include="Task\Reclamation\ReclamationCraftTaskPlugin.h" />
|
||||
<ClInclude Include="Task\Reclamation\Deprecated\ReclamationBattlePlugin.h" />
|
||||
<ClInclude Include="Task\Reclamation\Deprecated\ReclamationConclusionReportPlugin.h" />
|
||||
<ClInclude Include="Task\Reclamation\Deprecated\ReclamationControlTask.h" />
|
||||
<!-- 生息演算 .h End -->
|
||||
<ClInclude Include="Task\BattleHelper.h" />
|
||||
<ClInclude Include="Task\Interface\SingleStepTask.h" />
|
||||
@@ -283,9 +280,6 @@
|
||||
<ClCompile Include="Task\Reclamation\ReclamationConfig.cpp" />
|
||||
<ClCompile Include="Task\Reclamation\AbstractReclamationTaskPlugin.cpp" />
|
||||
<ClCompile Include="Task\Reclamation\ReclamationCraftTaskPlugin.cpp" />
|
||||
<ClCompile Include="Task\Reclamation\Deprecated\ReclamationBattlePlugin.cpp" />
|
||||
<ClCompile Include="Task\Reclamation\Deprecated\ReclamationConclusionReportPlugin.cpp" />
|
||||
<ClCompile Include="Task\Reclamation\Deprecated\ReclamationControlTask.cpp" />
|
||||
<!-- 生息演算 .cpp End -->
|
||||
<ClCompile Include="Task\BattleHelper.cpp" />
|
||||
<ClCompile Include="Task\Interface\SingleStepTask.cpp" />
|
||||
|
||||
@@ -462,12 +462,6 @@
|
||||
<ClInclude Include="Task\Roguelike\Map\RoguelikeMap.h">
|
||||
<Filter>Source\Task\Roguelike</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="Task\Roguelike\Map\RoguelikeRoutingTaskPlugin.h">
|
||||
<Filter>Source\Task\Roguelike</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="Task\Roguelike\Map\RoguelikeRoutingTask.h">
|
||||
<Filter>Source\Task\Roguelike</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Task\Roguelike\RoguelikeControlTaskPlugin.h">
|
||||
<Filter>Source\Task\Roguelike</Filter>
|
||||
</ClInclude>
|
||||
@@ -553,15 +547,6 @@
|
||||
<ClInclude Include="Task\Reclamation\ReclamationCraftTaskPlugin.h">
|
||||
<Filter>Source\Task\Reclamation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Task\Reclamation\Deprecated\ReclamationBattlePlugin.h">
|
||||
<Filter>Source\Task\Reclamation\Deprecated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Task\Reclamation\Deprecated\ReclamationConclusionReportPlugin.h">
|
||||
<Filter>Source\Task\Reclamation\Deprecated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Task\Reclamation\Deprecated\ReclamationControlTask.h">
|
||||
<Filter>Source\Task\Reclamation\Deprecated</Filter>
|
||||
</ClInclude>
|
||||
<!-- 生息演算 .h End -->
|
||||
<ClInclude Include="Utils\File.hpp">
|
||||
<Filter>Source\Utils</Filter>
|
||||
@@ -740,6 +725,7 @@
|
||||
<ClInclude Include="Vision\Roguelike\RoguelikeParameterAnalyzer.h">
|
||||
<Filter>Source\Vision\Roguelike</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Task\Roguelike\Map\RoguelikeRoutingTaskPlugin.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Vision\VisionHelper.cpp">
|
||||
@@ -826,12 +812,6 @@
|
||||
<ClCompile Include="Config\Roguelike\RoguelikeStageEncounterConfig.cpp">
|
||||
<Filter>Source\Resource\Roguelike</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Config\Roguelike\Sami\RoguelikeFoldartalConfig.cpp">
|
||||
<Filter>Source\Resource\Roguelike\Sami</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Config\Roguelike\Sami\RoguelikeCollapsalParadigmConfig.cpp">
|
||||
<Filter>Source\Resource\Roguelike\Sami</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Config\Miscellaneous\BattleDataConfig.cpp">
|
||||
<Filter>Source\Resource\Miscellaneous</Filter>
|
||||
</ClCompile>
|
||||
@@ -1085,15 +1065,6 @@
|
||||
<ClCompile Include="Task\Reclamation\ReclamationCraftTaskPlugin.cpp">
|
||||
<Filter>Source\Task\Reclamation</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Task\Reclamation\Deprecated\ReclamationBattlePlugin.cpp">
|
||||
<Filter>Source\Task\Reclamation\Deprecated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Task\Reclamation\Deprecated\ReclamationConclusionReportPlugin.cpp">
|
||||
<Filter>Source\Task\Reclamation\Deprecated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Task\Reclamation\Deprecated\ReclamationControlTask.cpp">
|
||||
<Filter>Source\Task\Reclamation\Deprecated</Filter>
|
||||
</ClCompile>
|
||||
<!-- 生息演算 .cpp End -->
|
||||
<ClCompile Include="Controller\Controller.cpp">
|
||||
<Filter>Source\Controller</Filter>
|
||||
@@ -1242,5 +1213,11 @@
|
||||
<ClCompile Include="Vision\Roguelike\RoguelikeParameterAnalyzer.cpp">
|
||||
<Filter>Source\Vision\Roguelike</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Config\Roguelike\Sami\RoguelikeCollapsalParadigmConfig.cpp">
|
||||
<Filter>Source\Resource\Roguelike</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Config\Roguelike\Sami\RoguelikeFoldartalConfig.cpp">
|
||||
<Filter>Source\Resource\Roguelike</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -1,217 +0,0 @@
|
||||
#include "ReclamationBattlePlugin.h"
|
||||
|
||||
#include "Utils/NoWarningCV.h"
|
||||
|
||||
#include "Config/TaskData.h"
|
||||
#include "Controller/Controller.h"
|
||||
#include "ReclamationControlTask.h"
|
||||
#include "Status.h"
|
||||
#include "Task/ProcessTask.h"
|
||||
#include "Utils/Logger.hpp"
|
||||
#include "Vision/Matcher.h"
|
||||
#include "Vision/OCRer.h"
|
||||
|
||||
using namespace asst;
|
||||
|
||||
asst::ReclamationBattlePlugin::ReclamationBattlePlugin(const AsstCallback& callback, Assistant* inst,
|
||||
std::string_view task_chain)
|
||||
: AbstractTaskPlugin(callback, inst, task_chain), BattleHelper(inst)
|
||||
{}
|
||||
|
||||
bool asst::ReclamationBattlePlugin::verify(AsstMsg, const json::value&) const
|
||||
{
|
||||
// 直接调用run()
|
||||
return false;
|
||||
}
|
||||
|
||||
ReclamationBattlePlugin& asst::ReclamationBattlePlugin::set_battle_mode(const ReclamationBattleMode& mode)
|
||||
{
|
||||
m_battle_mode = mode;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool asst::ReclamationBattlePlugin::_run()
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
wait_until_start(false);
|
||||
|
||||
if (m_battle_mode == ReclamationBattleMode::Giveup) {
|
||||
return quit_action();
|
||||
}
|
||||
else if (m_battle_mode == ReclamationBattleMode::BuyWater) {
|
||||
sleep(1500); // 等待技能图标
|
||||
bool result = buy_water();
|
||||
quit_action();
|
||||
return result;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool asst::ReclamationBattlePlugin::do_strategic_action(const cv::Mat&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool asst::ReclamationBattlePlugin::quit_action()
|
||||
{
|
||||
while (!need_exit()) {
|
||||
int retry = 0;
|
||||
while (!need_exit()) {
|
||||
bool stage1 = ProcessTask(*this, { "Reclamation@ClickExitLevel" }).set_retry_times(0).run();
|
||||
bool stage2 = ProcessTask(*this, { "Reclamation@ExitLevelConfirm" }).set_retry_times(3).run();
|
||||
Log.info(__FUNCTION__, "| click exit level perform ", stage1, stage2);
|
||||
if (stage2) break;
|
||||
retry++; // stage1==true&&stage2==false,应该是手动按了确定或是没按到退出
|
||||
if ((!stage1 && !stage2) || retry > 5) {
|
||||
// 已经到了结算界面,或是用户手动操作了
|
||||
Log.error(__FUNCTION__, "| fail to operate");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
sleep(Task.get("Reclamation@BattleStart")->special_params.front());
|
||||
|
||||
const auto img = ctrler()->get_image();
|
||||
bool check1 = check_in_battle(img, false);
|
||||
|
||||
OCRer confirmAnalyzer(img);
|
||||
confirmAnalyzer.set_task_info("Reclamation@ExitLevelConfirm");
|
||||
bool check2 = confirmAnalyzer.analyze().has_value();
|
||||
|
||||
// 出现Loading转一会儿就结算了,没结算还有error_next
|
||||
OCRer loadingAnalyzer(img);
|
||||
loadingAnalyzer.set_task_info("LoadingText");
|
||||
bool check3 = loadingAnalyzer.analyze().has_value();
|
||||
|
||||
Log.info(__FUNCTION__, "| click exit level check ", check1, check2, check3);
|
||||
|
||||
if (!check1 && !check2) break;
|
||||
if (check3) {
|
||||
sleep(Task.get("Reclamation@BattleStart")->special_params.at(1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool asst::ReclamationBattlePlugin::buy_water()
|
||||
{
|
||||
if (!communicate_with(Task.get<OcrTaskInfo>("Reclamation@Liaison")->text.front())) return false;
|
||||
if (!do_dialog_procedure(Task.get<OcrTaskInfo>("Reclamation@BuyWaterProcedure")->text)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool asst::ReclamationBattlePlugin::communicate_with(const std::string& npcName)
|
||||
{
|
||||
// 在存在两个及以上npc时地图会移动,从上到下、从下到上各试一次,还不行算了
|
||||
if (communicate_with_aux(npcName, [](const MatchRect& l, const MatchRect& r) {
|
||||
return l.rect.y < r.rect.y || (l.rect.y == r.rect.y && l.rect.x < r.rect.x);
|
||||
}))
|
||||
return true;
|
||||
if (communicate_with_aux(npcName, [](const MatchRect& l, const MatchRect& r) {
|
||||
return l.rect.y > r.rect.y || (l.rect.y == r.rect.y && l.rect.x > r.rect.x);
|
||||
}))
|
||||
return true;
|
||||
|
||||
Log.info(__FUNCTION__, " | ", "fail to communicate with npc");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool asst::ReclamationBattlePlugin::communicate_with_aux(
|
||||
const std::string& npcName, std::function<bool(const MatchRect&, const MatchRect&)> orderComp)
|
||||
{
|
||||
std::ignore = npcName;
|
||||
std::ignore = orderComp;
|
||||
// auto image = ctrler()->get_image();
|
||||
// BattlefieldClassifier skillReadyAnalyzer(image);
|
||||
// analyzer.set_object_of_interest({ .skill_ready = true });
|
||||
// if (!skillReadyAnalyzer.analyze()) {
|
||||
// Log.info(__FUNCTION__, " | ", "no ready skills");
|
||||
// return false;
|
||||
// }
|
||||
// std::vector<MatchRect> skill_results = skillReadyAnalyzer.get_result();
|
||||
//
|
||||
// std::sort(skill_results.begin(), skill_results.end(), orderComp);
|
||||
// for (const auto& [score, rect] : skill_results) {
|
||||
// Rect center(rect.x + rect.width / 2,
|
||||
// rect.y + rect.height / 2 +
|
||||
// Task.get("Reclamation@SkillReadyRoleOffset")->special_params.front(), 5, 5);
|
||||
//
|
||||
// const auto use_oper_task_ptr = Task.get("BattleUseOper");
|
||||
// ctrler()->click(center);
|
||||
// sleep(use_oper_task_ptr->pre_delay);
|
||||
//
|
||||
// image = ctrler()->get_image();
|
||||
// OCRer npcNameAnalyzer(image);
|
||||
// npcNameAnalyzer.set_task_info("Reclamation@Liaison");
|
||||
// npcNameAnalyzer.set_required({});
|
||||
// if (!npcNameAnalyzer.analyze()) {
|
||||
// // 地图发生了移动
|
||||
// Log.info(__FUNCTION__, " | ", "map moved ");
|
||||
// break;
|
||||
// }
|
||||
// if (npcNameAnalyzer.get_result().front() != npcName) {
|
||||
// // npc名称不正确
|
||||
// Log.info(__FUNCTION__, " | ", "npc name not match ", npcNameAnalyzer.get_result().front());
|
||||
// cancel_oper_selection();
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// ProcessTask skill_task(this_task(), { "Reclamation@BattleSkillReadyOnClick" });
|
||||
// skill_task.set_task_delay(0);
|
||||
//
|
||||
// bool ret = skill_task.set_retry_times(5).run();
|
||||
// if (!ret) {
|
||||
// cancel_oper_selection();
|
||||
// Log.info(__FUNCTION__, " | ", "fail to click skill of npc");
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool asst::ReclamationBattlePlugin::do_dialog_procedure(const std::vector<std::string>& procedure)
|
||||
{
|
||||
for (auto& step : procedure) {
|
||||
if (step == "Skip") {
|
||||
ProcessTask(this_task(), { "Reclamation@DialogSkip" }).set_task_delay(0).set_retry_times(5).run();
|
||||
}
|
||||
else {
|
||||
const int max_retry = 5;
|
||||
int retry = 0;
|
||||
bool succeed = false;
|
||||
while (!need_exit()) {
|
||||
if (retry == max_retry) break;
|
||||
|
||||
const auto& image = ctrler()->get_image();
|
||||
OCRer dialogAnalyzer(image);
|
||||
dialogAnalyzer.set_task_info("Reclamation@BalckMarketDialogOption");
|
||||
dialogAnalyzer.set_required({ step });
|
||||
if (!dialogAnalyzer.analyze()) {
|
||||
if (succeed) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
retry++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const auto& rect = dialogAnalyzer.get_result().front().rect;
|
||||
ctrler()->click(rect);
|
||||
Log.info(__FUNCTION__, " | ", "perform dialog option ", step);
|
||||
sleep(Task.get("Reclamation@BalckMarketDialogOption")->post_delay);
|
||||
succeed = true;
|
||||
}
|
||||
if (retry == max_retry) {
|
||||
Log.info(__FUNCTION__, " | ", "fail to perform dialog option ", step);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
#pragma once
|
||||
#include "Task/AbstractTaskPlugin.h"
|
||||
#include "Task/BattleHelper.h"
|
||||
#include "Task/Miscellaneous/BattleProcessTask.h"
|
||||
|
||||
namespace asst
|
||||
{
|
||||
enum class ReclamationBattleMode
|
||||
{
|
||||
Giveup,
|
||||
BuyWater
|
||||
};
|
||||
|
||||
enum class ReclamationTaskMode;
|
||||
|
||||
class ReclamationBattlePlugin : public AbstractTaskPlugin, private BattleHelper
|
||||
{
|
||||
public:
|
||||
ReclamationBattlePlugin(const AsstCallback& callback, Assistant* inst, std::string_view task_chain);
|
||||
virtual ~ReclamationBattlePlugin() override = default;
|
||||
|
||||
virtual bool verify(AsstMsg msg, const json::value& details) const override;
|
||||
|
||||
ReclamationBattlePlugin& set_battle_mode(const ReclamationBattleMode& mode);
|
||||
|
||||
protected:
|
||||
virtual bool _run() override;
|
||||
virtual bool do_strategic_action(const cv::Mat& reusable = cv::Mat()) override;
|
||||
virtual AbstractTask& this_task() override { return *this; }
|
||||
|
||||
bool quit_action();
|
||||
|
||||
bool buy_water();
|
||||
bool communicate_with(const std::string& npcName);
|
||||
bool communicate_with_aux(const std::string& npcName,
|
||||
std::function<bool(const MatchRect&, const MatchRect&)> orderComp);
|
||||
bool do_dialog_procedure(const std::vector<std::string>& procedure);
|
||||
|
||||
ReclamationBattleMode m_battle_mode = ReclamationBattleMode::Giveup;
|
||||
};
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
#include "ReclamationConclusionReportPlugin.h"
|
||||
|
||||
#include <regex>
|
||||
|
||||
#include "Config/TaskData.h"
|
||||
#include "Controller/Controller.h"
|
||||
#include "Status.h"
|
||||
#include "Task/ProcessTask.h"
|
||||
#include "Utils/Logger.hpp"
|
||||
#include "Vision/Matcher.h"
|
||||
#include "Vision/OCRer.h"
|
||||
|
||||
bool asst::ReclamationConclusionReportPlugin::verify(AsstMsg msg, const json::value& details) const
|
||||
{
|
||||
if (msg != AsstMsg::SubTaskStart || details.get("subtask", std::string()) != "ProcessTask") {
|
||||
return false;
|
||||
}
|
||||
const std::string task = details.at("details").at("task").as_string();
|
||||
if (task.ends_with("Reclamation@GiveupSkipConfirm")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool asst::ReclamationConclusionReportPlugin::_run()
|
||||
{
|
||||
const auto img = ctrler()->get_image();
|
||||
if (!check_page_valid(img)) {
|
||||
return false;
|
||||
}
|
||||
analyze(img);
|
||||
info_callback();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool asst::ReclamationConclusionReportPlugin::check_page_valid(const cv::Mat& image)
|
||||
{
|
||||
Matcher pageAnalyzer(image);
|
||||
pageAnalyzer.set_task_info("Reclamation@GiveupSkipConfirm");
|
||||
return pageAnalyzer.analyze().has_value();
|
||||
}
|
||||
|
||||
void asst::ReclamationConclusionReportPlugin::analyze(const cv::Mat& image)
|
||||
{
|
||||
m_badges = analyze_badges(image);
|
||||
m_construction_points = analyze_construction_points(image);
|
||||
|
||||
m_total_badges += (m_badges == -1 ? 0 : m_badges);
|
||||
m_total_cons_points += (m_construction_points == -1 ? 0 : m_construction_points);
|
||||
}
|
||||
|
||||
int asst::ReclamationConclusionReportPlugin::analyze_badges(const cv::Mat& image)
|
||||
{
|
||||
Matcher badgeIconAnalyzer(image);
|
||||
badgeIconAnalyzer.set_task_info("Reclamation@ConclusionReportBadgeIcon");
|
||||
if (!badgeIconAnalyzer.analyze()) return -1;
|
||||
const auto& iconRect = badgeIconAnalyzer.get_result();
|
||||
|
||||
OCRer badgeCntAnalyzer(image);
|
||||
badgeCntAnalyzer.set_task_info("NumberOcrReplace");
|
||||
Rect roi = Task.get("Reclamation@ReportBadgesOcr")->roi;
|
||||
int newX = iconRect.rect.x + iconRect.rect.width;
|
||||
roi.width -= (newX - roi.x);
|
||||
roi.x = newX;
|
||||
badgeCntAnalyzer.set_roi(roi);
|
||||
if (!badgeCntAnalyzer.analyze()) return -1;
|
||||
std::string result = badgeCntAnalyzer.get_result().front().text;
|
||||
try {
|
||||
return std::stoi(result);
|
||||
}
|
||||
catch (const std::invalid_argument&) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int asst::ReclamationConclusionReportPlugin::analyze_construction_points(const cv::Mat& image)
|
||||
{
|
||||
OCRer consAnalyzer(image);
|
||||
consAnalyzer.set_task_info("NumberOcrReplace");
|
||||
consAnalyzer.set_roi(Task.get("Reclamation@ReportConstructPointsOcr")->roi);
|
||||
if (!consAnalyzer.analyze()) return -1;
|
||||
std::string result = consAnalyzer.get_result().front().text;
|
||||
try {
|
||||
return std::stoi(result);
|
||||
}
|
||||
catch (const std::invalid_argument&) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void asst::ReclamationConclusionReportPlugin::info_callback()
|
||||
{
|
||||
json::value info = basic_info_with_what("ReclamationReport");
|
||||
json::value& details = info["details"];
|
||||
details["badges"] = m_badges;
|
||||
details["construction_points"] = m_construction_points;
|
||||
details["total_badges"] = m_total_badges;
|
||||
details["total_construction_points"] = m_total_cons_points;
|
||||
callback(AsstMsg::SubTaskExtraInfo, info);
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
#pragma once
|
||||
#include "Task/AbstractTaskPlugin.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <meojson/json.hpp>
|
||||
|
||||
#include "Config/Miscellaneous/StageDropsConfig.h"
|
||||
#include "Status.h"
|
||||
#include "Utils/NoWarningCVMat.h"
|
||||
|
||||
namespace asst
|
||||
{
|
||||
class ProcessTask;
|
||||
|
||||
class ReclamationConclusionReportPlugin final : public AbstractTaskPlugin
|
||||
{
|
||||
public:
|
||||
using AbstractTaskPlugin::AbstractTaskPlugin;
|
||||
virtual ~ReclamationConclusionReportPlugin() override = default;
|
||||
|
||||
virtual bool verify(AsstMsg msg, const json::value& details) const override;
|
||||
|
||||
private:
|
||||
virtual bool _run() override;
|
||||
|
||||
bool check_page_valid(const cv::Mat& image);
|
||||
|
||||
void analyze(const cv::Mat& image);
|
||||
int analyze_badges(const cv::Mat& image);
|
||||
int analyze_construction_points(const cv::Mat& image);
|
||||
|
||||
void info_callback();
|
||||
|
||||
int m_badges = 0;
|
||||
int m_construction_points = 0;
|
||||
int m_total_badges = 0;
|
||||
int m_total_cons_points = 0;
|
||||
};
|
||||
}
|
||||
@@ -1,244 +0,0 @@
|
||||
#include "ReclamationControlTask.h"
|
||||
|
||||
#include "Config/Miscellaneous/BattleDataConfig.h"
|
||||
#include "Controller/Controller.h"
|
||||
#include "Task/ProcessTask.h"
|
||||
#include "Utils/Logger.hpp"
|
||||
#include "Vision/OCRer.h"
|
||||
#include "Vision/RegionOCRer.h"
|
||||
|
||||
#include "ReclamationBattlePlugin.h"
|
||||
|
||||
#define RunCheckSuccess(func, ...) \
|
||||
do { \
|
||||
if (!func(__VA_ARGS__)) return false; \
|
||||
} while (false);
|
||||
|
||||
bool asst::ReclamationControlTask::_run()
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
if (m_task_mode == ReclamationTaskMode::GiveupUponFight) {
|
||||
int times = 0;
|
||||
while (!need_exit()) {
|
||||
procedure_start_callback(++times);
|
||||
run_giveup_upon_fight_procedure();
|
||||
}
|
||||
}
|
||||
else if (m_task_mode == ReclamationTaskMode::SmeltGold) {
|
||||
m_total_gold = 0;
|
||||
int times = 0;
|
||||
while (!need_exit()) {
|
||||
procedure_start_callback(++times);
|
||||
run_smelt_gold_procedure();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::run_giveup_upon_fight_procedure()
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
RunCheckSuccess(navigate_to_reclamation_home);
|
||||
give_up_last_algorithm_if();
|
||||
RunCheckSuccess(start_with_default_formation);
|
||||
|
||||
RunCheckSuccess(wait_between_day);
|
||||
skip_announce_report();
|
||||
while (!need_exit() && !check_emergency()) {
|
||||
RunCheckSuccess(reset_scope);
|
||||
RunCheckSuccess(click_center_base);
|
||||
RunCheckSuccess(click_any_zone);
|
||||
RunCheckSuccess(start_action_enter);
|
||||
RunCheckSuccess(battle_default_formation_start);
|
||||
RunCheckSuccess(ReclamationBattlePlugin(m_callback, m_inst, m_task_chain)
|
||||
.set_battle_mode(ReclamationBattleMode::Giveup)
|
||||
.run);
|
||||
RunCheckSuccess(level_complete_confirm);
|
||||
|
||||
if (enter_next_day_if_useup()) {
|
||||
RunCheckSuccess(wait_between_day);
|
||||
skip_announce_report();
|
||||
}
|
||||
}
|
||||
return navigate_to_reclamation_home();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::run_smelt_gold_procedure()
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
RunCheckSuccess(navigate_to_reclamation_home);
|
||||
give_up_last_algorithm_if();
|
||||
RunCheckSuccess(start_with_default_formation);
|
||||
|
||||
RunCheckSuccess(wait_between_day);
|
||||
skip_announce_report();
|
||||
|
||||
bool buy_result = false;
|
||||
while (!need_exit() && !buy_result) {
|
||||
RunCheckSuccess(reset_scope);
|
||||
RunCheckSuccess(click_corner_black_market);
|
||||
RunCheckSuccess(click_black_market);
|
||||
RunCheckSuccess(start_action_enter);
|
||||
buy_result = ReclamationBattlePlugin(m_callback, m_inst, m_task_chain)
|
||||
.set_battle_mode(ReclamationBattleMode::BuyWater)
|
||||
.set_retry_times(0)
|
||||
.run();
|
||||
RunCheckSuccess(level_complete_confirm);
|
||||
}
|
||||
|
||||
RunCheckSuccess(enter_command_center);
|
||||
for (int i = 0; i < 2; ++i)
|
||||
swipe_right();
|
||||
RunCheckSuccess(ProcessTask(*this, { "Reclamation@EnterSmeltGoldPage" }).run);
|
||||
|
||||
if (check_manufacture_status() != 1) return false;
|
||||
while (!need_exit() && check_manufacture_status() == 1) {
|
||||
smelt_gold_callback(++m_total_gold);
|
||||
do_manufacture();
|
||||
}
|
||||
|
||||
return navigate_to_reclamation_home();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::navigate_to_reclamation_home()
|
||||
{
|
||||
return ProcessTask(*this, { "NavigateHome@Reclamation@Begin" }).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::give_up_last_algorithm_if()
|
||||
{
|
||||
return ProcessTask(*this, { "GiveupAlgorithm@Reclamation@Begin" }).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::start_with_default_formation()
|
||||
{
|
||||
return ProcessTask(*this, { "StartWithDefaultFormation@Reclamation@StartAlgorithm" }).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::skip_announce_report()
|
||||
{
|
||||
return ProcessTask(*this, { "SkipAnnounceReport@Reclamation@Begin" }).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::start_action_enter()
|
||||
{
|
||||
return ProcessTask(*this, { "StartActionEnter@Reclamation@StartActionEnter" }).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::battle_default_formation_start()
|
||||
{
|
||||
return ProcessTask(*this, { "BattleDefaultFormationStart@Reclamation@Begin" }).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::level_complete_confirm()
|
||||
{
|
||||
return ProcessTask(*this, { "LevelCompleteConfirm@Reclamation@LevelComplete" }).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::enter_next_day_if_useup()
|
||||
{
|
||||
return ProcessTask(*this, { "EnterNextDay@Reclamation@Begin" }).set_retry_times(0).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::wait_between_day()
|
||||
{
|
||||
bool flag = false;
|
||||
while (!need_exit()) {
|
||||
if (ProcessTask(*this, { "WaitNextDayFlag@Reclamation@BetweenDayFlag" }).set_retry_times(0).run()) {
|
||||
flag = true;
|
||||
}
|
||||
else if (ProcessTask(*this, { "SkipAnnounceReport@Reclamation@Begin" }).set_retry_times(0).run()) {
|
||||
Log.info(__FUNCTION__, " | ", "arrive next day without detect BetweenDayFlag");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (flag) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::reset_scope()
|
||||
{
|
||||
return ProcessTask(*this, { "ResetScope@Reclamation@Begin" }).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::enter_command_center()
|
||||
{
|
||||
return ProcessTask(*this, { "Reclamation@ClickCmdCenter" }).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::do_manufacture()
|
||||
{
|
||||
return ProcessTask(*this, { "Reclamation@DoManufacture" }).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::check_next_day()
|
||||
{
|
||||
return ProcessTask(*this, { "CheckNextDay@Reclamation@NextDay" }).set_retry_times(0).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::check_emergency()
|
||||
{
|
||||
return ProcessTask(*this, { "CheckEmergency@Reclamation@Emergency" }).set_retry_times(0).run();
|
||||
}
|
||||
|
||||
int asst::ReclamationControlTask::check_manufacture_status()
|
||||
{
|
||||
if (ProcessTask(*this, { "Reclamation@ManufactureInsufficientMaterial" }).set_retry_times(0).run())
|
||||
return 0;
|
||||
else if (ProcessTask(*this, { "Reclamation@ManufactureSufficientMaterial" }).set_retry_times(0).run())
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::click_center_base()
|
||||
{
|
||||
return ProcessTask(*this, { "ClickCenterBase@Reclamation@Begin" }).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::click_corner_black_market()
|
||||
{
|
||||
return ProcessTask(*this, { "Reclamation@ClickBlackMarketCorner" }).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::click_any_zone()
|
||||
{
|
||||
return ProcessTask(*this, { "ClickAnyZone@Reclamation@Begin" }).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::click_black_market()
|
||||
{
|
||||
return ProcessTask(*this, { "Reclamation@ClickBlackMarket" }).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::swipe_right()
|
||||
{
|
||||
return ProcessTask(*this, { "Reclamation@CmdCenterSwipeRight" }).run();
|
||||
}
|
||||
|
||||
bool asst::ReclamationControlTask::swipe_left()
|
||||
{
|
||||
return ProcessTask(*this, { "Reclamation@CmdCenterSwipeLeft" }).run();
|
||||
}
|
||||
|
||||
void asst::ReclamationControlTask::procedure_start_callback(int times)
|
||||
{
|
||||
json::value info = basic_info_with_what("ReclamationProcedureStart");
|
||||
json::value& details = info["details"];
|
||||
details["times"] = times;
|
||||
callback(AsstMsg::SubTaskExtraInfo, info);
|
||||
}
|
||||
|
||||
void asst::ReclamationControlTask::smelt_gold_callback(int times)
|
||||
{
|
||||
json::value info = basic_info_with_what("ReclamationSmeltGold");
|
||||
json::value& details = info["details"];
|
||||
details["times"] = times;
|
||||
callback(AsstMsg::SubTaskExtraInfo, info);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
#pragma once
|
||||
#include "Task/AbstractTask.h"
|
||||
|
||||
namespace asst
|
||||
{
|
||||
enum class ReclamationTaskMode
|
||||
{
|
||||
GiveupUponFight,
|
||||
SmeltGold
|
||||
};
|
||||
|
||||
class ReclamationControlTask : public AbstractTask
|
||||
{
|
||||
public:
|
||||
using AbstractTask::AbstractTask;
|
||||
virtual ~ReclamationControlTask() override = default;
|
||||
|
||||
void set_task_mode(const ReclamationTaskMode& mode) { m_task_mode = mode; }
|
||||
|
||||
private:
|
||||
virtual bool _run() override;
|
||||
bool run_giveup_upon_fight_procedure();
|
||||
bool run_smelt_gold_procedure();
|
||||
|
||||
bool navigate_to_reclamation_home(); // 导航至生息演算主界面
|
||||
bool give_up_last_algorithm_if(); // 如果有,放弃上次演算
|
||||
bool start_with_default_formation(); // 开始演算,至第一天
|
||||
bool skip_announce_report(); // 跳过每日公告
|
||||
bool start_action_enter(); // 区域交互确认
|
||||
bool battle_default_formation_start(); // 默认战斗编队并开始战斗
|
||||
bool level_complete_confirm(); // 场景退出结算,至地图界面
|
||||
bool enter_next_day_if_useup(); // 如果决断点耗尽,进入下一天
|
||||
bool wait_between_day(); // 等待日期转换动画结束
|
||||
bool reset_scope(); // 重置地图大小
|
||||
bool enter_command_center(); // 进入侧边栏的命令中心
|
||||
bool do_manufacture(); // 点击制作按钮
|
||||
|
||||
bool check_next_day(); // 决断点消耗完进入下一天的标志
|
||||
bool check_emergency(); // 敌袭到达
|
||||
int check_manufacture_status(); // 制造界面是否材料充足,0不足,1充足,-1非建造页面
|
||||
|
||||
bool click_center_base(); // 点击中心基地图标
|
||||
bool click_corner_black_market(); // 点击左上角黑市图标
|
||||
bool click_any_zone(); // 点击奇遇外任意区
|
||||
bool click_black_market(); // 点击黑市
|
||||
|
||||
bool swipe_right();
|
||||
bool swipe_left();
|
||||
|
||||
void procedure_start_callback(int times);
|
||||
void smelt_gold_callback(int times);
|
||||
|
||||
ReclamationTaskMode m_task_mode = ReclamationTaskMode::GiveupUponFight;
|
||||
int m_total_gold = 0; // 制作赤金的次数
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user