private void testOsuMods(OsuRuleset ruleset)
        {
            var easierMods = ruleset.GetModsFor(ModType.DifficultyReduction);
            var harderMods = ruleset.GetModsFor(ModType.DifficultyIncrease);
            var assistMods = ruleset.GetModsFor(ModType.Special);

            var noFailMod = easierMods.FirstOrDefault(m => m is OsuModNoFail);
            var hiddenMod = harderMods.FirstOrDefault(m => m is OsuModHidden);

            var doubleTimeMod = harderMods.OfType <MultiMod>().FirstOrDefault(m => m.Mods.Any(a => a is OsuModDoubleTime));

            var autoPilotMod = assistMods.FirstOrDefault(m => m is OsuModAutopilot);

            var easy     = easierMods.FirstOrDefault(m => m is OsuModEasy);
            var hardRock = harderMods.FirstOrDefault(m => m is OsuModHardRock);

            testSingleMod(noFailMod);
            testMultiMod(doubleTimeMod);
            testIncompatibleMods(easy, hardRock);
            testDeselectAll(easierMods.Where(m => !(m is MultiMod)));
            testMultiplierTextColour(noFailMod, modSelect.LowMultiplierColour);
            testMultiplierTextColour(hiddenMod, modSelect.HighMultiplierColour);

            testUnimplmentedMod(autoPilotMod);
        }
        private void load()
        {
            var ruleset = new OsuRuleset().RulesetInfo;

            var normal = CreateWorkingBeatmap(ruleset).BeatmapSetInfo;

            normal.OnlineInfo.HasVideo      = true;
            normal.OnlineInfo.HasStoryboard = true;

            var undownloadable = getUndownloadableBeatmapSet(ruleset);

            Child = new BasicScrollContainer
            {
                RelativeSizeAxes = Axes.Both,
                Child            = new FillFlowContainer
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Direction        = FillDirection.Vertical,
                    Padding          = new MarginPadding(20),
                    Spacing          = new Vector2(0, 20),
                    Children         = new Drawable[]
                    {
                        new DirectGridPanel(normal),
                        new DirectListPanel(normal),
                        new DirectGridPanel(undownloadable),
                        new DirectListPanel(undownloadable),
                    },
                },
            };
        }
Exemple #3
0
        public void SetUpSteps()
        {
            AddStep("create editor overlay", () =>
            {
                SetContents(() =>
                {
                    var ruleset = new OsuRuleset();
                    var working = CreateWorkingBeatmap(ruleset.RulesetInfo);
                    var beatmap = working.GetPlayableBeatmap(ruleset.RulesetInfo);

                    var drawableRuleset = ruleset.CreateDrawableRulesetWith(beatmap);

                    var hudOverlay = new HUDOverlay(drawableRuleset, Array.Empty <Mod>())
                    {
                        Anchor = Anchor.Centre,
                        Origin = Anchor.Centre,
                    };

                    // Add any key just to display the key counter visually.
                    hudOverlay.KeyCounter.Add(new KeyCounterKeyboard(Key.Space));
                    scoreProcessor.Combo.Value = 1;

                    return(new Container
                    {
                        RelativeSizeAxes = Axes.Both,
                        Children = new Drawable[]
                        {
                            drawableRuleset,
                            hudOverlay,
                            new SkinEditor(hudOverlay),
                        }
                    });
                });
            });
        }
