2018-04-13 09:19:50 +00: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;
|
2018-06-15 11:48:36 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
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 14:43:58 +00:00
|
|
|
|
[TestFixture]
|
2018-06-15 11:48:36 +00:00
|
|
|
|
public class ManiaBeatmapConversionTest : BeatmapConversionTest<ManiaConvertMapping, ConvertValue>
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
protected override string ResourceAssembly => "osu.Game.Rulesets.Mania";
|
|
|
|
|
|
2018-05-07 04:28:01 +00:00
|
|
|
|
[TestCase("basic")]
|
2018-05-07 02:38:41 +00:00
|
|
|
|
public new void Test(string name)
|
2018-04-13 09:19:50 +00: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-06-15 11:48:36 +00:00
|
|
|
|
protected override ManiaConvertMapping CreateConvertMapping() => new ManiaConvertMapping(Converter);
|
|
|
|
|
|
2018-05-16 04:09:48 +00:00
|
|
|
|
protected override Ruleset CreateRuleset() => new ManiaRuleset();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-15 11:48:36 +00:00
|
|
|
|
public class ManiaConvertMapping : ConvertMapping<ConvertValue>, IEquatable<ManiaConvertMapping>
|
|
|
|
|
{
|
|
|
|
|
public uint RandomW;
|
|
|
|
|
public uint RandomX;
|
|
|
|
|
public uint RandomY;
|
|
|
|
|
public uint RandomZ;
|
|
|
|
|
|
|
|
|
|
public ManiaConvertMapping()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ManiaConvertMapping(IBeatmapConverter converter)
|
|
|
|
|
{
|
|
|
|
|
var maniaConverter = (ManiaBeatmapConverter)converter;
|
|
|
|
|
RandomW = maniaConverter.Random.W;
|
|
|
|
|
RandomX = maniaConverter.Random.X;
|
|
|
|
|
RandomY = maniaConverter.Random.Y;
|
|
|
|
|
RandomZ = maniaConverter.Random.Z;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Equals(ManiaConvertMapping other) => other != null && RandomW == other.RandomW && RandomX == other.RandomX && RandomY == other.RandomY && RandomZ == other.RandomZ;
|
|
|
|
|
public override bool Equals(ConvertMapping<ConvertValue> other) => base.Equals(other) && Equals(other as ManiaConvertMapping);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-15 08:38:43 +00:00
|
|
|
|
public struct ConvertValue : IEquatable<ConvertValue>
|
2018-04-13 09:19:50 +00: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;
|
|
|
|
|
}
|
|
|
|
|
}
|