2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-03-02 00:40:38 +08:00
|
|
|
|
using System;
|
2018-03-02 01:02:09 +08:00
|
|
|
|
using System.Collections.Generic;
|
2018-03-02 00:40:38 +08:00
|
|
|
|
using NUnit.Framework;
|
2020-01-09 12:43:44 +08:00
|
|
|
|
using osu.Framework.Utils;
|
2018-03-02 00:40:38 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-03-02 00:40:38 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Tests
|
|
|
|
|
{
|
2018-06-13 22:43:58 +08:00
|
|
|
|
[TestFixture]
|
|
|
|
|
public class TaikoBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
|
2018-03-02 00:40:38 +08:00
|
|
|
|
{
|
|
|
|
|
protected override string ResourceAssembly => "osu.Game.Rulesets.Taiko";
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-03-02 13:01:34 +08:00
|
|
|
|
[NonParallelizable]
|
2018-05-17 14:17:47 +08:00
|
|
|
|
[TestCase("basic")]
|
|
|
|
|
[TestCase("slider-generating-drumroll")]
|
2020-05-19 08:43:05 +08:00
|
|
|
|
[TestCase("sample-to-type-conversions")]
|
2020-07-16 00:20:32 +08:00
|
|
|
|
[TestCase("slider-conversion-v6")]
|
|
|
|
|
[TestCase("slider-conversion-v14")]
|
2021-01-12 16:49:18 +08:00
|
|
|
|
[TestCase("slider-generating-drumroll-2")]
|
2023-02-10 06:23:58 +08:00
|
|
|
|
[TestCase("file-hitsamples")]
|
2019-08-05 16:02:28 +08:00
|
|
|
|
public void Test(string name) => base.Test(name);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-03-02 01:02:09 +08:00
|
|
|
|
protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObject)
|
2018-03-02 00:40:38 +08:00
|
|
|
|
{
|
2018-03-02 01:02:09 +08:00
|
|
|
|
yield return new ConvertValue
|
|
|
|
|
{
|
|
|
|
|
StartTime = hitObject.StartTime,
|
2019-11-25 18:01:24 +08:00
|
|
|
|
EndTime = hitObject.GetEndTime(),
|
2020-03-23 11:08:15 +08:00
|
|
|
|
IsRim = (hitObject as Hit)?.Type == HitType.Rim,
|
|
|
|
|
IsCentre = (hitObject as Hit)?.Type == HitType.Centre,
|
2018-03-02 01:02:09 +08:00
|
|
|
|
IsDrumRoll = hitObject is DrumRoll,
|
|
|
|
|
IsSwell = hitObject is Swell,
|
2020-12-15 04:46:02 +08:00
|
|
|
|
IsStrong = (hitObject as TaikoStrongableHitObject)?.IsStrong == true
|
2018-03-02 01:02:09 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-05-16 12:09:48 +08:00
|
|
|
|
protected override Ruleset CreateRuleset() => new TaikoRuleset();
|
2018-03-02 00:40:38 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-06-13 22:43:58 +08:00
|
|
|
|
public struct ConvertValue : IEquatable<ConvertValue>
|
2018-03-02 00:40:38 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2020-05-19 08:43:05 +08:00
|
|
|
|
/// A sane value to account for osu!stable using ints everywhere.
|
2018-03-02 00:40:38 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
private const float conversion_lenience = 2;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-03-02 00:40:38 +08:00
|
|
|
|
public double StartTime;
|
|
|
|
|
public double EndTime;
|
|
|
|
|
public bool IsRim;
|
|
|
|
|
public bool IsCentre;
|
|
|
|
|
public bool IsDrumRoll;
|
|
|
|
|
public bool IsSwell;
|
|
|
|
|
public bool IsStrong;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-03-02 00:40:38 +08:00
|
|
|
|
public bool Equals(ConvertValue other)
|
2018-03-02 17:20:12 +08:00
|
|
|
|
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
|
2018-03-02 00:40:38 +08:00
|
|
|
|
&& Precision.AlmostEquals(EndTime, other.EndTime, conversion_lenience)
|
|
|
|
|
&& IsRim == other.IsRim
|
|
|
|
|
&& IsCentre == other.IsCentre
|
|
|
|
|
&& IsDrumRoll == other.IsDrumRoll
|
|
|
|
|
&& IsSwell == other.IsSwell
|
|
|
|
|
&& IsStrong == other.IsStrong;
|
|
|
|
|
}
|
|
|
|
|
}
|