2018-03-02 01:29:55 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.MathUtils;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Catch.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Tests
|
|
|
|
|
{
|
|
|
|
|
public class CatchBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
|
|
|
|
|
{
|
|
|
|
|
protected override string ResourceAssembly => "osu.Game.Rulesets.Catch";
|
|
|
|
|
|
2018-03-02 13:01:34 +08:00
|
|
|
|
[TestCase(875945), Ignore("See: https://github.com/ppy/osu/issues/2149")]
|
2018-03-02 01:29:55 +08:00
|
|
|
|
public new void Test(int beatmapId)
|
|
|
|
|
{
|
|
|
|
|
base.Test(beatmapId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObject)
|
|
|
|
|
{
|
|
|
|
|
if (hitObject is JuiceStream stream)
|
|
|
|
|
{
|
|
|
|
|
foreach (var nested in stream.NestedHitObjects)
|
|
|
|
|
{
|
|
|
|
|
yield return new ConvertValue
|
|
|
|
|
{
|
|
|
|
|
StartTime = nested.StartTime,
|
|
|
|
|
Position = ((CatchHitObject)nested).X * CatchPlayfield.BASE_WIDTH
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
yield return new ConvertValue
|
|
|
|
|
{
|
|
|
|
|
StartTime = hitObject.StartTime,
|
|
|
|
|
Position = ((CatchHitObject)hitObject).X * CatchPlayfield.BASE_WIDTH
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override ITestableBeatmapConverter CreateConverter(Beatmap beatmap) => new CatchBeatmapConverter();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct ConvertValue : IEquatable<ConvertValue>
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A sane value to account for osu!stable using ints everwhere.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const float conversion_lenience = 2;
|
|
|
|
|
|
|
|
|
|
public double StartTime;
|
|
|
|
|
public float Position;
|
|
|
|
|
|
|
|
|
|
public bool Equals(ConvertValue other)
|
2018-03-02 17:20:12 +08:00
|
|
|
|
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
|
2018-03-02 01:29:55 +08:00
|
|
|
|
&& Precision.AlmostEquals(Position, other.Position, conversion_lenience);
|
|
|
|
|
}
|
|
|
|
|
}
|