2018-04-13 17:19:50 +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.Rulesets.Mania.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Tests
|
|
|
|
|
{
|
2018-06-13 22:43:58 +08:00
|
|
|
|
[TestFixture]
|
|
|
|
|
public class ManiaBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
protected override string ResourceAssembly => "osu.Game.Rulesets.Mania";
|
|
|
|
|
|
|
|
|
|
[NonParallelizable]
|
2018-05-07 12:28:01 +08:00
|
|
|
|
[TestCase("basic")]
|
2018-05-07 10:38:41 +08:00
|
|
|
|
public new void Test(string name)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
base.Test(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObject)
|
|
|
|
|
{
|
|
|
|
|
yield return new ConvertValue
|
|
|
|
|
{
|
|
|
|
|
StartTime = hitObject.StartTime,
|
|
|
|
|
EndTime = (hitObject as IHasEndTime)?.EndTime ?? hitObject.StartTime,
|
|
|
|
|
Column = ((ManiaHitObject)hitObject).Column
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-16 12:09:48 +08:00
|
|
|
|
protected override Ruleset CreateRuleset() => new ManiaRuleset();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-13 22:43:58 +08:00
|
|
|
|
public struct ConvertValue : IEquatable<ConvertValue>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A sane value to account for osu!stable using ints everwhere.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const float conversion_lenience = 2;
|
|
|
|
|
|
|
|
|
|
public double StartTime;
|
|
|
|
|
public double EndTime;
|
|
|
|
|
public int Column;
|
|
|
|
|
|
|
|
|
|
public bool Equals(ConvertValue other)
|
|
|
|
|
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
|
|
|
|
|
&& Precision.AlmostEquals(EndTime, other.EndTime, conversion_lenience)
|
|
|
|
|
&& Column == other.Column;
|
|
|
|
|
}
|
|
|
|
|
}
|