Exemple #1
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 #2
0
        public void Add(RoundInfo stat)
        {
            Stats.Add(stat);
            Played++;
            switch (stat.Tier)
            {
            case (int)QualifyTier.Gold:
                Gold++;
                break;

            case (int)QualifyTier.Silver:
                Silver++;
                break;

            case (int)QualifyTier.Bronze:
                Bronze++;
                break;
            }
            Kudos += stat.Kudos;
            TimeSpan finishTime = stat.Finish.GetValueOrDefault(stat.End) - stat.Start;

            if (stat.Finish.HasValue && finishTime.TotalSeconds > 1.1)
            {
                if (Fastest == TimeSpan.Zero || Fastest > finishTime)
                {
                    Fastest = finishTime;
                }
                if (Longest < finishTime)
                {
                    Longest = finishTime;
                }
            }
            Duration  += stat.End - stat.Start;
            Qualified += stat.Qualified ? 1 : 0;
        }
Exemple #3
0
 private bool IsInStatsFilter(RoundInfo info)
 {
     return(menuAllStats.Checked ||
            (menuSeasonStats.Checked && info.Start.ToUniversalTime() > SeasonStart) ||
            (menuWeekStats.Checked && info.Start.ToUniversalTime() > WeekStart) ||
            (menuDayStats.Checked && info.Start.ToUniversalTime() > DayStart) ||
            (menuSessionStats.Checked && info.Start.ToUniversalTime() > SessionStart));
 }
Exemple #4
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 #5
0
        private void gridDetails_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            if (gridDetails.Columns[e.ColumnIndex].Name == "End")
            {
                RoundInfo info = gridDetails.Rows[e.RowIndex].DataBoundItem as RoundInfo;
                e.Value = (info.End - info.Start).ToString("m\\:ss");
            }
            else if (gridDetails.Columns[e.ColumnIndex].Name == "Finish")
            {
                RoundInfo info = gridDetails.Rows[e.RowIndex].DataBoundItem as RoundInfo;
                if (info.Finish.HasValue)
                {
                    e.Value = (info.Finish.Value - info.Start).ToString("m\\:ss\\.ff");
                }
            }
            else if (ShowStats == 2 && gridDetails.Columns[e.ColumnIndex].Name == "Qualified")
            {
                RoundInfo info = gridDetails.Rows[e.RowIndex].DataBoundItem as RoundInfo;
                e.Value = !string.IsNullOrEmpty(info.Name);
            }
            else if (gridDetails.Columns[e.ColumnIndex].Name == "Medal" && e.Value == null)
            {
                RoundInfo info = gridDetails.Rows[e.RowIndex].DataBoundItem as RoundInfo;
                if (info.Qualified)
                {
                    switch (info.Tier)
                    {
                    case 0: e.Value = Properties.Resources.medal_pink; break;

                    case 1: e.Value = Properties.Resources.medal_gold; break;

                    case 2: e.Value = Properties.Resources.medal_silver; break;

                    case 3: e.Value = Properties.Resources.medal_bronze; break;
                    }
                }
                else
                {
                    e.Value = Properties.Resources.medal_eliminated;
                }
            }
            else if (gridDetails.Columns[e.ColumnIndex].Name == "Name")
            {
                string name = null;
                if (LevelStats.DisplayNameLookup.TryGetValue((string)e.Value, out name))
                {
                    e.Value = name;
                }
            }
        }
Exemple #6
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);
            }
        }
 public void Add(RoundInfo stat)
 {
     Stats.Add(stat);
     Played++;
     if (stat.Tier == (int)QualifyTier.Gold)
     {
         Gold++;
     }
     else if (stat.Tier == (int)QualifyTier.Silver)
     {
         Silver++;
     }
     else if (stat.Tier == (int)QualifyTier.Bronze)
     {
         Bronze++;
     }
     Kudos     += stat.Kudos;
     Duration  += stat.End - stat.Start;
     Qualified += stat.Qualified ? 1 : 0;
 }
        private void ParseLines()
        {
            RoundInfo        stat     = null;
            List <RoundInfo> round    = new List <RoundInfo>();
            List <RoundInfo> allStats = new List <RoundInfo>();
            int    players            = 0;
            bool   countPlayers       = false;
            bool   currentlyInParty   = false;
            bool   privateLobby       = false;
            bool   findPosition       = false;
            string currentPlayerID    = string.Empty;
            int    lastPing           = 0;
            int    gameDuration       = 0;

            while (!stop)
            {
                try {
                    lock (lines) {
                        for (int i = 0; i < lines.Count; i++)
                        {
                            LogLine line = lines[i];
                            if (ParseLine(line, round, ref currentPlayerID, ref countPlayers, ref currentlyInParty, ref findPosition, ref players, ref stat, ref lastPing, ref gameDuration, ref privateLobby))
                            {
                                allStats.AddRange(round);
                            }
                        }

                        if (allStats.Count > 0)
                        {
                            OnParsedLogLines?.Invoke(allStats);
                            allStats.Clear();
                        }

                        lines.Clear();
                    }
                } catch (Exception ex) {
                    OnError?.Invoke(ex.ToString());
                }
                Thread.Sleep(UpdateDelay);
            }
        }
