private async void ExportDeck(Deck deck)
		{
			var export = true;
			if(Config.Instance.ShowExportingDialog)
			{
				var message =
					string.Format(
					              "1) create a new, empty {0}-Deck {1}.\n\n2) leave the deck creation screen open.\n\n3)do not move your mouse or type after clicking \"export\"",
					              deck.Class, (Config.Instance.AutoClearDeck ? "(or open an existing one to be cleared automatically)" : ""));

				if(deck.GetSelectedDeckVersion().Cards.Any(c => c.Name == "Stalagg" || c.Name == "Feugen"))
				{
					message +=
						"\n\nIMPORTANT: If you own golden versions of Feugen or Stalagg please make sure to configure\nOptions > Other > Exporting";
				}

				var settings = new MetroDialogSettings {AffirmativeButtonText = "export"};
				var result =
					await
					this.ShowMessageAsync("Export " + deck.Name + " to Hearthstone", message, MessageDialogStyle.AffirmativeAndNegative, settings);
				export = result == MessageDialogResult.Affirmative;
			}
			if(export)
			{
				var controller = await this.ShowProgressAsync("Creating Deck", "Please do not move your mouse or type.");
				Topmost = false;
				await Task.Delay(500);
				await DeckExporter.Export(deck);
				await controller.CloseAsync();

				if(deck.MissingCards.Any())
					this.ShowMissingCardsMessage(deck);
			}
		}
		public void UpdateDeckList(Deck selected)
		{
			ListViewDeck.ItemsSource = null;
			if(selected == null)
				return;
			ListViewDeck.ItemsSource = selected.GetSelectedDeckVersion().Cards;
			Helper.SortCardCollection(ListViewDeck.Items, Config.Instance.CardSortingClassFirst);
		}
예제 #3
0
 public static void SetPremadeDeck(Deck deck)
 {
     PlayerDeck.Clear();
     foreach (var card in deck.GetSelectedDeckVersion().Cards)
     {
         PlayerDeck.Add((Card)card.Clone());
     }
     IsUsingPremade = true;
 }
예제 #4
0
 public void SetPremadeDeck(Deck deck)
 {
     foreach (var card in deck.GetSelectedDeckVersion().Cards)
     {
         for (var i = 0; i < card.Count; i++)
         {
             Player.RevealDeckCard(card.Id, -1);
         }
     }
     IsUsingPremade = true;
 }
		public void SetDeck(Deck deck)
		{
			if(deck == null)
			{
				ClearDeck();
				return;
			}
			_deck = deck;
			deck.GetSelectedDeckVersion().Cards.CollectionChanged += (sender, args) => UpdateValues();
			UpdateValues();
		}
		public void SetDeck(Deck deck)
		{
			if(deck == null)
			{
				ClearDeck();
				return;
			}
			_deck = deck;
			deck.GetSelectedDeckVersion().Cards.CollectionChanged += (sender, args) => UpdateValues();
			UpdateValues();
			ItemsControlMechanics.ItemsSource = deck.Mechanics;
		}
		public void SetDeck(Deck deck)
		{
			if(deck == null)
			{
				ClearDeck();
				TextBlockNoMechanics.Visibility = Visible;
				return;
			}
			_deck = deck;
			deck.GetSelectedDeckVersion().Cards.CollectionChanged += (sender, args) => UpdateValues();
			UpdateValues();
			ItemsControlMechanics.ItemsSource = deck.Mechanics;
			TextBlockNoMechanics.Visibility = deck.Mechanics.Any() ? Collapsed : Visible;
		}
		public static async Task<bool> ShowAddGameDialog(this MetroWindow window, Deck deck)
		{
			if(deck == null)
				return false;
			var dialog = new AddGameDialog(deck);
			await window.ShowMetroDialogAsync(dialog, new MetroDialogSettings {AffirmativeButtonText = "save", NegativeButtonText = "cancel"});
			var game = await dialog.WaitForButtonPressAsync();
			await window.HideMetroDialogAsync(dialog);
			if(game == null)
				return false;
			deck.DeckStats.AddGameResult(game);
			if(Config.Instance.HearthStatsAutoUploadNewGames)
			{
				if(game.GameMode == GameMode.Arena)
					HearthStatsManager.UploadArenaMatchAsync(game, deck, true, true);
				else
					HearthStatsManager.UploadMatchAsync(game, deck.GetSelectedDeckVersion(), true, true);
			}
			DeckStatsList.Save();
			Core.MainWindow.DeckPickerList.UpdateDecks(forceUpdate: new[] {deck});
			return true;
		}
