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


C# Stats.GameStats类代码示例

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


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

示例1: AddGameDialog

		public AddGameDialog(GameStats game)
		{
			InitializeComponent();
			_tcs = new TaskCompletionSource<GameStats>();
			_editing = true;
			_game = game;
			if(game == null)
				return;
			ComboBoxResult.SelectedItem = game.Result;
			HeroClass heroClass;
			if(Enum.TryParse(game.OpponentHero, out heroClass))
				ComboBoxOpponent.SelectedItem = heroClass;
			ComboBoxMode.SelectedItem = game.GameMode;
			ComboBoxRegion.SelectedItem = game.Region;
			if(game.GameMode == GameMode.Ranked)
				TextBoxRank.Text = game.Rank.ToString();
			TextBoxRank.IsEnabled = game.GameMode == GameMode.Ranked;
			ComboBoxCoin.SelectedItem = game.Coin ? YesNo.Yes : YesNo.No;
			ComboBoxConceded.SelectedItem = game.WasConceded ? YesNo.Yes : YesNo.No;
			TextBoxTurns.Text = game.Turns.ToString();
			TextBoxDuration.Text = game.Duration;
			TextBoxDuration.IsEnabled = false;
			TextBoxNote.Text = game.Note;
			TextBoxOppName.Text = game.OpponentName;
			BtnSave.Content = "save";
		}
开发者ID:karimsah,项目名称:Hearthstone-Deck-Tracker,代码行数:26,代码来源:AddGameDialog.xaml.cs

示例2: Upload

		public static async Task<bool> Upload(string[] logLines, GameMetaData gameMetaData, GameStats game)
		{
			var log = string.Join(Environment.NewLine, logLines);
			var item = new UploaderItem(log.GetHashCode());
			if(InProgress.Contains(item))
			{
				Log.Info($"{item.Hash} already in progress. Waiting for it to complete...");
				InProgress.Add(item);
				return await item.Success;
			}
			InProgress.Add(item);
			Log.Info($"Uploading {item.Hash}...");
			var success = false;
			try
			{
				success = await TryUpload(logLines, gameMetaData, game, true);
			}
			catch(Exception ex)
			{
				Log.Error(ex);
				Influx.OnGameUploadFailed();
			}
			Log.Info($"{item.Hash} complete. Success={success}");
			foreach(var waiting in InProgress.Where(x => x.Hash == item.Hash))
				waiting.Complete(success);
			InProgress.RemoveAll(x => x.Hash == item.Hash);
			return success;
		}
开发者ID:irufus,项目名称:Hearthstone-Deck-Tracker,代码行数:28,代码来源:LogUploader.cs

示例3: Apply

 public string Apply(GameStats game)
 {
     var name = "";
     foreach(var token in Pattern)
     {
         var tokenLower = token.ToLower();
         if(tokenLower == "{playerclass}")
         {
             name += game.PlayerHero;
         }
         else if(tokenLower == "{opponentclass}")
         {
             name += game.OpponentHero;
         }
         else if(tokenLower == "{playername}")
         {
             name += game.PlayerName;
         }
         else if(tokenLower == "{opponentname}")
         {
             name += game.OpponentName;
         }
         else if(tokenLower.Contains("{date:"))
         {
             name += ParseDate(token);
         }
         else
         {
             name += token;
         }
     }
     return name;
 }
开发者ID:eefret,项目名称:hdt-plugin-endgame,代码行数:33,代码来源:NamingPattern.cs

示例4: AddGameDialog

		public AddGameDialog(GameStats game)
		{
			InitializeComponent();
			_tcs = new TaskCompletionSource<GameStats>();
			_editing = true;
			_game = game;
			if(game == null)
				return;
			ComboBoxResult.SelectedItem = game.Result;
			HeroClass heroClass;
			if(!string.IsNullOrWhiteSpace(game.OpponentHero) && Enum.TryParse(game.OpponentHero, out heroClass))
				ComboBoxOpponent.SelectedItem = heroClass;
			ComboBoxMode.SelectedItem = game.GameMode;
			ComboBoxFormat.SelectedItem = game.Format;
			ComboBoxRegion.SelectedItem = game.Region;
			if(game.GameMode == Ranked)
			{
				TextBoxRank.Text = game.Rank.ToString();
				TextBoxLegendRank.Text = game.LegendRank.ToString();
			}
			PanelRank.Visibility = PanelLegendRank.Visibility = game.GameMode == Ranked ? Visible : Collapsed;
			PanelFormat.Visibility = game.GameMode == Ranked || game.GameMode == Casual ? Visible : Collapsed;
			ComboBoxCoin.SelectedItem = game.Coin ? Yes : No;
			ComboBoxConceded.SelectedItem = game.WasConceded ? Yes : No;
			TextBoxTurns.Text = game.Turns.ToString();
			TextBoxDuration.Text = game.Duration;
			TextBoxDuration.IsEnabled = false;
			TextBoxNote.Text = game.Note;
			TextBoxOppName.Text = game.OpponentName;
			TextBoxPlayerName.Text = game.PlayerName;
			BtnSave.Content = "save";
			Title = "Edit game";
		}
