mirror of
https://github.com/babalae/better-genshin-impact
synced 2025-01-08 11:57:53 +08:00
add claim mail
This commit is contained in:
parent
dffccd0740
commit
99c8cd450e
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
@ -33,10 +33,13 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
public RecognitionObject BagArtifactChecked;
|
||||
public RecognitionObject BtnArtifactSalvage;
|
||||
public RecognitionObject BtnArtifactSalvageConfirm;
|
||||
|
||||
|
||||
public RecognitionObject BtnClaimEncounterPointsRewards;
|
||||
public RecognitionObject PrimogemRo;
|
||||
|
||||
public RecognitionObject EscMailReward;
|
||||
public RecognitionObject CollectRo;
|
||||
|
||||
|
||||
private ElementAssets()
|
||||
{
|
||||
@ -208,24 +211,42 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
RegionOfInterest = CaptureRect.CutBottom(0.1),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
|
||||
|
||||
// 历练点奖励
|
||||
BtnClaimEncounterPointsRewards = new RecognitionObject
|
||||
{
|
||||
Name = "BtnClaimEncounterPointsRewards",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "btn_claim_encounter_points_rewards.png"),
|
||||
RegionOfInterest = CaptureRect.CutRightBottom(0.3,0.5),
|
||||
RegionOfInterest = CaptureRect.CutRightBottom(0.3, 0.5),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
|
||||
|
||||
PrimogemRo = new RecognitionObject
|
||||
{
|
||||
Name = "Primogem",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage("AutoSkip", "primogem.png"),
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "primogem.png"),
|
||||
RegionOfInterest = new Rect(0, CaptureRect.Height / 3, CaptureRect.Width, CaptureRect.Height / 3),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
|
||||
// 邮件
|
||||
EscMailReward = new RecognitionObject
|
||||
{
|
||||
Name = "EscMailReward",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "esc_mail_reward.png"),
|
||||
RegionOfInterest = CaptureRect.CutRightBottom(0.1, 0.5)
|
||||
}.InitTemplate();
|
||||
|
||||
CollectRo = new RecognitionObject
|
||||
{
|
||||
Name = "Collect",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "collect.png"),
|
||||
RegionOfInterest = new Rect(0, CaptureRect.Height - CaptureRect.Height / 3, CaptureRect.Width / 4, CaptureRect.Height / 3),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using BetterGenshinImpact.Helpers.Extensions;
|
||||
@ -52,7 +51,12 @@ public class ClaimBattlePassRewardsTask
|
||||
await ClaimAll(ct);
|
||||
|
||||
// 领取战令2
|
||||
await Delay(1500, ct);
|
||||
await Delay(2000, ct); // 等待升级动画
|
||||
// 还可能存在领取到原石的情况
|
||||
if (CaptureToRectArea().Find(ElementAssets.Instance.PrimogemRo).IsExist())
|
||||
{
|
||||
TaskContext.Instance().PostMessageSimulator.KeyPress(User32.VK.VK_ESCAPE);
|
||||
}
|
||||
GameCaptureRegion.GameRegion1080PPosClick(858, 45);
|
||||
await Delay(500, ct);
|
||||
await ClaimAll(ct);
|
||||
|
@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.Common.Job;
|
||||
|
||||
/// <summary>
|
||||
/// 领取邮件奖励
|
||||
/// </summary>
|
||||
public class ClaimMailRewardsTask
|
||||
{
|
||||
private readonly ReturnMainUiTask _returnMainUiTask = new();
|
||||
|
||||
public async Task Start(CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
await DoOnce(ct);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogDebug(e, "领取邮件奖励异常");
|
||||
Logger.LogError("领取邮件奖励异常: {Msg}", e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DoOnce(CancellationToken ct)
|
||||
{
|
||||
await _returnMainUiTask.Start(ct);
|
||||
|
||||
await Delay(200, ct);
|
||||
|
||||
TaskContext.Instance().PostMessageSimulator.KeyPress(User32.VK.VK_ESCAPE); // ESC
|
||||
|
||||
await Delay(700, ct);
|
||||
|
||||
var ra = CaptureToRectArea();
|
||||
var mailIcon = ra.Find(ElementAssets.Instance.EscMailReward);
|
||||
if (mailIcon.IsExist())
|
||||
{
|
||||
mailIcon.Click();
|
||||
await Delay(1000, ct);
|
||||
ra = CaptureToRectArea();
|
||||
var claimAll = ra.Find(ElementAssets.Instance.CollectRo);
|
||||
if (claimAll.IsExist())
|
||||
{
|
||||
claimAll.Click();
|
||||
Logger.LogInformation("邮件:{Text}", "全部领取");
|
||||
await Delay(200, ct);
|
||||
// TODO 截图
|
||||
|
||||
TaskContext.Instance().PostMessageSimulator.KeyPress(User32.VK.VK_ESCAPE); // ESC
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInformation("邮件:{Text}", "没有邮件奖励");
|
||||
}
|
||||
|
||||
ra.Dispose();
|
||||
|
||||
// 关闭
|
||||
await _returnMainUiTask.Start(ct);
|
||||
}
|
||||
}
|
@ -566,7 +566,10 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
// Task.Run(async () => { await artifactSalvageTask.Start(4, new CancellationToken()); });
|
||||
|
||||
// 领取纪行奖励
|
||||
Task.Run(async () => { await new ClaimBattlePassRewardsTask().Start(new CancellationToken()); });
|
||||
// Task.Run(async () => { await new ClaimBattlePassRewardsTask().Start(new CancellationToken()); });
|
||||
|
||||
// 领取邮件奖励
|
||||
Task.Run(async () => { await new ClaimMailRewardsTask().Start(new CancellationToken()); });
|
||||
}
|
||||
));
|
||||
debugDirectory.Children.Add(new HotKeySettingModel(
|
||||
|
@ -34,7 +34,7 @@ public partial class OneDragonFlowViewModel : ObservableObject, INavigationAware
|
||||
// new OneDragonTaskItem(typeof(SereniteaPotViewModel)), // 领取尘歌壶奖励
|
||||
// new OneDragonTaskItem(typeof(TcgViewModel)), // 自动七圣召唤
|
||||
|
||||
new OneDragonTaskItem("领取邮件", async () => { await Task.Delay(100); }),
|
||||
new OneDragonTaskItem("领取邮件", async () => { await new ClaimMailRewardsTask().Start(CancellationContext.Instance.Cts.Token); }),
|
||||
new OneDragonTaskItem("合成树脂", async () =>
|
||||
{
|
||||
await new GoToCraftingBenchTask()
|
||||
|
Loading…
Reference in New Issue
Block a user