Exemple #4
0
        private void load(GameHost host, AudioManager audio)
        {
            Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
            Dependencies.Cache(manager  = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default));

            var beatmaps = new List <BeatmapInfo>();

            for (int i = 0; i < 6; i++)
            {
                int beatmapId = 10 * 10 + i;

                int    length = RNG.Next(30000, 200000);
                double bpm    = RNG.NextSingle(80, 200);

                beatmaps.Add(new BeatmapInfo
                {
                    Ruleset         = new OsuRuleset().RulesetInfo,
                    OnlineBeatmapID = beatmapId,
                    Version         = $"{beatmapId} (length {TimeSpan.FromMilliseconds(length):m\\:ss}, bpm {bpm:0.#})",
                    Length          = length,
                    BPM             = bpm,
                    BaseDifficulty  = new BeatmapDifficulty
                    {
                        OverallDifficulty = 3.5f,
                    },
                });
        public void TestMod()
        {
            var ruleset = new OsuRuleset();

            var mod1 = new OsuModDoubleTime {
                SpeedChange = { Value = 1.25 }
            };
            var mod2 = new OsuModDoubleTime {
                SpeedChange = { Value = 1.26 }
            };
            var mod3 = new OsuModDoubleTime {
                SpeedChange = { Value = 1.26 }
            };

            var doubleConvertedMod1 = new APIMod(mod1).ToMod(ruleset);
            var doubleConvertedMod2 = new APIMod(mod2).ToMod(ruleset);
            var doubleConvertedMod3 = new APIMod(mod3).ToMod(ruleset);

            Assert.That(mod1, Is.Not.EqualTo(mod2));
            Assert.That(doubleConvertedMod1, Is.Not.EqualTo(doubleConvertedMod2));

            Assert.That(mod2, Is.EqualTo(mod2));
            Assert.That(doubleConvertedMod2, Is.EqualTo(doubleConvertedMod2));

            Assert.That(mod2, Is.EqualTo(mod3));
            Assert.That(doubleConvertedMod2, Is.EqualTo(doubleConvertedMod3));

            Assert.That(mod3, Is.EqualTo(mod2));
            Assert.That(doubleConvertedMod3, Is.EqualTo(doubleConvertedMod2));
        }
Exemple #6
0
        public void TestLegacyBeatmapReplayOffsetsEncodeDecode(int beatmapVersion)
        {
            const double first_frame_time  = 2000;
            const double second_frame_time = 3000;

            var ruleset   = new OsuRuleset().RulesetInfo;
            var scoreInfo = TestResources.CreateTestScoreInfo(ruleset);
            var beatmap   = new TestBeatmap(ruleset)
            {
                BeatmapInfo =
                {
                    BeatmapVersion = beatmapVersion
                }
            };

            var score = new Score
            {
                ScoreInfo = scoreInfo,
                Replay    = new Replay
                {
                    Frames = new List <ReplayFrame>
                    {
                        new OsuReplayFrame(first_frame_time, OsuPlayfield.BASE_SIZE / 2, OsuAction.LeftButton),
                        new OsuReplayFrame(second_frame_time, OsuPlayfield.BASE_SIZE / 2, OsuAction.LeftButton)
                    }
                }
            };

            var decodedAfterEncode = encodeThenDecode(beatmapVersion, score, beatmap);

            Assert.That(decodedAfterEncode.Replay.Frames[0].Time, Is.EqualTo(first_frame_time));
            Assert.That(decodedAfterEncode.Replay.Frames[1].Time, Is.EqualTo(second_frame_time));
        }
        public void TestOsuMods()
        {
            changeRuleset(0);

            var osu = new OsuRuleset();

            var easierMods     = osu.GetModsFor(ModType.DifficultyReduction);
            var harderMods     = osu.GetModsFor(ModType.DifficultyIncrease);
            var conversionMods = osu.GetModsFor(ModType.Conversion);

            var noFailMod = osu.GetModsFor(ModType.DifficultyReduction).FirstOrDefault(m => m is OsuModNoFail);
            var hiddenMod = harderMods.FirstOrDefault(m => m is OsuModHidden);

            var doubleTimeMod = harderMods.OfType <MultiMod>().FirstOrDefault(m => m.Mods.Any(a => a is OsuModDoubleTime));

            var targetMod = conversionMods.FirstOrDefault(m => m is OsuModTarget);

            var easy     = easierMods.FirstOrDefault(m => m is OsuModEasy);
            var hardRock = harderMods.FirstOrDefault(m => m is OsuModHardRock);

            testSingleMod(noFailMod);
            testMultiMod(doubleTimeMod);
            testIncompatibleMods(easy, hardRock);
            testDeselectAll(easierMods.Where(m => !(m is MultiMod)));
            testMultiplierTextColour(noFailMod, () => modSelect.LowMultiplierColour);
            testMultiplierTextColour(hiddenMod, () => modSelect.HighMultiplierColour);

            testUnimplementedMod(targetMod);
        }
Exemple #8
0
        public TestSceneGameplayCursor()
        {
            var ruleset = new OsuRuleset();

            gameplayState = new GameplayState(CreateBeatmap(ruleset.RulesetInfo), ruleset, Array.Empty <Mod>());

            AddStep("change background colour", () =>
            {
                background?.Expire();

                Add(background = new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Depth            = float.MaxValue,
                    Colour           = new Colour4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1)
                });
            });

            AddSliderStep("circle size", 0f, 10f, 0f, val =>
            {
                config.SetValue(OsuSetting.AutoCursorSize, true);
                gameplayState.Beatmap.Difficulty.CircleSize = val;
                Scheduler.AddOnce(loadContent);
            });

            AddStep("test cursor container", () => loadContent(false));
        }
        public void TestDisplayTeamResults(int team1Score, int team2Score)
        {
            MultiplayerResultsScreen screen = null;

            AddStep("show results screen", () =>
            {
                var rulesetInfo = new OsuRuleset().RulesetInfo;
                var beatmapInfo = CreateBeatmap(rulesetInfo).BeatmapInfo;
                var score       = TestResources.CreateTestScoreInfo(beatmapInfo);

                PlaylistItem playlistItem = new PlaylistItem
                {
                    BeatmapID = beatmapInfo.OnlineID,
                };

                SortedDictionary <int, BindableInt> teamScores = new SortedDictionary <int, BindableInt>
                {
                    { 0, new BindableInt(team1Score) },
                    { 1, new BindableInt(team2Score) }
                };

                Stack.Push(screen = new MultiplayerTeamResultsScreen(score, 1, playlistItem, teamScores));
            });

            AddUntilStep("wait for loaded", () => screen.IsLoaded);
        }
