Skip to content

Commit 442e6eb

Browse files
committed
物品过期处理
1 parent 40accef commit 442e6eb

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

BetterGenshinImpact/GameTask/AutoArtifactSalvage/AutoArtifactSalvageTask.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,21 @@ public static async Task OpenInventory(GridScreenName gridScreenName, InputSimul
136136

137137
// B键打开背包
138138
input.SimulateAction(GIActions.OpenInventory);
139-
await Delay(1000, ct);
139+
await Delay(1200, ct);
140140

141141
var openBagSuccess = await NewRetry.WaitForAction(() =>
142142
{
143143
using var ra = CaptureToRectArea();
144+
145+
// 判断是否在提示对话框(物品过期提示)
146+
if (Bv.IsInPromptDialog(ra))
147+
{
148+
// 如果存在物品过期提示,则点击确认按钮
149+
Bv.ClickWhiteConfirmButton(ra.DeriveCrop(0, 0, ra.Width, ra.Height - ra.Height / 0.2));
150+
Sleep(300, ct);
151+
return false;
152+
}
153+
144154
using var artifactBtn = ra.Find(recognitionObjectChecked);
145155
if (artifactBtn.IsEmpty())
146156
{

BetterGenshinImpact/GameTask/Common/BgiVision/BvStatus.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using BetterGenshinImpact.GameTask.AutoFight.Assets;
1212
using BetterGenshinImpact.GameTask.AutoSkip.Assets;
1313
using BetterGenshinImpact.GameTask.GameLoading.Assets;
14+
using BetterGenshinImpact.Helpers.Extensions;
1415

1516

1617
namespace BetterGenshinImpact.GameTask.Common.BgiVision;
@@ -273,6 +274,17 @@ public static async Task<bool> WaitAndSkipForTalkUi(CancellationToken ct, int re
273274
{
274275
return await NewRetry.WaitForAction(() => IsInTalkUi(TaskControl.CaptureToRectArea()), ct, retryTimes, 500);
275276
}
277+
278+
/// <summary>
279+
/// 是否存在提示框/确认框
280+
/// 黑白款都能识别
281+
/// </summary>
282+
/// <param name="captureRa"></param>
283+
/// <returns></returns>
284+
public static bool IsInPromptDialog(ImageRegion captureRa)
285+
{
286+
return captureRa.Find(ElementAssets.Instance.PromptDialogLeftBottomStar).IsExist();
287+
}
276288
}
277289

278290
public enum MotionStatus
1.14 KB
Loading

BetterGenshinImpact/GameTask/Common/Element/Assets/ElementAssets.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace BetterGenshinImpact.GameTask.Common.Element.Assets;
88

99
public class ElementAssets : BaseAssets<ElementAssets>
1010
{
11+
public RecognitionObject PromptDialogLeftBottomStar; // 弹出框左下角的星星
12+
1113
public RecognitionObject BtnWhiteConfirm;
1214
public RecognitionObject BtnWhiteCancel;
1315
public RecognitionObject BtnBlackConfirm;
@@ -87,6 +89,14 @@ public class ElementAssets : BaseAssets<ElementAssets>
8789

8890
private ElementAssets()
8991
{
92+
PromptDialogLeftBottomStar = new RecognitionObject
93+
{
94+
Name = "PromptDialogLeftBottomStar",
95+
RecognitionType = RecognitionTypes.TemplateMatch,
96+
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "prompt_dialog_left_bottom_star.png"),
97+
RegionOfInterest = new Rect(0, CaptureRect.Height / 2, CaptureRect.Width / 2, CaptureRect.Height - CaptureRect.Height / 2),
98+
Threshold = 0.8,
99+
}.InitTemplate();
90100
// 按钮
91101
BtnWhiteConfirm = new RecognitionObject
92102
{

0 commit comments

Comments
 (0)