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


C# GameStats.GetOpponentDeck方法代码示例

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


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

示例1: ImportOpponentDeck

		private void ImportOpponentDeck(GameStats stats)
		{
			if(stats == null)
				return;
			Core.MainWindow.DeckFlyout.SetDeck(stats.GetOpponentDeck());
			Core.MainWindow.FlyoutDeck.Header = "Opponent";
			Core.MainWindow.FlyoutDeck.IsOpen = true;
			BtnOverallShowOpponentDeck.Content = BtnOpponentDeckTextHide;
			BtnShowOpponentDeck.Content = BtnOpponentDeckTextHide;
		}
开发者ID:nakaneku,项目名称:Hearthstone-Deck-Tracker,代码行数:10,代码来源:DeckStatsControl.xaml.cs

示例2: PostGameResultAsync

		public static async Task<PostResult> PostGameResultAsync(GameStats game, Deck deck)
		{
			if(!IsValidGame(game))
				return PostResult.Failed;
			if(!deck.HasHearthStatsId)
			{
				Logger.WriteLine("can not upload game, deck has no hearthstats id", "HearthStatsAPI");
				return PostResult.Failed;
			}
			long versionId;
			if(!long.TryParse(deck.HearthStatsDeckVersionId, out versionId))
			{
				Logger.WriteLine("error: invalid HearthStatsDeckVersionId", "HearthStatsAPI");
				return PostResult.Failed;
			}
			Logger.WriteLine("uploading match: " + game, "HearthStatsAPI");
			var url = BaseUrl + "/matches?auth_token=" + _authToken;

			dynamic gameObj = new ExpandoObject();
			gameObj.mode = game.GameMode.ToString();
			[email protected] = string.IsNullOrEmpty(game.PlayerHero) ? deck.Class : game.PlayerHero;
			gameObj.result = game.Result.ToString();
			gameObj.coin = game.Coin.ToString().ToLower();
			gameObj.numturns = game.Turns;
			gameObj.duration = (int)(game.EndTime - game.StartTime).TotalSeconds;
			gameObj.deck_id = deck.HearthStatsIdForUploading;
			gameObj.deck_version_id = versionId;
			if(!string.IsNullOrEmpty(game.OpponentHero))
				gameObj.oppclass = game.OpponentHero;
			if(!string.IsNullOrEmpty(game.OpponentName))
				gameObj.oppname = game.OpponentName;
			if(!string.IsNullOrEmpty(game.Note))
				gameObj.notes = game.Note;
			if(game.GameMode == GameMode.Ranked && game.HasRank)
				gameObj.ranklvl = game.Rank.ToString();
			var opponentCards = game.GetOpponentDeck().Cards;
			if(opponentCards.Where(Database.IsActualCard).Any())
				gameObj.oppcards = opponentCards.Where(Database.IsActualCard).Select(c => new {id = c.Id, count = c.Count}).ToArray();
			gameObj.created_at = game.StartTime.ToUniversalTime().ToString("s");

			var data = JsonConvert.SerializeObject(gameObj);

			try
			{
				var response = await PostAsync(url, data);
				var json = JsonConvert.DeserializeObject(response);
				if(json.status.ToString() == "200")
				{
					game.HearthStatsId = json.data.id;
					Logger.WriteLine("assigned id to match: " + game.HearthStatsId, "HearthStatsAPI");
					return PostResult.WasSuccess;
				}
				if(json.status.ToString() == "fail" && json.message.ToString().Contains("Deck could not be found"))
				{
					//deck does not exist on hearthstats
					deck.ResetHearthstatsIds();
					DeckList.Save();
					deck.DeckStats.Games.ForEach(g => g.ResetHearthstatsIds());
					DeckStatsList.Save();
				}
				return PostResult.Failed;
			}
			catch(Exception e)
			{
				Logger.WriteLine(e.ToString(), "HearthStatsAPI");
				return PostResult.Failed;
			}
		}
开发者ID:nakaneku,项目名称:Hearthstone-Deck-Tracker,代码行数:68,代码来源:HearthStatsAPI.cs


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