Exemple #10
0
 private void testOsuBeatmap(OsuRuleset ruleset)
 {
     AddAssert("check version", () => infoWedge.Info.VersionLabel.Text == $"{ruleset.ShortName}Version");
     AddAssert("check title", () => infoWedge.Info.TitleLabel.Text == $"{ruleset.ShortName}Source — {ruleset.ShortName}Title");
     AddAssert("check artist", () => infoWedge.Info.ArtistLabel.Text == $"{ruleset.ShortName}Artist");
     AddAssert("check author", () => infoWedge.Info.MapperContainer.Children.OfType <OsuSpriteText>().Any(s => s.Text == $"{ruleset.ShortName}Author"));
 }
Exemple #11
0
        public void TestDisplayResults()
        {
            MultiplayerResultsScreen screen = null;

            AddStep("show results screen", () =>
            {
                var rulesetInfo = new OsuRuleset().RulesetInfo;
                var beatmapInfo = CreateBeatmap(rulesetInfo).BeatmapInfo;

                var score = new ScoreInfo
                {
                    Rank        = ScoreRank.B,
                    TotalScore  = 987654,
                    Accuracy    = 0.8,
                    MaxCombo    = 500,
                    Combo       = 250,
                    BeatmapInfo = beatmapInfo,
                    User        = new APIUser {
                        Username = "******"
                    },
                    Date          = DateTimeOffset.Now,
                    OnlineScoreID = 12345,
                    Ruleset       = rulesetInfo,
                };

                PlaylistItem playlistItem = new PlaylistItem
                {
                    BeatmapID = beatmapInfo.OnlineID ?? -1,
                };

                Stack.Push(screen = new MultiplayerResultsScreen(score, 1, playlistItem));
            });

            AddUntilStep("wait for loaded", () => screen.IsLoaded);
        }