Exemple #9
0
 private void LogFile_OnParsedLogLinesCurrent(List <RoundInfo> round)
 {
     lock (CurrentRound) {
         if (CurrentRound == null || CurrentRound.Count != round.Count)
         {
             CurrentRound = round;
         }
         else
         {
             for (int i = 0; i < CurrentRound.Count; i++)
             {
                 RoundInfo info = CurrentRound[i];
                 if (!info.Equals(round[i]))
                 {
                     CurrentRound = round;
                     break;
                 }
             }
         }
     }
 }
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;

            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);
        }
Exemple #11
0
        private void UpdateInfo()
        {
            if (StatsForm == null)
            {
                return;
            }

            lock (StatsForm.CurrentRound) {
                bool hasCurrentRound = StatsForm.CurrentRound != null && StatsForm.CurrentRound.Count > 0;
                if (hasCurrentRound && (lastRound == null || Stats.InShow || Stats.EndedShow))
                {
                    if (Stats.EndedShow)
                    {
                        Stats.EndedShow = false;
                    }
                    lastRound = StatsForm.CurrentRound[StatsForm.CurrentRound.Count - 1];
                }

                lblFilter.Text = StatsForm.GetCurrentFilter();

                if (lastRound != null && !string.IsNullOrEmpty(lastRound.Name))
                {
                    string roundName = lastRound.VerifiedName();
                    lblName.Text = $"ROUND {lastRound.Round}:";

                    if (StatsForm.StatLookup.TryGetValue(roundName, out var level))
                    {
                        roundName = level.Name.ToUpper();
                    }

                    if (roundName.StartsWith("round_", StringComparison.OrdinalIgnoreCase))
                    {
                        roundName = roundName.Substring(6).Replace('_', ' ').ToUpper();
                    }
                    if (roundName.Length > 15)
                    {
                        roundName = roundName.Substring(0, 15);
                    }

                    StatSummary levelInfo = StatsForm.GetLevelInfo(roundName);
                    lblName.TextRight = roundName;

                    float  winChance        = levelInfo.TotalWins * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows);
                    string winChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : $" - {winChance:0.0}%";
                    if (StatsForm.CurrentSettings.PreviousWins > 0)
                    {
                        lblWins.TextRight = $"{levelInfo.TotalWins} ({levelInfo.AllWins + StatsForm.CurrentSettings.PreviousWins}){winChanceDisplay}";
                    }
                    else if (StatsForm.CurrentSettings.FilterType != 0)
                    {
                        lblWins.TextRight = $"{levelInfo.TotalWins} ({levelInfo.AllWins}){winChanceDisplay}";
                    }
                    else
                    {
                        lblWins.TextRight = $"{levelInfo.TotalWins}{winChanceDisplay}";
                    }

                    float  finalChance        = levelInfo.TotalFinals * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows);
                    string finalText          = $"{levelInfo.TotalFinals} / {levelInfo.TotalShows}";
                    string finalChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : finalText.Length > 9 ? $" - {finalChance:0}%" : $" - {finalChance:0.0}%";
                    lblFinals.TextRight = $"{finalText}{finalChanceDisplay}";

                    SetQualifyChanceLabel(levelInfo);
                    LevelType levelType = (level?.Type).GetValueOrDefault();
                    SetFastestLabel(levelInfo, levelType);
                    SetPlayersLabel();
                    SetStreakInfo(levelInfo);
                    if (isTimeToSwitch)
                    {
                        switchCount++;
                    }

                    DateTime Start  = lastRound.Start;
                    DateTime End    = lastRound.End;
                    DateTime?Finish = lastRound.Finish;

                    if (lastRound.Playing != startedPlaying)
                    {
                        if (lastRound.Playing)
                        {
                            startTime = DateTime.UtcNow;
                        }
                        startedPlaying = lastRound.Playing;
                    }

                    if (Finish.HasValue)
                    {
                        TimeSpan Time = Finish.GetValueOrDefault(End) - Start;
                        if (lastRound.Position > 0)
                        {
                            lblFinish.TextRight = $"# {lastRound.Position} - {Time:m\\:ss\\.ff}";
                        }
                        else
                        {
                            lblFinish.TextRight = $"{Time:m\\:ss\\.ff}";
                        }

                        if (levelType == LevelType.Race || levelType == LevelType.Hunt || roundName == "ROCK'N'ROLL" || roundName == "SNOWY SCRAP")
                        {
                            if (Time < levelInfo.BestFinish.GetValueOrDefault(TimeSpan.MaxValue) && Time > levelInfo.BestFinishOverall.GetValueOrDefault(TimeSpan.MaxValue))
                            {
                                lblFinish.ForeColor = Color.LightGreen;
                            }
                            else if (Time < levelInfo.BestFinishOverall.GetValueOrDefault(TimeSpan.MaxValue))
                            {
                                lblFinish.ForeColor = Color.Gold;
                            }
                        }
                        else if (Time > levelInfo.LongestFinish && Time < levelInfo.LongestFinishOverall)
                        {
                            lblFinish.ForeColor = Color.LightGreen;
                        }
                        else if (Time > levelInfo.LongestFinishOverall)
                        {
                            lblFinish.ForeColor = Color.Gold;
                        }
                    }
                    else if (lastRound.Playing)
                    {
                        if (Start > DateTime.UtcNow)
                        {
                            lblFinish.TextRight = $"{DateTime.UtcNow - startTime:m\\:ss}";
                        }
                        else
                        {
                            lblFinish.TextRight = $"{DateTime.UtcNow - Start:m\\:ss}";
                        }
                    }
                    else
                    {
                        lblFinish.TextRight = "-";
                        lblFinish.ForeColor = Color.White;
                    }

                    if (lastRound.GameDuration > 0)
                    {
                        lblDuration.Text = $"TIME ({TimeSpan.FromSeconds(lastRound.GameDuration):m\\:ss}):";
                    }
                    else
                    {
                        lblDuration.Text = "TIME:";
                    }

                    if (End != DateTime.MinValue)
                    {
                        lblDuration.TextRight = $"{End - Start:m\\:ss\\.ff}";
                    }
                    else if (lastRound.Playing)
                    {
                        if (Start > DateTime.UtcNow)
                        {
                            lblDuration.TextRight = $"{DateTime.UtcNow - startTime:m\\:ss}";
                        }
                        else
                        {
                            lblDuration.TextRight = $"{DateTime.UtcNow - Start:m\\:ss}";
                        }
                    }
                    else
                    {
                        lblDuration.TextRight = "-";
                    }
                }
                Invalidate();
            }

            if (StatsForm.CurrentSettings.UseNDI)
            {
                SendNDI();
            }
        }
