mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 08:03:52 +09:00
Fix CalculateAverageHitError
throwing if there are zero HitEvent
s
This commit is contained in:
@ -29,8 +29,15 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// A non-null <see langword="double"/> value if unstable rate could be calculated,
|
/// A non-null <see langword="double"/> value if unstable rate could be calculated,
|
||||||
/// and <see langword="null"/> if unstable rate cannot be calculated due to <paramref name="hitEvents"/> being empty.
|
/// and <see langword="null"/> if unstable rate cannot be calculated due to <paramref name="hitEvents"/> being empty.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static double? CalculateAverageHitError(this IEnumerable<HitEvent> hitEvents) =>
|
public static double? CalculateAverageHitError(this IEnumerable<HitEvent> hitEvents)
|
||||||
hitEvents.Where(affectsUnstableRate).Select(ev => ev.TimeOffset).Average();
|
{
|
||||||
|
double[] timeOffsets = hitEvents.Where(affectsUnstableRate).Select(ev => ev.TimeOffset).ToArray();
|
||||||
|
|
||||||
|
if (timeOffsets.Length == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return timeOffsets.Average();
|
||||||
|
}
|
||||||
|
|
||||||
private static bool affectsUnstableRate(HitEvent e) => !(e.HitObject.HitWindows is HitWindows.EmptyHitWindows) && e.Result.IsHit();
|
private static bool affectsUnstableRate(HitEvent e) => !(e.HitObject.HitWindows is HitWindows.EmptyHitWindows) && e.Result.IsHit();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user