mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 10:10:45 +08:00
feat:宿舍中识别干员是否有异格在其他设施 (#1592)
* feat:识别信赖值 * fix:检测空信赖 * feat:识别干员是否有异格在其他设施 * fix:清理调试用代码 * fix:清理调试用代码 * feat:添加在宿舍换班前进行未进驻筛选的选项 * feat:可在gui.json中设置是否启用蹭信赖与未进驻筛选 * feat:在gui中添加复选框选项"宿舍空余位置蹭信赖"与“不将已进驻的干员放入宿舍” * fix: 移除 bool 的 move 操作,格式化代码 Co-authored-by: MistEO <mistereo@hotmail.com>
This commit is contained in:
@@ -4286,6 +4286,17 @@
|
||||
22
|
||||
]
|
||||
},
|
||||
"InfrastOperFacilityOcr": {
|
||||
"algorithm": "OcrDetect",
|
||||
"text": [],
|
||||
"rectMove_Doc": "基于笑脸的位置移动",
|
||||
"rectMove": [
|
||||
14,
|
||||
-209,
|
||||
40,
|
||||
22
|
||||
]
|
||||
},
|
||||
"InfrastOperFaceHash": {
|
||||
"algorithm": "Hash",
|
||||
"hash": [],
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace asst::infrast
|
||||
Rect rect;
|
||||
// 因为OCR识别名字比较费时间,所以仅在name_filter不为空(有识别名字需求)的时候才识别,否则仅保存图片但不识别
|
||||
cv::Mat name_img;
|
||||
cv::Mat facility_img;
|
||||
};
|
||||
|
||||
struct SkillsComb
|
||||
|
||||
@@ -7,6 +7,20 @@
|
||||
#include "OcrImageAnalyzer.h"
|
||||
#include "ProcessTask.h"
|
||||
#include "Resource.h"
|
||||
#include "OcrWithPreprocessImageAnalyzer.h"
|
||||
#include <regex>
|
||||
|
||||
asst::InfrastDormTask& asst::InfrastDormTask::set_notstationed_enabled(bool notstationed_enabled) noexcept
|
||||
{
|
||||
m_notstationed_enabled = notstationed_enabled;
|
||||
return *this;
|
||||
}
|
||||
|
||||
asst::InfrastDormTask& asst::InfrastDormTask::set_trust_enabled(bool trust_enabled) noexcept
|
||||
{
|
||||
m_trust_enabled = trust_enabled;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool asst::InfrastDormTask::_run()
|
||||
{
|
||||
@@ -22,12 +36,23 @@ bool asst::InfrastDormTask::_run()
|
||||
return false;
|
||||
}
|
||||
|
||||
Log.trace("m_notstationed_enabled:", m_notstationed_enabled);
|
||||
if (m_notstationed_enabled && !m_if_filter_notstationed_haspressed) {
|
||||
Log.trace("click_filter_menu_not_stationed_button");
|
||||
click_filter_menu_not_stationed_button();
|
||||
m_if_filter_notstationed_haspressed = true;
|
||||
}
|
||||
|
||||
click_clear_button();
|
||||
|
||||
opers_choose();
|
||||
|
||||
click_confirm_button();
|
||||
click_return_button();
|
||||
|
||||
if (m_finished_stage == 3) {//不蹭信赖或所有干员满信赖
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -35,6 +60,7 @@ bool asst::InfrastDormTask::_run()
|
||||
bool asst::InfrastDormTask::opers_choose()
|
||||
{
|
||||
size_t num_of_selected = 0;
|
||||
size_t num_of_fulltrust = 0;
|
||||
|
||||
while (num_of_selected < max_num_of_opers()) {
|
||||
if (need_exit()) {
|
||||
@@ -64,21 +90,83 @@ bool asst::InfrastDormTask::opers_choose()
|
||||
switch (oper.smiley.type) {
|
||||
case infrast::SmileyType::Rest:
|
||||
// 如果所有心情不满的干员已经放入宿舍,就把信赖不满的干员放入宿舍
|
||||
if (m_finished_stage > 0 && oper.selected == false && oper.doing != infrast::Doing::Working && oper.doing != infrast::Doing::Resting) {
|
||||
m_ctrler->click(oper.rect);
|
||||
if (++num_of_selected >= max_num_of_opers()) {
|
||||
Log.trace("num_of_selected:", num_of_selected, ", just break");
|
||||
break;
|
||||
if (m_trust_enabled && m_finished_stage > 0 && oper.selected == false && oper.doing != infrast::Doing::Working && oper.doing != infrast::Doing::Resting) {
|
||||
|
||||
//获得干员信赖值
|
||||
OcrWithPreprocessImageAnalyzer trust_analyzer(oper.name_img);
|
||||
if (!trust_analyzer.analyze()) {
|
||||
Log.trace("ERROR:!trust_analyzer.analyze():");
|
||||
//return false;
|
||||
}
|
||||
|
||||
std::string opertrust = trust_analyzer.get_result().front().text;
|
||||
std::regex rule("[^0-9]");//只保留数字
|
||||
opertrust = std::regex_replace(opertrust, rule, "");
|
||||
|
||||
Log.trace("opertrust:", opertrust);
|
||||
|
||||
bool if_opertrust_not_full = false;
|
||||
if (opertrust != "" && atoi(opertrust.c_str()) < 200) {
|
||||
if_opertrust_not_full = true;
|
||||
}
|
||||
else if (opertrust != "" && atoi(opertrust.c_str()) >= 200) {
|
||||
num_of_fulltrust++;
|
||||
}
|
||||
if (num_of_fulltrust >= 6) {//所有干员都满信赖了
|
||||
m_finished_stage = 3;
|
||||
Log.trace("num_of_fulltrust:", num_of_fulltrust, ", just return");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//获得干员所在设施
|
||||
OcrWithPreprocessImageAnalyzer facility_analyzer(oper.facility_img);
|
||||
if (!facility_analyzer.analyze()) {
|
||||
Log.trace("ERROR:!facility_analyzer.analyze():");
|
||||
//return false;
|
||||
}
|
||||
|
||||
std::string facilityname = facility_analyzer.get_result().front().text;
|
||||
std::regex rule2("[^BF0-9]");//只保留B、F和数字
|
||||
facilityname = std::regex_replace(facilityname, rule2, "");
|
||||
|
||||
Log.trace("facilityname:<" + facilityname + ">");
|
||||
bool if_oper_not_stationed = facilityname.length() < 4;//只有形如1F01或B101才是设施标签
|
||||
|
||||
//判断要不要把人放进宿舍if_opertrust_not_full && if_oper_not_stationed
|
||||
if (if_opertrust_not_full && if_oper_not_stationed) {
|
||||
Log.trace("put oper in");
|
||||
|
||||
m_ctrler->click(oper.rect);
|
||||
if (++num_of_selected >= max_num_of_opers()) {
|
||||
Log.trace("num_of_selected:", num_of_selected, ", just break");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.trace("not put oper in");
|
||||
}
|
||||
|
||||
}
|
||||
// 如果当前页面休息完成的人数超过5个,说明已经已经把所有心情不满的滑过一遍、没有更多的了
|
||||
else if (++num_of_resting > max_num_of_opers()) {
|
||||
Log.trace("num_of_resting:", num_of_resting, ", dorm finished");
|
||||
Log.trace("click_filter_menu_not_stationed_button");
|
||||
click_filter_menu_not_stationed_button();
|
||||
Log.trace("click_sort_by_trust_button");
|
||||
click_sort_by_trust_button();
|
||||
m_finished_stage = 1;// 选中未进驻标签并按信赖值排序
|
||||
if (m_trust_enabled) {
|
||||
Log.trace("m_trust_enabled:", m_trust_enabled);
|
||||
if (!m_if_filter_notstationed_haspressed) {
|
||||
Log.trace("click_filter_menu_not_stationed_button");
|
||||
click_filter_menu_not_stationed_button();
|
||||
m_if_filter_notstationed_haspressed = true;
|
||||
}
|
||||
Log.trace("click_sort_by_trust_button");
|
||||
click_sort_by_trust_button();
|
||||
m_finished_stage = 1;// 选中未进驻标签并按信赖值排序
|
||||
}
|
||||
else {
|
||||
m_finished_stage = 3;
|
||||
Log.trace("m_trust_enabled:", m_trust_enabled, ", just return");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case infrast::SmileyType::Work:
|
||||
|
||||
@@ -11,14 +11,28 @@ namespace asst
|
||||
|
||||
virtual size_t max_num_of_opers() const noexcept override { return 5ULL; }
|
||||
|
||||
InfrastDormTask& set_notstationed_enabled(bool notstationed_enabled) noexcept;
|
||||
InfrastDormTask& set_trust_enabled(bool m_trust_enabled) noexcept;
|
||||
|
||||
private:
|
||||
virtual bool _run() override;
|
||||
//virtual bool click_confirm_button() override;
|
||||
|
||||
bool opers_choose();
|
||||
|
||||
bool m_notstationed_enabled = false;//设置是否启用未进驻筛选
|
||||
bool m_trust_enabled = true;//设置是否启用蹭信赖
|
||||
|
||||
int m_cur_dorm_index = 0;
|
||||
int m_max_num_of_dorm = 4;
|
||||
/*
|
||||
* m_finished_stage
|
||||
* 0:心情恢复阶段
|
||||
* 1:心情恢复完成
|
||||
* 2:蹭信赖阶段
|
||||
* 3:全部任务完成
|
||||
*/
|
||||
int m_finished_stage = 0;
|
||||
bool m_if_filter_notstationed_haspressed = false;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -85,8 +85,9 @@ void asst::InfrastOperImageAnalyzer::oper_detect()
|
||||
|
||||
const Rect skill_rect_move = Task.get("InfrastSkills")->rect_move;
|
||||
const Rect name_rect_move = Task.get("InfrastOperNameOcr")->rect_move;
|
||||
const Rect facility_rect_move = Task.get("InfrastOperFacilityOcr")->rect_move;
|
||||
const Rect prg_rect_move = Task.get("InfrastOperMoodProgressBar")->roi;
|
||||
const std::vector<Rect> all_rect_move = { skill_rect_move, name_rect_move, prg_rect_move };
|
||||
const std::vector<Rect> all_rect_move = { skill_rect_move, name_rect_move,facility_rect_move, prg_rect_move };
|
||||
|
||||
InfrastSmileyImageAnalyzer smiley_analyzer(m_image);
|
||||
|
||||
@@ -120,6 +121,7 @@ void asst::InfrastOperImageAnalyzer::oper_detect()
|
||||
infrast::Oper oper;
|
||||
oper.smiley = smiley;
|
||||
oper.name_img = m_image(utils::make_rect<cv::Rect>(smiley_rect.move(name_rect_move)));
|
||||
oper.facility_img = m_image(utils::make_rect<cv::Rect>(smiley_rect.move(facility_rect_move)));
|
||||
m_result.emplace_back(std::move(oper));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +102,12 @@ bool asst::InfrastTask::set_params(const json::value& params)
|
||||
m_office_task_ptr->set_mood_threshold(threshold);
|
||||
m_dorm_task_ptr->set_mood_threshold(threshold);
|
||||
|
||||
bool notstationed_enabled = params.get("notstationed_enabled", false);
|
||||
m_dorm_task_ptr->set_notstationed_enabled(notstationed_enabled);
|
||||
|
||||
bool trust_enabled = params.get("trust_enabled", true);
|
||||
m_dorm_task_ptr->set_trust_enabled(trust_enabled);
|
||||
|
||||
bool replenish = params.get("replenish", false);
|
||||
m_replenish_task_ptr->set_enable(replenish);
|
||||
|
||||
|
||||
@@ -1173,8 +1173,10 @@ namespace MeoAsstGui
|
||||
/// </list>
|
||||
/// </param>
|
||||
/// <param name="dorm_threshold">宿舍进驻心情阈值。</param>
|
||||
/// <param name="dorm_filter_not_stationed_enabled">宿舍是否使用未进驻筛选标签</param>
|
||||
/// <param name="dorm_trust_enabled">宿舍是否使用蹭信赖功能</param>
|
||||
/// <returns>是否成功。</returns>
|
||||
public bool AsstAppendInfrast(string[] order, string uses_of_drones, double dorm_threshold)
|
||||
public bool AsstAppendInfrast(string[] order, string uses_of_drones, double dorm_threshold, bool dorm_filter_not_stationed_enabled, bool dorm_trust_enabled)
|
||||
{
|
||||
var task_params = new JObject();
|
||||
|
||||
@@ -1182,6 +1184,8 @@ namespace MeoAsstGui
|
||||
task_params["facility"] = new JArray(order);
|
||||
task_params["drones"] = uses_of_drones;
|
||||
task_params["threshold"] = dorm_threshold;
|
||||
task_params["notstationed_enabled"] = dorm_filter_not_stationed_enabled;
|
||||
task_params["trust_enabled"] = dorm_trust_enabled;
|
||||
task_params["replenish"] = true;
|
||||
TaskId id = AsstAppendTaskWithEncoding("Infrast", task_params);
|
||||
_latestTaskId[TaskType.Infrast] = id;
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
<system:String x:Key="PureGold">Pure Gold</system:String>
|
||||
<system:String x:Key="OriginStone">Originium Shards</system:String>
|
||||
<system:String x:Key="Chip">Chip Packs</system:String>
|
||||
<system:String x:Key="DormTrustEnabled">Trust farming in dorm</system:String>
|
||||
<system:String x:Key="DormFilterNotStationedEnabled">Do not put stationed opers in dorm</system:String>
|
||||
|
||||
<system:String x:Key="General">General Mode</system:String>
|
||||
<system:String x:Key="BlueStacks">BlueStacks</system:String>
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
<system:String x:Key="PureGold">製造所-純金</system:String>
|
||||
<system:String x:Key="OriginStone">製造所-源石の欠片</system:String>
|
||||
<system:String x:Key="Chip">製造所-中級SoC</system:String>
|
||||
<system:String x:Key="DormTrustEnabled">宿舍空余位置蹭信赖</system:String>
|
||||
<system:String x:Key="DormFilterNotStationedEnabled">不将已进驻的干员放入宿舍</system:String>
|
||||
|
||||
<system:String x:Key="General">一般モード</system:String>
|
||||
<system:String x:Key="BlueStacks">BlueStacks</system:String>
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
<system:String x:Key="PureGold">제조소-순금</system:String>
|
||||
<system:String x:Key="OriginStone">제조소-오리지늄 조각</system:String>
|
||||
<system:String x:Key="Chip">제조소-칩</system:String>
|
||||
<system:String x:Key="DormTrustEnabled">宿舍空余位置蹭信赖</system:String>
|
||||
<system:String x:Key="DormFilterNotStationedEnabled">不将已进驻的干员放入宿舍</system:String>
|
||||
|
||||
<system:String x:Key="General">일반 모드</system:String>
|
||||
<system:String x:Key="BlueStacks">블루스택</system:String>
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
<system:String x:Key="PureGold">🍸🍸🍻🍷</system:String>
|
||||
<system:String x:Key="OriginStone">🍸🍻🍻🍻🍻</system:String>
|
||||
<system:String x:Key="Chip">🍺🍻🍷🍷</system:String>
|
||||
<system:String x:Key="DormTrustEnabled">宿舍空余位置蹭信赖</system:String>
|
||||
<system:String x:Key="DormFilterNotStationedEnabled">不将已进驻的干员放入宿舍</system:String>
|
||||
|
||||
<system:String x:Key="General">🍻🍸🕺</system:String>
|
||||
<system:String x:Key="BlueStacks">🍺🕺🍻</system:String>
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
<system:String x:Key="PureGold">制造站-赤金</system:String>
|
||||
<system:String x:Key="OriginStone">制造站-源石碎片</system:String>
|
||||
<system:String x:Key="Chip">制造站-芯片组</system:String>
|
||||
<system:String x:Key="DormTrustEnabled">宿舍空余位置蹭信赖</system:String>
|
||||
<system:String x:Key="DormFilterNotStationedEnabled">不将已进驻的干员放入宿舍</system:String>
|
||||
|
||||
<system:String x:Key="General">通用模式</system:String>
|
||||
<system:String x:Key="BlueStacks">蓝叠模拟器</system:String>
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
<system:String x:Key="PureGold">製造站-赤金</system:String>
|
||||
<system:String x:Key="OriginStone">製造站-源石碎片</system:String>
|
||||
<system:String x:Key="Chip">製造站-晶片組</system:String>
|
||||
<system:String x:Key="DormTrustEnabled">宿舍空余位置蹭信賴</system:String>
|
||||
<system:String x:Key="DormFilterNotStationedEnabled">不將已進駐的幹員放入宿舍</system:String>
|
||||
|
||||
<system:String x:Key="General">通用模式</system:String>
|
||||
<system:String x:Key="BlueStacks">藍疊模擬器</system:String>
|
||||
|
||||
@@ -36,12 +36,12 @@
|
||||
</ListBox>
|
||||
<Grid Grid.Column="1" Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="37*" />
|
||||
<RowDefinition Height="19*" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
Margin="0,20"
|
||||
Margin="0,10,0,103"
|
||||
Orientation="Vertical">
|
||||
<TextBlock
|
||||
Margin="0,5"
|
||||
@@ -58,8 +58,7 @@
|
||||
SelectedValuePath="Value" />
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
Margin="0,20"
|
||||
Margin="0,87,0,19"
|
||||
Orientation="Vertical">
|
||||
<TextBlock
|
||||
Margin="0,5"
|
||||
@@ -76,6 +75,16 @@
|
||||
Minimum="0"
|
||||
Value="{Binding DormThreshold}" />
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
Margin="0,171,0,-11"
|
||||
Orientation="Vertical" Grid.RowSpan="2">
|
||||
<CheckBox
|
||||
Content="{DynamicResource DormTrustEnabled}"
|
||||
IsChecked="{Binding DormTrustEnabled}" Height="24"/>
|
||||
<CheckBox
|
||||
Content="{DynamicResource DormFilterNotStationedEnabled}"
|
||||
IsChecked="{Binding DormFilterNotStationedEnabled}" Height="24"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -581,6 +581,44 @@ namespace MeoAsstGui
|
||||
}
|
||||
}
|
||||
|
||||
private string _dormFilterNotStationedEnabled = ViewStatusStorage.Get("Infrast.DormFilterNotStationedEnabled", false.ToString());
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the not stationed filter in dorm is enabled.
|
||||
/// </summary>
|
||||
public bool DormFilterNotStationedEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return bool.Parse(_dormFilterNotStationedEnabled);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _dormFilterNotStationedEnabled, value.ToString());
|
||||
ViewStatusStorage.Set("Infrast.DormFilterNotStationedEnabled", value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private string _dormTrustEnabled = ViewStatusStorage.Get("Infrast.DormTrustEnabled", true.ToString());
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether get trust in dorm is enabled.
|
||||
/// </summary>
|
||||
public bool DormTrustEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return bool.Parse(_dormTrustEnabled);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _dormTrustEnabled, value.ToString());
|
||||
ViewStatusStorage.Set("Infrast.DormTrustEnabled", value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#region 设置页面列表和滚动视图联动绑定
|
||||
|
||||
private enum NotifyType
|
||||
|
||||
@@ -900,7 +900,7 @@ namespace MeoAsstGui
|
||||
settings.SaveInfrastOrderList();
|
||||
var asstProxy = _container.Get<AsstProxy>();
|
||||
return asstProxy.AsstAppendInfrast(order.ToArray(),
|
||||
settings.UsesOfDrones, settings.DormThreshold / 100.0);
|
||||
settings.UsesOfDrones, settings.DormThreshold / 100.0, settings.DormFilterNotStationedEnabled, settings.DormTrustEnabled);
|
||||
}
|
||||
|
||||
private bool appendMall()
|
||||
|
||||
Reference in New Issue
Block a user