Esempio n. 1
0
        private void CalcRating()
        {
            string text = null, output;

            isCalculating = true;

            try
            {
#if DEBUG
                var sw = new Stopwatch();
                sw.Start();
#endif
                Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                {
                    text = PathText.Text;
                }));

                var map          = new BeatmapInfo(text);
                var jack         = new PatternAnalyzer(map.Notes, map.LNs, map.Data.Keys, map.Data.Bpms, map.Data.SpecialStyle);
                var specialStyle = map.Data.SpecialStyle ||
                                   (map.Data.Keys == 8 && PatternAnalyzer.IsSpecialStyle(map.Notes, map.LNs));
                var maxBpm = Math.Round(map.Data.Bpms.Select(cur => cur.Item1).Max(), 2);
                var minBpm = Math.Round(map.Data.Bpms.Select(cur => cur.Item1).Min(), 2);

                output = map.Data.Artist + " - " + map.Data.Title + " [" + map.Data.Diff + "]\nMade by " + map.Data.Creator
                         + "\nBPM: " + (Math.Abs(maxBpm - minBpm) < 0.001 ? $"{maxBpm}" : $"{minBpm} - {maxBpm}\t")
                         + "\tOD: " + map.Data.Od + "\tHP: " + map.Data.Hp
                         + "\tKeys: " + (map.Data.Keys == 8 || specialStyle ? Convert.ToString(map.Data.Keys - 1) + "+1" : Convert.ToString(map.Data.Keys))
#if DEBUG
                         + "\nJack Score: " + Math.Round(RatingCalculator.CalcJackScore(jack), 2) + "    "
                         + "\tVibro Ratio: " + Math.Round(jack.GetVibroRatio() * 100, 2) + "%"
                         + "\tSpam Ratio: " + Math.Round(jack.GetSpamRatio() * 100, 2) + "%"
                         + "\nDensity Score: " + Math.Round(map.JenksDensity, 2)
                         + "\tSpeed Score: " + Math.Round(map.JenksSpeed, 2)
#endif
                         + "\nRating: " + Math.Round(RatingCalculator.CalcRating(map, jack), 2);
#if DEBUG
                sw.Stop();

                output += "\nElapsed Time: " + sw.ElapsedMilliseconds;
#endif
            }
            catch (Exception ex)
            {
                output = ex.Message;
            }

            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
            {
                StateBlock.Text = output;
            }));

            isCalculating = false;
        }