예제 #1
0
        public override void Execute()
        {
            var ruleset = new OsuRuleset();

            var allLines = File.ReadAllLines(ScoreSetsPath).Select(a => a.Split(','));
            var lines    = allLines.Where(l => l[0] == SetName);

            var sw = new StringWriter();

            sw.WriteLine("ID, Beatmap, Mods, Combo, Max Combo, Accuracy, Aim pp, Tap pp, Acc pp, pp");

            foreach (var l in lines)
            {
                var s    = new Score(l);
                var mods = s.Mods.ToArray();

                string beatmapID = s.ID;

                string cachePath = Path.Combine("cache", $"{beatmapID}.osu");

                if (!File.Exists(cachePath))
                {
                    Console.WriteLine($"Downloading {beatmapID}.osu...");
                    new FileWebRequest(cachePath, $"{base_url}/osu/{beatmapID}").Perform();
                }

                var workingBeatmap = new ProcessorWorkingBeatmap(cachePath);
                var beatmap        = workingBeatmap.GetPlayableBeatmap(ruleset.RulesetInfo, mods);

                var beatmapMaxCombo = getMaxCombo(beatmap);
                var maxCombo        = (int)Math.Round(s.PercentCombo / 100 * beatmapMaxCombo);
                var accuracy        = s.Accuracy;

                var statistics = generateHitResults(accuracy, beatmap, s.MissCount);

                var scoreInfo = new ScoreInfo
                {
                    Accuracy   = accuracy,
                    MaxCombo   = maxCombo,
                    Statistics = statistics,
                    Mods       = mods,
                };
                var    categoryAttribs = new Dictionary <string, double>();
                double pp = ruleset.CreatePerformanceCalculator(workingBeatmap, scoreInfo).Calculate(categoryAttribs);

                var resultLine = new List <string>()
                {
                    beatmap.BeatmapInfo.OnlineBeatmapID.ToString(),
                    beatmap.BeatmapInfo.ToString().Replace(",", ";"),
                    string.Join("", s.ModStrings),

                    maxCombo.ToString(),
                    beatmapMaxCombo.ToString(),
                    (accuracy * 100).ToString("F2"),
                    categoryAttribs["Aim"].ToString("F2"),
                    categoryAttribs["Tap"].ToString("F2"),
                    categoryAttribs["Accuracy"].ToString("F2"),
                    pp.ToString("F2")
                };

                sw.WriteLine(string.Join(", ", resultLine));
            }
            if (OutputFile == null)
            {
                Console.Write(sw.ToString());
            }
            else
            {
                File.WriteAllText(OutputFile, sw.ToString());
            }

            sw.Dispose();
        }
예제 #2
0
        public ppData Calculate()
        {
            var ruleset = new OsuRuleset();

            Mod[]  mods = ruleset.ConvertLegacyMods((LegacyMods)score.EnabledMods).ToArray();
            double objectCount;
            double hitCount = score.CountGeki + score.Count300 + score.Count100 + score.CountKatu + score.Count50 + score.CountMiss;

            if (gamemode == 1 || gamemode == 2)
            {
                objectCount = score.CountGeki + score.Count300 + score.Count100 + score.CountKatu + score.Count50 + score.CountMiss;
            }
            else
            {
                objectCount = beatmap.CountNormal + beatmap.CountSlider + beatmap.CountSpinner;
            }

            double hitMultiplier = objectCount / hitCount;

            var workingBeatmap = new ProcessorWorkingBeatmap(beatmap.BeatmapId.ToString());

            workingBeatmap.BeatmapInfo.Ruleset = ruleset.RulesetInfo;

            var result = new ppData();

            var parsedScore = new ProcessorScoreParser(workingBeatmap).Parse(new ScoreInfo
            {
                Ruleset    = ruleset.RulesetInfo,
                MaxCombo   = score.MaxCombo,
                TotalScore = score.Score,
                Mods       = mods,
                Accuracy   = OsuHelper.CalculateAccuracy(score, gamemode),
                Statistics = new Dictionary <HitResult, int>
                {
                    { HitResult.Perfect, score.CountGeki },
                    { HitResult.Great, score.Count300 },
                    { HitResult.Good, score.Count100 },
                    { HitResult.Ok, score.CountKatu },
                    { HitResult.Meh, score.Count50 },
                    { HitResult.Miss, score.CountMiss }
                }
            });

            result.AchievedPp = ruleset.CreatePerformanceCalculator(workingBeatmap, parsedScore.ScoreInfo).Calculate();

            if (!score.Perfect && gamemode != 1 && gamemode != 3)
            {
                var fullComboScore = new ProcessorScoreParser(workingBeatmap).Parse(new ScoreInfo
                {
                    Ruleset    = ruleset.RulesetInfo,
                    MaxCombo   = beatmap.MaxCombo,
                    TotalScore = score.Score,
                    Mods       = mods,
                    Accuracy   = OsuHelper.CalculateAccuracy(score, gamemode),
                    Statistics = new Dictionary <HitResult, int>
                    {
                        { HitResult.Perfect, (int)Math.Round(hitMultiplier * score.CountGeki) },
                        { HitResult.Great, (int)Math.Round(hitMultiplier * score.Count300) },
                        { HitResult.Good, (int)Math.Round(hitMultiplier * score.Count100) },
                        { HitResult.Ok, (int)Math.Round(hitMultiplier * score.CountKatu) },
                        { HitResult.Meh, (int)Math.Round(hitMultiplier * score.Count50 + score.CountMiss) },
                        { HitResult.Miss, 0 }
                    }
                });

                result.FullComboPp = ruleset.CreatePerformanceCalculator(workingBeatmap, fullComboScore.ScoreInfo).Calculate();
            }

            if (OsuHelper.CalculateAccuracy(score, gamemode) != 1)
            {
                var ssScore = new ProcessorScoreParser(workingBeatmap).Parse(new ScoreInfo
                {
                    Ruleset    = ruleset.RulesetInfo,
                    MaxCombo   = beatmap.MaxCombo,
                    Mods       = mods,
                    Accuracy   = 1,
                    Statistics = new Dictionary <HitResult, int>
                    {
                        { HitResult.Perfect, 0 },
                        { HitResult.Great, (int)objectCount },
                        { HitResult.Good, 0 },
                        { HitResult.Ok, 0 },
                        { HitResult.Meh, 0 },
                        { HitResult.Miss, 0 }
                    }
                });

                result.ssPp = ruleset.CreatePerformanceCalculator(workingBeatmap, ssScore.ScoreInfo).Calculate();
            }

            return(result);
        }