开发者ID:ChuckJrster,项目名称:Hearthstone-Deck-Tracker,代码行数:33,代码来源:AddGameDialog.xaml.cs

示例5: TryUpload

		private static async Task<bool> TryUpload(string[] logLines, GameMetaData gameMetaData, GameStats game, bool submitFailure)
		{
			try
			{
				game?.HsReplay.UploadTry();
				Influx.OnGameUpload(game?.HsReplay.UploadTries ?? 1);
				var lines = logLines.SkipWhile(x => !x.Contains("CREATE_GAME")).ToArray();
				var metaData = UploadMetaDataGenerator.Generate(lines, gameMetaData, game);
				Log.Info("Creating upload request...");
				var uploadRequest = await ApiWrapper.CreateUploadRequest(metaData);
				Log.Info("Upload Id: " + uploadRequest.ShortId);
				await ApiWrapper.UploadLog(uploadRequest, lines);
				Log.Info("Upload complete");
				if(game != null)
				{
					game.HsReplay.UploadId = uploadRequest.ShortId;
					game.HsReplay.ReplayUrl = uploadRequest.ReplayUrl;
					if(DefaultDeckStats.Instance.DeckStats.Any(x => x.DeckId == game.DeckId))
						DefaultDeckStats.Save();
					else
						DeckStatsList.Save();
				}
				return true;
			}
			catch(WebException ex)
			{
				Log.Error(ex);
				if(submitFailure)
					Influx.OnGameUploadFailed(ex.Status);
				return false;
			}
		}
开发者ID:irufus,项目名称:Hearthstone-Deck-Tracker,代码行数:32,代码来源:LogUploader.cs

示例6: ShowDeleteGameStatsMessage

		public static async Task<MessageDialogResult> ShowDeleteGameStatsMessage(MetroWindow window, GameStats stats)
		{
			var settings = new MetroDialogSettings {AffirmativeButtonText = "Yes", NegativeButtonText = "No"};
			return
				await
				window.ShowMessageAsync("Delete Game",
				                        stats.Result + " vs " + stats.OpponentHero + "\nfrom " + stats.StartTime + "\n\nAre you sure?",
				                        MessageDialogStyle.AffirmativeAndNegative, settings);
		}
开发者ID:hertzg,项目名称:Hearthstone-Deck-Tracker,代码行数:9,代码来源:MessageDialogs.cs

示例7: ShowDeleteGameStatsMessage

		//LocUtil.Get()}

		public static async Task<MessageDialogResult> ShowDeleteGameStatsMessage(this MetroWindow window, GameStats stats)
			=> await window.ShowMessageAsync(LocUtil.Get(LocDeleteGameStatsTitle),
				stats + Environment.NewLine + Environment.NewLine + LocUtil.Get(LocDeleteGameStatsSure),
				AffirmativeAndNegative,
				new Settings
				{
					AffirmativeButtonText = LocUtil.Get(LocDeleteGameStatsButtonDelete),
					NegativeButtonText = LocUtil.Get(LocDeleteGameStatsButtonCancel)
				});
开发者ID:irufus,项目名称:Hearthstone-Deck-Tracker,代码行数:11,代码来源:MessageDialogs.cs

示例8: NoteDialog

		public NoteDialog(GameStats game)
		{
			InitializeComponent();
			_game = game;
			CheckBoxEnterToSave.IsChecked = Config.Instance.EnterToSaveNote;
			Show();
			Activate();
			TextBoxNote.Focus();
			_initialized = true;
		}
开发者ID:christopher7694,项目名称:Hearthstone-Deck-Tracker,代码行数:10,代码来源:NoteDialog.xaml.cs