Exemple #12
0
        public void TestInterfaceModType()
        {
            ModIcon icon = null;

            var ruleset = new OsuRuleset();

            AddStep("create mod icon", () => Child = icon = new ModIcon(ruleset.AllMods.First(m => m.Acronym == "DT")));
            AddStep("change mod", () => icon.Mod   = ruleset.AllMods.First(m => m.Acronym == "EZ"));
        }
Exemple #13
0
 public override void SetUp()
 {
     base.SetUp();
     ruleset          = new OsuRuleset();
     apiModDoubleTime = new APIMod {
         Acronym = "DT"
     };
     apiModDifficultyAdjust = new APIMod {
         Acronym = "DA"
     };
 }
        public void TestWithDefaultDate()
        {
            AddStep("show autoplay score", () =>
            {
                var ruleset = new OsuRuleset();

                var mods    = new Mod[] { ruleset.GetAutoplayMod() };
                var beatmap = createTestBeatmap(new APIUser());

                showPanel(new TestScoreInfo(ruleset.RulesetInfo)
                {
                    Mods        = mods,
                    BeatmapInfo = beatmap,
                    Date        = default,
Exemple #15
0
        public void TestDisplayResults()
        {
            MultiplayerResultsScreen screen = null;

            AddStep("show results screen", () =>
            {
                var rulesetInfo = new OsuRuleset().RulesetInfo;
                var beatmapInfo = CreateBeatmap(rulesetInfo).BeatmapInfo;
                var score       = TestResources.CreateTestScoreInfo(beatmapInfo);

                Stack.Push(screen = new MultiplayerResultsScreen(score, 1, new PlaylistItem(beatmapInfo)));
            });

            AddUntilStep("wait for loaded", () => screen.IsLoaded);
        }
Exemple #16
0
        public BeatmapStats Calculate()
        {
            if (!string.IsNullOrEmpty(BeatmapId))
            {
                ProcessedBeatmap = new ProcessorWorkingBeatmap(BeatmapId);
                var ruleset = new OsuRuleset();

                ProcessedBeatmap.BeatmapInfo.Ruleset = ruleset.RulesetInfo;

                var attributes = ruleset.CreateDifficultyCalculator(ProcessedBeatmap).Calculate(GetModObjects(Mods, ruleset));

                switch (attributes)
                {
                case OsuDifficultyAttributes osu:
                    double[] strainPeakTotal = new double[osu.Skills[0].StrainPeaks.Count];
                    double[] strainPeakAim   = osu.Skills[0].StrainPeaks.ToArray();
                    double[] strainPeakSpeed = osu.Skills[1].StrainPeaks.ToArray();

                    for (int i = 0; i < osu.Skills[0].StrainPeaks.Count; i++)
                    {
                        strainPeakAim[i]   = Math.Sqrt(strainPeakAim[i] * 9.999) * difficultyMultiplier;
                        strainPeakSpeed[i] = Math.Sqrt(strainPeakSpeed[i] * 9.999) * difficultyMultiplier;

                        strainPeakTotal[i] = strainPeakAim[i] + strainPeakSpeed[i] + Math.Abs(strainPeakAim[i] - strainPeakSpeed[i]) / 2;
                    }

                    return(new BeatmapStats
                    {
                        DiffAim = osu.AimSR,
                        DiffSpeed = osu.TapSR,
                        DiffTotal = osu.StarRating,
                        StrainPeakAim = strainPeakAim,
                        StrainPeakSpeed = strainPeakSpeed,
                        StrainPeakTotal = strainPeakTotal
                    });

                default:
                    return(new BeatmapStats {
                    });
                }
            }
            else
            {
                throw new ArgumentNullException("No beatmap ID provided");
            }
        }
Exemple #17
0
        public void TestCultureInvariance()
        {
            var ruleset   = new OsuRuleset().RulesetInfo;
            var scoreInfo = new TestScoreInfo(ruleset);
            var beatmap   = new TestBeatmap(ruleset);
            var score     = new Score
            {
                ScoreInfo = scoreInfo,
                Replay    = new Replay
                {
                    Frames = new List <ReplayFrame>
                    {
                        new OsuReplayFrame(2000, OsuPlayfield.BASE_SIZE / 2, OsuAction.LeftButton)
                    }
                }
            };

            // the "se" culture is used here, as it encodes the negative number sign as U+2212 MINUS SIGN,
            // rather than the classic ASCII U+002D HYPHEN-MINUS.
            CultureInfo.CurrentCulture = new CultureInfo("se");

            var encodeStream = new MemoryStream();

            var encoder = new LegacyScoreEncoder(score, beatmap);

            encoder.Encode(encodeStream);

            var decodeStream = new MemoryStream(encodeStream.GetBuffer());

            var decoder            = new TestLegacyScoreDecoder();
            var decodedAfterEncode = decoder.Parse(decodeStream);

            Assert.Multiple(() =>
            {
                Assert.That(decodedAfterEncode, Is.Not.Null);

                Assert.That(decodedAfterEncode.ScoreInfo.User.Username, Is.EqualTo(scoreInfo.User.Username));
                Assert.That(decodedAfterEncode.ScoreInfo.BeatmapInfoID, Is.EqualTo(scoreInfo.BeatmapInfoID));
                Assert.That(decodedAfterEncode.ScoreInfo.Ruleset, Is.EqualTo(scoreInfo.Ruleset));
                Assert.That(decodedAfterEncode.ScoreInfo.TotalScore, Is.EqualTo(scoreInfo.TotalScore));
                Assert.That(decodedAfterEncode.ScoreInfo.MaxCombo, Is.EqualTo(scoreInfo.MaxCombo));
                Assert.That(decodedAfterEncode.ScoreInfo.Date, Is.EqualTo(scoreInfo.Date));

                Assert.That(decodedAfterEncode.Replay.Frames.Count, Is.EqualTo(1));
            });
        }
Exemple #18
0
        public void TestWithDefaultDate()
        {
            AddStep("show autoplay score", () =>
            {
                var ruleset = new OsuRuleset();

                var mods    = new Mod[] { ruleset.GetAutoplayMod() };
                var beatmap = createTestBeatmap(new RealmUser());

                var score = TestResources.CreateTestScoreInfo(beatmap);

                score.Mods = mods;
                score.Date = default;

                showPanel(score);
            });

            AddAssert("play time not displayed", () => !this.ChildrenOfType <ExpandedPanelMiddleContent.PlayedOnText>().Any());
        }
        public void TestRulesetChanges()
        {
            changeRuleset(0);

            var noFailMod = new OsuRuleset().GetModsFor(ModType.DifficultyReduction).FirstOrDefault(m => m is OsuModNoFail);

            AddStep("set mods externally", () => { SelectedMods.Value = new[] { noFailMod }; });

            changeRuleset(0);

            AddAssert("ensure mods still selected", () => modDisplay.Current.Value.Single(m => m is OsuModNoFail) != null);

            changeRuleset(3);

            AddAssert("ensure mods not selected", () => modDisplay.Current.Value.Count == 0);

            changeRuleset(0);

            AddAssert("ensure mods not selected", () => modDisplay.Current.Value.Count == 0);
        }
Exemple #20
0
        public void TestDisplayTeamResults(int team1Score, int team2Score)
        {
            MultiplayerResultsScreen screen = null;

            AddStep("show results screen", () =>
            {
                var rulesetInfo = new OsuRuleset().RulesetInfo;
                var beatmapInfo = CreateBeatmap(rulesetInfo).BeatmapInfo;

                var score = new ScoreInfo
                {
                    Rank        = ScoreRank.B,
                    TotalScore  = 987654,
                    Accuracy    = 0.8,
                    MaxCombo    = 500,
                    Combo       = 250,
                    BeatmapInfo = beatmapInfo,
                    User        = new User {
                        Username = "******"
                    },
                    Date          = DateTimeOffset.Now,
                    OnlineScoreID = 12345,
                    Ruleset       = rulesetInfo,
                };

                PlaylistItem playlistItem = new PlaylistItem
                {
                    BeatmapID = beatmapInfo.ID,
                };

                SortedDictionary <int, BindableInt> teamScores = new SortedDictionary <int, BindableInt>
                {
                    { 0, new BindableInt(team1Score) },
                    { 1, new BindableInt(team2Score) }
                };

                Stack.Push(screen = new MultiplayerTeamResultsScreen(score, 1, playlistItem, teamScores));
            });

            AddUntilStep("wait for loaded", () => screen.IsLoaded);
        }
Exemple #21
0
        public void TestOsuMods()
        {
            changeRuleset(0);

            var osu = new OsuRuleset();

            var easierMods = osu.GetModsFor(ModType.DifficultyReduction);
            var harderMods = osu.GetModsFor(ModType.DifficultyIncrease);

            var noFailMod = osu.GetModsFor(ModType.DifficultyReduction).FirstOrDefault(m => m is OsuModNoFail);

            var doubleTimeMod = harderMods.OfType <MultiMod>().FirstOrDefault(m => m.Mods.Any(a => a is OsuModDoubleTime));

            var easy     = easierMods.FirstOrDefault(m => m is OsuModEasy);
            var hardRock = harderMods.FirstOrDefault(m => m is OsuModHardRock);

            testSingleMod(noFailMod);
            testMultiMod(doubleTimeMod);
            testIncompatibleMods(easy, hardRock);
            testDeselectAll(easierMods.Where(m => !(m is MultiMod)));
        }
Exemple #22
0
        private List <Mod> getMods()
        {
            var mods = new List <Mod>();

            if (ModStrings[0] == "")
            {
                return(mods);
            }

            var availableMods = new OsuRuleset().GetAllMods().ToList();

            foreach (var modString in ModStrings)
            {
                Mod newMod = availableMods.FirstOrDefault(m => string.Equals(m.Acronym, modString, StringComparison.CurrentCultureIgnoreCase));
                if (newMod == null)
                {
                    throw new ArgumentException($"Invalid mod provided: {modString}");
                }

                mods.Add(newMod);
            }

            return(mods);
        }
Exemple #23
0
        public void TestCultureInvariance()
        {
            var ruleset   = new OsuRuleset().RulesetInfo;
            var scoreInfo = TestResources.CreateTestScoreInfo(ruleset);
            var beatmap   = new TestBeatmap(ruleset);
            var score     = new Score
            {
                ScoreInfo = scoreInfo,
                Replay    = new Replay
                {
                    Frames = new List <ReplayFrame>
                    {
                        new OsuReplayFrame(2000, OsuPlayfield.BASE_SIZE / 2, OsuAction.LeftButton)
                    }
                }
            };

            // the "se" culture is used here, as it encodes the negative number sign as U+2212 MINUS SIGN,
            // rather than the classic ASCII U+002D HYPHEN-MINUS.
            CultureInfo.CurrentCulture = new CultureInfo("se");

            var decodedAfterEncode = encodeThenDecode(LegacyBeatmapDecoder.LATEST_VERSION, score, beatmap);

            Assert.Multiple(() =>
            {
                Assert.That(decodedAfterEncode, Is.Not.Null);

                Assert.That(decodedAfterEncode.ScoreInfo.User.Username, Is.EqualTo(scoreInfo.User.Username));
                Assert.That(decodedAfterEncode.ScoreInfo.Ruleset, Is.EqualTo(scoreInfo.Ruleset));
                Assert.That(decodedAfterEncode.ScoreInfo.TotalScore, Is.EqualTo(scoreInfo.TotalScore));
                Assert.That(decodedAfterEncode.ScoreInfo.MaxCombo, Is.EqualTo(scoreInfo.MaxCombo));
                Assert.That(decodedAfterEncode.ScoreInfo.Date, Is.EqualTo(scoreInfo.Date));

                Assert.That(decodedAfterEncode.Replay.Frames.Count, Is.EqualTo(1));
            });
        }
Exemple #24
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();
        }
Exemple #25
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);
        }