예제 #9
0
 private static List <IGrouping <string, Entity> > GetMissingCards(List <IGrouping <string, Entity> > revealed, Deck deck) =>
 revealed.Where(x => !deck.GetSelectedDeckVersion().Cards.Any(c => c.Id == x.Key && c.Count >= x.Count())).ToList();
예제 #10
0
		public static void SetPremadeDeck(Deck deck)
		{
			PlayerDeck.Clear();
			foreach(var card in deck.GetSelectedDeckVersion().Cards)
				PlayerDeck.Add((Card)card.Clone());
			IsUsingPremade = true;
		}
		public void SetNewDeck(Deck deck, bool editing = false)
		{
			if(deck != null)
			{
				ClearNewDeckSection();
				SelectDeck(null, false);
				EditingDeck = editing;
				if(editing)
				{
					editedDeckName = deck.Name;
					_originalDeck = deck;
				}
				_newDeck = (Deck)deck.Clone();

				_newDeck.Cards.Clear();
				foreach(var card in deck.GetSelectedDeckVersion().Cards)
					_newDeck.Cards.Add(card.Clone() as Card);
				_newDeck.SelectedVersion = _newDeck.Version;
				UpdateExpansionIcons();

				ListViewDeck.ItemsSource = _newDeck.Cards;
				Helper.SortCardCollection(ListViewDeck.ItemsSource, false);
				TextBoxDeckName.Text = _newDeck.Name;
				UpdateDeckHistoryPanel(deck, !editing);
				UpdateDbListView();
				ExpandNewDeck();
				UpdateCardCount();
				ManaCurveMyDecks.SetDeck(_newDeck);
			}
		}
예제 #12
0
		public void SetPremadeDeck(Deck deck)
		{
			foreach(var card in deck.GetSelectedDeckVersion().Cards)
			{
				for(var i = 0; i < card.Count; i++)
					Player.RevealDeckCard(card.Id, -1);
			}
			IsUsingPremade = true;
		}
		public void SetNewDeck(Deck deck, bool editing = false)
		{
			if(deck == null)
				return;
			ClearNewDeckSection();
			SelectDeck(null, false);
			EditingDeck = editing;
			if(editing)
			{
				_editedDeckName = deck.Name;
				_originalDeck = deck;
			}
			_newDeck = (Deck)deck.Clone();

			_newDeck.Cards.Clear();
			foreach(var card in deck.GetSelectedDeckVersion().Cards)
				_newDeck.Cards.Add(card.Clone() as Card);
			_newDeck.SelectedVersion = _newDeck.Version;
			UpdateExpansionIcons();

			ListViewDeck.ItemsSource = _newDeck.Cards;
			Helper.SortCardCollection(ListViewDeck.ItemsSource, false);
			TextBoxDeckName.Text = _newDeck.Name;
			BorderConstructedCardLimits.Visibility = _newDeck.IsArenaDeck ? Collapsed : Visible;
			CheckBoxConstructedCardLimits.IsChecked = true;
			UpdateDeckHistoryPanel(deck, !editing);
			UpdateDbListView();
			ExpandNewDeck();
			UpdateCardCount();
			ManaCurveMyDecks.SetDeck(_newDeck);
		}
		/// <summary>
		/// Returns true if Hearthstone lost focus in the process
		/// </summary>
		public static async Task<bool> CreateDeck(Deck deck, ExportingInfo info)
		{
			Log.Info("Creating deck...");
			deck.MissingCards.Clear();
			foreach(var card in deck.GetSelectedDeckVersion().Cards.ToSortedCardList())
			{
				var missingCardsCount = await AddCardToDeck(card, info);
				if(missingCardsCount < 0)
					return true;
				if(missingCardsCount > 0)
				{
					var missingCard = (Card)card.Clone();
					missingCard.Count = missingCardsCount;
					deck.MissingCards.Add(missingCard);
				}
			}
			Log.Info(deck.MissingCards.Count + " missing cards");
			if(deck.MissingCards.Any())
				DeckList.Save();
			return false;
		}