示例9: CreateGame

        public static GameStats CreateGame(Guid deck, Region region, GameMode mode, int days)
        {
            var game = new GameStats(GameResult.Win, "Mage", "Mage");
            game.DeckId = deck;
            game.Region = region;
            game.GameMode = mode;
            game.StartTime = DateTime.Now.Subtract(TimeSpan.FromDays(days));

            return game;
        }
开发者ID:ChuckFork,项目名称:hdt-plugin-statsconverter,代码行数:10,代码来源:TestHelper.cs

示例10: NoteDialog

        public NoteDialog(GameStats game, List<Image> screenshots)
        {
            InitializeComponent();
            _game = game;
            CheckBoxEnterToSave.IsChecked = Config.Instance.EnterToSaveNote;
            Show();
            Activate();
            TextBoxNote.Focus();

            ListBox_Images.DataContext = screenshots;

            _initialized = true;
        }
开发者ID:eefret,项目名称:hdt-plugin-endgame,代码行数:13,代码来源:NoteDialog.xaml.cs

示例11: NoteDialog

		public NoteDialog(GameStats game)
		{
			InitializeComponent();
			_game = game;
			CheckBoxEnterToSave.IsChecked = Config.Instance.EnterToSaveNote;
			TextBoxNote.Text = game.Note;
			DeckList.ItemsSource = game.OpponentCards
				.Select(x => new NoteCard(x))
				.OrderBy(x => x.Cost);
			Show();
			Activate();
			TextBoxNote.Focus();
			_initialized = true;
		}
开发者ID:irufus,项目名称:Hearthstone-Deck-Tracker,代码行数:14,代码来源:NoteDialog.xaml.cs

示例12: ShowGameResultToast

		internal static void ShowGameResultToast(string deckName, GameStats game)
		{
			if(game == null)
				return;
			var result = new ToastHelper(new GameResultToast(deckName, game));
			if(Config.Instance.ShowReplayShareToast)
			{
				var replay = new ToastHelper(new ReplayToast(game));
				GameResultToasts.Add(replay, result);
				ShowToast(result);
				ShowToast(replay);
			}
			else
				ShowToast(result);
		}
开发者ID:irufus,项目名称:Hearthstone-Deck-Tracker,代码行数:15,代码来源:ToastManager.cs

示例13: SaveImage

		public static void SaveImage(GameStats game, Image screenshot, String note = null)
		{
			if(game != null)
			{
				if (!String.IsNullOrEmpty(note))
					game.Note = note;
				DeckStatsList.Save();

				if(Config.Instance.StatsInWindow)
				{
					((DeckStatsControl)Helper.MainWindow.StatsWindow.FindName("StatsControl")).Refresh();
				}
				else
				{
					((DeckStatsControl)Helper.MainWindow.FindName("DeckStatsFlyout")).Refresh();
				}

				if(screenshot != null)
				{
					try
					{
						var dir = Settings.Default.OutputDir;
						if(!Directory.Exists(dir))
						{
							dir = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
						}
						var pattern = Settings.Default.FileNamePattern;
						NamingPattern np = null;
						if(!NamingPattern.TryParse(pattern, out np))
							Logger.WriteLine("Invalid file name pattern, using default", "EndGame");
						var filename = np.Apply(game);
						SaveAsPng(screenshot.Full, Path.Combine(dir, filename));
					}
					catch(Exception e)
					{
						Logger.WriteLine("Error saving image: " + e.Message, "EndGame");
					}
				}
				else
				{
					Logger.WriteLine("Screenshot is null", "EndGame");
				}
			}
			else
			{
				Logger.WriteLine("Game is null", "EndGame");
			}
		}
开发者ID:eefret,项目名称:hdt-plugin-endgame,代码行数:48,代码来源:Capture.cs

