Exemple #1
0
        private void SetFastestLabel(StatSummary levelInfo, LevelStats level)
        {
            int fastestSwitchCount = switchCount;

            if (!StatsForm.CurrentSettings.SwitchBetweenLongest)
            {
                fastestSwitchCount = level.Type.FastestLabel();
            }
            switch (fastestSwitchCount % (levelInfo.BestScore.HasValue ? 3 : 2))
            {
            case 0:
                lblFastest.Text      = "LONGEST:";
                lblFastest.TextRight = levelInfo.LongestFinish.HasValue ? $"{levelInfo.LongestFinish:m\\:ss\\.ff}" : "-";
                break;

            case 1:
                lblFastest.Text      = "FASTEST:";
                lblFastest.TextRight = levelInfo.BestFinish.HasValue ? $"{levelInfo.BestFinish:m\\:ss\\.ff}" : "-";
                break;

            case 2:
                lblFastest.Text      = "HIGH SCORE:";
                lblFastest.TextRight = levelInfo.BestScore.Value.ToString();
                break;
            }
        }
Exemple #2
0
        private void gridDetails_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try {
                if (e.RowIndex < 0)
                {
                    return;
                }

                if (gridDetails.Columns[e.ColumnIndex].Name == "Info")
                {
                    using (LevelDetails levelDetails = new LevelDetails()) {
                        LevelStats stats = gridDetails.Rows[e.RowIndex].DataBoundItem as LevelStats;
                        levelDetails.LevelName = stats.Name;
                        List <RoundInfo> rounds = stats.Stats;
                        rounds.Sort(delegate(RoundInfo one, RoundInfo two) {
                            return(one.Start.CompareTo(two.Start));
                        });
                        levelDetails.RoundDetails = rounds;
                        levelDetails.StatsForm    = this;
                        levelDetails.ShowDialog(this);
                    }
                }
            } catch (Exception ex) {
                MessageBox.Show(this, ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
        public void ResetStats()
        {
            for (int i = 0; i < StatDetails.Count; i++)
            {
                LevelStats calculator = StatDetails[i];
                calculator.Clear();
            }

            ClearTotals();

            if (RoundDetails.Count() > 0)
            {
                nextShowID = RoundDetails.Max(x => x.ShowID);
                AllStats.Clear();
                AllStats.AddRange(RoundDetails.FindAll());
                AllStats.Sort(delegate(RoundInfo one, RoundInfo two) {
                    int showCompare = one.ShowID.CompareTo(two.ShowID);
                    return(showCompare != 0 ? showCompare : one.Round.CompareTo(two.Round));
                });

                for (int i = AllStats.Count - 1; i >= 0; i--)
                {
                    RoundInfo info = AllStats[i];
                    CurrentRound.Insert(0, info);
                    if (info.Round == 1)
                    {
                        break;
                    }
                }
                loadingExisting = true;
                LogFile_OnParsedLogLines(AllStats);
                loadingExisting = false;
            }
        }
Exemple #4
0
        private void gridDetails_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            try {
                if (e.RowIndex < 0)
                {
                    return;
                }

                LevelStats info = gridDetails.Rows[e.RowIndex].DataBoundItem as LevelStats;

                if (gridDetails.Columns[e.ColumnIndex].Name == "Name")
                {
                    switch (info.Type)
                    {
                    case LevelType.Race: e.CellStyle.BackColor = Color.LightGoldenrodYellow; break;

                    case LevelType.Survival: e.CellStyle.BackColor = Color.LightBlue; break;

                    case LevelType.Team: e.CellStyle.BackColor = Color.LightGreen; break;

                    case LevelType.Final: e.CellStyle.BackColor = Color.Pink; break;
                    }
                }
                else if (gridDetails.Columns[e.ColumnIndex].Name == "Info" && e.Value == null)
                {
                    gridDetails.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = "Click to view level stats";
                    e.Value = Properties.Resources.info;
                }
                else if (gridDetails.Columns[e.ColumnIndex].Name == "Qualified")
                {
                    float qualifyChance = (float)info.Qualified * 100f / (info.Played == 0 ? 1 : info.Played);
                    gridDetails.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = $"{qualifyChance:0.0}%";
                }
                else if (gridDetails.Columns[e.ColumnIndex].Name == "Gold")
                {
                    float qualifyChance = (float)info.Gold * 100f / (info.Played == 0 ? 1 : info.Played);
                    gridDetails.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = $"{qualifyChance:0.0}%";
                }
                else if (gridDetails.Columns[e.ColumnIndex].Name == "Silver")
                {
                    float qualifyChance = (float)info.Silver * 100f / (info.Played == 0 ? 1 : info.Played);
                    gridDetails.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = $"{qualifyChance:0.0}%";
                }
                else if (gridDetails.Columns[e.ColumnIndex].Name == "Bronze")
                {
                    float qualifyChance = (float)info.Bronze * 100f / (info.Played == 0 ? 1 : info.Played);
                    gridDetails.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = $"{qualifyChance:0.0}%";
                }
                else if (gridDetails.Columns[e.ColumnIndex].Name == "AveDuration")
                {
                    e.Value = info.AveDuration.ToString("m\\:ss");
                }
            } catch (Exception ex) {
                MessageBox.Show(this, ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #5
0
        private void lblTotalWins_Click(object sender, EventArgs e)
        {
            try {
                List <RoundInfo> rounds = new List <RoundInfo>();
                for (int i = 0; i < StatDetails.Count; i++)
                {
                    rounds.AddRange(StatDetails[i].Stats);
                }
                rounds.Sort(delegate(RoundInfo one, RoundInfo two) {
                    return(one.Start.CompareTo(two.Start));
                });

                using (StatsDisplay display = new StatsDisplay()
                {
                    Text = "Wins Per Day"
                }) {
                    DataTable dt = new DataTable();
                    dt.Columns.Add("Date", typeof(DateTime));
                    dt.Columns.Add("Wins", typeof(int));

                    if (rounds.Count > 0)
                    {
                        DateTime start       = rounds[0].Start;
                        int      currentWins = 0;
                        for (int i = 0; i < rounds.Count; i++)
                        {
                            RoundInfo  info       = rounds[i];
                            LevelStats levelStats = null;
                            if (info.Qualified && StatLookup.TryGetValue(info.Name, out levelStats) && levelStats.Type == LevelType.Final)
                            {
                                currentWins++;
                            }

                            if (info.Start.Date != start.Date)
                            {
                                dt.Rows.Add(start.Date, currentWins);
                                currentWins = 0;
                                start       = info.Start;
                            }
                        }

                        dt.Rows.Add(start.Date, currentWins);
                    }
                    else
                    {
                        dt.Rows.Add(DateTime.Now.Date, 0);
                    }

                    display.Details = dt;
                    display.ShowDialog(this);
                }
            } catch (Exception ex) {
                MessageBox.Show(this, ex.ToString(), "Error Updating", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #6
0
        private void gridDetails_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            string    columnName = gridDetails.Columns[e.ColumnIndex].Name;
            SortOrder sortOrder  = gridDetails.GetSortOrder(columnName);

            StatDetails.Sort(delegate(LevelStats one, LevelStats two) {
                int typeCompare = ((int)one.Type).CompareTo((int)two.Type);
                int nameCompare = one.Name.CompareTo(two.Name);

                if (sortOrder == SortOrder.Descending)
                {
                    LevelStats temp = one;
                    one             = two;
                    two             = temp;
                }

                if (typeCompare == 0)
                {
                    switch (columnName)
                    {
                    case "Gold": typeCompare = one.Gold.CompareTo(two.Gold); break;

                    case "Silver": typeCompare = one.Silver.CompareTo(two.Silver); break;

                    case "Bronze": typeCompare = one.Bronze.CompareTo(two.Bronze); break;

                    case "Played": typeCompare = one.Played.CompareTo(two.Played); break;

                    case "Qualified": typeCompare = one.Qualified.CompareTo(two.Qualified); break;

                    case "Kudos": typeCompare = one.Kudos.CompareTo(two.Kudos); break;

                    case "AveKudos": typeCompare = one.AveKudos.CompareTo(two.AveKudos); break;

                    case "AveDuration": typeCompare = one.AveDuration.CompareTo(two.AveDuration); break;

                    default: typeCompare = one.Name.CompareTo(two.Name); break;
                    }
                }

                if (typeCompare == 0)
                {
                    typeCompare = nameCompare;
                }

                return(typeCompare);
            });

            gridDetails.DataSource = null;
            gridDetails.DataSource = StatDetails;
            gridDetails.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection = sortOrder;
        }
Exemple #7
0
        private void lblTotalShows_Click(object sender, EventArgs e)
        {
            try {
                using (LevelDetails levelDetails = new LevelDetails()) {
                    levelDetails.LevelName = "Shows";
                    List <RoundInfo> rounds = new List <RoundInfo>();
                    for (int i = 0; i < StatDetails.Count; i++)
                    {
                        rounds.AddRange(StatDetails[i].Stats);
                    }
                    rounds.Sort(delegate(RoundInfo one, RoundInfo two) {
                        return(one.Start.CompareTo(two.Start));
                    });

                    List <RoundInfo> shows = new List <RoundInfo>();
                    int      roundCount    = 0;
                    int      kudosTotal    = 0;
                    bool     won           = false;
                    bool     isFinal       = false;
                    DateTime endDate       = DateTime.MinValue;
                    for (int i = rounds.Count - 1; i >= 0; i--)
                    {
                        RoundInfo info = rounds[i];
                        if (roundCount == 0)
                        {
                            endDate = info.End;
                            won     = info.Qualified;
                            LevelStats levelStats = StatLookup[info.Name];
                            isFinal = levelStats.Type == LevelType.Final;
                        }
                        roundCount++;
                        kudosTotal += info.Kudos;
                        if (info.Round == 1)
                        {
                            shows.Insert(0, new RoundInfo()
                            {
                                Name = isFinal ? "Final" : string.Empty, End = endDate, Start = info.Start, Kudos = kudosTotal, Qualified = won, Round = roundCount, ShowID = info.ShowID, Tier = won ? 1 : 0
                            });
                            roundCount = 0;
                            kudosTotal = 0;
                        }
                    }
                    levelDetails.RoundDetails = shows;
                    levelDetails.StatsForm    = this;
                    levelDetails.ShowDialog(this);
                }
            } catch (Exception ex) {
                MessageBox.Show(this, ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #8
0
        private void menuStats_Click(object sender, EventArgs e)
        {
            try {
                ToolStripMenuItem button = sender as ToolStripMenuItem;
                if (button == menuAllStats || button == menuSeasonStats || button == menuWeekStats || button == menuDayStats || button == menuSessionStats)
                {
                    if (!menuAllStats.Checked && !menuSeasonStats.Checked && !menuWeekStats.Checked && !menuDayStats.Checked && !menuSessionStats.Checked)
                    {
                        button.Checked = true;
                        return;
                    }

                    foreach (ToolStripItem item in menuStatsFilter.DropDownItems)
                    {
                        if (item is ToolStripMenuItem menuItem && menuItem.Checked && menuItem != button)
                        {
                            menuItem.Checked = false;
                        }
                    }
                }

                if (button == menuAllPartyStats || button == menuSoloStats || button == menuPartyStats)
                {
                    if (!menuAllPartyStats.Checked && !menuSoloStats.Checked && !menuPartyStats.Checked)
                    {
                        button.Checked = true;
                        return;
                    }

                    foreach (ToolStripItem item in menuPartyFilter.DropDownItems)
                    {
                        if (item is ToolStripMenuItem menuItem && menuItem.Checked && menuItem != button)
                        {
                            menuItem.Checked = false;
                        }
                    }

                    button = menuAllStats.Checked ? menuAllStats : menuSeasonStats.Checked ? menuSeasonStats : menuWeekStats.Checked ? menuWeekStats : menuDayStats.Checked ? menuDayStats : menuSessionStats;
                }

                for (int i = 0; i < StatDetails.Count; i++)
                {
                    LevelStats calculator = StatDetails[i];
                    calculator.Clear();
                }

                ClearTotals();

                bool             soloOnly = menuSoloStats.Checked;
                List <RoundInfo> rounds   = new List <RoundInfo>();
                if (button == menuAllStats)
                {
                    if (!menuAllPartyStats.Checked)
                    {
                        rounds.AddRange(RoundDetails.Find(x => x.InParty == !soloOnly));
                    }
                    else
                    {
                        rounds.AddRange(AllStats);
                    }
                }
                else if (button == menuSeasonStats)
                {
                    if (!menuAllPartyStats.Checked)
                    {
                        rounds.AddRange(RoundDetails.Find(x => x.Start > SeasonStart && x.InParty == !soloOnly));
                    }
                    else
                    {
                        rounds.AddRange(RoundDetails.Find(x => x.Start > SeasonStart));
                    }
                }
                else if (button == menuWeekStats)
                {
                    if (!menuAllPartyStats.Checked)
                    {
                        rounds.AddRange(RoundDetails.Find(x => x.Start > WeekStart && x.InParty == !soloOnly));
                    }
                    else
                    {
                        rounds.AddRange(RoundDetails.Find(x => x.Start > WeekStart));
                    }
                }
                else if (button == menuDayStats)
                {
                    if (!menuAllPartyStats.Checked)
                    {
                        rounds.AddRange(RoundDetails.Find(x => x.Start > DayStart && x.InParty == !soloOnly));
                    }
                    else
                    {
                        rounds.AddRange(RoundDetails.Find(x => x.Start > DayStart));
                    }
                }
                else if (!menuAllPartyStats.Checked)
                {
                    rounds.AddRange(RoundDetails.Find(x => x.Start > SessionStart && x.InParty == !soloOnly));
                }
                else
                {
                    rounds.AddRange(RoundDetails.Find(x => x.Start > SessionStart));
                }

                rounds.Sort(delegate(RoundInfo one, RoundInfo two) {
                    return(one.Start.CompareTo(two.Start));
                });

                if (rounds.Count > 0 && (button == menuWeekStats || button == menuDayStats || button == menuSessionStats))
                {
                    int minShowID = rounds[0].ShowID;
                    if (button == menuWeekStats)
                    {
                        rounds.AddRange(RoundDetails.Find(x => x.ShowID == minShowID && x.Start < WeekStart));
                    }
                    else if (button == menuDayStats)
                    {
                        rounds.AddRange(RoundDetails.Find(x => x.ShowID == minShowID && x.Start < DayStart));
                    }
                    else
                    {
                        rounds.AddRange(RoundDetails.Find(x => x.ShowID == minShowID && x.Start < SessionStart));
                    }
                }

                CurrentSettings.FilterType = menuAllStats.Checked ? 0 : menuSeasonStats.Checked ? 1 : menuWeekStats.Checked ? 2 : menuDayStats.Checked ? 3 : 4;
                SaveUserSettings();

                loadingExisting = true;
                LogFile_OnParsedLogLines(rounds);
                loadingExisting = false;
            } catch (Exception ex) {
                MessageBox.Show(this, ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #9
0
        public Stats()
        {
            InitializeComponent();

            Text = $"Fall Guys Stats v{Assembly.GetExecutingAssembly().GetName().Version.ToString(2)}";

            logFile.OnParsedLogLines        += LogFile_OnParsedLogLines;
            logFile.OnNewLogFileDate        += LogFile_OnNewLogFileDate;
            logFile.OnError                 += LogFile_OnError;
            logFile.OnParsedLogLinesCurrent += LogFile_OnParsedLogLinesCurrent;

            StatDetails.Add(new LevelStats("round_door_dash", LevelType.Race));
            StatDetails.Add(new LevelStats("round_gauntlet_02", LevelType.Race));
            StatDetails.Add(new LevelStats("round_dodge_fall", LevelType.Race));
            StatDetails.Add(new LevelStats("round_chompchomp", LevelType.Race));
            StatDetails.Add(new LevelStats("round_gauntlet_01", LevelType.Race));
            StatDetails.Add(new LevelStats("round_see_saw", LevelType.Race));
            StatDetails.Add(new LevelStats("round_lava", LevelType.Race));
            StatDetails.Add(new LevelStats("round_tip_toe", LevelType.Race));
            StatDetails.Add(new LevelStats("round_gauntlet_03", LevelType.Race));

            StatDetails.Add(new LevelStats("round_block_party", LevelType.Survival));
            StatDetails.Add(new LevelStats("round_jump_club", LevelType.Survival));
            StatDetails.Add(new LevelStats("round_match_fall", LevelType.Survival));
            StatDetails.Add(new LevelStats("round_tunnel", LevelType.Survival));
            StatDetails.Add(new LevelStats("round_tail_tag", LevelType.Survival));

            StatDetails.Add(new LevelStats("round_egg_grab", LevelType.Team));
            StatDetails.Add(new LevelStats("round_fall_ball_60_players", LevelType.Team));
            StatDetails.Add(new LevelStats("round_ballhogs", LevelType.Team));
            StatDetails.Add(new LevelStats("round_hoops", LevelType.Team));
            StatDetails.Add(new LevelStats("round_jinxed", LevelType.Team));
            StatDetails.Add(new LevelStats("round_rocknroll", LevelType.Team));
            StatDetails.Add(new LevelStats("round_conveyor_arena", LevelType.Team));

            StatDetails.Add(new LevelStats("round_fall_mountain_hub_complete", LevelType.Final));
            StatDetails.Add(new LevelStats("round_floor_fall", LevelType.Final));
            StatDetails.Add(new LevelStats("round_jump_showdown", LevelType.Final));
            StatDetails.Add(new LevelStats("round_royal_rumble", LevelType.Final));

            for (int i = 0; i < StatDetails.Count; i++)
            {
                LevelStats calculator = StatDetails[i];
                StatLookup.Add(calculator.LevelName, calculator);
            }

            gridDetails.DataSource = StatDetails;

            StatsDB      = new LiteDatabase(@"data.db");
            RoundDetails = StatsDB.GetCollection <RoundInfo>("RoundDetails");
            UserSettings = StatsDB.GetCollection <UserSettings>("UserSettings");
            StatsDB.BeginTrans();
            if (UserSettings.Count() == 0)
            {
                CurrentSettings = GetDefaultSettings();
                UserSettings.Insert(CurrentSettings);
            }
            else
            {
                try {
                    CurrentSettings = UserSettings.FindAll().First();
                } catch {
                    UserSettings.DeleteAll();
                    CurrentSettings = GetDefaultSettings();
                    UserSettings.Insert(CurrentSettings);
                }
            }
            RoundDetails.EnsureIndex(x => x.Name);
            RoundDetails.EnsureIndex(x => x.ShowID);
            RoundDetails.EnsureIndex(x => x.Round);
            RoundDetails.EnsureIndex(x => x.Start);
            RoundDetails.EnsureIndex(x => x.InParty);
            StatsDB.Commit();

            CurrentRound = new List <RoundInfo>();
            overlay      = new Overlay()
            {
                StatsForm = this
            };
            overlay.Show();
            overlay.Visible = false;
            overlay.StartTimer();
        }
Exemple #10
0
        public StatSummary GetLevelInfo(string name)
        {
            StatSummary summary = new StatSummary();

            summary.CurrentFilter = menuAllStats.Checked ? "All" : menuSeasonStats.Checked ? "Season" : menuWeekStats.Checked ? "Week" : menuDayStats.Checked ? "Day" : "Session";
            LevelStats levelDetails = null;

            summary.AllWins     = 0;
            summary.TotalShows  = 0;
            summary.TotalPlays  = 0;
            summary.TotalWins   = 0;
            summary.TotalFinals = 0;
            int lastShow = -1;

            for (int i = 0; i < AllStats.Count; i++)
            {
                RoundInfo info              = AllStats[i];
                TimeSpan  finishTime        = info.Finish.GetValueOrDefault(info.End) - info.Start;
                bool      hasLevelDetails   = StatLookup.TryGetValue(info.Name, out levelDetails);
                bool      isCurrentLevel    = name.Equals(info.Name, StringComparison.OrdinalIgnoreCase);
                bool      isInQualifyFilter = CurrentSettings.QualifyFilter == 0 ||
                                              (CurrentSettings.QualifyFilter == 1 && IsInStatsFilter(info) && IsInPartyFilter(info)) ||
                                              (CurrentSettings.QualifyFilter == 2 && IsInStatsFilter(info)) ||
                                              (CurrentSettings.QualifyFilter == 3 && IsInPartyFilter(info));
                bool isInFastestFilter = CurrentSettings.FastestFilter == 0 ||
                                         (CurrentSettings.FastestFilter == 1 && IsInStatsFilter(info) && IsInPartyFilter(info)) ||
                                         (CurrentSettings.FastestFilter == 2 && IsInStatsFilter(info)) ||
                                         (CurrentSettings.FastestFilter == 3 && IsInPartyFilter(info));
                bool isInWinsFilter = CurrentSettings.WinsFilter == 3 ||
                                      (CurrentSettings.WinsFilter == 0 && IsInStatsFilter(info) && IsInPartyFilter(info)) ||
                                      (CurrentSettings.WinsFilter == 1 && IsInStatsFilter(info)) ||
                                      (CurrentSettings.WinsFilter == 2 && IsInPartyFilter(info));

                if (info.ShowID != lastShow)
                {
                    lastShow = info.ShowID;
                    if (isInWinsFilter)
                    {
                        summary.TotalShows++;
                    }
                }

                if (isCurrentLevel)
                {
                    if (isInQualifyFilter)
                    {
                        summary.TotalPlays++;
                    }

                    if (isInFastestFilter)
                    {
                        if ((!hasLevelDetails || levelDetails.Type == LevelType.Team) && info.Score.HasValue && (!summary.BestScore.HasValue || info.Score.Value > summary.BestScore.Value))
                        {
                            summary.BestScore = info.Score;
                        }
                    }
                }

                if (info.Qualified)
                {
                    if (hasLevelDetails && levelDetails.Type == LevelType.Final)
                    {
                        summary.AllWins++;

                        if (isInWinsFilter)
                        {
                            summary.TotalWins++;
                            summary.TotalFinals++;
                        }

                        summary.CurrentStreak++;
                        if (summary.CurrentStreak > summary.BestStreak)
                        {
                            summary.BestStreak = summary.CurrentStreak;
                        }
                    }

                    if (isCurrentLevel)
                    {
                        if (isInQualifyFilter)
                        {
                            if (info.Tier == (int)QualifyTier.Gold)
                            {
                                summary.TotalGolds++;
                            }
                            summary.TotalQualify++;
                        }

                        if (isInFastestFilter)
                        {
                            if (finishTime.TotalSeconds > 1.1 && (!summary.BestFinish.HasValue || summary.BestFinish.Value > finishTime))
                            {
                                summary.BestFinish = finishTime;
                            }
                            if (finishTime.TotalSeconds > 1.1 && info.Finish.HasValue && (!summary.LongestFinish.HasValue || summary.LongestFinish.Value < finishTime))
                            {
                                summary.LongestFinish = finishTime;
                            }
                        }
                    }
                }
                else
                {
                    summary.CurrentStreak = 0;
                    if (isInWinsFilter && hasLevelDetails && levelDetails.Type == LevelType.Final)
                    {
                        summary.TotalFinals++;
                    }
                }
            }

            return(summary);
        }
Exemple #11
0
        private void LogFile_OnParsedLogLines(List <RoundInfo> round)
        {
            try {
                lock (StatsDB) {
                    if (!loadingExisting)
                    {
                        StatsDB.BeginTrans();
                    }

                    foreach (RoundInfo stat in round)
                    {
                        if (!loadingExisting)
                        {
                            RoundInfo info = RoundDetails.FindOne(x => x.Start == stat.Start && x.Name == stat.Name);
                            if (info == null)
                            {
                                if (stat.Round == 1)
                                {
                                    nextShowID++;
                                }
                                stat.ShowID = nextShowID;

                                RoundDetails.Insert(stat);
                                AllStats.Add(stat);
                            }
                            else
                            {
                                continue;
                            }
                        }

                        if (stat.Round == 1)
                        {
                            Shows++;
                        }
                        Rounds++;
                        Duration += stat.End - stat.Start;
                        Kudos    += stat.Kudos;

                        if (StatLookup.ContainsKey(stat.Name))
                        {
                            stat.ToLocalTime();
                            LevelStats levelStats = StatLookup[stat.Name];
                            if (levelStats.Type == LevelType.Final)
                            {
                                Finals++;
                                if (stat.Qualified)
                                {
                                    Wins++;
                                }
                            }
                            levelStats.Add(stat);
                        }
                    }

                    if (!loadingExisting)
                    {
                        StatsDB.Commit();
                    }
                }

                lock (CurrentRound) {
                    CurrentRound.Clear();
                    for (int i = round.Count - 1; i >= 0; i--)
                    {
                        RoundInfo info = round[i];
                        CurrentRound.Insert(0, info);
                        if (info.Round == 1)
                        {
                            break;
                        }
                    }
                }

                if (!this.Disposing && !this.IsDisposed)
                {
                    try {
                        this.Invoke((Action)UpdateTotals);
                    } catch { }
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #12
0
        public StatSummary GetLevelInfo(string name)
        {
            StatSummary summary = new StatSummary();

            summary.CurrentFilter = menuAllStats.Checked ? "All" : menuSeasonStats.Checked ? "Season" : menuWeekStats.Checked ? "Week" : menuDayStats.Checked ? "Day" : "Session";
            LevelStats levelDetails = null;

            AllWins = 0;
            for (int i = 0; i < AllStats.Count; i++)
            {
                RoundInfo info            = AllStats[i];
                TimeSpan  finishTime      = info.Finish.GetValueOrDefault(info.End) - info.Start;
                bool      hasLevelDetails = StatLookup.TryGetValue(info.Name, out levelDetails);
                bool      isCurrentLevel  = name.Equals(info.Name, StringComparison.OrdinalIgnoreCase);

                if (isCurrentLevel)
                {
                    if ((!hasLevelDetails || levelDetails.Type == LevelType.Team) && info.Score.HasValue && (!summary.BestScore.HasValue || info.Score.Value > summary.BestScore.Value))
                    {
                        summary.BestScore = info.Score;
                    }
                }

                if (info.Qualified)
                {
                    if (hasLevelDetails && levelDetails.Type == LevelType.Final)
                    {
                        AllWins++;
                        summary.CurrentStreak++;
                        if (summary.CurrentStreak > summary.BestStreak)
                        {
                            summary.BestStreak = summary.CurrentStreak;
                        }
                    }

                    if (isCurrentLevel)
                    {
                        if (finishTime.TotalSeconds > 1.1 && (!summary.BestFinish.HasValue || summary.BestFinish.Value > finishTime))
                        {
                            summary.BestFinish = finishTime;
                        }
                        if (finishTime.TotalSeconds > 1.1 && info.Finish.HasValue && (!summary.LongestFinish.HasValue || summary.LongestFinish.Value < finishTime))
                        {
                            summary.LongestFinish = finishTime;
                        }
                    }
                }
                else
                {
                    summary.CurrentStreak = 0;
                }
            }

            if (StatLookup.TryGetValue(name, out levelDetails))
            {
                summary.TotalPlays = levelDetails.Stats.Count;
                for (int i = 0; i < summary.TotalPlays; i++)
                {
                    RoundInfo info = levelDetails.Stats[i];

                    if (info.Qualified)
                    {
                        summary.TotalQualify++;
                    }
                }
            }

            return(summary);
        }