private static bool IsLegendRank(Bitmap bmp) { var b = HueAndBrightness.GetAverage(bmp).Brightness; var h = HueAndBrightness.GetAverage(bmp).Hue; return(b > _legendMinBrightness && h > _legendMinHue); }
// Color check to determine if it is a legend rank private static bool IsLegendRank(Bitmap bmp) { var b = HueAndBrightness.GetAverage(bmp).Brightness; var h = HueAndBrightness.GetAverage(bmp).Hue; return(b > LegendBrightness.Min && h > LegendHue.Min && b < LegendBrightness.Max && h < LegendHue.Max); }
public async Task Squelch() { if (!User32.IsHearthstoneInForeground()) { Squelched = false; return; } IntPtr hearthstoneWindow = User32.GetHearthstoneWindow(); var HsRect = User32.GetHearthstoneRect(false); var Ratio = (4.0 / 3.0) / ((double)HsRect.Width / HsRect.Height); Point opponentHeroPosition = new Point((int)Helper.GetScaledXPos(0.5, HsRect.Width, Ratio), (int)(0.17 * HsRect.Height)); Point squelchBubblePosition = new Point((int)Helper.GetScaledXPos(0.4, HsRect.Width, Ratio), (int)(0.1 * HsRect.Height)); // setting this as a "width" value relative to height, maybe not best solution? const double xScale = 0.051; // 55px @ height = 1080 const double yScale = 0.025; // 27px @ height = 1080 const double minBrightness = 0.67; var lockWidth = (int)Math.Round(HsRect.Height * xScale); var lockHeight = (int)Math.Round(HsRect.Height * yScale); bool squelchBubbleVisible = false; do { if (!PluginRunning || !GameInProgress) { Squelched = false; return; } await MouseHelpers.ClickOnPoint(hearthstoneWindow, opponentHeroPosition, false); await Task.Delay(TimeSpan.FromMilliseconds(DeckExportDelay * 4)); var capture = await ScreenCapture.CaptureHearthstoneAsync(squelchBubblePosition, lockWidth, lockHeight, hearthstoneWindow); squelchBubbleVisible = HueAndBrightness.GetAverage(capture).Brightness > minBrightness; if (!squelchBubbleVisible) { await Task.Delay(TimeSpan.FromSeconds(0.5)); } } while (!squelchBubbleVisible); await MouseHelpers.ClickOnPoint(hearthstoneWindow, squelchBubblePosition, true); }