mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 09:50:40 +08:00
feat: 如果任务流程中勾选了刷理智,则在任务链结束时提供一个理智回满的预测时间 (#6456)
This commit is contained in:
@@ -3973,7 +3973,7 @@
|
||||
"roi": [
|
||||
1120,
|
||||
20,
|
||||
150,
|
||||
160,
|
||||
40
|
||||
],
|
||||
"ocrReplace": [
|
||||
|
||||
@@ -421,6 +421,14 @@ void Assistant::working_proc()
|
||||
|
||||
if (m_tasks_list.empty()) {
|
||||
callback_json["finished_tasks"] = json::array(finished_tasks);
|
||||
|
||||
const auto& sanity_str = status()->get_str(Status::FightSanityReport);
|
||||
if (sanity_str) {
|
||||
auto sanity_array = json::array(json::parse(*sanity_str).value_or(json::value(json::array())));
|
||||
// ["100/135", "2023-09-01 09:31:53.527"]
|
||||
callback_json["sanity"] = sanity_array;
|
||||
}
|
||||
|
||||
append_callback(AsstMsg::AllTasksCompleted, callback_json);
|
||||
finished_tasks.clear();
|
||||
clear_cache();
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace asst
|
||||
|
||||
public:
|
||||
static inline const std::string InfrastAvailableOpersForGroup = "InfrastAvailableOpersForGroup";
|
||||
static inline const std::string FightSanityReport = "FightSanityReport";
|
||||
|
||||
static inline const std::string RoguelikeCharElitePrefix = "RoguelikeElite-";
|
||||
static inline const std::string RoguelikeCharLevelPrefix = "RoguelikeLevel-";
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "Config/TaskData.h"
|
||||
#include "Controller/Controller.h"
|
||||
#include "Status.h"
|
||||
#include "Utils/ImageIo.hpp"
|
||||
#include "Utils/Logger.hpp"
|
||||
#include "Vision/RegionOCRer.h"
|
||||
@@ -19,6 +20,10 @@ bool asst::SanityBeforeStagePlugin::verify(AsstMsg msg, const json::value& detai
|
||||
if (task.ends_with("StartButton1")) {
|
||||
return true;
|
||||
}
|
||||
else if (task.ends_with("Stop") && details.at("pre_task").as_string().ends_with("StartButton1")) {
|
||||
// 次数达限
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
@@ -49,8 +54,8 @@ void asst::SanityBeforeStagePlugin::get_sanity()
|
||||
if (!analyzer.analyze()) {
|
||||
Log.info(__FUNCTION__, "Current Sanity analyze failed");
|
||||
|
||||
cv::rectangle(img, make_rect<cv::Rect>(Task.get("SanityMatch")->roi), cv::Scalar(0, 0, 255), 2);
|
||||
std::string stem = utils::get_time_filestem();
|
||||
cv::rectangle(img, make_rect<cv::Rect>(Task.get("SanityMatch")->roi), cv::Scalar(0, 0, 255), 2);
|
||||
imwrite(utils::path("debug") / utils::path("sanity") / (stem + "_failed_img.png"), img);
|
||||
return;
|
||||
}
|
||||
@@ -69,4 +74,9 @@ void asst::SanityBeforeStagePlugin::get_sanity()
|
||||
json::value sanity_info = basic_info_with_what("SanityBeforeStage");
|
||||
sanity_info["details"]["sanity"] = text;
|
||||
callback(AsstMsg::SubTaskExtraInfo, sanity_info);
|
||||
|
||||
json::array value;
|
||||
value.emplace_back(std::move(text));
|
||||
value.emplace_back(utils::get_format_time());
|
||||
status()->set_str(Status::FightSanityReport, value.dumps());
|
||||
}
|
||||
|
||||
@@ -589,6 +589,7 @@ namespace MaaWpfGui.Main
|
||||
case AsstMsg.AllTasksCompleted:
|
||||
bool isMainTaskQueueAllCompleted = true;
|
||||
var finished_tasks = details["finished_tasks"] as JArray;
|
||||
var sanity_report = details["sanity"] as JArray;
|
||||
if (finished_tasks.Count == 1)
|
||||
{
|
||||
var unique_finished_task = (AsstTaskId)finished_tasks[0];
|
||||
@@ -617,19 +618,49 @@ namespace MaaWpfGui.Main
|
||||
|
||||
if (isMainTaskQueueAllCompleted)
|
||||
{
|
||||
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("AllTasksComplete"));
|
||||
bool isSanityForecastSucc = true;
|
||||
DateTimeOffset? reportTime = null;
|
||||
TimeSpan timeDiff = TimeSpan.Zero;
|
||||
if (isSanityForecastSucc &= sanity_report.Count == 2 && ((string)sanity_report[0]).Contains("/"))
|
||||
{
|
||||
int[] sanity = ((string)sanity_report[0]).Split('/').Select(i => Convert.ToInt32(i)).ToArray();
|
||||
reportTime = DateTimeOffset.Parse((string)sanity_report[1]);
|
||||
if (isSanityForecastSucc &= sanity.Length == 2 && sanity[1] > 1)
|
||||
{
|
||||
timeDiff = new TimeSpan(0, sanity[0] < sanity[1] ? (sanity[1] - sanity[0]) * 6 : 0, 0);
|
||||
reportTime = reportTime?.AddMinutes(timeDiff.TotalMinutes);
|
||||
}
|
||||
}
|
||||
|
||||
var allTaskCompleteTitle = LocalizationHelper.GetString("AllTasksComplete");
|
||||
var allTaskCompleteMessage = LocalizationHelper.GetString("AllTaskCompleteContent");
|
||||
var sanityReport = LocalizationHelper.GetString("SanityReport");
|
||||
|
||||
var configurationPreset = ConfigurationHelper.GetValue(ConfigurationKeys.CurrentConfiguration, "Default");
|
||||
var configurationPreset = ConfigurationHelper.GetCurrentConfiguration();
|
||||
|
||||
allTaskCompleteMessage = allTaskCompleteMessage
|
||||
.Replace("{Datetime}", DateTime.Now.ToString("U"))
|
||||
.Replace("{DateTime}", DateTime.Now.ToString("U"))
|
||||
.Replace("{Preset}", configurationPreset);
|
||||
if (isSanityForecastSucc)
|
||||
{
|
||||
sanityReport = sanityReport.Replace("{DateTime}", reportTime?.ToString("T")).Replace("{TimeDiff}", timeDiff.ToString(@"hh\:mm"));
|
||||
|
||||
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("AllTasksComplete") + Environment.NewLine + sanityReport);
|
||||
ExternalNotificationService.Send(allTaskCompleteTitle, allTaskCompleteMessage + Environment.NewLine + sanityReport);
|
||||
}
|
||||
else
|
||||
{
|
||||
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("AllTasksComplete"));
|
||||
ExternalNotificationService.Send(allTaskCompleteTitle, allTaskCompleteMessage);
|
||||
}
|
||||
|
||||
ExternalNotificationService.Send(allTaskCompleteTitle, allTaskCompleteMessage);
|
||||
using (var toast = new ToastNotification(allTaskCompleteTitle))
|
||||
{
|
||||
if (isSanityForecastSucc)
|
||||
{
|
||||
toast.AppendContentText(sanityReport);
|
||||
}
|
||||
|
||||
toast.Show();
|
||||
}
|
||||
|
||||
|
||||
@@ -541,7 +541,8 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla
|
||||
<system:String x:Key="StartCombat" xml:space="preserve">Start combat: </system:String>
|
||||
<system:String x:Key="CompleteCombat">Complete combat</system:String>
|
||||
<system:String x:Key="AllTasksComplete">All task(s) completed!</system:String>
|
||||
<system:String x:Key="AllTaskCompleteContent">MAA has completed all tasks under the {Preset} configuration in {Datetime}.</system:String>
|
||||
<system:String x:Key="SanityReport">Sanity will be full on {DateTime} ({TimeDiff} later).</system:String>
|
||||
<system:String x:Key="AllTaskCompleteContent">MAA has completed all tasks under the {Preset} configuration in {DateTime}.</system:String>
|
||||
<system:String x:Key="BackgroundLinkStarted">Tasks started</system:String>
|
||||
<system:String x:Key="BackgroundLinkStopped">Tasks stopped</system:String>
|
||||
<system:String x:Key="FailedToOpenClient">Failed to open the client. Please check the configuration file</system:String>
|
||||
|
||||
@@ -541,7 +541,8 @@ Bilibili: ログイン インターフェイスに表示されるアカウント
|
||||
<system:String x:Key="StartCombat" xml:space="preserve">戦闘開始: </system:String>
|
||||
<system:String x:Key="CompleteCombat">戦闘完了</system:String>
|
||||
<system:String x:Key="AllTasksComplete">すべてのタスクが完了しました!</system:String>
|
||||
<system:String x:Key="AllTaskCompleteContent">MAA は、{Datetime} の {Preset} 構成の下にあるすべてのプリセット タスクを完了しました。</system:String>
|
||||
<system:String x:Key="SanityReport">理性は {DateTime} に満杯になります ({TimeDiff} 後)。</system:String>
|
||||
<system:String x:Key="AllTaskCompleteContent">MAA は、{DateTime} の {Preset} 構成の下にあるすべてのプリセット タスクを完了しました。</system:String>
|
||||
<system:String x:Key="BackgroundLinkStarted">Tasks started</system:String>
|
||||
<system:String x:Key="BackgroundLinkStopped">Tasks stopped</system:String>
|
||||
<system:String x:Key="FailedToOpenClient">クライアントを開くのに失敗しました。構成ファイルを確認してください</system:String>
|
||||
|
||||
@@ -541,7 +541,8 @@ Bilibili: 로그인 인터페이스에 표시되는 계정 이름(예: Zhang San
|
||||
<system:String x:Key="StartCombat" xml:space="preserve">작전 시작: </system:String>
|
||||
<system:String x:Key="CompleteCombat">작전 완료</system:String>
|
||||
<system:String x:Key="AllTasksComplete">모든 작업이 완료되었습니다!</system:String>
|
||||
<system:String x:Key="AllTaskCompleteContent">MAA는 {Datetime}의 {Preset} 구성에서 모든 사전 설정 작업을 완료했습니다.</system:String>
|
||||
<system:String x:Key="SanityReport">{DateTime}({TimeDiff} 이후)에 정신 상태가 가득 차게 됩니다.</system:String>
|
||||
<system:String x:Key="AllTaskCompleteContent">MAA는 {DateTime}의 {Preset} 구성에서 모든 사전 설정 작업을 완료했습니다.</system:String>
|
||||
<system:String x:Key="BackgroundLinkStarted">작업 시작됨</system:String>
|
||||
<system:String x:Key="BackgroundLinkStopped">작업 중지됨</system:String>
|
||||
<system:String x:Key="FailedToOpenClient">클라이언트를 시작하지 못했습니다. 설정 파일을 확인하세요</system:String>
|
||||
|
||||
@@ -541,7 +541,8 @@
|
||||
<system:String x:Key="StartCombat" xml:space="preserve">开始战斗: </system:String>
|
||||
<system:String x:Key="CompleteCombat">完成战斗</system:String>
|
||||
<system:String x:Key="AllTasksComplete">任务已全部完成!</system:String>
|
||||
<system:String x:Key="AllTaskCompleteContent">MAA 已在 {Datetime} 完成了 {Preset} 配置下所有预设的任务。</system:String>
|
||||
<system:String x:Key="SanityReport">理智将在 {DateTime} ({TimeDiff} 后) 回满。</system:String>
|
||||
<system:String x:Key="AllTaskCompleteContent">MAA 已在 {DateTime} 完成了 {Preset} 配置下所有预设的任务。</system:String>
|
||||
<system:String x:Key="BackgroundLinkStarted">开始执行任务</system:String>
|
||||
<system:String x:Key="BackgroundLinkStopped">任务终止</system:String>
|
||||
<system:String x:Key="FailedToOpenClient">打开客户端失败,请检查配置文件</system:String>
|
||||
|
||||
@@ -541,7 +541,8 @@
|
||||
<system:String x:Key="StartCombat" xml:space="preserve">開始戰鬥: </system:String>
|
||||
<system:String x:Key="CompleteCombat">完成戰鬥</system:String>
|
||||
<system:String x:Key="AllTasksComplete">任務已全部完成!</system:String>
|
||||
<system:String x:Key="AllTaskCompleteContent">MAA 已在 {Datetime} 完成了 {Preset} 配置下所有預設的任務。</system:String>
|
||||
<system:String x:Key="SanityReport">理智會在 {DateTime} ({TimeDiff} 後) 回滿。</system:String>
|
||||
<system:String x:Key="AllTaskCompleteContent">MAA 已在 {DateTime} 完成了 {Preset} 配置下所有預設的任務。</system:String>
|
||||
<system:String x:Key="BackgroundLinkStarted">開始執行任務</system:String>
|
||||
<system:String x:Key="BackgroundLinkStopped">任務終止</system:String>
|
||||
<system:String x:Key="FailedToOpenClient">打開用戶端失敗,請檢查設定檔</system:String>
|
||||
|
||||
Reference in New Issue
Block a user