Example #1
0
        private static void RemoveNullValues(IRun run)
        {
            var cache    = new List <int>();
            var maxIndex = run.AttemptHistory.Select(x => x.Index).DefaultIfEmpty(0).Max();

            for (var runIndex = run.GetMinSegmentHistoryIndex(); runIndex <= maxIndex; runIndex++)
            {
                for (var index = 0; index < run.Count; index++)
                {
                    Time segmentHistoryElement;
                    if (!run[index].SegmentHistory.TryGetValue(runIndex, out segmentHistoryElement))
                    {
                        //Remove null times in history that aren't followed by a non-null time
                        RemoveItemsFromCache(run, index, cache);
                    }
                    else if (segmentHistoryElement.RealTime == null && segmentHistoryElement.GameTime == null)
                    {
                        cache.Add(runIndex);
                    }
                    else
                    {
                        cache.Clear();
                    }
                }
                RemoveItemsFromCache(run, run.Count, cache);
            }
        }
Example #2
0
        private static void RemoveNullValues(IRun run, TimingMethod method)
        {
            var cache    = new List <IIndexedTime>();
            var maxIndex = run.AttemptHistory.Select(x => x.Index).DefaultIfEmpty(0).Max();

            for (var runIndex = run.GetMinSegmentHistoryIndex(); runIndex <= maxIndex; runIndex++)
            {
                for (var index = 0; index < run.Count; index++)
                {
                    var segmentHistoryElement = run[index].SegmentHistory.FirstOrDefault(x => x.Index == runIndex);
                    if (segmentHistoryElement == null)
                    {
                        RemoveItemsFromCache(run, index, cache);
                    }
                    else if (segmentHistoryElement.Time.RealTime == null && segmentHistoryElement.Time.GameTime == null)
                    {
                        cache.Add(segmentHistoryElement);
                    }
                    else
                    {
                        cache.Clear();
                    }
                }
                RemoveItemsFromCache(run, run.Count, cache);
                cache.Clear();
            }
        }
Example #3
0
        private static void ReattachUnattachedSegmentHistoryElements(IRun run)
        {
            int max_id = run.AttemptHistory.Select(x => x.Index).DefaultIfEmpty().Max();
            int min_id = run.GetMinSegmentHistoryIndex();

            int unattached_id;

            // can't use `default` keyword because repo isn't on C# 7.1 yet so we use 0 instead
            while ((unattached_id = run
                                    .Select(seg => seg.SegmentHistory.Select(x => x.Key).DefaultIfEmpty().Max())
                                    .Where(i => i > max_id)
                                    .DefaultIfEmpty()
                                    .Max()) > 0)
            {
                var reassign_id = min_id - 1;

                foreach (Segment segment in run)
                {
                    if (segment.SegmentHistory.TryGetValue(unattached_id, out Time time))
                    {
                        segment.SegmentHistory.Add(reassign_id, time);
                        segment.SegmentHistory.Remove(unattached_id);
                    }
                }

                min_id = reassign_id;
            }
        }