This commit is contained in:
MistEO
2022-07-31 20:32:13 +08:00
8 changed files with 64 additions and 79 deletions

View File

@@ -67,8 +67,8 @@ MAAは、MAA Assistant Arknightsです。
### 基本設定
1. この[サポートされているエミュレータ(英語)](docs/en/EMULATOR_SUPPORTS.md)を参照して、対応する操作に進んでください。
2. エミュレータ解像度を`16:9``1280 * 720`以上に変更してください。それより大きい解像度も大丈夫です。
1. この[サポートされているエミュレータ(英語)](docs/en/EMULATOR_SUPPORTS.md)を参照して、対応する操作に進んでください。
2. エミュレータ解像度を`16:9``1280 * 720`以上に変更してください。それより大きい解像度も大丈夫です。
3. ゲームスタート!
詳しいマニュアルは[ユーザーマニュアル(英語)](docs/en/USER_MANUAL.md)を参照してください。

View File

@@ -127,21 +127,12 @@ bool asst::AutoRecruitTask::_run()
if (!recruit_begin()) return false;
if (!check_recruit_home_page()) {
return false;
}
static constexpr int slot_retry_limit = 3;
if (!m_use_expedited) { // analyze once only
if (!analyze_start_buttons()) return true;
}
static constexpr size_t slot_retry_limit = 3;
// m_cur_times means how many times has the confirm button been pressed, NOT expedited plan used
while ((m_use_expedited || !m_pending_recruit_slot.empty()) && m_cur_times != m_max_times) {
// m_cur_times means how many times has the confirm button been pressed, NOT expedited plans used
while (m_cur_times != m_max_times) {
if (m_force_discard_flag) { return false; }
if (m_slot_fail >= slot_retry_limit) { return false; }
if (!check_recruit_home_page()) { return false; }
if (m_use_expedited) {
Log.info("ready to use expedited");
if (need_exit()) return false;
@@ -149,10 +140,15 @@ bool asst::AutoRecruitTask::_run()
m_force_discard_flag = true;
return false;
}
analyze_start_buttons();
}
auto start_rect = try_get_start_button(m_ctrler->get_image());
if (!start_rect) {
if (!check_recruit_home_page()) return false;
Log.info("There is no available start button.");
return true;
}
if (need_exit()) return false;
if (!recruit_one())
if (!recruit_one(start_rect.value()))
++m_slot_fail;
else
++m_cur_times;
@@ -160,25 +156,14 @@ bool asst::AutoRecruitTask::_run()
return true;
}
bool asst::AutoRecruitTask::analyze_start_buttons()
std::optional<asst::Rect> asst::AutoRecruitTask::try_get_start_button(const cv::Mat& image)
{
OcrImageAnalyzer start_analyzer;
start_analyzer.set_task_info("StartRecruit");
auto image = m_ctrler->get_image();
start_analyzer.set_image(image);
m_pending_recruit_slot.clear();
if (!start_analyzer.analyze()) {
Log.info("There is no start button");
return false;
}
if (!start_analyzer.analyze()) return std::nullopt;
start_analyzer.sort_result_horizontal();
m_start_buttons = start_analyzer.get_result();
for (size_t i = 0; i < m_start_buttons.size(); ++i) {
m_pending_recruit_slot.emplace_back(i);
}
Log.info("Recruit start button size", m_start_buttons.size());
return true;
return start_analyzer.get_result().front().rect;
}
/// open a pending recruit slot, set timer and tags then confirm, or leave the slot doing nothing
@@ -186,29 +171,18 @@ bool asst::AutoRecruitTask::analyze_start_buttons()
/// - recognition failed
/// - timer or tags corrupted
/// - failed to confirm
bool asst::AutoRecruitTask::recruit_one()
bool asst::AutoRecruitTask::recruit_one(const Rect& button)
{
LogTraceFunction;
int delay = Resrc.cfg().get_options().task_delay;
if (m_pending_recruit_slot.empty()) return false;
size_t index = m_pending_recruit_slot.front();
if (index > m_start_buttons.size()) {
Log.info("index", index, "out of range.");
m_pending_recruit_slot.pop_front();
return false;
}
Log.info("recruit_index", index);
Rect button = m_start_buttons.at(index).rect;
m_ctrler->click(button);
sleep(delay);
auto calc_result = recruit_calc_task();
sleep(delay);
m_pending_recruit_slot.pop_front();
if (!calc_result.success) {
// recognition failed, perhaps open the slot again would not help
{
@@ -233,8 +207,7 @@ bool asst::AutoRecruitTask::recruit_one()
// timer was not set to 09:00:00 properly, likely the tag selection was also corrupted
// see https://github.com/MaaAssistantArknights/MaaAssistantArknights/pull/300#issuecomment-1073287984
// return and try later
Log.info("Timer of this slot has not been reduced as expected, will retry later.");
m_pending_recruit_slot.push_back(index);
Log.info("Timer of this slot has not been reduced as expected.");
click_return_button();
return false;
}

View File

@@ -5,6 +5,7 @@
#include <vector>
#include <list>
#include <optional>
namespace asst
{
@@ -26,8 +27,8 @@ namespace asst
virtual bool _run() override;
bool is_calc_only_task() { return m_max_times <= 0 || m_confirm_level.empty(); }
bool analyze_start_buttons();
bool recruit_one();
static std::optional<Rect> try_get_start_button(const cv::Mat&);
bool recruit_one(const Rect&);
bool check_recruit_home_page();
bool recruit_begin();
bool check_time_unreduced();
@@ -54,8 +55,6 @@ namespace asst
bool m_skip_robot = true;
bool m_set_time = true;
std::vector<TextRect> m_start_buttons;
std::list<size_t> m_pending_recruit_slot;
int m_slot_fail = 0;
int m_cur_times = 0;
};

View File

@@ -6,6 +6,7 @@
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <numeric>
#include "AsstTypes.h"
@@ -44,15 +45,20 @@ namespace asst
double avg_level = 0;
void update_attributes() {
double sum = 0;
min_level = 7;
max_level = 0;
for (const auto& op : opers) {
sum += op.level;
min_level = (std::min)(min_level, op.level);
max_level = (std::max)(max_level, op.level);
}
avg_level = sum / static_cast<double>(opers.size());
min_level = std::transform_reduce(
opers.cbegin(), opers.cend(), 7,
[](int a, int b) -> int { return (std::min)(a, b); },
std::mem_fn(&RecruitOperInfo::level));
max_level = std::transform_reduce(
opers.cbegin(), opers.cend(), 0,
[](int a, int b) -> int { return (std::max)(a, b); },
std::mem_fn(&RecruitOperInfo::level));
avg_level = std::transform_reduce(
opers.cbegin(), opers.cend(), 0.,
std::plus<double>{},
std::mem_fn(&RecruitOperInfo::level)) / static_cast<double>(opers.size());
}
// intersection of two recruit combs

View File

@@ -55,6 +55,7 @@
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<DocumentationFile>..\..\x64\Release\MeoAsstGui.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'RelWithDebInfo|x64'">
<OutputPath>..\..\x64\RelWithDebInfo\</OutputPath>

View File

@@ -70,7 +70,7 @@
<system:String x:Key="SwitchLanguage">切換語言</system:String>
<system:String x:Key="Language">語言</system:String>
<system:String x:Key="LanguageChangedTip">語言設定已更,是否現在重啟 MAA 以用語言設定?</system:String>
<system:String x:Key="LanguageChangedTip">語言設定已更,是否現在重啟 MAA 以用語言設定?</system:String>
<system:String x:Key="Ok">好的</system:String>
<system:String x:Key="ManualRestart">稍後</system:String>
<system:String x:Key="Tip">提示</system:String>
@@ -208,20 +208,20 @@
<!-- 日誌 -->
<!-- 一鍵長草 -->
<!-- 公招識 -->
<system:String x:Key="Recognition">公招識</system:String>
<!-- 公招識 -->
<system:String x:Key="Recognition">公招識</system:String>
<system:String x:Key="RecognitionTip">小提示和主介面的自動公招是兩個獨立的功能請手動打開遊戲公招Tags介面後使用~</system:String>
<system:String x:Key="AutoSettingTime">自動設定時間</system:String>
<system:String x:Key="AutoSelectLevel3Tags">自動選擇3星Tags</system:String>
<system:String x:Key="AutoSelectLevel4Tags">自動選擇4星Tags</system:String>
<system:String x:Key="AutoSelectLevel5Tags">自動選擇5星Tags</system:String>
<system:String x:Key="AutoSelectLevel6Tags">自動選擇6星Tags</system:String>
<system:String x:Key="BeganToRecruit">開始識</system:String>
<system:String x:Key="BeganToRecruit">開始識</system:String>
<!-- 日誌 -->
<system:String x:Key="Identifying">正在識……</system:String>
<system:String x:Key="Identifying">正在識……</system:String>
<!-- 日誌 -->
<!-- 公招識 -->
<!-- 公招識 -->
<!-- 自動戰鬥 -->
<system:String x:Key="Copilot">自動戰鬥 Beta</system:String>
@@ -229,7 +229,7 @@
<system:String x:Key="SelectTheFile">選擇作業</system:String>
<system:String x:Key="SelectTheFileTip">作業檔可以直接用滑鼠拖進來喔 (o゚v゚)</system:String>
<system:String x:Key="AutoSquad">自動編隊</system:String>
<system:String x:Key="AutoSquadTip">自動編隊暫時無法識“特別關注”的幹員</system:String>
<system:String x:Key="AutoSquadTip">自動編隊暫時無法識“特別關注”的幹員</system:String>
<system:String x:Key="Start">開始</system:String>
@@ -238,18 +238,18 @@
<!-- 日誌 -->
<system:String x:Key="CopilotTip">小提示:</system:String>
<system:String x:Key="CopilotTip1">1. 請將模擬器及遊戲率設定為 60 或更高;</system:String>
<system:String x:Key="CopilotTip1">1. 請將模擬器及遊戲影格率設定為 60 或更高;</system:String>
<system:String x:Key="CopilotTip2">2. 請在有“開始行動”按鈕的介面再使用本功能;</system:String>
<system:String x:Key="CopilotTip3">3. 使用好友助戰可以關閉“自動編隊”,手動選擇幹員後開始;</system:String>
<system:String x:Key="CopilotTip4">4. 模擬悖論需要關閉“自動編隊”,並選好技能後處於“開始模擬”按鈕的介面再開始;</system:String>
<system:String x:Key="CopilotTip5">5. “自動編隊”暫時無法識“特別關注”的幹員,如有需求請取消特別關注或手動編隊;</system:String>
<system:String x:Key="CopilotTip5">5. “自動編隊”暫時無法識“特別關注”的幹員,如有需求請取消特別關注或手動編隊;</system:String>
<system:String x:Key="CopilotFileReadError">讀取檔失敗!</system:String>
<system:String x:Key="CopilotFileReadError">讀取檔失敗!</system:String>
<system:String x:Key="CopilotNoFound">未找到對應作業!</system:String>
<system:String x:Key="NetworkServiceError">請求網路服務錯誤!</system:String>
<system:String x:Key="CopilotJsonError">解析作業檔錯誤!</system:String>
<system:String x:Key="NotCopilotJson">非作業檔</system:String>
<system:String x:Key="CheckTheFile">請檢查檔內容!</system:String>
<system:String x:Key="CopilotJsonError">解析作業檔錯誤!</system:String>
<system:String x:Key="NotCopilotJson">非作業檔</system:String>
<system:String x:Key="CheckTheFile">請檢查檔內容!</system:String>
<!-- 日誌 -->
<!-- 自動戰鬥 -->
@@ -262,7 +262,7 @@
<system:String x:Key="TryToReconnect">模擬器斷開,正在嘗試重連</system:String>
<system:String x:Key="ReconnectSuccess">重連成功,繼續任務</system:String>
<system:String x:Key="ReconnectFailed">重連失敗,連接斷開!</system:String>
<system:String x:Key="IdentifyTheMistakes">識錯誤</system:String>
<system:String x:Key="IdentifyTheMistakes">識錯誤</system:String>
<system:String x:Key="TaskError">任務出錯:</system:String>
<system:String x:Key="CombatError">戰鬥出錯:</system:String>
<system:String x:Key="StartTask">開始任務:</system:String>
@@ -270,10 +270,10 @@
<system:String x:Key="StartCombat">開始戰鬥:</system:String>
<system:String x:Key="CompleteCombat">完成戰鬥:</system:String>
<system:String x:Key="AllTasksComplete">任務已全部完成!</system:String>
<system:String x:Key="FailedToOpenClient">打開用戶端失敗,請檢查配置檔</system:String>
<system:String x:Key="FailedToOpenClient">打開用戶端失敗,請檢查設定檔</system:String>
<system:String x:Key="ErrorOccurred">出現錯誤</system:String>
<system:String x:Key="HasReturned">已返回</system:String>
<system:String x:Key="DropRecognitionError">掉落識錯誤</system:String>
<system:String x:Key="DropRecognitionError">掉落識錯誤</system:String>
<system:String x:Key="GiveUpUploadingPenguins">放棄上傳企鵝物流</system:String>
<system:String x:Key="TheEX">EX 關卡,已停止</system:String>
<system:String x:Key="OnTheMove">已開始行動</system:String>
@@ -291,7 +291,7 @@
<system:String x:Key="FightFailed">戰鬥失敗</system:String>
<system:String x:Key="UpperLimit">投資達到上限</system:String>
<system:String x:Key="GameCrash">遊戲崩潰,重新啟動</system:String>
<system:String x:Key="GameDrop">遊戲線,重新連接</system:String>
<system:String x:Key="GameDrop">遊戲線,重新連接</system:String>
<system:String x:Key="Trader">關卡:詭意行商</system:String>
<system:String x:Key="SafeHouse">關卡:安全的角落</system:String>
<system:String x:Key="Encounter">關卡:不期而遇</system:String>
@@ -302,19 +302,19 @@
<system:String x:Key="Drop">本次掉落:</system:String>
<system:String x:Key="TotalDrop">掉落統計:</system:String>
<system:String x:Key="ThisFacility">當前設施:</system:String>
<system:String x:Key="RecruitingResults">公招識結果:</system:String>
<system:String x:Key="RecruitingResults">公招識結果:</system:String>
<system:String x:Key="RecruitingTips">公招提示</system:String>
<system:String x:Key="RecruitmentOfStar">公招出 {0} 星了喔!</system:String>
<system:String x:Key="RecruitmentOfBot">公招出小車了喔!</system:String>
<system:String x:Key="Choose">選擇</system:String>
<system:String x:Key="Refreshed">當前槽位已刷新</system:String>
<system:String x:Key="NotEnoughStaff">可用幹員不足</system:String>
<system:String x:Key="StageInfoError">關卡識錯誤</system:String>
<system:String x:Key="StageInfoError">關卡識錯誤</system:String>
<system:String x:Key="BattleFormation">開始編隊</system:String>
<system:String x:Key="BattleFormationSelected">選擇幹員:</system:String>
<system:String x:Key="CurrentSteps">當前步驟:</system:String>
<system:String x:Key="UnsupportedLevel">不支持的關卡,請更新 MAA 軟體版本,或檢查作業檔</system:String>
<system:String x:Key="RecruitTagsDetected">識結果:</system:String>
<system:String x:Key="UnsupportedLevel">不支持的關卡,請更新 MAA 軟體版本,或檢查作業檔</system:String>
<system:String x:Key="RecruitTagsDetected">識結果:</system:String>
<system:String x:Key="ConnectFailed">連接失敗</system:String>
<system:String x:Key="TryToStartEmulator">正在嘗試啟動模擬器</system:String>
<system:String x:Key="CheckSettings">請檢查連接設定或嘗試重啟電腦</system:String>
@@ -345,7 +345,7 @@
<system:String x:Key="AutoSelectLevel4">自動確認 4 星</system:String>
<system:String x:Key="AutoSelectLevel5">自動確認 5 星</system:String>
<system:String x:Key="AutoSelectLevel6">自動確認 6 星</system:String>
<system:String x:Key="Level1Tip">勾選時識到 1 星詞條時跳過該次招募,未勾選時將忽略 1 星詞條</system:String>
<system:String x:Key="Level1Tip">勾選時識到 1 星詞條時跳過該次招募,未勾選時將忽略 1 星詞條</system:String>
<!-- AutoRecruitSettings -->
<system:String x:Key="Burping">呃......咳嗯</system:String>

View File

@@ -1257,6 +1257,9 @@ namespace MeoAsstGui
private bool _notChooseLevel1 = Convert.ToBoolean(ViewStatusStorage.Get("AutoRecruit.NotChooseLevel1", bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether not to choose level 1.
/// </summary>
public bool NotChooseLevel1
{
get

View File

@@ -865,6 +865,9 @@ namespace MeoAsstGui
}
}
/// <summary>
/// Closes view model.
/// </summary>
public void Close()
{
RequestClose();