Merge pull request #723 from lhhxxxxx/feat/robot

[New Feature] 公招小车识别
This commit is contained in:
MistEO
2022-06-04 01:18:51 +08:00
committed by GitHub
9 changed files with 42 additions and 8 deletions

View File

@@ -37,6 +37,12 @@ asst::AutoRecruitTask& asst::AutoRecruitTask::set_use_expedited(bool use_or_not)
return *this;
}
asst::AutoRecruitTask& asst::AutoRecruitTask::set_skip_robot(bool skip_robot) noexcept
{
m_skip_robot = skip_robot;
return *this;
}
bool asst::AutoRecruitTask::_run()
{
if (!check_recruit_home_page()) {
@@ -152,7 +158,7 @@ bool asst::AutoRecruitTask::calc_and_recruit()
return false;
}
if (std::find(m_confirm_level.cbegin(), m_confirm_level.cend(), maybe_level) != m_confirm_level.cend()) {
if (!(m_skip_robot && recruit_task.get_has_robot_tag()) && std::find(m_confirm_level.cbegin(), m_confirm_level.cend(), maybe_level) != m_confirm_level.cend()) {
if (!confirm()) {
return false;
}

View File

@@ -16,6 +16,7 @@ namespace asst
AutoRecruitTask& set_need_refresh(bool need_refresh) noexcept;
AutoRecruitTask& set_max_times(int max_times) noexcept;
AutoRecruitTask& set_use_expedited(bool use_or_not) noexcept;
AutoRecruitTask& set_skip_robot(bool skip_robot) noexcept;
protected:
virtual bool _run() override;
@@ -34,6 +35,7 @@ namespace asst
bool m_need_refresh = false;
bool m_use_expedited = false;
int m_max_times = 0;
bool m_skip_robot = true;
std::vector<TextRect> m_start_buttons;
int m_cur_times = 0;

View File

@@ -63,17 +63,22 @@ bool RecruitCalcTask::_run()
m_has_special_tag = true;
}
static const std::string Robot = "支援机械";
auto robot_iter = all_tags_name.find(Robot);
if (robot_iter != all_tags_name.end()) {
m_has_robot_tag = true;
}
// 识别到的5个Tags全组合排列
std::vector<std::vector<std::string>> all_combs;
size_t len = all_tags.size();
int count = static_cast<int>(std::pow(2, len));
int count = 1 << len;
for (int i = 0; i < count; ++i) {
std::vector<std::string> temp;
for (int j = 0, mask = 1; j < len; ++j) {
if ((i & mask) != 0) { // What the fuck???
for (int j = 0; j < len; ++j) {
if (i & 1 << j) { // i第j位为1
temp.emplace_back(all_tags.at(j).text);
}
mask = mask * 2;
}
// 游戏里最多选择3个tag
if (!temp.empty() && temp.size() <= 3) {

View File

@@ -26,6 +26,10 @@ namespace asst
{
return m_maybe_level;
}
bool get_has_robot_tag() const noexcept
{
return m_has_robot_tag;
}
protected:
virtual bool _run() override;
@@ -37,6 +41,7 @@ namespace asst
/* 内部处理用参数*/
int m_maybe_level = 0;
bool m_has_special_tag = false;
bool m_has_robot_tag = false;
bool m_has_refresh = false;
};
}

View File

@@ -46,6 +46,7 @@ bool asst::RecruitTask::set_params(const json::value& params)
int times = params.get("times", 0);
bool expedite = params.get("expedite", false);
[[maybe_unused]] int expedite_times = params.get("expedite_times", 0);
bool skip_robot = params.get("skip_robot", true);
if (times <= 0 || confirm.empty()) { // 仅识别的情况
m_recruit_begin_task_ptr->set_enable(false);
@@ -63,7 +64,8 @@ bool asst::RecruitTask::set_params(const json::value& params)
.set_need_refresh(refresh)
.set_use_expedited(expedite)
.set_select_level(std::move(select))
.set_confirm_level(std::move(confirm));
.set_confirm_level(std::move(confirm))
.set_skip_robot(skip_robot);
}
return true;

View File

@@ -680,7 +680,7 @@ namespace MeoAsstGui
return AsstAppendTaskWithEncoding("Mall", task_params);
}
public bool AsstAppendRecruit(int max_times, int[] select_level, int required_len, int[] confirm_level, int confirm_len, bool need_refresh, bool use_expedited)
public bool AsstAppendRecruit(int max_times, int[] select_level, int required_len, int[] confirm_level, int confirm_len, bool need_refresh, bool use_expedited, bool skip_robot)
{
var task_params = new JObject();
task_params["refresh"] = need_refresh;
@@ -690,6 +690,7 @@ namespace MeoAsstGui
task_params["set_time"] = true;
task_params["expedite"] = use_expedited;
task_params["expedite_times"] = max_times;
task_params["skip_robot"] = skip_robot;
return AsstAppendTaskWithEncoding("Recruit", task_params);
}

View File

@@ -25,6 +25,7 @@
</StackPanel>
</StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center" Margin="10">
<CheckBox IsChecked="{Binding NotChooseLevel1}" Content="手动确认1星" Margin="5" />
<CheckBox IsChecked="{Binding ChooseLevel3}" Content="自动确认3星" Margin="5" />
<CheckBox IsChecked="{Binding ChooseLevel4}" Content="自动确认4星" Margin="5" />
<CheckBox IsChecked="{Binding ChooseLevel5}" Content="自动确认5星" Margin="5" />

View File

@@ -517,6 +517,18 @@ namespace MeoAsstGui
set { SetAndNotify(ref _useExpedited, value); }
}
private bool _notChooseLevel1 = Convert.ToBoolean(ViewStatusStorage.Get("AutoRecruit.NotChooseLevel1", bool.TrueString));
public bool NotChooseLevel1
{
get { return _notChooseLevel1; }
set
{
SetAndNotify(ref _notChooseLevel1, value);
ViewStatusStorage.Set("AutoRecruit.NotChooseLevel1", value.ToString());
}
}
private bool _chooseLevel3 = Convert.ToBoolean(ViewStatusStorage.Get("AutoRecruit.ChooseLevel3", bool.TrueString));
public bool ChooseLevel3

View File

@@ -412,7 +412,7 @@ namespace MeoAsstGui
var asstProxy = _container.Get<AsstProxy>();
return asstProxy.AsstAppendRecruit(
max_times, reqList.ToArray(), reqList.Count, cfmList.ToArray(), cfmList.Count, need_refresh, use_expedited);
max_times, reqList.ToArray(), reqList.Count, cfmList.ToArray(), cfmList.Count, need_refresh, use_expedited, settings.NotChooseLevel1);
}
private bool appendRoguelike()