示例14: ShowReplay

		public static async Task<bool> ShowReplay(GameStats game, bool showToast)
		{
			if(game == null)
				return false;
			if(Config.Instance.ForceLocalReplayViewer)
			{
				ReplayReader.LaunchReplayViewer(game.ReplayFile, false);
				return true;
			}
			Action<ReplayProgress> setToastStatus = null;
			if(game.HasReplayFile && !game.HsReplay.Uploaded)
			{
				if(showToast)
					setToastStatus = ToastManager.ShowReplayProgressToast();
				var log = GetLogFromHdtReplay(game.ReplayFile).ToArray();
				var validationResult = LogValidator.Validate(log);
				if(validationResult.IsValid)
					await LogUploader.Upload(log, null, game);
				else
				{
					Log.Error("Invalid log: " + validationResult.Reason);
					game.HsReplay.Unsupported = true;
				}
				if(DefaultDeckStats.Instance.DeckStats.Any(x => x.DeckId == game.DeckId))
					DefaultDeckStats.Save();
				else
					DeckStatsList.Save();
			}
			if(game.HsReplay?.Uploaded ?? false)
			{
				setToastStatus?.Invoke(ReplayProgress.Complete);
				Helper.TryOpenUrl(game.HsReplay?.Url);
			}
			else if(game.HasReplayFile)
			{
				setToastStatus?.Invoke(ReplayProgress.Error);
				ReplayReader.LaunchReplayViewer(game.ReplayFile, true);
			}
			else
			{
				setToastStatus?.Invoke(ReplayProgress.Error);
				return false;
			}
			return true;
		}
开发者ID:irufus,项目名称:Hearthstone-Deck-Tracker,代码行数:45,代码来源:ReplayLauncher.cs

示例15: Generate

		public static UploadMetaData Generate(string[] log, GameMetaData gameMetaData, GameStats game)
		{
			var metaData = new UploadMetaData();
			var playerInfo = GetPlayerInfo(log, game);
			if(playerInfo != null)
			{
				metaData.Player1 = playerInfo.Player1;
				metaData.Player2 = playerInfo.Player2;
			}
			if(!string.IsNullOrEmpty(gameMetaData?.ServerInfo?.Address))
				metaData.ServerIp = gameMetaData.ServerInfo.Address;
			if(gameMetaData?.ServerInfo?.Port > 0)
				metaData.ServerPort = gameMetaData.ServerInfo.Port.ToString();
			if(gameMetaData?.ServerInfo?.GameHandle > 0)
				metaData.GameHandle = gameMetaData.ServerInfo.GameHandle.ToString();
			if(gameMetaData?.ServerInfo?.ClientHandle > 0)
				metaData.ClientHandle = gameMetaData.ServerInfo.ClientHandle.ToString();
			if(!string.IsNullOrEmpty(gameMetaData?.ServerInfo?.SpectatorPassword))
				metaData.SpectatePassword = gameMetaData.ServerInfo.SpectatorPassword;
			if(!string.IsNullOrEmpty(gameMetaData?.ServerInfo?.AuroraPassword))
				metaData.AuroraPassword = gameMetaData.ServerInfo.AuroraPassword;
			if(!string.IsNullOrEmpty(gameMetaData?.ServerInfo?.Version))
				metaData.ServerVersion = gameMetaData.ServerInfo.Version;
			if(game?.StartTime > DateTime.MinValue)
				metaData.MatchStart = game.StartTime.ToString("o");
			if(game != null)
				metaData.GameType = game.GameType != GameType.GT_UNKNOWN ? (int)HearthDbConverter.GetBnetGameType(game.GameType, game.Format) : (int)HearthDbConverter.GetGameType(game.GameMode, game.Format);
			if(game?.Format != null)
				metaData.Format = (int)HearthDbConverter.GetFormatType(game.Format);
			metaData.SpectatorMode = game?.GameMode == GameMode.Spectator;
			metaData.Reconnected = gameMetaData?.Reconnected ?? false;
			metaData.Resumable = gameMetaData?.ServerInfo?.Resumable ?? false;
			metaData.FriendlyPlayerId = game?.FriendlyPlayerId > 0 ? game.FriendlyPlayerId : (playerInfo?.FriendlyPlayerId > 0 ? playerInfo?.FriendlyPlayerId : null);
			var scenarioId = game?.ScenarioId ?? gameMetaData?.ServerInfo?.Mission;
			if(scenarioId > 0)
				metaData.ScenarioId = scenarioId;
			var build = gameMetaData?.HearthstoneBuild ?? game?.HearthstoneBuild ?? (game != null ? BuildDates.GetByDate(game.StartTime) : null);
			if(build > 0)
				metaData.HearthstoneBuild = build;
			if(game?.BrawlSeasonId > 0)
				metaData.BrawlSeason = game.BrawlSeasonId;
			if(game?.RankedSeasonId > 0)
				metaData.LadderSeason = game.RankedSeasonId;
			return metaData;
		}
开发者ID:irufus,项目名称:Hearthstone-Deck-Tracker,代码行数:45,代码来源:UploadMetaDataGenerator.cs


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