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-16 16:02:41 +08:00
|
|
|
|
[TestCase("basic"), Ignore("See: https://github.com/ppy/osu/issues/2232")]
|
2018-03-02 17:20:33 +08:00
|
|
|
|
public new void Test(string name)
|
2018-03-02 01:29:55 +08:00
|
|
|
|
{
|
2018-03-02 17:20:33 +08:00
|
|
|
|
base.Test(name);
|
2018-03-02 01:29:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-02 19:19:47 +08:00
|
|
|
|
protected override IBeatmapConverter CreateConverter(Beatmap beatmap) => new CatchBeatmapConverter();
|
2018-03-02 01:29:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|