Skip to content

Commit 2ebb97a

Browse files
committed
fix use hero res not work
1 parent bb028a1 commit 2ebb97a

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

MainCore/Tasks/Sim/UpgradeBuilding.cs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private void UpgradeAds(PlanTask buildingTask)
175175
var nodeNotShowAgainConfirm = html.DocumentNode.SelectSingleNode("//input[@name='adSalesVideoInfoScreen']");
176176
if (nodeNotShowAgainConfirm is not null)
177177
{
178-
var elements = chrome.FindElements(By.XPath(nodeNotShowAgainConfirm.XPath));
178+
var elements = chrome.FindElements(By.XPath(nodeNotShowAgainConfirm.ParentNode.XPath));
179179
elements[0].Click();
180180
chrome.ExecuteScript("jQuery(window).trigger('showVideoWindowAfterInfoScreen')");
181181
}
@@ -229,23 +229,19 @@ private void UpgradeAds(PlanTask buildingTask)
229229

230230
{
231231
var wait = _chromeBrowser.GetWait();
232-
try
233-
{
234-
wait.Until(driver => driver.Url.Contains("dorf"));
235-
wait.Until(driver => ((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState").Equals("complete"));
236-
}
237-
catch
232+
wait.Until(driver => driver.Url.Contains("dorf"));
233+
wait.Until(driver => ((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState").Equals("complete"));
234+
235+
html = _chromeBrowser.GetHtml();
236+
if (html.GetElementbyId("dontShowThisAgain") is not null)
238237
{
239-
html = _chromeBrowser.GetHtml();
240-
if (html.GetElementbyId("dontShowThisAgain") is not null)
241-
{
242-
var dontshowthisagain = chrome.FindElements(By.Id("dontShowThisAgain"));
243-
dontshowthisagain[0].Click();
244-
Thread.Sleep(800);
245-
var dialogbuttonok = chrome.FindElements(By.ClassName("dialogButtonOk"));
246-
dialogbuttonok[0].Click();
247-
}
238+
var dontshowthisagain = chrome.FindElements(By.Id("dontShowThisAgain"));
239+
dontshowthisagain[0].Click();
240+
Thread.Sleep(800);
241+
var dialogbuttonok = chrome.FindElements(By.ClassName("dialogButtonOk"));
242+
dialogbuttonok[0].Click();
248243
}
244+
249245
}
250246
}
251247

TravianOfficialNewHeroUICore/FindElements/HeroPage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static HtmlNode GetItemSlot(HtmlDocument doc, int type)
3333

3434
foreach (var itemSlot in heroItemDivs)
3535
{
36-
if (itemSlot.ChildNodes.Count != 2) continue;
36+
if (itemSlot.ChildNodes.Count < 2) continue;
3737
var itemNode = itemSlot.ChildNodes[1];
3838
var classes = itemNode.GetClasses();
3939
if (classes.Count() != 2) continue;
@@ -43,7 +43,7 @@ public static HtmlNode GetItemSlot(HtmlDocument doc, int type)
4343
var itemValueStr = new string(itemValue.Where(c => char.IsDigit(c)).ToArray());
4444
if (string.IsNullOrEmpty(itemValueStr)) continue;
4545

46-
if (int.Parse(itemValueStr) == type) return itemNode;
46+
if (int.Parse(itemValueStr) == type) return itemSlot;
4747
}
4848
return null;
4949
}

TravianOfficialNewHeroUICore/Parsers/HeroInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static int GetAdventureNum(HtmlDocument doc)
6161

6262
foreach (var itemSlot in heroItemDivs)
6363
{
64-
if (itemSlot.ChildNodes.Count != 2) continue;
64+
if (itemSlot.ChildNodes.Count < 2) continue;
6565
var itemNode = itemSlot.ChildNodes[1];
6666
var classes = itemNode.GetClasses();
6767
if (classes.Count() != 2) continue;
@@ -74,7 +74,7 @@ public static int GetAdventureNum(HtmlDocument doc)
7474

7575
if (itemSlot.GetAttributeValue("data-tier", "").Contains("consumable"))
7676
{
77-
if (itemSlot.ChildNodes.Count != 3)
77+
if (itemSlot.ChildNodes.Count < 3)
7878
{
7979
heroItems.Add((int.Parse(itemValueStr), 1));
8080
continue;

0 commit comments

Comments
 (0)