feat: 新增自动编队时,自动补充低信赖干员选项

This commit is contained in:
status102
2023-09-09 14:01:56 +08:00
parent 6a9bbc90ca
commit 9ac8c487d4
15 changed files with 142 additions and 18 deletions

View File

@@ -6800,6 +6800,29 @@
],
"postDelay": 500
},
"BattleQuickFormationFilter-Trust": {
"action": "ClickSelf",
"roi": [
1010,
70,
35,
580
],
"postDelay": 500,
"next": [
"BattleQuickFormationFilter-Click2"
]
},
"BattleQuickFormationFilter-Click2": {
"action": "ClickSelf",
"roi": [
1125,
60,
150,
600
],
"postDelay": 500
},
"BattleQuickFormationFilterClose": {
"algorithm": "JustReturn",
"action": "ClickRect",
@@ -6811,6 +6834,15 @@
],
"postDelay": 500
},
"BattleQuickFormationTrustIcon": {
"templThreshold": 0.9,
"roi": [
360,
280,
735,
360
]
},
"BattleQuickFormationRole-All": {
"baseTask": "BattleQuickFormationRole",
"roi": [

Binary file not shown.

After

Width:  |  Height:  |  Size: 973 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 797 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -70,6 +70,7 @@ bool asst::CopilotTask::set_params(const json::value& params)
bool with_formation = params.get("formation", false);
m_formation_task_ptr->set_enable(with_formation);
m_formation_task_ptr->set_add_trust(params.get("add_trust", false));
std::string support_unit_name = params.get("support_unit_name", std::string());
m_formation_task_ptr->set_support_unit_name(std::move(support_unit_name));

View File

@@ -10,6 +10,7 @@
#include "Task/ProcessTask.h"
#include "Utils/ImageIo.hpp"
#include "Utils/Logger.hpp"
#include "Vision/MultiMatcher.h"
#include "Vision/TemplDetOCRer.h"
void asst::BattleFormationTask::append_additional_formation(AdditionalFormation formation)
@@ -22,6 +23,11 @@ void asst::BattleFormationTask::set_support_unit_name(std::string name)
m_support_unit_name = std::move(name);
}
void asst::BattleFormationTask::set_add_trust(bool add_trust)
{
m_add_trust = add_trust;
}
void asst::BattleFormationTask::set_data_resource(DataResource resource)
{
m_data_resource = resource;
@@ -70,7 +76,9 @@ bool asst::BattleFormationTask::_run()
}
add_additional();
if (m_add_trust) {
add_trust_operators();
}
confirm_selection();
// 借一个随机助战
@@ -85,6 +93,7 @@ bool asst::BattleFormationTask::_run()
bool asst::BattleFormationTask::add_additional()
{
// 但是干员名在除开获取时间的情况下都会被遮挡so ?
LogTraceFunction;
if (m_additional.empty()) {
@@ -128,6 +137,46 @@ bool asst::BattleFormationTask::add_additional()
return true;
}
bool asst::BattleFormationTask::add_trust_operators()
{
LogTraceFunction;
if (need_exit()) {
return false;
}
ProcessTask(*this, { "BattleQuickFormationFilter" }).run();
// 双击信赖
ProcessTask(*this, { "BattleQuickFormationFilter-Trust" }).run();
ProcessTask(*this, { "BattleQuickFormationFilterClose" }).run();
// 重置职能,保证处于最左
click_role_table(battle::Role::Caster);
click_role_table(battle::Role::Unknown);
int append_count = 12 - m_operators_in_formation;
int failed_count = 0;
while (!need_exit() && append_count > 0 && failed_count < 3) {
MultiMatcher matcher(ctrler()->get_image());
matcher.set_task_info("BattleQuickFormationTrustIcon");
if (!matcher.analyze() || matcher.get_result().size() == 0) {
failed_count++;
}
else {
failed_count = 0;
for (const auto& trust_icon : matcher.get_result()) {
// 匹配完干员左下角信赖表将roi偏移到整个干员标
ctrler()->click(trust_icon.rect.move({ 20, -225, 110, 250 }));
if (--append_count <= 0 || need_exit()) {
break;
}
}
}
swipe_page();
}
return append_count == 0;
}
bool asst::BattleFormationTask::select_random_support_unit()
{
return ProcessTask(*this, { "BattleSupportUnitFormation" }).run();
@@ -289,6 +338,7 @@ bool asst::BattleFormationTask::parse_formation()
groups = &SSSCopilot.get_data().groups;
}
m_operators_in_formation = 0;
for (const auto& [name, opers_vec] : *groups) {
if (opers_vec.empty()) {
continue;
@@ -303,6 +353,7 @@ bool asst::BattleFormationTask::parse_formation()
// for unknown, will use { "BattleQuickFormationRole-All", "BattleQuickFormationRole-All-OCR" }
m_formation[same_role ? role : battle::Role::Unknown].emplace_back(opers_vec);
m_operators_in_formation++;
}
callback(AsstMsg::SubTaskExtraInfo, info);

View File

@@ -25,6 +25,7 @@ namespace asst
void append_additional_formation(AdditionalFormation formation);
void set_support_unit_name(std::string name);
void set_add_trust(bool add_trust);
enum class DataResource
{
@@ -37,8 +38,10 @@ namespace asst
using OperGroup = std::vector<battle::OperUsage>;
virtual bool _run() override;
// 追加附加干员(按部署费用等小分类)
bool add_additional();
// 补充刷信赖的干员,从最小的开始
bool add_trust_operators();
bool enter_selection_page();
bool select_opers_in_cur_page(std::vector<OperGroup>& groups);
@@ -53,6 +56,10 @@ namespace asst
std::string m_stage_name;
std::unordered_map<battle::Role, std::vector<OperGroup>> m_formation;
// 编队中干员个数
int m_operators_in_formation = 0;
// 是否需要追加信赖干员
bool m_add_trust = false;
std::string m_support_unit_name;
DataResource m_data_resource = DataResource::Copilot;
std::vector<AdditionalFormation> m_additional;

View File

@@ -1792,15 +1792,17 @@ namespace MaaWpfGui.Main
/// </summary>
/// <param name="filename">作业 JSON 的文件路径,绝对、相对路径均可。</param>
/// <param name="formation">是否进行 “快捷编队”。</param>
/// <param name="add_trust">是否追加信赖干员</param>
/// <param name="type">任务类型</param>
/// <param name="loop_times">任务重复执行次数</param>
/// <returns>是否成功。</returns>
public bool AsstStartCopilot(string filename, bool formation, string type, int loop_times)
public bool AsstStartCopilot(string filename, bool formation, bool add_trust, string type, int loop_times)
{
var task_params = new JObject
{
["filename"] = filename,
["formation"] = formation,
["add_trust"] = add_trust,
["loop_times"] = loop_times,
};
AsstTaskId id = AsstAppendTaskWithEncoding(type, task_params);

View File

@@ -438,8 +438,9 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla
<system:String x:Key="FailedToLikeWebJson">An error occurred, the like failed. : &lt;</system:String>
<system:String x:Key="ThanksForLikeWebJson">Thanks for the likes!\nThe comment section is already open on the web page, please feel free to leave your comment!</system:String>
<system:String x:Key="AutoSquad">Auto Squad</system:String>
<system:String x:Key="LoopTimes">Loop Times</system:String>
<system:String x:Key="AutoSquadTip">「Favourite」 marked operators cannot be recognized at this time</system:String>
<system:String x:Key="AddTrust">Add low-trust operators</system:String>
<system:String x:Key="LoopTimes">Loop Times</system:String>
<system:String x:Key="Start">Start</system:String>
<system:String x:Key="VideoLink">Video Link</system:String>
<!-- Logs -->

View File

@@ -429,8 +429,9 @@
<system:String x:Key="FailedToLikeWebJson">エラーが発生しました、いいねに失敗しました。 : &lt;</system:String>
<system:String x:Key="ThanksForLikeWebJson">感謝と評価!\nウェブページには既にコメント欄が開放されており、あなたのコメントを心待ちにしています</system:String>
<system:String x:Key="AutoSquad">自動編成</system:String>
<system:String x:Key="LoopTimes">ループ回数</system:String>
<system:String x:Key="AutoSquadTip">自動編成では、一時的に「戦術要員」オペレーターを認識できません</system:String>
<system:String x:Key="AddTrust">信頼性の低いオペレーターを追加する</system:String>
<system:String x:Key="LoopTimes">ループ回数</system:String>
<system:String x:Key="Start">開始</system:String>
<system:String x:Key="VideoLink">映像へのハイパーリンク</system:String>
<!-- Export to Lolicon -->

View File

@@ -441,8 +441,9 @@ OF-1을 해금하지 않았다면 선택하지 말아 주세요.</system:String>
<system:String x:Key="FailedToLikeWebJson">오류로 인해 평가에 실패했습니다 : &lt;</system:String>
<system:String x:Key="ThanksForLikeWebJson">감사합니다!\n웹사이트에 댓글을 남길 수도 있으니 의견을 남겨 주세요!</system:String>
<system:String x:Key="AutoSquad">자동 편성</system:String>
<system:String x:Key="LoopTimes">반복 횟수</system:String>
<system:String x:Key="AutoSquadTip">자동 편성은 '선호' 오퍼레이터를 인식할 수 없습니다</system:String>
<system:String x:Key="AddTrust">신뢰도가 낮은 운영자 추가</system:String>
<system:String x:Key="LoopTimes">반복 횟수</system:String>
<system:String x:Key="Start">시작</system:String>
<system:String x:Key="VideoLink">영상 링크</system:String>
<!-- Start -->

View File

@@ -442,8 +442,9 @@
<system:String x:Key="FailedToLikeWebJson">出现错误,评价失败 : &lt;</system:String>
<system:String x:Key="ThanksForLikeWebJson">感谢评价!\n网页已经开放评论区欢迎前往留下你的评论</system:String>
<system:String x:Key="AutoSquad">自动编队</system:String>
<system:String x:Key="LoopTimes">循环次数</system:String>
<system:String x:Key="AutoSquadTip">自动编队暂时无法识别「特别关注」的干员</system:String>
<system:String x:Key="AddTrust">补充低信赖干员</system:String>
<system:String x:Key="LoopTimes">循环次数</system:String>
<system:String x:Key="Start">开始</system:String>
<system:String x:Key="VideoLink">视频链接</system:String>
<!-- 日志 -->

View File

@@ -441,8 +441,9 @@
<system:String x:Key="FailedToLikeWebJson">出現錯誤,評價失敗 : &lt;</system:String>
<system:String x:Key="ThanksForLikeWebJson">感謝評價!\n網頁已經開放評論區歡迎前往留下你的評論</system:String>
<system:String x:Key="AutoSquad">自動編隊</system:String>
<system:String x:Key="LoopTimes">循環次數</system:String>
<system:String x:Key="AutoSquadTip">自動編隊暫時無法辨識「特別關注」的幹員</system:String>
<system:String x:Key="AddTrust">補充低信賴幹員</system:String>
<system:String x:Key="LoopTimes">循環次數</system:String>
<system:String x:Key="Start">開始</system:String>
<system:String x:Key="VideoLink">影片連結</system:String>
<!-- 影片連結 -->

View File

@@ -462,6 +462,17 @@ namespace MaaWpfGui.ViewModels.UI
set => SetAndNotify(ref _form, value);
}
private bool _addTrust;
/// <summary>
/// Gets or sets a value indicating whether to use auto-formation.
/// </summary>
public bool AddTrust
{
get => _addTrust;
set => SetAndNotify(ref _addTrust, value);
}
public bool Loop { get; set; }
private int _loopTimes = int.Parse(ConfigurationHelper.GetValue(ConfigurationKeys.CopilotLoopTimes, "1"));
@@ -517,7 +528,7 @@ namespace MaaWpfGui.ViewModels.UI
AddLog(errMsg, UiLogColor.Error);
}
bool ret = Instances.AsstProxy.AsstStartCopilot(IsDataFromWeb ? TempCopilotFile : Filename, Form, _taskType,
bool ret = Instances.AsstProxy.AsstStartCopilot(IsDataFromWeb ? TempCopilotFile : Filename, Form, AddTrust, _taskType,
Loop ? LoopTimes : 1);
if (ret)
{

View File

@@ -70,15 +70,30 @@
Content="{DynamicResource SelectTheFile}"
IsEnabled="{Binding Idle}"
ToolTip="{DynamicResource SelectTheFileTip}" />
<CheckBox
Height="50"
Margin="0,0,0,30"
HorizontalAlignment="Center"
Content="{DynamicResource AutoSquad}"
IsChecked="{Binding Form}"
IsEnabled="{Binding Idle}"
IsHitTestVisible="{Binding Idle}"
ToolTip="{DynamicResource AutoSquadTip}" />
<Grid
Margin="0,15,00,40"
HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="100" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<CheckBox
HorizontalAlignment="Center"
Content="{DynamicResource AutoSquad}"
IsChecked="{Binding Form}"
IsEnabled="{Binding Idle}"
IsHitTestVisible="{Binding Idle}"
ToolTip="{DynamicResource AutoSquadTip}" Padding="4,-1,10,0" />
<CheckBox
Grid.Column="1"
HorizontalAlignment="Center"
Content="{DynamicResource AddTrust}"
IsChecked="{Binding AddTrust}"
IsEnabled="{c:Binding '(Form) and (Idle)'}"
IsHitTestVisible="{Binding Idle}"/>
</Grid>
<StackPanel
Margin="10"
HorizontalAlignment="Center"