public void Update(Card card, List <Card> cards, AnimatedCardList view, Dictionary <int, double> winrates) { for (var i = 0; i < cards.Count; i++) { if (!_winratesToCardMapping.ContainsKey(cards[i])) { var winrate = new HearthstoneTextBlock { FontSize = 18, TextAlignment = TextAlignment.Left }; if (view.Items.Count > i) { if ((view.Items.GetItemAt(i) as UserControl)?.Content is Grid grid) { grid.Width = 260; ((Hearthstone_Deck_Tracker.Controls.Card)grid.Children[0]).HorizontalAlignment = HorizontalAlignment.Right; ((Rectangle)grid.Children[1]).Width = 260; grid.Children.Add(winrate); } } _winratesToCardMapping.Add(cards[i], winrate); } winrates.TryGetValue(cards[i].DbfIf, out var winratePercentage); _winratesToCardMapping[cards[i]].Text = winratePercentage.ToString(); } }
new public bool Update(Card card) { if (!base.Update(card)) { return(false); } // Silverware Golem and Clutchmother Zaras are still counted as discarded, even when their effects trigger var count = (double)Cards.Aggregate(0, (total, c) => total + c.Count); for (var i = 0; i < Cards.Count(); i++) { if (!_chances.ContainsKey(Cards[i])) { var chance = new HearthstoneTextBlock(); chance.FontSize = 18; chance.TextAlignment = TextAlignment.Left; var grid = (View.Items.GetItemAt(i) as UserControl).Content as Grid; grid.Width = 260; (grid.Children[0] as Rectangle).HorizontalAlignment = HorizontalAlignment.Right; (grid.Children[1] as Rectangle).Width = 260; grid.Children.Add(chance); _chances.Add(Cards[i], chance); } _chances[Cards[i]].Text = $"{Math.Round(Cards[i].Count / count * 100)}%"; } return(true); }
public void Update(List <HeroInfo> heros) { Children.Clear(); var Label = new HearthstoneTextBlock(); Label.FontSize = 16; Label.Text = "Winrate %"; Label.Visibility = Visibility.Visible; Children.Add(Label); for (int i = 0; i < heros.Count; i++) { // TODO: Create a custom View for this that takes a list of HeroInfo var hero = heros[i]; Label = new HearthstoneTextBlock(); Label.FontSize = 18; var text = $"#{i+1} {hero.name} {hero.win_rate}%"; // TODO: May want to just use a table/cols instead Label.Text = text; Label.Fill = new SolidColorBrush(GetPercentageColor(hero.win_rate, 55, 45)); //var margin = Label.Margin; //margin.Top = 0; //Label.Margin = margin; Children.Add(Label); Label.Visibility = Visibility.Visible; } this.UpdatePosition(); }
public MultiTurnView(string title, int turns) { Turns = turns; Visibility = Visibility.Collapsed; Orientation = Orientation.Vertical; MinWidth = 250; // Title Label = new HearthstoneTextBlock { FontSize = 16, TextAlignment = TextAlignment.Center, Text = title, Margin = new Thickness(0, 20, 0, 0), }; Children.Add(Label); // Turn Card Lists for (int i = 0; i < Turns + 1; i++) { Views.Add(new TurnView(i == 0 ? "#" : i.ToString())); Children.Add(Views[i]); CardLists.Add(new List <Card>()); } }
public void OnLoad() { _displayBlock = new HearthstoneTextBlock { FontSize = 36, Visibility = Visibility.Collapsed }; _calculator = new DamageCalculator(); ConfigHandler(); _display = new AnyfinDisplay(_config) { Visibility = Visibility.Collapsed }; _toolTip = new CardToolTip(); _toolTipsPanel = new StackPanel(); GameEvents.OnPlayerHandMouseOver.Add(OnMouseOver); GameEvents.OnMouseOverOff.Add(OnMouseOff); GameEvents.OnGameStart.Add(OnGameStart); GameEvents.OnGameEnd.Add(OnGameEnd); GameEvents.OnOpponentPlayToGraveyard.Add(UpdateDisplay); GameEvents.OnPlayerPlayToGraveyard.Add(UpdateDisplay); GameEvents.OnPlayerPlay.Add(UpdateDisplay); GameEvents.OnOpponentPlay.Add(UpdateDisplay); DeckManagerEvents.OnDeckSelected.Add(OnGameStart); Core.OverlayCanvas.Children.Add(_display); if (!Core.Game.IsInMenu) { OnGameStart(); } }
private void ToggleAutosquelch() { AutosquelchDisabled = !AutosquelchDisabled; // Notify that plugin is active/inactive var textBlock = new HearthstoneTextBlock(); textBlock.FontSize = 14; textBlock.Text = "Autosquelch is now " + (AutosquelchDisabled ? "disabled" : "enabled"); textBlock.Loaded += SetHorizontalPosition; Canvas.SetBottom(textBlock, 50); var overlay = Core.OverlayCanvas; textBlock.HorizontalAlignment = HorizontalAlignment.Center; overlay.Children.Add(textBlock); Core.OverlayWindow.Update(false); const double notificationDurationSeconds = 1.5; Task.Delay(TimeSpan.FromSeconds(notificationDurationSeconds)).ContinueWith(_ => { Core.OverlayCanvas.Children.Remove(textBlock); Core.OverlayWindow.Update(false); }, TaskScheduler.FromCurrentSynchronizationContext()); }
public PlayPredictorList() { //InitializeComponent(); Orientation = Orientation.Vertical; // Section Label this.Label = new HearthstoneTextBlock(); Label.FontSize = 16; Label.TextAlignment = TextAlignment.Center; Label.Text = "Opponent's Next Move"; var margin = Label.Margin; margin.Top = 0; Label.Margin = margin; Children.Add(Label); Label.Visibility = Visibility.Hidden; // Card View this.View = new AnimatedCardList(); Children.Add(View); Cards = new List <Card>(); // TODO: How to enable card mouseover tooltips? }
private static void AddTextBlock() { var canvas = Hearthstone_Deck_Tracker.API.Core.OverlayCanvas; _textBlock = new HearthstoneTextBlock(); _textBlock.Text = "?"; _textBlock.FontSize = 22; PositionTextBlock(); canvas.Children.Add(_textBlock); }
public DamageInfoBox(string name = "Untitled", int position = 0) { _info = new HearthstoneTextBlock(); _info.Text = ""; _info.FontSize = 18; _info.Opacity = 0; _canvas.Children.Add(_info); Name = name; Damage = 0; Health = 0; fromTop(position); }
public void OnLoad() { damageControl = new HearthstoneTextBlock(); CoreAPI.OverlayCanvas.Children.Add(damageControl); double fromLeft = Helper.GetScaledXPos(Config.Instance.AttackIconPlayerHorizontalPosition / 100, (int)CoreAPI.OverlayCanvas.Width, (4.0 / 3.0) / (CoreAPI.OverlayCanvas.Width / CoreAPI.OverlayCanvas.Height)) + 52; double fromTop = CoreAPI.OverlayCanvas.Height * Config.Instance.AttackIconPlayerVerticalPosition / 100 + 26; Canvas.SetLeft(damageControl, fromLeft); Canvas.SetTop(damageControl, fromTop); Damage damage = new Damage(damageControl); //GameEvents.OnGameStart.Add(curvy.GameStart); GameEvents.OnInMenu.Add(damage.InMenu); GameEvents.OnTurnStart.Add(damage.TurnStart); }
public MulticasterView() { Visibility = Visibility.Collapsed; Orientation = Orientation.Vertical; Label = new HearthstoneTextBlock { FontSize = 16, TextAlignment = TextAlignment.Center, Text = Strings.GetLocalized("Multicaster"), Margin = new Thickness(0, 20, 0, 0), }; Children.Add(Label); Cards = new AnimatedCardList(); Children.Add(Cards); }
public void Update() { if (Children.Count > 0) { this.UpdatePosition(); this.Show(); return; } var label = new HearthstoneTextBlock(); label.FontSize = 18; label.Text = GetHeroControlAggroScale(); label.Visibility = Visibility.Visible; Children.Add(label); this.UpdatePosition(); this.Show(); }
public LastCardView(string title = "Last Card") { Visibility = Visibility.Collapsed; Orientation = Orientation.Vertical; // Title Label = new HearthstoneTextBlock { FontSize = 16, TextAlignment = TextAlignment.Center, Text = title, Margin = new Thickness(0, 20, 0, 0), }; Children.Add(Label); Cards = new AnimatedCardList(); Children.Add(Cards); }
public TurnView(string name) { Orientation = Orientation.Horizontal; Title = new HearthstoneTextBlock { FontSize = 24, TextAlignment = TextAlignment.Center, VerticalAlignment = VerticalAlignment.Top, MinHeight = 30, MinWidth = 30, Text = name, }; Children.Add(Title); Cards = new AnimatedCardList(); Children.Add(Cards); }
private void SetUpWinrates() { Reset(); var shortId = ShortIdHelper.GetShortId(DeckList.Instance.ActiveDeck); //check to see if shortId is in the hsreplay_decks.cache if so go get data var pos = Array.IndexOf(HsReplayDataManager.Decks.AvailableDecks, shortId); var has = pos >= 0; if (has) { _winrates = CreateWinRatesDictionary(shortId); foreach (int key in _winrates.Keys) { Mulligan.Update(new Card(Cards.GetFromDbfId(key)), _winrates); } Mulligan = new MulliganView { Label = { Visibility = Visibility.Hidden } }; var label = new HearthstoneTextBlock { FontSize = 16, TextAlignment = TextAlignment.Center, Text = "Deck Winrate: " + _deckWinrate }; var margin = label.Margin; margin.Top = 20; label.Margin = margin; Mulligan.Children.Add(label); _friendlyPanel.Children.Add(Mulligan); Mulligan.Visibility = Visibility.Visible; Mulligan.MulliganWinratesCardList.Visibility = Visibility.Visible; Mulligan.Label.Visibility = Visibility.Visible; } //foreach (var winrate in _winrates.Keys) //{ // Mulligan.Update(new Card(HearthDb.Cards.GetFromDbfId(winrate)),_winrates ); //} }
public AnyfinView() { // Section Label Label.Text = Strings.Anyfin; // Damage Label _dmg = new HearthstoneTextBlock(); _dmg.FontSize = 24; _dmg.TextAlignment = TextAlignment.Center; _dmg.Text = "0"; Children.Add(_dmg); _dmg.Visibility = Visibility.Hidden; _secondDmg = new HearthstoneTextBlock(); _secondDmg.FontSize = 24; _secondDmg.TextAlignment = TextAlignment.Center; _secondDmg.Text = "0"; Children.Add(_secondDmg); _secondDmg.Visibility = Visibility.Hidden; }
public MulliganView() { // Section Label Orientation = Orientation.Vertical; Label = new HearthstoneTextBlock { FontSize = 16, TextAlignment = TextAlignment.Center, Text = "Mulligan Winrates" }; var margin = Label.Margin; margin.Top = 20; Label.Margin = margin; Children.Add(Label); // Card View MulliganWinratesCardList = new AnimatedCardList(); Children.Add(MulliganWinratesCardList); Cards = new List <Card>(); }
public BattlecryView() { Orientation = Orientation.Vertical; Label = new HearthstoneTextBlock(); Label.FontSize = 16; Label.TextAlignment = TextAlignment.Center; Label.Text = "Played Battlecrys"; var margin = Label.Margin; margin.Top = 20; Label.Margin = margin; Children.Add(Label); Label.Visibility = Visibility.Hidden; View = new AnimatedCardList(); View.Visibility = Visibility.Visible; Children.Add(View); _history = new List <Card>(); }
public NormalView() { Orientation = Orientation.Vertical; // Section Label Label = new HearthstoneTextBlock(); Label.FontSize = 16; Label.TextAlignment = TextAlignment.Center; Label.Text = Strings.Graveyard; var margin = Label.Margin; margin.Top = 20; Label.Margin = margin; Children.Add(Label); Label.Visibility = Visibility.Hidden; // Card View View = new AnimatedCardList(); Children.Add(View); Cards = new List <Card>(); }
public void Update(Card card, List <Card> Cards, AnimatedCardList View) { var count = (double)Cards.Aggregate(0, (total, c) => total + c.Count); for (var i = 0; i < Cards.Count(); i++) { if (!_chances.ContainsKey(Cards[i])) { var chance = new HearthstoneTextBlock(); chance.FontSize = 18; chance.TextAlignment = TextAlignment.Left; var grid = (View.Items.GetItemAt(i) as UserControl).Content as Grid; grid.Width = 260; (grid.Children[0] as Hearthstone_Deck_Tracker.Controls.Card).HorizontalAlignment = HorizontalAlignment.Right; (grid.Children[1] as Rectangle).Width = 260; grid.Children.Add(chance); _chances.Add(Cards[i], chance); } _chances[Cards[i]].Text = $"{Math.Round(Cards[i].Count / count * 100)}%"; } }
public static void Load() { _player = null; // A text block using the HS font _info = new HearthstoneTextBlock(); _info.Text = ""; _info.FontSize = 18; // Get the HDT Overlay canvas object var canvas = Overlay.OverlayCanvas; // Give the text block its position within the canvas Canvas.SetTop(_info, canvas.Height / 2); Canvas.SetLeft(_info, canvas.Width / 2); // Add the text block to the canvas canvas.Children.Add(_info); // Register methods to be called when GameEvents occur GameEvents.OnGameStart.Add(NewGame); GameEvents.OnPlayerDraw.Add(HandInfo); }
public static void Load() { _player = null; //String[] fileNames = Directory.GetFiles("Sample Decks", "*.txt"); /* TODO: Add automatic deck importing of Sample Decks after newest HDT Update * foreach (String fileName in fileNames) * { * try * { * Deck deck = null; * if (fileName.EndsWith(".txt")) * { * using (var sr = new StreamReader(fileName)) * deck = Core.MainWindow.ParseCardString(sr.ReadToEnd()); * * } * else if (fileName.EndsWith(".xml")) * { * deck = XmlManager<Deck>.Load(fileName); * //not all required information is saved in xml * foreach (var card in deck.Cards) * card.Load(); * TagControlEdit.SetSelectedTags(deck.Tags); * } * SetNewDeck(deck); * if (Config.Instance.AutoSaveOnImport) * SaveDeckWithOverwriteCheck(); * } * catch (Exception ex) * { * Logger.WriteLine("Error getting deck from file: \n" + ex, "Import"); * } * }*/ // A border to put around the text block Border blockBorder = new Border(); blockBorder.BorderBrush = Brushes.Black; blockBorder.BorderThickness = new Thickness(1.0); blockBorder.Padding = new Thickness(8.0); // A text block using the HS font _info = new HearthstoneTextBlock(); _info.Text = ""; _info.FontSize = 18; // Add the text block as a child of the border element blockBorder.Child = _info; // Create an image at the corner of the text bloxk Image image = new Image(); // Create the image source BitmapImage bi = new BitmapImage(new Uri("pack://siteoforigin:,,,/Plugins/card.png")); // Set the image source image.Source = bi; // Get the HDT Overlay canvas object var canvas = Core.OverlayCanvas; // Get canvas centre var fromTop = canvas.Height / 2; var fromLeft = canvas.Width / 2; // Give the text block its position within the canvas, roughly in the center Canvas.SetTop(blockBorder, fromTop); Canvas.SetLeft(blockBorder, fromLeft); // Give the text block its position within the canvas Canvas.SetTop(image, fromTop - 12); Canvas.SetLeft(image, fromLeft - 12); // Add the text block and image to the canvas canvas.Children.Add(blockBorder); canvas.Children.Add(image); // Register methods to be called when GameEvents occur GameEvents.OnGameStart.Add(NewGame); GameEvents.OnPlayerDraw.Add(DeckInfo); GameEvents.OnGameEnd.Add(analyzeDeck); }
public Damage(HearthstoneTextBlock damageControl) { control = damageControl; }