Exemple #12
0
        private void gridDetails_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.RowIndex < 0 || e.RowIndex >= gridDetails.Rows.Count)
            {
                return;
            }

            if (gridDetails.Columns[e.ColumnIndex].Name == "End")
            {
                RoundInfo info = gridDetails.Rows[e.RowIndex].DataBoundItem as RoundInfo;
                e.Value = (info.End - info.Start).ToString("m\\:ss");
            }
            else if (gridDetails.Columns[e.ColumnIndex].Name == "Start")
            {
                RoundInfo info = gridDetails.Rows[e.RowIndex].DataBoundItem as RoundInfo;
                e.Value = info.StartLocal.ToString("yyyy-MM-dd HH:mm");
            }
            else if (gridDetails.Columns[e.ColumnIndex].Name == "Finish")
            {
                RoundInfo info = gridDetails.Rows[e.RowIndex].DataBoundItem as RoundInfo;
                if (info.Finish.HasValue)
                {
                    e.Value = (info.Finish.Value - info.Start).ToString("m\\:ss\\.ff");
                }
            }
            else if (ShowStats == 2 && gridDetails.Columns[e.ColumnIndex].Name == "Qualified")
            {
                RoundInfo info = gridDetails.Rows[e.RowIndex].DataBoundItem as RoundInfo;
                e.Value = !string.IsNullOrEmpty(info.Name);
            }
            else if (gridDetails.Columns[e.ColumnIndex].Name == "Medal" && e.Value == null)
            {
                RoundInfo info = gridDetails.Rows[e.RowIndex].DataBoundItem as RoundInfo;
                if (info.Qualified)
                {
                    switch (info.Tier)
                    {
                    case 0:
                        gridDetails.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = "Pink";
                        e.Value = Properties.Resources.medal_pink;
                        break;

                    case 1:
                        gridDetails.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = "Gold";
                        e.Value = Properties.Resources.medal_gold;
                        break;

                    case 2:
                        gridDetails.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = "Silver";
                        e.Value = Properties.Resources.medal_silver;
                        break;

                    case 3:
                        gridDetails.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = "Bronze";
                        e.Value = Properties.Resources.medal_bronze;
                        break;
                    }
                }
                else
                {
                    gridDetails.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = "Eliminated";
                    e.Value = Properties.Resources.medal_eliminated;
                }
            }
            else if (gridDetails.Columns[e.ColumnIndex].Name == "Name")
            {
                if (StatsForm.StatLookup.TryGetValue((string)e.Value, out LevelStats level))
                {
                    e.Value = level.Name;
                }
            }
        }
