当前位置: 首页>>代码示例>>C#>>正文


C# Deck.GetVersion方法代码示例

本文整理汇总了C#中Hearthstone_Deck_Tracker.Hearthstone.Deck.GetVersion方法的典型用法代码示例。如果您正苦于以下问题:C# Deck.GetVersion方法的具体用法?C# Deck.GetVersion怎么用?C# Deck.GetVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Hearthstone_Deck_Tracker.Hearthstone.Deck的用法示例。


在下文中一共展示了Deck.GetVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MoveGamesToOtherDeckWithoutConfirmation

		internal static void MoveGamesToOtherDeckWithoutConfirmation(Deck targetDeck, SerializableVersion targetVersion,
																	 params GameStats[] games)
		{
			if(games == null)
				return;
			foreach(var game in games)
			{
				var defaultDeck = DefaultDeckStats.Instance.DeckStats.FirstOrDefault(ds => ds.Games.Contains(game));
				if(defaultDeck != null)
				{
					defaultDeck.Games.Remove(game);
					DefaultDeckStats.Save();
				}
				else
				{
					var deck = DeckList.Instance.Decks.FirstOrDefault(d => game.DeckId == d.DeckId);
					deck?.DeckStats.Games.Remove(game);
				}
				game.PlayerDeckVersion = targetVersion;
				game.HearthStatsDeckVersionId = targetDeck.GetVersion(targetVersion).HearthStatsDeckVersionId;
				game.DeckId = targetDeck.DeckId;
				game.DeckName = targetDeck.Name;
				targetDeck.DeckStats.Games.Add(game);
				if(HearthStatsAPI.IsLoggedIn && Config.Instance.HearthStatsAutoUploadNewGames)
					HearthStatsManager.MoveMatchAsync(game, targetDeck, background: true).Forget();
			}
			DeckStatsList.Save();
			DeckList.Save();
			Core.MainWindow.DeckPickerList.UpdateDecks();
		}
开发者ID:ChuckJrster,项目名称:Hearthstone-Deck-Tracker,代码行数:30,代码来源:GameStatsHelper.cs

示例2: UploadDeckAsync

		public static async Task<PostResult> UploadDeckAsync(Deck deck, bool saveFilesAfter = true, bool background = false)
		{
			Log.Info("trying to upload deck " + deck);
			if(!HearthStatsAPI.IsLoggedIn)
			{
				Log.Error("not logged in");
				return PostResult.Failed;
			}

			if(background)
				AddBackgroundActivity();
			var first = deck.GetVersion(1, 0);
			if(!first.IsArenaDeck && first.HasHearthStatsId && !deck.HasHearthStatsId && !deck.HearthStatsIdsAlreadyReset)
			{
				first.HearthStatsId = first.HearthStatsIdForUploading;
				await HearthStatsAPI.DeleteDeckAsync(first);
				await Task.Delay(1000);

				//reset everything
				foreach(var version in deck.VersionsIncludingSelf.Select(deck.GetVersion))
				{
					version.ResetHearthstatsIds();
					foreach(var game in version.DeckStats.Games)
					{
						game.HearthStatsDeckId = null;
						game.HearthStatsDeckVersionId = null;
						game.HearthStatsId = null;
					}
				}
			}
			var result = await HearthStatsAPI.PostDeckAsync(first, deck);
			if(!result.Success && result.Retry)
			{
				await Task.Delay(RetryDelay);
				Log.Info("try #2 to upload deck " + deck);
				result = await HearthStatsAPI.PostDeckAsync(first, deck);
			}
			if(result.Success)
			{
				var versions =
					deck.VersionsIncludingSelf.Where(v => v != new SerializableVersion(1, 0))
					    .Select(deck.GetVersion)
					    .Where(d => d != null && !d.HasHearthStatsDeckVersionId)
					    .ToList();
				if(versions.Any())
				{
					foreach(var v in versions)
					{
						await Task.Delay(VersionDelay);
						await UploadVersionAsync(v, first.HearthStatsIdForUploading, false);
					}
					deck.HearthStatsId = first.HearthStatsId;
					first.HearthStatsId = "";
					first.HearthStatsIdForUploading = deck.HearthStatsId;
				}
				if(saveFilesAfter)
					DeckList.Save();
				if(background)
					RemoveBackgroundActivity();
				Log.Info("success uploading deck " + deck);
				return PostResult.WasSuccess;
			}
			if(background)
				RemoveBackgroundActivity();
			return PostResult.Failed;
		}
开发者ID:JDurman,项目名称:Hearthstone-Deck-Tracker,代码行数:66,代码来源:HearthStatsManager.cs


注:本文中的Hearthstone_Deck_Tracker.Hearthstone.Deck.GetVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。