private void CalculateWinsAndLosses(HearthStatsDbContext context, Expression <Func <ArenaSession, bool> > filter)
        {
            var arenas = context.ArenaSessions.Where(filter);

            if (!arenas.Any())
            {
                WinsAndLosses.Add(new StatModel("Wins", 0));
                WinsAndLosses.Add(new StatModel("Losses", 0));
                return;
            }

            float total  = arenas.Sum(a => a.Wins + a.Losses);
            float wins   = arenas.Sum(a => a.Wins);
            float losses = arenas.Sum(a => a.Losses);

            WinsAndLosses.Clear();
            if (total <= 0)
            {
                WinsAndLosses.Add(new StatModel("Wins", 0));
                WinsAndLosses.Add(new StatModel("Losses", 0));
                return;
            }

            WinsAndLosses.Add(new StatModel(string.Format("Wins: {0}", wins), wins / total * 100));
            WinsAndLosses.Add(new StatModel(string.Format("Losses: {0}", losses), losses / total * 100));
        }
        private void AddDesignModeData()
        {
            WinsAndLosses.Add(new StatModel("Wins", 30));
            WinsAndLosses.Add(new StatModel("Losses", 70));

            WinRatios.Add(new StatModel("0-6", 10));
            WinRatios.Add(new StatModel("7+", 14));
            WinRatios.Add(new StatModel("12", 3));
        }
示例#3
0
        private void CalculateWinsAndLosses(HearthStatsDbContext context, Expression <Func <GameResult, bool> > filter)
        {
            var   games    = context.Games;
            float total    = games.Where(filter).Count();
            float winsC    = games.Where(filter).Count(x => x.Victory && !x.GoFirst);
            float lossesC  = games.Where(filter).Count(x => !x.Victory && !x.GoFirst);
            float winsNC   = games.Where(filter).Count(x => x.Victory && x.GoFirst);
            float lossesNC = games.Where(filter).Count(x => !x.Victory && x.GoFirst);
            var   wins     = winsC + winsNC;
            var   losses   = lossesC + lossesNC;

            WinsAndLosses.Clear();
            Wins.Clear();
            Losses.Clear();
            WithCoin.Clear();
            WithoutCoin.Clear();
            if (total <= 0)
            {
                WinsAndLosses.Add(new StatModel("Wins", 0));
                WinsAndLosses.Add(new StatModel("Losses", 0));
                Wins.Add(new StatModel("Coin", 0));
                Wins.Add(new StatModel("No coin", 0));
                Losses.Add(new StatModel("Coin", 0));
                Losses.Add(new StatModel("No coin", 0));
                WithCoin.Add(new StatModel("Losses", 0));
                WithCoin.Add(new StatModel("Losses", 0));
                WithoutCoin.Add(new StatModel("Losses", 0));
                WithoutCoin.Add(new StatModel("Losses", 0));

                return;
            }

            WinsAndLosses.Add(new StatModel(string.Format("Wins: {0}", wins), wins / total * 100));
            WinsAndLosses.Add(new StatModel(string.Format("Losses: {0}", losses), losses / total * 100));

            Wins.Add(new StatModel(string.Format("Coin: {0}", winsC), winsC / wins * 100));
            Wins.Add(new StatModel(string.Format("No coin: {0}", winsNC), winsNC / wins * 100));

            Losses.Add(new StatModel(string.Format("Coin: {0}", lossesC), lossesC / losses * 100));
            Losses.Add(new StatModel(string.Format("No coin: {0}", lossesNC), lossesNC / losses * 100));

            WithCoin.Add(new StatModel(string.Format("Wins: {0}", winsC), winsC / (winsC + lossesC) * 100));
            WithCoin.Add(new StatModel(string.Format("Losses: {0}", lossesC), lossesC / (winsC + lossesC) * 100));

            WithoutCoin.Add(new StatModel(string.Format("Wins: {0}", winsNC), winsNC / (winsNC + lossesNC) * 100));
            WithoutCoin.Add(new StatModel(string.Format("Losses: {0}", lossesNC), lossesNC / (winsNC + lossesNC) * 100));
        }
示例#4
0
 private void AddDesignModeData()
 {
     WinsAndLosses.Add(new StatModel("Wins", 30));
     WinsAndLosses.Add(new StatModel("Losses", 70));
 }