Exemple #13
0
        private void UpdateInfo()
        {
            if (StatsForm == null)
            {
                return;
            }

            lock (StatsForm.CurrentRound) {
                bool hasCurrentRound = StatsForm.CurrentRound != null && StatsForm.CurrentRound.Count > 0;
                if (hasCurrentRound && (lastRound == null || Stats.InShow || Stats.EndedShow))
                {
                    if (Stats.EndedShow)
                    {
                        Stats.EndedShow = false;
                    }
                    lastRound = StatsForm.CurrentRound[StatsForm.CurrentRound.Count - 1];
                }

                StatSummary levelInfo = StatsForm.GetLevelInfo(lastRound?.Name);
                lblFilter.Text = levelInfo.CurrentFilter;

                if (lastRound != null)
                {
                    lblName.Text = $"ROUND {lastRound.Round}:";

                    lblName.TextRight = LevelStats.ALL.TryGetValue(lastRound.Name, out var level) ? level.Name.ToUpper() : string.Empty;

                    float  winChance        = (float)levelInfo.TotalWins * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows);
                    string winChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : $" - {winChance:0.0}%";
                    if (StatsForm.CurrentSettings.PreviousWins > 0)
                    {
                        lblWins.TextRight = $"{levelInfo.TotalWins} ({levelInfo.AllWins + StatsForm.CurrentSettings.PreviousWins}){winChanceDisplay}";
                    }
                    else if (StatsForm.CurrentSettings.FilterType != 0)
                    {
                        lblWins.TextRight = $"{levelInfo.TotalWins} ({levelInfo.AllWins}){winChanceDisplay}";
                    }
                    else
                    {
                        lblWins.TextRight = $"{levelInfo.TotalWins}{winChanceDisplay}";
                    }

                    float  finalChance        = (float)levelInfo.TotalFinals * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows);
                    string finalText          = $"{levelInfo.TotalFinals} / {levelInfo.TotalShows}";
                    string finalChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : finalText.Length > 9 ? $" - {finalChance:0}%" : $" - {finalChance:0.0}%";
                    lblFinals.TextRight = $"{finalText}{finalChanceDisplay}";

                    lblStreak.TextRight = $"{levelInfo.CurrentStreak} (BEST {levelInfo.BestStreak})";

                    SetQualifyChanceLabel(levelInfo);
                    SetFastestLabel(levelInfo, level);
                    SetPlayersLabel();
                    if (isTimeToSwitch)
                    {
                        switchCount++;
                    }

                    DateTime Start  = lastRound.Start;
                    DateTime End    = lastRound.End;
                    DateTime?Finish = lastRound.Finish;

                    if (lastRound.Playing != startedPlaying)
                    {
                        if (lastRound.Playing)
                        {
                            startTime = DateTime.UtcNow;
                        }
                        startedPlaying = lastRound.Playing;
                    }

                    if (Finish.HasValue)
                    {
                        if (lastRound.Position > 0)
                        {
                            lblFinish.TextRight = $"# {lastRound.Position} - {Finish.GetValueOrDefault(End) - Start:m\\:ss\\.ff}";
                        }
                        else
                        {
                            lblFinish.TextRight = $"{Finish.GetValueOrDefault(End) - Start:m\\:ss\\.ff}";
                        }
                    }
                    else if (lastRound.Playing)
                    {
                        if (Start > DateTime.UtcNow)
                        {
                            lblFinish.TextRight = $"{DateTime.UtcNow - startTime:m\\:ss}";
                        }
                        else
                        {
                            lblFinish.TextRight = $"{DateTime.UtcNow - Start:m\\:ss}";
                        }
                    }
                    else
                    {
                        lblFinish.TextRight = "-";
                    }

                    if (End != DateTime.MinValue)
                    {
                        lblDuration.TextRight = (End - Start).ToString("m\\:ss\\.ff");
                    }
                    else if (lastRound.Playing)
                    {
                        if (Start > DateTime.UtcNow)
                        {
                            lblDuration.TextRight = (DateTime.UtcNow - startTime).ToString("m\\:ss");
                        }
                        else
                        {
                            lblDuration.TextRight = (DateTime.UtcNow - Start).ToString("m\\:ss");
                        }
                    }
                    else
                    {
                        lblDuration.TextRight = "-";
                    }
                }
                this.Invalidate();
            }

            if (StatsForm.CurrentSettings.UseNDI)
            {
                SendNDI();
            }
        }
