Update test scene to allow checking samples

This commit is contained in:
Bartłomiej Dach 2020-06-27 15:59:26 +02:00
parent a4254802c1
commit c47f762f24
4 changed files with 25 additions and 12 deletions

View File

@ -29,13 +29,16 @@ namespace osu.Game.Rulesets.Mania.Tests
StartTime = hitObject.StartTime, StartTime = hitObject.StartTime,
EndTime = hitObject.GetEndTime(), EndTime = hitObject.GetEndTime(),
Column = ((ManiaHitObject)hitObject).Column, Column = ((ManiaHitObject)hitObject).Column,
NodeSamples = getSampleNames((hitObject as HoldNote)?.NodeSamples) Samples = getSampleNames(hitObject.Samples),
NodeSamples = getNodeSampleNames((hitObject as HoldNote)?.NodeSamples)
}; };
} }
private IList<IList<string>> getSampleNames(List<IList<HitSampleInfo>> hitSampleInfo) private IList<string> getSampleNames(IList<HitSampleInfo> hitSampleInfo)
=> hitSampleInfo?.Select(samples => => hitSampleInfo.Select(sample => sample.LookupNames.First()).ToList();
(IList<string>)samples.Select(sample => sample.LookupNames.First()).ToList())
private IList<IList<string>> getNodeSampleNames(List<IList<HitSampleInfo>> hitSampleInfo)
=> hitSampleInfo?.Select(getSampleNames)
.ToList(); .ToList();
protected override Ruleset CreateRuleset() => new ManiaRuleset(); protected override Ruleset CreateRuleset() => new ManiaRuleset();
@ -51,14 +54,19 @@ namespace osu.Game.Rulesets.Mania.Tests
public double StartTime; public double StartTime;
public double EndTime; public double EndTime;
public int Column; public int Column;
public IList<string> Samples;
public IList<IList<string>> NodeSamples; public IList<IList<string>> NodeSamples;
public bool Equals(SampleConvertValue other) public bool Equals(SampleConvertValue other)
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience) => Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
&& Precision.AlmostEquals(EndTime, other.EndTime, conversion_lenience) && Precision.AlmostEquals(EndTime, other.EndTime, conversion_lenience)
&& samplesEqual(NodeSamples, other.NodeSamples); && samplesEqual(Samples, other.Samples)
&& nodeSamplesEqual(NodeSamples, other.NodeSamples);
private static bool samplesEqual(ICollection<IList<string>> firstSampleList, ICollection<IList<string>> secondSampleList) private static bool samplesEqual(ICollection<string> firstSampleList, ICollection<string> secondSampleList)
=> firstSampleList.SequenceEqual(secondSampleList);
private static bool nodeSamplesEqual(ICollection<IList<string>> firstSampleList, ICollection<IList<string>> secondSampleList)
{ {
if (firstSampleList == null && secondSampleList == null) if (firstSampleList == null && secondSampleList == null)
return true; return true;

View File

@ -9,7 +9,8 @@
["normal-hitnormal"], ["normal-hitnormal"],
["soft-hitnormal"], ["soft-hitnormal"],
["drum-hitnormal"] ["drum-hitnormal"]
] ],
"Samples": ["drum-hitnormal"]
}, { }, {
"StartTime": 1875.0, "StartTime": 1875.0,
"EndTime": 2750.0, "EndTime": 2750.0,
@ -17,14 +18,16 @@
"NodeSamples": [ "NodeSamples": [
["soft-hitnormal"], ["soft-hitnormal"],
["drum-hitnormal"] ["drum-hitnormal"]
] ],
"Samples": ["drum-hitnormal"]
}] }]
}, { }, {
"StartTime": 3750.0, "StartTime": 3750.0,
"Objects": [{ "Objects": [{
"StartTime": 3750.0, "StartTime": 3750.0,
"EndTime": 3750.0, "EndTime": 3750.0,
"Column": 3 "Column": 3,
"Samples": ["normal-hitnormal"]
}] }]
}] }]
} }

View File

@ -13,4 +13,4 @@ SliderTickRate:1
[HitObjects] [HitObjects]
88,99,1000,6,0,L|306:259,2,245,0|0|0,1:0|2:0|3:0,0:0:0:0: 88,99,1000,6,0,L|306:259,2,245,0|0|0,1:0|2:0|3:0,0:0:0:0:
259,118,3750,1,0,0:0:0:0: 259,118,3750,1,0,1:0:0:0:

View File

@ -8,7 +8,8 @@
"NodeSamples": [ "NodeSamples": [
["normal-hitnormal"], ["normal-hitnormal"],
[] []
] ],
"Samples": ["normal-hitnormal"]
}] }]
}, { }, {
"StartTime": 2000.0, "StartTime": 2000.0,
@ -19,7 +20,8 @@
"NodeSamples": [ "NodeSamples": [
["drum-hitnormal"], ["drum-hitnormal"],
[] []
] ],
"Samples": ["drum-hitnormal"]
}] }]
}] }]
} }