Esempio n. 1
0
        private void Clear()
        {
            IsRunning    = false;
            StartTime    = DateTime.Now;
            Hero         = null;
            OpponentHero = null;
            GoFirst      = true;
            Turns        = 1;
            Notes        = String.Empty;
            WinLossRatio.Clear();
            WinLossRatioHero.Clear();
            WinLossRatioOpponentHero.Clear();

            // don't reset (e.g. just remember last deck)
            //if (this.decks.Count > 0)
            //{
            //    this.SelectedDeck = this.decks.First();
            //}
        }
Esempio n. 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));
            }
        }