Пример #1
0
        public double PPIfRestFCed()
        {
            double pp = double.NaN;

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

            if (PlayTime <= 0)
            {
                PpCalculator.Goods        = 0;
                PpCalculator.Mehs         = 0;
                PpCalculator.Combo        = null;
                PpCalculator.PercentCombo = 100;
                return(PpCalculator.Calculate()); //fc pp
            }

            if (_currentPlayMode == PlayMode.CatchTheBeat)
            {
                PpCalculator.Goods  = Play.Hit100;
                PpCalculator.Mehs   = null;
                PpCalculator.Misses = Play.HitMiss;
                PpCalculator.Katsus = Play.HitKatu;
                PpCalculator.Combo  = Play.MaxCombo;
                PpCalculator.Score  = Play.Score;
            }

            ComboLeft = PpCalculator.GetMaxCombo((int)PlayTime);

            var newMaxCombo = Math.Max(Play.MaxCombo, ComboLeft + Play.Combo);

            PpCalculator.Combo = newMaxCombo;

            pp = PpCalculator.Calculate(null);


            return(pp);
        }
Пример #2
0
        public void SetPpCalculator(IPpCalculator ppCalculator, CancellationToken cancellationToken)
        {
            _currentPlayMode = (PlayMode)ppCalculator.RulesetId;
            try
            {
                ppCalculator.Calculate(cancellationToken);
            }
            catch (OperationCanceledException)
            {
                PpCalculator = null;
                throw;
            }

            PpCalculator = ppCalculator;
        }
Пример #3
0
        public static Dictionary <int, double> CalculateStrains(this IPpCalculator ppCalculator,
                                                                CancellationToken cancellationToken, int?targetAmount = null)
        {
            var strains = new Dictionary <int, double>(targetAmount ?? 200);

            if (ppCalculator == null)
            {
                return(strains);
            }

            var mapLength = ppCalculator.BeatmapLength;
            //data for 2min map
            var strainLength = 5000;
            var interval     = 1500;
            var time         = 0;

            if (targetAmount.HasValue)
            {
                strainLength = Convert.ToInt32(Math.Floor(strainLength * (mapLength / 120_000d)));
                interval     = Convert.ToInt32(Math.Ceiling(mapLength - strainLength / 2d) / targetAmount) + 1;
                //var strainsAmount = (mapLength - strainLength / 2d) / interval;
            }

            var a = new Dictionary <string, double>();

            while (time + strainLength / 2 < mapLength)
            {
                cancellationToken.ThrowIfCancellationRequested();
                var strain = ppCalculator.Calculate(time, time + strainLength, a);
                if (double.IsNaN(strain) || strain < 0)
                {
                    strain = 0;
                }
                else if (strain > 2000)
                {
                    strain = 2000; //lets not freeze everything with aspire/fancy 100* maps
                }
                strains.Add(time, strain);
                time += interval;
                a.Clear();
            }

            return(strains);
        }