mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 18:20:39 +08:00
feat.完成肉鸽干员选择(技能选择还没做)
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define AsstParamIdPenguinId "penguin_id"
|
||||
#define AsstParamIdOcrText "ocr_text"
|
||||
@@ -519,6 +519,7 @@
|
||||
]
|
||||
},
|
||||
"EndOfAction": {
|
||||
"Doc": "本任务注册了插件 StageDropsTaskPlugin",
|
||||
"algorithm": "OcrDetect",
|
||||
"text": [
|
||||
"行动结束"
|
||||
@@ -3898,69 +3899,16 @@
|
||||
"rearDelay": 1000
|
||||
},
|
||||
"Roguelike1ChooseOper": {
|
||||
"Doc": "本任务注册了插件 RoguelikeRecruitTaskPlugin",
|
||||
"algorithm": "JustReturn",
|
||||
"action": "DoNothing",
|
||||
"next": [
|
||||
"Roguelike1ChooseOperConfirm"
|
||||
]
|
||||
},
|
||||
"Roguelike1RecruitData": {
|
||||
"algorithm": "OcrDetect",
|
||||
"action": "ClickSelf",
|
||||
"cache": false,
|
||||
"Doc": "所有肉鸽可能招募的干员,不在列表里的不会则被招募,可以手动修改,在前面的会优先招募",
|
||||
"Doc2": "画面中如果既有低星又有高星,说明希望不够(高星是灰的不让选,但也被识别到了),所以尽量把低星的放前面,优先招募",
|
||||
"text": [
|
||||
"---三星备选干员---",
|
||||
"芬",
|
||||
"玫兰莎",
|
||||
"香草",
|
||||
"梓兰",
|
||||
"芙蓉",
|
||||
"安赛尔",
|
||||
"预备干员",
|
||||
"---近卫---",
|
||||
"幽灵鲨",
|
||||
"煌",
|
||||
"帕拉斯",
|
||||
"银灰",
|
||||
"陈",
|
||||
"棘刺",
|
||||
"---先锋---",
|
||||
"凛冬",
|
||||
"德克萨斯",
|
||||
"风笛",
|
||||
"嵯峨",
|
||||
"推进之王",
|
||||
"---重装---",
|
||||
"古米",
|
||||
"蛇屠箱",
|
||||
"临光",
|
||||
"泥岩",
|
||||
"塞雷娅",
|
||||
"星熊",
|
||||
"---狙击---",
|
||||
"白金",
|
||||
"能天使",
|
||||
"假日威龙陈",
|
||||
"黑",
|
||||
"---术士---",
|
||||
"阿米娅",
|
||||
"天火",
|
||||
"艾雅法拉",
|
||||
"异客",
|
||||
"---治疗---",
|
||||
"白面鸮",
|
||||
"赫默",
|
||||
"凯尔希",
|
||||
"闪灵",
|
||||
"夜莺",
|
||||
"---辅助---",
|
||||
"梅尔",
|
||||
"巫恋",
|
||||
"初雪",
|
||||
"真理",
|
||||
"安洁莉娜",
|
||||
"铃兰",
|
||||
"麦哲伦",
|
||||
"令",
|
||||
"---特种---",
|
||||
"水月",
|
||||
"狮蝎"
|
||||
],
|
||||
"text": [],
|
||||
"ocrReplace": [
|
||||
[
|
||||
"白面.+",
|
||||
@@ -3976,9 +3924,6 @@
|
||||
69,
|
||||
666,
|
||||
614
|
||||
],
|
||||
"next": [
|
||||
"Roguelike1ChooseOperConfirm"
|
||||
]
|
||||
},
|
||||
"Roguelike1ChooseOperConfirm": {
|
||||
@@ -4196,6 +4141,9 @@
|
||||
298,
|
||||
289
|
||||
],
|
||||
"reduceOtherTimes": [
|
||||
"Roguelike1StageTraderInvestConfirm"
|
||||
],
|
||||
"next": [
|
||||
"Roguelike1StageTraderInvestCancel"
|
||||
]
|
||||
@@ -4593,6 +4541,7 @@
|
||||
]
|
||||
},
|
||||
"Roguelike1QuickFormation": {
|
||||
"Doc": "本任务注册了插件 RoguelikeFormationTaskPlugin",
|
||||
"action": "ClickSelf",
|
||||
"roi": [
|
||||
817,
|
||||
@@ -4640,6 +4589,7 @@
|
||||
]
|
||||
},
|
||||
"Roguelike1StartAction": {
|
||||
"Doc": "本任务注册了插件 RoguelikeBattleTaskPlugin",
|
||||
"action": "ClickSelf",
|
||||
"roi": [
|
||||
905,
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace asst
|
||||
|
||||
virtual void set_image(const cv::Mat image, const Rect& roi = Rect());
|
||||
virtual void set_roi(const Rect& roi) noexcept;
|
||||
void set_task_data(std::shared_ptr<TaskData> task_data);
|
||||
|
||||
virtual bool analyze() = 0;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ void asst::InfrastProductionTask::set_product(std::string product_name) noexcept
|
||||
|
||||
json::value callback_info = basic_info_with_what("ProductOfFacility");
|
||||
callback_info["details"]["product"] = m_product;
|
||||
// 该回调注册了插件 DronesForShamareTaskPlugin
|
||||
callback(AsstMsg::SubTaskExtraInfo, callback_info);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\include\AsstCaller.h" />
|
||||
<ClInclude Include="..\..\include\AsstDef.h" />
|
||||
<ClInclude Include="..\..\include\AsstPort.h" />
|
||||
<ClInclude Include="AbstractConfiger.h" />
|
||||
<ClInclude Include="AbstractImageAnalyzer.h" />
|
||||
@@ -70,6 +69,7 @@
|
||||
<ClInclude Include="RecruitConfiger.h" />
|
||||
<ClInclude Include="RoguelikeFormationTaskPlugin.h" />
|
||||
<ClInclude Include="RoguelikeFormationImageAnalyzer.h" />
|
||||
<ClInclude Include="RoguelikeRecruitTaskPlugin.h" />
|
||||
<ClInclude Include="RoguelikeTask.h" />
|
||||
<ClInclude Include="RuntimeStatus.h" />
|
||||
<ClInclude Include="StageDropsTaskPlugin.h" />
|
||||
@@ -135,6 +135,7 @@
|
||||
<ClCompile Include="RecruitConfiger.cpp" />
|
||||
<ClCompile Include="RoguelikeFormationTaskPlugin.cpp" />
|
||||
<ClCompile Include="RoguelikeFormationImageAnalyzer.cpp" />
|
||||
<ClCompile Include="RoguelikeRecruitTaskPlugin.cpp" />
|
||||
<ClCompile Include="RoguelikeTask.cpp" />
|
||||
<ClCompile Include="RuntimeStatus.cpp" />
|
||||
<ClCompile Include="StageDropsTaskPlugin.cpp" />
|
||||
|
||||
@@ -270,9 +270,6 @@
|
||||
<ClInclude Include="StartUpTask.h">
|
||||
<Filter>头文件\Task</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\AsstDef.h">
|
||||
<Filter>头文件\Caller</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\AsstPort.h">
|
||||
<Filter>头文件\Caller</Filter>
|
||||
</ClInclude>
|
||||
@@ -294,6 +291,9 @@
|
||||
<ClInclude Include="RoguelikeTask.h">
|
||||
<Filter>头文件\Task</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RoguelikeRecruitTaskPlugin.h">
|
||||
<Filter>头文件\Task\Plugin</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Controller.cpp">
|
||||
@@ -482,6 +482,9 @@
|
||||
<ClCompile Include="RoguelikeTask.cpp">
|
||||
<Filter>源文件\Task</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RoguelikeRecruitTaskPlugin.cpp">
|
||||
<Filter>源文件\Task\Plugin</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\resource\config.json">
|
||||
|
||||
41
src/MeoAssistant/RoguelikeRecruitTaskPlugin.cpp
Normal file
41
src/MeoAssistant/RoguelikeRecruitTaskPlugin.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "RoguelikeRecruitTaskPlugin.h"
|
||||
|
||||
#include "OcrImageAnalyzer.h"
|
||||
#include "Controller.h"
|
||||
#include "TaskData.h"
|
||||
|
||||
void asst::RoguelikeRecruitTaskPlugin::set_opers(std::vector<std::string> opers)
|
||||
{
|
||||
m_opers = std::move(opers);
|
||||
}
|
||||
|
||||
bool asst::RoguelikeRecruitTaskPlugin::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() == "Roguelike1ChooseOper") {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool asst::RoguelikeRecruitTaskPlugin::_run()
|
||||
{
|
||||
OcrImageAnalyzer analyzer(m_ctrler->get_image());
|
||||
analyzer.set_task_info(Task.get("Roguelike1RecruitData"));
|
||||
analyzer.set_required(m_opers);
|
||||
|
||||
if (!analyzer.analyze()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Rect target = analyzer.get_result().front().rect;
|
||||
m_ctrler->click(target);
|
||||
|
||||
return true;
|
||||
}
|
||||
21
src/MeoAssistant/RoguelikeRecruitTaskPlugin.h
Normal file
21
src/MeoAssistant/RoguelikeRecruitTaskPlugin.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "AbstractTaskPlugin.h"
|
||||
|
||||
namespace asst
|
||||
{
|
||||
class RoguelikeRecruitTaskPlugin : public AbstractTaskPlugin
|
||||
{
|
||||
public:
|
||||
using AbstractTaskPlugin::AbstractTaskPlugin;
|
||||
virtual ~RoguelikeRecruitTaskPlugin() = default;
|
||||
|
||||
virtual bool verify(AsstMsg msg, const json::value& details) const override;
|
||||
|
||||
void set_opers(std::vector<std::string> opers);
|
||||
|
||||
protected:
|
||||
virtual bool _run() override;
|
||||
|
||||
std::vector<std::string> m_opers;
|
||||
};
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "ProcessTask.h"
|
||||
#include "RoguelikeFormationTaskPlugin.h"
|
||||
#include "RoguelikeBattleTaskPlugin.h"
|
||||
#include "RoguelikeRecruitTaskPlugin.h"
|
||||
|
||||
#include "Logger.hpp"
|
||||
|
||||
@@ -12,8 +13,11 @@ asst::RoguelikeTask::RoguelikeTask(AsstCallback callback, void* callback_arg)
|
||||
{
|
||||
m_roguelike_task_ptr->set_tasks({ "Roguelike1Begin" })
|
||||
.set_retry_times(50);
|
||||
|
||||
m_roguelike_task_ptr->regiseter_plugin<RoguelikeFormationTaskPlugin>();
|
||||
m_roguelike_task_ptr->regiseter_plugin<RoguelikeBattleTaskPlugin>();
|
||||
m_recruit_task_ptr = m_roguelike_task_ptr->regiseter_plugin<RoguelikeRecruitTaskPlugin>();
|
||||
m_recruit_task_ptr->set_retry_times(2);
|
||||
|
||||
// 这个任务如果卡住会放弃当前的肉鸽并重新开始,所以多添加一点。先这样凑合用
|
||||
for (int i = 0; i != 10000; ++i) {
|
||||
@@ -28,6 +32,21 @@ bool asst::RoguelikeTask::set_params(const json::value& params)
|
||||
// 2 - 投资过后再退出,没有投资就继续往后打
|
||||
int mode = params.get("mode", 0);
|
||||
|
||||
std::vector<std::string> opers_vec;
|
||||
if (params.contains("opers") && params.at("opers").is_array()) {
|
||||
for (auto& oper : params.at("opers").as_array()) {
|
||||
if (oper.contains("name") && oper.at("name").is_string()) {
|
||||
opers_vec.emplace_back(oper.at("name").as_string());
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
break;
|
||||
@@ -42,9 +61,7 @@ bool asst::RoguelikeTask::set_params(const json::value& params)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (params.contains("opers") && params.at("opers").is_array()) {
|
||||
// TODO
|
||||
}
|
||||
m_recruit_task_ptr->set_opers(std::move(opers_vec));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
namespace asst
|
||||
{
|
||||
class ProcessTask;
|
||||
class RoguelikeRecruitTaskPlugin;
|
||||
|
||||
class RoguelikeTask : public PackageTask
|
||||
{
|
||||
@@ -17,5 +18,6 @@ namespace asst
|
||||
|
||||
private:
|
||||
std::shared_ptr<ProcessTask> m_roguelike_task_ptr = nullptr;
|
||||
std::shared_ptr<RoguelikeRecruitTaskPlugin> m_recruit_task_ptr = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -69,6 +69,22 @@ int main(int argc, char** argv)
|
||||
)");
|
||||
AsstAppendTask(ptr, "Award", R"({})");
|
||||
|
||||
AsstAppendTask(ptr, "Roguelike", R"(
|
||||
{
|
||||
"opers": [
|
||||
{
|
||||
"name": "帕拉斯"
|
||||
},
|
||||
{
|
||||
"name": "梓兰"
|
||||
},
|
||||
{
|
||||
"name": "安赛尔"
|
||||
}
|
||||
]
|
||||
}
|
||||
)");
|
||||
|
||||
AsstStart(ptr);
|
||||
|
||||
getchar();
|
||||
|
||||
Reference in New Issue
Block a user