Exemple #14
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 #15
0
        private void UpdateInfo()
        {
            if (StatsForm == null)
            {
                return;
            }

            lock (StatsForm.CurrentRound) {
                bool hasCurrentRound = StatsForm.CurrentRound != null && StatsForm.CurrentRound.Count > 0;
                if (hasCurrentRound && (lastRound == null || Stats.InShow || Stats.EndedShow))
                {
                    if (Stats.EndedShow)
                    {
                        Stats.EndedShow = false;
                    }
                    lastRound = StatsForm.CurrentRound[StatsForm.CurrentRound.Count - 1];
                }

                StatSummary levelInfo = StatsForm.GetLevelInfo(lastRound?.Name);
                lblFilter.Text = levelInfo.CurrentFilter;

                if (lastRound != null)
                {
                    lblName.Text = $"ROUND {lastRound.Round}:";

                    string displayName = string.Empty;
                    LevelStats.DisplayNameLookup.TryGetValue(lastRound.Name, out displayName);
                    lblName.TextRight    = displayName.ToUpper();
                    lblPlayers.TextRight = lastRound.Players.ToString();

                    float winChance = (float)levelInfo.TotalWins * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows);
                    if (StatsForm.CurrentSettings.PreviousWins > 0)
                    {
                        lblWins.TextRight = $"{levelInfo.TotalWins} ({levelInfo.AllWins + StatsForm.CurrentSettings.PreviousWins}) - {winChance:0.0}%";
                    }
                    else if (StatsForm.CurrentSettings.FilterType != 0)
                    {
                        lblWins.TextRight = $"{levelInfo.TotalWins} ({levelInfo.AllWins}) - {winChance:0.0}%";
                    }
                    else
                    {
                        lblWins.TextRight = $"{levelInfo.TotalWins} - {winChance:0.0}%";
                    }

                    float finalChance = (float)levelInfo.TotalFinals * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows);
                    lblFinalChance.TextRight = $"{levelInfo.TotalFinals} - {finalChance:0.0}%";

                    lblStreak.TextRight = $"{levelInfo.CurrentStreak} (BEST {levelInfo.BestStreak})";

                    if ((labelToShow % 2) == 0)
                    {
                        lblQualifyChance.Text = "QUALIFY:";
                        float qualifyChance = (float)levelInfo.TotalQualify * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays);
                        lblQualifyChance.TextRight = $"{levelInfo.TotalQualify} / {levelInfo.TotalPlays} - {qualifyChance:0.0}%";
                    }
                    else
                    {
                        lblQualifyChance.Text = "GOLD:";
                        float qualifyChance = (float)levelInfo.TotalGolds * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays);
                        lblQualifyChance.TextRight = $"{levelInfo.TotalGolds} / {levelInfo.TotalPlays} - {qualifyChance:0.0}%";
                    }

                    int modCount = levelInfo.BestScore.HasValue ? 3 : 2;
                    if ((labelToShow % modCount) == 1)
                    {
                        lblFastest.Text      = "FASTEST:";
                        lblFastest.TextRight = levelInfo.BestFinish.HasValue ? $"{levelInfo.BestFinish:m\\:ss\\.ff}" : "-";
                    }
                    else if ((labelToShow % modCount) == 2)
                    {
                        lblFastest.Text      = "HIGH SCORE:";
                        lblFastest.TextRight = levelInfo.BestScore.Value.ToString();
                    }
                    else
                    {
                        lblFastest.Text      = "LONGEST:";
                        lblFastest.TextRight = levelInfo.LongestFinish.HasValue ? $"{levelInfo.LongestFinish:m\\:ss\\.ff}" : "-";
                    }

                    DateTime Start  = lastRound.Start;
                    DateTime End    = lastRound.End;
                    DateTime?Finish = lastRound.Finish;

                    if (lastRound.Playing != startedPlaying)
                    {
                        if (lastRound.Playing)
                        {
                            startTime = DateTime.UtcNow;
                        }
                        startedPlaying = lastRound.Playing;
                    }

                    if (Finish.HasValue)
                    {
                        if (lastRound.Position > 0)
                        {
                            lblFinish.TextRight = $"# {lastRound.Position} - {Finish.GetValueOrDefault(End) - Start:m\\:ss\\.ff}";
                        }
                        else
                        {
                            lblFinish.TextRight = $"{Finish.GetValueOrDefault(End) - Start:m\\:ss\\.ff}";
                        }
                    }
                    else if (lastRound.Playing)
                    {
                        if (Start > DateTime.UtcNow)
                        {
                            lblFinish.TextRight = $"{DateTime.UtcNow - startTime:m\\:ss}";
                        }
                        else
                        {
                            lblFinish.TextRight = $"{DateTime.UtcNow - Start:m\\:ss}";
                        }
                    }
                    else
                    {
                        lblFinish.TextRight = "-";
                    }

                    if (End != DateTime.MinValue)
                    {
                        lblDuration.TextRight = (End - Start).ToString("m\\:ss");
                    }
                    else if (lastRound.Playing)
                    {
                        if (Start > DateTime.UtcNow)
                        {
                            lblDuration.TextRight = (DateTime.UtcNow - startTime).ToString("m\\:ss");
                        }
                        else
                        {
                            lblDuration.TextRight = (DateTime.UtcNow - Start).ToString("m\\:ss");
                        }
                    }
                    else
                    {
                        lblDuration.TextRight = "-";
                    }
                }
            }

            if (StatsForm.CurrentSettings.UseNDI)
            {
                SendNDI();
            }
        }
        private bool ParseLine(LogLine line, List <RoundInfo> round, LogRound logRound)
        {
            int index;

            if ((index = line.Line.IndexOf("[StateGameLoading] Loading game level scene", StringComparison.OrdinalIgnoreCase)) > 0)
            {
                logRound.Info = new RoundInfo();
                int index2 = line.Line.IndexOf(' ', index + 44);
                if (index2 < 0)
                {
                    index2 = line.Line.Length;
                }

                logRound.Info.SceneName  = line.Line.Substring(index + 44, index2 - index - 44);
                logRound.FindingPosition = false;
                round.Add(logRound.Info);
            }
            else if (logRound.Info != null && (index = line.Line.IndexOf("[StateGameLoading] Finished loading game level", StringComparison.OrdinalIgnoreCase)) > 0)
            {
                int index2 = line.Line.IndexOf(". ", index + 62);
                if (index2 < 0)
                {
                    index2 = line.Line.Length;
                }

                logRound.Info.Name         = line.Line.Substring(index + 62, index2 - index - 62);
                logRound.Info.Round        = round.Count;
                logRound.Info.Start        = line.Date;
                logRound.Info.InParty      = logRound.CurrentlyInParty;
                logRound.Info.PrivateLobby = logRound.PrivateLobby;
                logRound.Info.GameDuration = logRound.Duration;
                logRound.CountingPlayers   = true;
                logRound.Info.IsFinal      = logRound.IsFinal || (!logRound.HasIsFinal && LevelStats.SceneToRound.TryGetValue(logRound.Info.SceneName, out string roundName) && LevelStats.ALL.TryGetValue(roundName, out LevelStats stats) && stats.IsFinal);
            }
            else if ((index = line.Line.IndexOf("[StateMatchmaking] Begin matchmaking", StringComparison.OrdinalIgnoreCase)) > 0 ||
                     (index = line.Line.IndexOf("[GameStateMachine] Replacing FGClient.StateMainMenu with FGClient.StatePrivateLobby", StringComparison.OrdinalIgnoreCase)) > 0)
            {
                logRound.PrivateLobby     = line.Line.IndexOf("StatePrivateLobby") > 0;
                logRound.CurrentlyInParty = logRound.PrivateLobby || !line.Line.Substring(index + 37).Equals("solo", StringComparison.OrdinalIgnoreCase);
                if (logRound.Info != null)
                {
                    if (logRound.Info.End == DateTime.MinValue)
                    {
                        logRound.Info.End = line.Date;
                    }
                    logRound.Info.Playing = false;
                }
                logRound.FindingPosition = false;
                Stats.InShow             = true;
                round.Clear();
                logRound.Info = null;
            }
            else if ((index = line.Line.IndexOf("NetworkGameOptions: durationInSeconds=", StringComparison.OrdinalIgnoreCase)) > 0)
            {
                int nextIndex = line.Line.IndexOf(" ", index + 38);
                logRound.Duration   = int.Parse(line.Line.Substring(index + 38, nextIndex - index - 38));
                index               = line.Line.IndexOf("isFinalRound=", StringComparison.OrdinalIgnoreCase);
                logRound.HasIsFinal = index > 0;
                index               = line.Line.IndexOf("isFinalRound=True", StringComparison.OrdinalIgnoreCase);
                logRound.IsFinal    = index > 0;
            }
            else if (logRound.Info != null && logRound.CountingPlayers && (line.Line.IndexOf("[ClientGameManager] Finalising spawn", StringComparison.OrdinalIgnoreCase) > 0 || line.Line.IndexOf("[ClientGameManager] Added player ", StringComparison.OrdinalIgnoreCase) > 0))
            {
                logRound.Info.Players++;
            }
            else if ((index = line.Line.IndexOf("[ClientGameManager] Handling bootstrap for local player FallGuy [", StringComparison.OrdinalIgnoreCase)) > 0)
            {
                int prevIndex = line.Line.IndexOf(']', index + 65);
                logRound.CurrentPlayerID = line.Line.Substring(index + 65, prevIndex - index - 65);
            }
            else if (logRound.Info != null && line.Line.IndexOf($"[ClientGameManager] Handling unspawn for player FallGuy [{logRound.CurrentPlayerID}]", StringComparison.OrdinalIgnoreCase) > 0)
            {
                if (logRound.Info.End == DateTime.MinValue)
                {
                    logRound.Info.Finish = line.Date;
                }
                else
                {
                    logRound.Info.Finish = logRound.Info.End;
                }
                logRound.FindingPosition = true;
            }
            else if (logRound.Info != null && logRound.FindingPosition && (index = line.Line.IndexOf("[ClientGameSession] NumPlayersAchievingObjective=")) > 0)
            {
                int position = int.Parse(line.Line.Substring(index + 49));
                if (position > 0)
                {
                    logRound.FindingPosition = false;
                    logRound.Info.Position   = position;
                }
            }
            else if (logRound.Info != null && line.Line.IndexOf("Client address: ", StringComparison.OrdinalIgnoreCase) > 0)
            {
                index = line.Line.IndexOf("RTT: ");
                if (index > 0)
                {
                    int msIndex = line.Line.IndexOf("ms", index);
                    logRound.LastPing = int.Parse(line.Line.Substring(index + 5, msIndex - index - 5));
                }
            }
            else if (logRound.Info != null && line.Line.IndexOf("[GameSession] Changing state from Countdown to Playing", StringComparison.OrdinalIgnoreCase) > 0)
            {
                logRound.Info.Start      = line.Date;
                logRound.Info.Playing    = true;
                logRound.CountingPlayers = false;
            }
            else if (logRound.Info != null &&
                     (line.Line.IndexOf("[GameSession] Changing state from Playing to GameOver", StringComparison.OrdinalIgnoreCase) > 0 ||
                      line.Line.IndexOf("Changing local player state to: SpectatingEliminated", StringComparison.OrdinalIgnoreCase) > 0 ||
                      line.Line.IndexOf("[GlobalGameStateClient] SwitchToDisconnectingState", StringComparison.OrdinalIgnoreCase) > 0 ||
                      line.Line.IndexOf("[GameStateMachine] Replacing FGClient.StatePrivateLobby with FGClient.StateMainMenu", StringComparison.OrdinalIgnoreCase) > 0))
            {
                if (logRound.Info.End == DateTime.MinValue)
                {
                    logRound.Info.End = line.Date;
                }
                logRound.Info.Playing = false;
            }
            else if (line.Line.IndexOf("[StateMainMenu] Loading scene MainMenu", StringComparison.OrdinalIgnoreCase) > 0)
            {
                if (logRound.Info != null)
                {
                    if (logRound.Info.End == DateTime.MinValue)
                    {
                        logRound.Info.End = line.Date;
                    }
                    logRound.Info.Playing = false;
                }
                logRound.FindingPosition = false;
                logRound.CountingPlayers = false;
                Stats.InShow             = false;
            }
            else if (line.Line.IndexOf(" == [CompletedEpisodeDto] ==", StringComparison.OrdinalIgnoreCase) > 0)
            {
                if (logRound.Info == null)
                {
                    return(false);
                }

                RoundInfo    temp = null;
                StringReader sr   = new StringReader(line.Line);
                string       detail;
                bool         foundRound = false;
                int          maxRound   = 0;
                DateTime     showStart  = DateTime.MinValue;
                while ((detail = sr.ReadLine()) != null)
                {
                    if (detail.IndexOf("[Round ", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        foundRound = true;
                        int    roundNum  = (int)detail[7] - 0x30 + 1;
                        string roundName = detail.Substring(11, detail.Length - 12);

                        if (roundNum - 1 < round.Count)
                        {
                            if (roundNum > maxRound)
                            {
                                maxRound = roundNum;
                            }

                            temp = round[roundNum - 1];
                            if (string.IsNullOrEmpty(temp.Name) || !temp.Name.Equals(roundName, StringComparison.OrdinalIgnoreCase))
                            {
                                return(false);
                            }

                            temp.VerifyName();
                            if (roundNum == 1)
                            {
                                showStart = temp.Start;
                            }
                            temp.ShowStart            = showStart;
                            temp.Playing              = false;
                            temp.Round                = roundNum;
                            logRound.PrivateLobby     = temp.PrivateLobby;
                            logRound.CurrentlyInParty = temp.InParty;
                        }
                        else
                        {
                            return(false);
                        }

                        if (temp.End == DateTime.MinValue)
                        {
                            temp.End = line.Date;
                        }
                        if (temp.Start == DateTime.MinValue)
                        {
                            temp.Start = temp.End;
                        }
                        if (!temp.Finish.HasValue)
                        {
                            temp.Finish = temp.End;
                        }
                    }
                    else if (foundRound)
                    {
                        if (detail.IndexOf("> Position: ", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            temp.Position = int.Parse(detail.Substring(12));
                        }
                        else if (detail.IndexOf("> Team Score: ", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            temp.Score = int.Parse(detail.Substring(14));
                        }
                        else if (detail.IndexOf("> Qualified: ", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            char qualified = detail[13];
                            temp.Qualified = qualified == 'T';
                            temp.Finish    = temp.Qualified ? temp.Finish : null;
                        }
                        else if (detail.IndexOf("> Bonus Tier: ", StringComparison.OrdinalIgnoreCase) == 0 && detail.Length == 15)
                        {
                            char tier = detail[14];
                            temp.Tier = (int)tier - 0x30 + 1;
                        }
                        else if (detail.IndexOf("> Kudos: ", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            temp.Kudos += int.Parse(detail.Substring(9));
                        }
                        else if (detail.IndexOf("> Bonus Kudos: ", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            temp.Kudos += int.Parse(detail.Substring(15));
                        }
                        else if (detail.IndexOf("> Fame: ", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            temp.Fame += int.Parse(detail.Substring(8));
                        }
                        else if (detail.IndexOf("> Bonus Fame: ", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            temp.Fame += int.Parse(detail.Substring(14));
                        }
                    }
                }

                if (round.Count > maxRound)
                {
                    return(false);
                }

                logRound.Info = round[round.Count - 1];
                DateTime showEnd = logRound.Info.End;
                for (int i = 0; i < round.Count; i++)
                {
                    round[i].ShowEnd = showEnd;
                }
                if (logRound.Info.Qualified)
                {
                    logRound.Info.Crown = true;
                }
                logRound.Info   = null;
                Stats.InShow    = false;
                Stats.EndedShow = true;
                return(true);
            }
            return(false);
        }
Exemple #17
0
 private bool IsInPartyFilter(RoundInfo info)
 {
     return(menuAllPartyStats.Checked ||
            (menuSoloStats.Checked && !info.InParty) ||
            (menuPartyStats.Checked && info.InParty));
 }
Exemple #18
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);
        }