mirror of
https://github.com/ppy/osu
synced 2024-12-26 00:32:52 +00:00
Rename function and make public
again for test usage
This commit is contained in:
parent
c75ffe9b07
commit
035a84e75c
@ -32,9 +32,12 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
|
||||
{
|
||||
var testBeatmap = createRawBeatmap();
|
||||
var noteValues = new List<double>(testBeatmap.HitObjects.OfType<HoldNote>().Count());
|
||||
foreach (HoldNote h in testBeatmap.HitObjects.OfType<HoldNote>()) {
|
||||
noteValues.Add(ManiaModHoldOff.getNoteValue(h, (ManiaBeatmap)testBeatmap));
|
||||
|
||||
foreach (HoldNote h in testBeatmap.HitObjects.OfType<HoldNote>())
|
||||
{
|
||||
noteValues.Add(ManiaModHoldOff.GetNoteDurationInBeatLength(h, (ManiaBeatmap)testBeatmap));
|
||||
}
|
||||
|
||||
noteValues.Sort();
|
||||
Assert.AreEqual(noteValues, new List<double> { 0.125, 0.250, 0.500, 1.000, 2.000 });
|
||||
}
|
||||
@ -43,7 +46,8 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
|
||||
[TestCase(ManiaModHoldOff.BeatDivisors.Half)]
|
||||
[TestCase(ManiaModHoldOff.BeatDivisors.Quarter)]
|
||||
[TestCase(ManiaModHoldOff.BeatDivisors.Eighth)]
|
||||
public void TestCorrectObjectCount(ManiaModHoldOff.BeatDivisors minBeatSnap) {
|
||||
public void TestCorrectObjectCount(ManiaModHoldOff.BeatDivisors minBeatSnap)
|
||||
{
|
||||
/*
|
||||
This test is to ensure that, given that end notes are enabled,
|
||||
the mod produces the expected number of objects when the mod is applied.
|
||||
@ -55,14 +59,19 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
|
||||
|
||||
// Calculate expected number of objects
|
||||
int expectedObjectCount = 0;
|
||||
double beatSnapValue = 1/(Math.Pow(2, (int)minBeatSnap));
|
||||
double beatSnapValue = 1 / (Math.Pow(2, (int)minBeatSnap));
|
||||
|
||||
foreach (ManiaHitObject h in rawBeatmap.HitObjects) {
|
||||
foreach (ManiaHitObject h in rawBeatmap.HitObjects)
|
||||
{
|
||||
// Both notes and hold notes account for at least one object
|
||||
expectedObjectCount++;
|
||||
if (h.GetType() == typeof(HoldNote)) {
|
||||
var noteValue = ManiaModHoldOff.getNoteValue((HoldNote)h, (ManiaBeatmap)rawBeatmap);
|
||||
if (noteValue >= beatSnapValue) {
|
||||
|
||||
if (h.GetType() == typeof(HoldNote))
|
||||
{
|
||||
var noteValue = ManiaModHoldOff.GetNoteDurationInBeatLength((HoldNote)h, (ManiaBeatmap)rawBeatmap);
|
||||
|
||||
if (noteValue >= beatSnapValue)
|
||||
{
|
||||
// Should generate an end note if it's longer than the minimum note value
|
||||
expectedObjectCount++;
|
||||
}
|
||||
@ -73,10 +82,12 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDifficultyIncrease() {
|
||||
public void TestDifficultyIncrease()
|
||||
{
|
||||
// A lower minimum beat snap divisor should only make the map harder, never easier
|
||||
// (as more notes can be spawned)
|
||||
var beatmaps = new ManiaBeatmap[] {
|
||||
var beatmaps = new ManiaBeatmap[]
|
||||
{
|
||||
createModdedBeatmap(ManiaModHoldOff.BeatDivisors.Whole),
|
||||
createModdedBeatmap(ManiaModHoldOff.BeatDivisors.Half),
|
||||
createModdedBeatmap(ManiaModHoldOff.BeatDivisors.Quarter),
|
||||
@ -85,18 +96,22 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
|
||||
};
|
||||
|
||||
var mapDifficulties = new double[beatmaps.Length];
|
||||
for (int i = 0; i < mapDifficulties.Length; i++) {
|
||||
|
||||
for (int i = 0; i < mapDifficulties.Length; i++)
|
||||
{
|
||||
var workingBeatmap = new TestWorkingBeatmap(beatmaps[i]);
|
||||
var difficultyCalculator = new ManiaDifficultyCalculator(new ManiaRuleset().RulesetInfo, workingBeatmap);
|
||||
mapDifficulties[i] = difficultyCalculator.Calculate().StarRating;
|
||||
if (i > 0) {
|
||||
Assert.LessOrEqual(mapDifficulties[i-1], mapDifficulties[i]);
|
||||
Assert.LessOrEqual(beatmaps[i-1].HitObjects.Count, beatmaps[i].HitObjects.Count);
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
Assert.LessOrEqual(mapDifficulties[i - 1], mapDifficulties[i]);
|
||||
Assert.LessOrEqual(beatmaps[i - 1].HitObjects.Count, beatmaps[i].HitObjects.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static ManiaBeatmap createModdedBeatmap(ManiaModHoldOff.BeatDivisors minBeatSnap=ManiaModHoldOff.BeatDivisors.Whole)
|
||||
private static ManiaBeatmap createModdedBeatmap(ManiaModHoldOff.BeatDivisors minBeatSnap = ManiaModHoldOff.BeatDivisors.Whole)
|
||||
{
|
||||
var beatmap = createRawBeatmap();
|
||||
var holdOffMod = new ManiaModHoldOff();
|
||||
@ -110,17 +125,18 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
|
||||
|
||||
return (ManiaBeatmap)beatmap;
|
||||
}
|
||||
|
||||
private static ManiaBeatmap createRawBeatmap()
|
||||
{
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 });
|
||||
beatmap.ControlPointInfo.Add(0.0, new TimingControlPoint { BeatLength = 1000 } ); // Set BPM to 60
|
||||
beatmap.ControlPointInfo.Add(0.0, new TimingControlPoint { BeatLength = 1000 }); // Set BPM to 60
|
||||
|
||||
// Add test hit objects
|
||||
beatmap.HitObjects.Add(new Note { StartTime = 4000 });
|
||||
beatmap.HitObjects.Add(new Note { StartTime = 4500 });
|
||||
beatmap.HitObjects.Add(new HoldNote { StartTime = 0, EndTime = 125 }); // 1/8 note
|
||||
beatmap.HitObjects.Add(new HoldNote { StartTime = 0, EndTime = 250 }); // 1/4 note
|
||||
beatmap.HitObjects.Add(new HoldNote { StartTime = 0, EndTime = 500 }); // 1/2 note
|
||||
beatmap.HitObjects.Add(new HoldNote { StartTime = 0, EndTime = 125 }); // 1/8 note
|
||||
beatmap.HitObjects.Add(new HoldNote { StartTime = 0, EndTime = 250 }); // 1/4 note
|
||||
beatmap.HitObjects.Add(new HoldNote { StartTime = 0, EndTime = 500 }); // 1/2 note
|
||||
beatmap.HitObjects.Add(new HoldNote { StartTime = 0, EndTime = 1000 }); // 1/1 note
|
||||
beatmap.HitObjects.Add(new HoldNote { StartTime = 0, EndTime = 2000 }); // 2/1 note
|
||||
|
||||
|
@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
});
|
||||
|
||||
// Don't add an end note if the duration is shorter than some threshold, or end notes are disabled
|
||||
double noteValue = getNoteValue(h, maniaBeatmap); // 1/1, 1/2, 1/4, etc.
|
||||
double noteValue = GetNoteDurationInBeatLength(h, maniaBeatmap); // 1/1, 1/2, 1/4, etc.
|
||||
|
||||
if (AddEndNotes.Value && noteValue >= beatSnap)
|
||||
{
|
||||
@ -72,7 +72,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
maniaBeatmap.HitObjects = maniaBeatmap.HitObjects.OfType<Note>().Concat(newObjects).OrderBy(h => h.StartTime).ToList();
|
||||
}
|
||||
|
||||
private static double getNoteValue(HoldNote holdNote, ManiaBeatmap beatmap)
|
||||
public static double GetNoteDurationInBeatLength(HoldNote holdNote, ManiaBeatmap beatmap)
|
||||
{
|
||||
double bpmAtNoteTime = beatmap.ControlPointInfo.TimingPointAt(holdNote.StartTime).BPM;
|
||||
return (60 * holdNote.Duration) / (1000 * bpmAtNoteTime);
|
||||
|
Loading…
Reference in New Issue
Block a user