Example #1
0
 public CurrentGameFlyoutViewModel()
 {
     if (Execute.InDesignMode)
     {
         IsRunning = true;
         WinLossRatio.Add(new StatModel("Wins", 60));
         WinLossRatio.Add(new StatModel("Losses", 40));
         WinLossRatioHero.Add(new StatModel("Wins", 0));
         WinLossRatioHero.Add(new StatModel("Losses", 0));
         WinLossRatioOpponentHero.Add(new StatModel("Wins", 50));
         WinLossRatioOpponentHero.Add(new StatModel("Losses", 50));
     }
 }
Example #2
0
        private void RefreshStats()
        {
            var   from = dateFilter.From;
            float wins;
            float losses;
            float total;

            WinLossRatio.Clear();
            if (Hero != null &&
                OpponentHero != null)
            {
                wins =
                    gameRepository.Query(
                        x => x.Count(g => g.Started > @from && g.Victory && g.Hero.Id == Hero.Id && g.OpponentHero.Id == OpponentHero.Id));
                losses =
                    gameRepository.Query(
                        x => x.Count(g => g.Started > @from && !g.Victory && g.Hero.Id == Hero.Id && g.OpponentHero.Id == OpponentHero.Id));
                total = wins + losses;
                if (total > 0)
                {
                    WinLossRatio.Add(new StatModel(string.Format("Wins: {0}", wins), wins / total * 100));
                    WinLossRatio.Add(new StatModel(string.Format("Losses: {0}", losses), losses / total * 100));
                }
                else
                {
                    WinLossRatio.Add(new StatModel("Wins", 0));
                    WinLossRatio.Add(new StatModel("Losses", 0));
                }
            }
            else
            {
                WinLossRatio.Add(new StatModel("Wins", 0));
                WinLossRatio.Add(new StatModel("Losses", 0));
            }

            WinLossRatioHero.Clear();
            if (Hero != null)
            {
                wins   = gameRepository.Query(x => x.Count(g => g.Started > @from && g.Victory && g.Hero.Id == Hero.Id));
                losses = gameRepository.Query(x => x.Count(g => g.Started > @from && !g.Victory && g.Hero.Id == Hero.Id));
                total  = wins + losses;
                if (total > 0)
                {
                    WinLossRatioHero.Add(new StatModel(string.Format("Wins: {0}", wins), wins / total * 100));
                    WinLossRatioHero.Add(new StatModel(string.Format("Losses: {0}", losses), losses / total * 100));
                }
                else
                {
                    WinLossRatioHero.Add(new StatModel("Wins", 0));
                    WinLossRatioHero.Add(new StatModel("Losses", 0));
                }
            }
            else
            {
                WinLossRatioHero.Add(new StatModel("Wins", 0));
                WinLossRatioHero.Add(new StatModel("Losses", 0));
            }

            WinLossRatioOpponentHero.Clear();
            if (OpponentHero != null)
            {
                wins   = gameRepository.Query(x => x.Count(g => g.Started > @from && g.Victory && g.OpponentHero.Id == OpponentHero.Id));
                losses = gameRepository.Query(x => x.Count(g => g.Started > @from && !g.Victory && g.OpponentHero.Id == OpponentHero.Id));
                total  = wins + losses;
                if (total > 0)
                {
                    WinLossRatioOpponentHero.Add(new StatModel(string.Format("Wins: {0}", wins), wins / total * 100));
                    WinLossRatioOpponentHero.Add(new StatModel(string.Format("Losses: {0}", losses), losses / total * 100));
                }
                else
                {
                    WinLossRatioOpponentHero.Add(new StatModel("Wins", 0));
                    WinLossRatioOpponentHero.Add(new StatModel("Losses", 0));
                }
            }
            else
            {
                WinLossRatioOpponentHero.Add(new StatModel("Wins", 0));
                WinLossRatioOpponentHero.Add(new StatModel("Losses", 0));
            }
        }