Skip to content

Commit 3b3ac00

Browse files
committed
处理刷取次数过多的情况
1 parent 8799f34 commit 3b3ac00

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

BetterGenshinImpact/GameTask/AutoDomain/AutoDomainTask.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,11 +1025,12 @@ private async Task<bool> GettingTreasure()
10251025
// res.Click();
10261026
return true;
10271027
}
1028+
10281029
return false;
10291030
}, _ct, 10, 500);
10301031
Debug.WriteLine("识别到选择树脂页");
10311032
await Delay(800, _ct);
1032-
1033+
10331034
// 再 OCR 一次,弹出框,确认当前是否有原粹树脂
10341035
using var ra2 = CaptureToRectArea();
10351036
var textListInPrompt = ra2.FindMulti(RecognitionObject.Ocr(ra2.Width * 0.25, ra2.Height * 0.2, ra2.Width * 0.5, ra2.Height * 0.6));
@@ -1047,6 +1048,7 @@ private async Task<bool> GettingTreasure()
10471048

10481049
if (!_taskParam.SpecifyResinUse)
10491050
{
1051+
// 自动刷干树脂
10501052
// 识别树脂状况
10511053
var resinStatus = ResinStatus.RecogniseFromRegion(ra3);
10521054
resinStatus.Print(Logger);
@@ -1070,8 +1072,10 @@ private async Task<bool> GettingTreasure()
10701072
}
10711073
else
10721074
{
1075+
// 指定使用树脂
10731076
var textListInPrompt2 = ra3.FindMulti(RecognitionObject.Ocr(ra3.Width * 0.25, ra3.Height * 0.2, ra3.Width * 0.5, ra3.Height * 0.6));
10741077
// 按优先级使用
1078+
var failCount = 0;
10751079
foreach (var record in _resinPriorityListWhenSpecifyUse)
10761080
{
10771081
if (record.RemainCount > 0 && PressUseResin(textListInPrompt2, record.Name))
@@ -1080,13 +1084,26 @@ private async Task<bool> GettingTreasure()
10801084
Logger.LogInformation("自动秘境:{Name} 刷取 {Re}/{Max}", record.Name, record.MaxCount - record.RemainCount, record.MaxCount);
10811085
break;
10821086
}
1087+
else
1088+
{
1089+
failCount++;
1090+
}
10831091
}
10841092

10851093
if (_resinPriorityListWhenSpecifyUse.Sum(o => o.RemainCount) <= 0)
10861094
{
10871095
// 全部刷完
10881096
isLastTurn = true;
10891097
}
1098+
1099+
if (failCount == _resinPriorityListWhenSpecifyUse.Count)
1100+
{
1101+
// 没有找到对应的树脂
1102+
Logger.LogWarning("自动秘境:指定树脂领取次数时,当前可用树脂选项无法满足配置。你可能设置的刷取次数过多!退出秘境。");
1103+
Logger.LogInformation("当前刷取情况:{ResinList}", string.Join(", ", _resinPriorityListWhenSpecifyUse.Select(o => $"{o.Name}({o.MaxCount - o.RemainCount}/{o.MaxCount})")));
1104+
await ExitDomain();
1105+
return false;
1106+
}
10901107
}
10911108
}
10921109
else
@@ -1120,6 +1137,7 @@ private async Task<bool> GettingTreasure()
11201137
{
11211138
// TODO 前面没有弹框的情况下,意味着只有原粹树脂,要再识别一次右上角确认树脂余量,没有余量直接退出
11221139
}
1140+
11231141
// 有体力继续
11241142
confirmRectArea.Click();
11251143
return true;

0 commit comments

Comments
 (0)