Ejemplo n.º 1
0
        public double SimulatedPp()
        {
            double pp = double.NaN;

            if (PpCalculator == null)
            {
                return(pp);
            }


            PpCalculator.Goods        = null;
            PpCalculator.Mehs         = null;
            PpCalculator.Misses       = 0;
            PpCalculator.Combo        = null;
            PpCalculator.PercentCombo = 100;
            PpCalculator.Score        = 1_000_000;
            pp = PpCalculator.Calculate(PlayTime, null);

            if (double.IsInfinity(pp))
            {
                pp = Double.NaN;
            }


            return(pp);
        }
Ejemplo n.º 2
0
        public double NoChokePp()
        {
            double pp = double.NaN;

            if (PpCalculator == null || _currentPlayMode == PlayMode.OsuMania)
            {
                return(pp);
            }


            PpCalculator.Goods        = Play.Hit100;
            PpCalculator.Mehs         = Play.Hit50;
            PpCalculator.Misses       = 0;
            PpCalculator.Combo        = null;
            PpCalculator.PercentCombo = 100;
            PpCalculator.Score        = Play.Score;
            pp = PpCalculator.Calculate(PlayTime, null);

            if (double.IsInfinity(pp))
            {
                pp = Double.NaN;
            }


            return(pp);
        }
Ejemplo n.º 3
0
        public double PPIfBeatmapWouldEndNow()
        {
            if (PpCalculator != null && PlayTime > 0)
            {
                PpCalculator.Goods  = Play.Hit100;
                PpCalculator.Mehs   = Play.Hit50;
                PpCalculator.Misses = Play.HitMiss;
                PpCalculator.Combo  = Play.MaxCombo;
                PpCalculator.Score  = Play.Score;
                attribs.Clear();
                var pp = PpCalculator.Calculate(PlayTime, attribs);
                if (!double.IsInfinity(pp))
                {
                    double accuracy, aim, strain, speed;
                    switch (_currentPlayMode)
                    {
                    case PlayMode.Taiko:
                    case PlayMode.OsuMania:
                        attribs.TryGetValue("Strain", out strain);
                        StrainPPIfBeatmapWouldEndNow = strain;
                        attribs.TryGetValue("Accuracy", out accuracy);
                        AccPPIfBeatmapWouldEndNow   = accuracy;
                        AimPPIfBeatmapWouldEndNow   = double.NaN;
                        SpeedPPIfBeatmapWouldEndNow = double.NaN;
                        break;

                    case PlayMode.CatchTheBeat:
                        ResetValues();
                        break;

                    default:
                        attribs.TryGetValue("Aim", out aim);
                        AimPPIfBeatmapWouldEndNow = aim;
                        attribs.TryGetValue("Speed", out speed);
                        SpeedPPIfBeatmapWouldEndNow = speed;
                        attribs.TryGetValue("Accuracy", out accuracy);
                        AccPPIfBeatmapWouldEndNow    = accuracy;
                        StrainPPIfBeatmapWouldEndNow = double.NaN;
                        break;
                    }

                    return(pp);
                }
            }
            ResetValues();
            return(double.NaN);

            void ResetValues()
            {
                AimPPIfBeatmapWouldEndNow    = double.NaN;
                SpeedPPIfBeatmapWouldEndNow  = double.NaN;
                AccPPIfBeatmapWouldEndNow    = double.NaN;
                StrainPPIfBeatmapWouldEndNow = double.NaN;
            }
        }
Ejemplo n.º 4
0
        public async Task <Image> GetImageAsync()
        {
            Image image = await Image.LoadAsync("./Static/usernotfound.png");

            var user = await GetUserAsync(_username, _mode);

            if (user is null)
            {
                return(image);
            }

            var score = _scoreType switch
            {
                ScoreType.Best => await GetBestScoreAsync(user),
                ScoreType.Recent => await GetRecentScoreAsync(user),
                _ => null
            };

            if (score is null)
            {
                return(image);
            }

            List <string> mods = Utils.GetModsList(score.Mods);
            var           pp   = new PpCalculator(score.Beatmap.BeatmapId);
            await pp.CacheBeatmap();

            score.Beatmap.PP = (await pp.GetFcPp(score, mods, _mode)).Pp;
            score.PP         = (await pp.GetScorePp(score, mods, _mode)).Pp;

            ImageGenerator imageGenerator = _scoreType switch
            {
                ScoreType.Best => new BestScoreImage(user, score),
                ScoreType.Recent => new RecentScoreImage(user, score),
                _ => null
            };

            try
            {
                image = imageGenerator?.Generate();
            }
            catch (Exception e)
            {
                // ignored
            }

            return(image);
        }
Ejemplo n.º 5
0
        public double PPIfBeatmapWouldEndNow()
        {
            if (PpCalculator != null && PlayTime > 0)
            {
                try
                {
                    PpCalculator.Goods  = Play.C100;
                    PpCalculator.Mehs   = Play.C50;
                    PpCalculator.Misses = Play.CMiss;
                    PpCalculator.Combo  = Play.MaxCombo;
                    PpCalculator.Score  = Play.Score;
                    var pp = PpCalculator.Calculate(PlayTime, attribs);
                    if (!double.IsInfinity(pp))
                    {
                        switch (_currentPlayMode)
                        {
                        case PlayMode.Taiko:
                        case PlayMode.OsuMania:
                            StrainPPIfBeatmapWouldEndNow = attribs["Strain"];
                            AccPPIfBeatmapWouldEndNow    = attribs["Accuracy"];
                            AimPPIfBeatmapWouldEndNow    = double.NaN;
                            SpeedPPIfBeatmapWouldEndNow  = double.NaN;
                            break;

                        default:
                            AimPPIfBeatmapWouldEndNow   = attribs["Aim"];
                            SpeedPPIfBeatmapWouldEndNow = attribs["Speed"];
                            AccPPIfBeatmapWouldEndNow   = attribs["Accuracy"];
                            break;
                        }

                        attribs.Clear();

                        return(pp);
                    }

                    attribs.Clear();
                }
                catch { }
            }
            AimPPIfBeatmapWouldEndNow    = double.NaN;
            SpeedPPIfBeatmapWouldEndNow  = double.NaN;
            AccPPIfBeatmapWouldEndNow    = double.NaN;
            StrainPPIfBeatmapWouldEndNow = double.NaN;
            return(double.NaN);
        }
        public void CalculateTest(int c100, int c50, int cMiss, int combo, string mods, double expectedPp, int mapId, PpCalculator ppCalculator, int score = 0)
        {
            ppCalculator.PreProcess(GetMapPath(mapId));
            ppCalculator.Goods  = c100;
            ppCalculator.Mehs   = c50;
            ppCalculator.Misses = cMiss;
            ppCalculator.Combo  = combo;
            ppCalculator.Score  = score;
            ppCalculator.Mods   = mods.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);

            var calculatedPp = ppCalculator.Calculate();

            Assert.That(calculatedPp, Is.EqualTo(expectedPp).Within(0.01));
        }