Skip to content

Commit

Permalink
Merge branch 'ppy:master' into pattern-2
Browse files Browse the repository at this point in the history
  • Loading branch information
vunyunt authored Nov 24, 2024
2 parents 7fab6d2 354bc42 commit e85a78f
Show file tree
Hide file tree
Showing 109 changed files with 746 additions and 631 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 29,7 @@ public void TestAlwaysHidden()
},
Autoplay = true,
PassCondition = () => Player.ScoreProcessor.Combo.Value == 2,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand Down Expand Up @@ -59,7 59,7 @@ public void TestVisibleDuringBreak()
},
Autoplay = true,
PassCondition = () => true,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand Down Expand Up @@ -99,7 99,7 @@ public void TestVisibleAfterComboBreak()
},
Autoplay = true,
PassCondition = () => true,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 28,7 @@ public void TestModRelax() => CreateModTest(new ModTestData
Mod = new CatchModRelax(),
Autoplay = false,
PassCondition = passCondition,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Catch.Tests/TestSceneCatchModHidden.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 24,7 @@ public void TestJuiceStream()
{
CreateModTest(new ModTestData
{
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Catch/Edit/CatchDistanceSnapProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 10,7 @@ namespace osu.Game.Rulesets.Catch.Edit
{
public partial class CatchDistanceSnapProvider : ComposerDistanceSnapProvider
{
protected override double ReadCurrentDistanceSnap(HitObject before, HitObject after)
public override double ReadCurrentDistanceSnap(HitObject before, HitObject after)
{
// osu!catch's distance snap implementation is limited, in that a custom spacing cannot be specified.
// Therefore this functionality is not currently used.
Expand Down
2 changes: 2 additions & 0 deletions osu.Game.Rulesets.Catch/Edit/CatchHitObjectComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 70,8 @@ private void load()
}));
}

protected override Drawable CreateHitObjectInspector() => new CatchHitObjectInspector(DistanceSnapProvider);

protected override IEnumerable<TernaryButton> CreateTernaryButtons()
=> base.CreateTernaryButtons()
.Concat(DistanceSnapProvider.CreateTernaryButtons());
Expand Down
41 changes: 41 additions & 0 deletions osu.Game.Rulesets.Catch/Edit/CatchHitObjectInspector.cs
Original file line number Diff line number Diff line change
@@ -0,0 1,41 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System.Linq;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Objects;
using osu.Game.Screens.Edit.Compose.Components;

namespace osu.Game.Rulesets.Catch.Edit
{
public partial class CatchHitObjectInspector(CatchDistanceSnapProvider snapProvider) : HitObjectInspector
{
protected override void AddInspectorValues(HitObject[] objects)
{
base.AddInspectorValues(objects);

if (objects.Length > 0)
{
HitObject firstSelectedHitObject = objects.MinBy(ho => ho.StartTime)!;
HitObject lastSelectedHitObject = objects.MaxBy(ho => ho.GetEndTime())!;

HitObject? precedingObject = EditorBeatmap.HitObjects.LastOrDefault(ho => ho.GetEndTime() < firstSelectedHitObject.StartTime);
HitObject? nextObject = EditorBeatmap.HitObjects.FirstOrDefault(ho => ho.StartTime > lastSelectedHitObject.GetEndTime());

if (precedingObject != null && precedingObject is not BananaShower)
{
double previousSnap = snapProvider.ReadCurrentDistanceSnap(precedingObject, firstSelectedHitObject);
AddHeader("To previous");
AddValue($"{previousSnap:#,0.##}x");
}

if (nextObject != null && nextObject is not BananaShower)
{
double nextSnap = snapProvider.ReadCurrentDistanceSnap(lastSelectedHitObject, nextObject);
AddHeader("To next");
AddValue($"{nextSnap:#,0.##}x");
}
}
}
}
}
39 changes: 39 additions & 0 deletions osu.Game.Rulesets.Mania.Tests/ManiaScoreProcessorTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 1,39 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System.Collections.Generic;
using NUnit.Framework;
using osu.Game.Rulesets.Mania.Scoring;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;

namespace osu.Game.Rulesets.Mania.Tests
{
[TestFixture]
public class ManiaScoreProcessorTest
{
[TestCase(ScoreRank.X, 1, HitResult.Perfect)]
[TestCase(ScoreRank.X, 0.99, HitResult.Great)]
[TestCase(ScoreRank.D, 0.1, HitResult.Great)]
[TestCase(ScoreRank.X, 0.99, HitResult.Perfect, HitResult.Great)]
[TestCase(ScoreRank.X, 0.99, HitResult.Great, HitResult.Great)]
[TestCase(ScoreRank.S, 0.99, HitResult.Perfect, HitResult.Good)]
[TestCase(ScoreRank.S, 0.99, HitResult.Perfect, HitResult.Ok)]
[TestCase(ScoreRank.S, 0.99, HitResult.Perfect, HitResult.Meh)]
[TestCase(ScoreRank.S, 0.99, HitResult.Perfect, HitResult.Miss)]
[TestCase(ScoreRank.S, 0.99, HitResult.Great, HitResult.Good)]
[TestCase(ScoreRank.S, 0.99, HitResult.Great, HitResult.Ok)]
[TestCase(ScoreRank.S, 0.99, HitResult.Great, HitResult.Meh)]
[TestCase(ScoreRank.S, 0.99, HitResult.Great, HitResult.Miss)]
public void TestRanks(ScoreRank expected, double accuracy, params HitResult[] results)
{
var scoreProcessor = new ManiaScoreProcessor();

Dictionary<HitResult, int> resultsDict = new Dictionary<HitResult, int>();
foreach (var result in results)
resultsDict[result] = resultsDict.GetValueOrDefault(result) 1;

Assert.That(scoreProcessor.RankFromScore(accuracy, resultsDict), Is.EqualTo(expected));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 19,7 @@ public void TestPerfectScoreOnShortHoldNote()
CreateModTest(new ModTestData
{
Autoplay = true,
Beatmap = new ManiaBeatmap(new StageDefinition(1))
CreateBeatmap = () => new ManiaBeatmap(new StageDefinition(1))
{
HitObjects = new List<ManiaHitObject>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 29,7 @@ public void TestHitWindowWithoutDoubleTime() => CreateModTest(new ModTestData
&& Precision.AlmostEquals(Player.ScoreProcessor.Accuracy.Value, 0.9836, 0.01)
&& Player.ScoreProcessor.TotalScore.Value == 946_049,
Autoplay = false,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo },
Difficulty = { OverallDifficulty = 10 },
Expand All @@ -56,7 56,7 @@ public void TestHitWindowWithDoubleTime()
&& Player.ScoreProcessor.Accuracy.Value == 1
&& Player.ScoreProcessor.TotalScore.Value == (long)(1_000_000 * doubleTime.ScoreMultiplier),
Autoplay = false,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo },
Difficulty = { OverallDifficulty = 10 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 74,7 @@ public void TestNoCoverageDuringBreak()
CreateModTest(new ModTestData
{
Mod = new ManiaModHidden(),
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = Enumerable.Range(1, 100).Select(i => (HitObject)new Note { StartTime = 1000 200 * i }).ToList(),
Breaks = { new BreakPeriod(2000, 28000) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 74,7 @@ public void TestNoCoverageDuringBreak()
CreateModTest(new ModTestData
{
Mod = new ManiaModHidden(),
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = Enumerable.Range(1, 100).Select(i => (HitObject)new Note { StartTime = 1000 200 * i }).ToList(),
Breaks = { new BreakPeriod(2000, 28000) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 36,7 @@ public void TestGreatHit() => CreateModTest(new ModTestData
Mod = new ManiaModPerfect(),
PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(false),
Autoplay = false,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand All @@ -59,7 59,7 @@ public void TestBreakOnHoldNote() => CreateModTest(new ModTestData
Mod = new ManiaModPerfect(),
PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(true) && Player.Results.Count == 2,
Autoplay = false,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 28,7 @@ public void TestGreatHit() => CreateModTest(new ModTestData
Mod = new ManiaModSuddenDeath(),
PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(false),
Autoplay = false,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand All @@ -51,7 51,7 @@ public void TestBreakOnHoldNote() => CreateModTest(new ModTestData
Mod = new ManiaModSuddenDeath(),
PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(true) && Player.Results.Count == 2,
Autoplay = false,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand Down
19 changes: 19 additions & 0 deletions osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 9,7 @@
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;

namespace osu.Game.Rulesets.Mania.Scoring
{
Expand Down Expand Up @@ -58,6 59,24 @@ private int getBaseComboScoreForResult(HitResult result)
return GetBaseScoreForResult(result);
}

public override ScoreRank RankFromScore(double accuracy, IReadOnlyDictionary<HitResult, int> results)
{
ScoreRank rank = base.RankFromScore(accuracy, results);

if (rank != ScoreRank.S)
return rank;

// SS is expected as long as all hitobjects have been hit with either a GREAT or PERFECT result.

bool anyImperfect =
results.GetValueOrDefault(HitResult.Good) > 0
|| results.GetValueOrDefault(HitResult.Ok) > 0
|| results.GetValueOrDefault(HitResult.Meh) > 0
|| results.GetValueOrDefault(HitResult.Miss) > 0;

return anyImperfect ? rank : ScoreRank.X;
}

private class JudgementOrderComparer : IComparer<HitObject>
{
public static readonly JudgementOrderComparer DEFAULT = new JudgementOrderComparer();
Expand Down
8 changes: 4 additions & 4 deletions osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModAlternate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 23,7 @@ public void TestInputAlternating() => CreateModTest(new ModTestData
Mod = new OsuModAlternate(),
PassCondition = () => Player.ScoreProcessor.Combo.Value == 4,
Autoplay = false,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand Down Expand Up @@ -68,7 68,7 @@ public void TestInputSingular() => CreateModTest(new ModTestData
Mod = new OsuModAlternate(),
PassCondition = () => Player.ScoreProcessor.Combo.Value == 0 && Player.ScoreProcessor.HighestCombo.Value == 1,
Autoplay = false,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand Down Expand Up @@ -101,7 101,7 @@ public void TestInputSingularAtIntro() => CreateModTest(new ModTestData
Mod = new OsuModAlternate(),
PassCondition = () => Player.ScoreProcessor.Combo.Value == 1,
Autoplay = false,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand Down Expand Up @@ -131,7 131,7 @@ public void TestInputSingularWithBreak([Values] bool pressBeforeSecondObject) =>
Mod = new OsuModAlternate(),
PassCondition = () => Player.ScoreProcessor.Combo.Value == 0 && Player.ScoreProcessor.HighestCombo.Value == 2,
Autoplay = false,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
Breaks =
{
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModAutoplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 60,7 @@ public void TestPerfectScoreOnShortSliderWithRepeat(float pathLength)
CreateModTest(new ModTestData
{
Autoplay = true,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand Down Expand Up @@ -90,7 90,7 @@ private void runSpmTest(Mod mod)
{
Autoplay = true,
Mod = mod,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects =
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 21,7 @@ public partial class TestSceneOsuModDifficultyAdjust : OsuModTestScene
public void TestNoAdjustment() => CreateModTest(new ModTestData
{
Mod = new OsuModDifficultyAdjust(),
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
BeatmapInfo = new BeatmapInfo
{
Expand Down
6 changes: 3 additions & 3 deletions osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModFlashlight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 68,7 @@ public void TestSliderDimsOnlyAfterStartTime()
Player.GameplayClockContainer.CurrentTime < 1000 && Player.ChildrenOfType<ModFlashlight<OsuHitObject>.Flashlight>().Single().FlashlightDim > 0;
return Player.GameplayState.HasPassed && !sliderDimmedBeforeStartTime;
},
Beatmap = new OsuBeatmap
CreateBeatmap = () => new OsuBeatmap
{
HitObjects = new List<OsuHitObject>
{
Expand Down Expand Up @@ -114,7 114,7 @@ public void TestSliderDoesDimAfterStartTimeIfHitEarly()
Player.GameplayClockContainer.CurrentTime >= 1000 && Player.ChildrenOfType<ModFlashlight<OsuHitObject>.Flashlight>().Single().FlashlightDim > 0;
return Player.GameplayState.HasPassed && sliderDimmed;
},
Beatmap = new OsuBeatmap
CreateBeatmap = () => new OsuBeatmap
{
HitObjects = new List<OsuHitObject>
{
Expand Down Expand Up @@ -153,7 153,7 @@ public void TestSliderDoesDimAfterStartTimeIfHitLate()
Player.GameplayClockContainer.CurrentTime >= 1000 && Player.ChildrenOfType<ModFlashlight<OsuHitObject>.Flashlight>().Single().FlashlightDim > 0;
return Player.GameplayState.HasPassed && sliderDimmed;
},
Beatmap = new OsuBeatmap
CreateBeatmap = () => new OsuBeatmap
{
HitObjects = new List<OsuHitObject>
{
Expand Down
8 changes: 4 additions & 4 deletions osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModHidden.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 28,7 @@ public void FirstCircleAfterTwoSpinners() => CreateModTest(new ModTestData
{
Mod = new TestOsuModHidden(),
Autoplay = true,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand Down Expand Up @@ -63,7 63,7 @@ public void FirstSliderAfterTwoSpinners() => CreateModTest(new ModTestData
{
Mod = new TestOsuModHidden(),
Autoplay = true,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand Down Expand Up @@ -98,7 98,7 @@ public void TestWithSliderReuse() => CreateModTest(new ModTestData
{
Mod = new TestOsuModHidden(),
Autoplay = true,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand All @@ -122,7 122,7 @@ public void TestApproachCirclesOnly() => CreateModTest(new ModTestData
{
Mod = new OsuModHidden { OnlyFadeApproachCircles = { Value = true } },
Autoplay = true,
Beatmap = new Beatmap
CreateBeatmap = () => new Beatmap
{
HitObjects = new List<HitObject>
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModMirror.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 21,7 @@ public partial class TestSceneOsuModMirror : OsuModTestScene
public void TestCorrectReflections([Values] OsuModMirror.MirrorType type, [Values] bool withStrictTracking) => CreateModTest(new ModTestData
{
Autoplay = true,
Beatmap = new OsuBeatmap
CreateBeatmap = () => new OsuBeatmap
{
HitObjects =
{
Expand Down
Loading

0 comments on commit e85a78f

Please sign in to comment.