Skip to content

Commit eb46b8b

Browse files
committed
fix reading hero health
1 parent b76b4ca commit eb46b8b

File tree

3 files changed

+12
-25
lines changed

3 files changed

+12
-25
lines changed

TbsCore/Helpers/NavigationHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public static async Task<bool> ToHero(Account acc, HeroTab tab)
287287
{
288288
var wait = new WebDriverWait(acc.Wb.Driver, TimeSpan.FromMinutes(1));
289289

290-
if (!acc.Wb.CurrentUrl.Contains("hero"))
290+
if (!(acc.Wb.CurrentUrl.Contains("hero/inventory") || acc.Wb.CurrentUrl.Contains("hero/attributes") || acc.Wb.CurrentUrl.Contains("hero/appearance")))
291291
{
292292
var heroAvatarNode = acc.Wb.Html.GetElementbyId("heroImageButton");
293293

TbsCore/Parsers/HeroParser.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,18 @@ public static int GetHeroHealth(HtmlDocument htmlDoc)
184184
var path = htmlDoc.GetElementbyId("healthMask").Descendants("path").FirstOrDefault();
185185
if (path == null) return 0;
186186
var commands = path.GetAttributeValue("d", "").Split(' ');
187-
var xx = double.Parse(commands[commands.Length - 2], System.Globalization.CultureInfo.InvariantCulture);
188-
var yy = double.Parse(commands[commands.Length - 1], System.Globalization.CultureInfo.InvariantCulture);
187+
try
188+
{
189+
var xx = double.Parse(commands[commands.Length - 2], System.Globalization.CultureInfo.InvariantCulture);
190+
var yy = double.Parse(commands[commands.Length - 1], System.Globalization.CultureInfo.InvariantCulture);
189191

190-
var rad = Math.Atan2(yy - 55, xx - 55);
191-
return (int)Math.Round(-56.173 * rad + 96.077);
192+
var rad = Math.Atan2(yy - 55, xx - 55);
193+
return (int)Math.Round(-56.173 * rad + 96.077);
194+
}
195+
catch
196+
{
197+
return 100;
198+
}
192199
}
193200

194201
/// <summary>

TbsWinformNet6/Views/HeroUc.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -257,26 +257,6 @@ private void button7_Click(object sender, EventArgs e)
257257

258258
private void autoAuction_CheckedChanged(object sender, EventArgs e)
259259
{
260-
var acc = GetSelectedAcc();
261-
acc.Hero.Settings.AutoAuction = autoAuction.Checked;
262-
TbsCore.Tasks.BotTask task = acc.Tasks.FindTask(typeof(SellOnAuctions));
263-
if (autoAuction.Checked)
264-
{
265-
if (task == null)
266-
{
267-
acc.Tasks.Add(new SellOnAuctions()
268-
{
269-
ExecuteAt = DateTime.Now,
270-
});
271-
}
272-
}
273-
else
274-
{
275-
if (task != null)
276-
{
277-
acc.Tasks.Remove(task);
278-
}
279-
}
280260
}
281261
}
282262
}

0 commit comments

Comments
 (0)