2020-04-24 12:59:05 +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.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2020-05-01 03:41:57 +08:00
|
|
|
using Humanizer;
|
2020-04-24 12:59:05 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
2020-04-30 06:14:27 +08:00
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2020-04-24 12:59:05 +08:00
|
|
|
using osu.Framework.Testing;
|
2020-04-27 07:40:57 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2020-04-24 12:59:05 +08:00
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Rulesets.Taiko.Judgements;
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
2020-05-01 03:41:57 +08:00
|
|
|
using osu.Game.Rulesets.Taiko.Scoring;
|
2020-04-24 12:59:05 +08:00
|
|
|
using osu.Game.Rulesets.Taiko.UI;
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Tests.Skinning
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class TestSceneDrawableTaikoMascot : TaikoSkinnableTestScene
|
|
|
|
{
|
|
|
|
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Concat(new[]
|
|
|
|
{
|
|
|
|
typeof(DrawableTaikoMascot),
|
2020-04-30 03:27:02 +08:00
|
|
|
typeof(TaikoMascotAnimation)
|
2020-04-24 12:59:05 +08:00
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
[Cached(typeof(IScrollingInfo))]
|
|
|
|
private ScrollingTestContainer.TestScrollingInfo info = new ScrollingTestContainer.TestScrollingInfo
|
|
|
|
{
|
|
|
|
Direction = { Value = ScrollingDirection.Left },
|
|
|
|
TimeRange = { Value = 5000 },
|
|
|
|
};
|
|
|
|
|
2020-05-01 03:41:57 +08:00
|
|
|
private TaikoScoreProcessor scoreProcessor;
|
|
|
|
|
2020-04-30 03:27:02 +08:00
|
|
|
private IEnumerable<DrawableTaikoMascot> mascots => this.ChildrenOfType<DrawableTaikoMascot>();
|
2020-04-29 05:22:50 +08:00
|
|
|
private IEnumerable<TaikoPlayfield> playfields => this.ChildrenOfType<TaikoPlayfield>();
|
2020-04-28 05:17:19 +08:00
|
|
|
|
2020-05-01 03:41:57 +08:00
|
|
|
[SetUp]
|
|
|
|
public void SetUp()
|
|
|
|
{
|
|
|
|
scoreProcessor = new TaikoScoreProcessor();
|
|
|
|
}
|
|
|
|
|
2020-04-24 12:59:05 +08:00
|
|
|
[Test]
|
2020-04-30 03:27:02 +08:00
|
|
|
public void TestStateAnimations()
|
2020-04-24 12:59:05 +08:00
|
|
|
{
|
2020-04-30 02:28:46 +08:00
|
|
|
AddStep("set beatmap", () => setBeatmap());
|
2020-04-24 12:59:05 +08:00
|
|
|
|
2020-04-30 03:27:02 +08:00
|
|
|
AddStep("clear state", () => SetContents(() => new TaikoMascotAnimation(TaikoMascotAnimationState.Clear)));
|
|
|
|
AddStep("idle state", () => SetContents(() => new TaikoMascotAnimation(TaikoMascotAnimationState.Idle)));
|
|
|
|
AddStep("kiai state", () => SetContents(() => new TaikoMascotAnimation(TaikoMascotAnimationState.Kiai)));
|
|
|
|
AddStep("fail state", () => SetContents(() => new TaikoMascotAnimation(TaikoMascotAnimationState.Fail)));
|
2020-04-24 12:59:05 +08:00
|
|
|
}
|
|
|
|
|
2020-05-01 04:03:39 +08:00
|
|
|
[Test]
|
|
|
|
public void TestInitialState()
|
|
|
|
{
|
|
|
|
AddStep("create mascot", () => SetContents(() => new DrawableTaikoMascot()));
|
|
|
|
|
|
|
|
AddAssert("mascot initially idle", () => allMascotsIn(TaikoMascotAnimationState.Idle));
|
|
|
|
}
|
|
|
|
|
2020-04-30 06:14:27 +08:00
|
|
|
[Test]
|
|
|
|
public void TestClearStateTransition()
|
|
|
|
{
|
|
|
|
AddStep("set beatmap", () => setBeatmap());
|
|
|
|
|
|
|
|
// the bindables need to be independent for each content cell to prevent interference,
|
|
|
|
// as if some of the skins don't implement the animation they'll immediately revert to the previous state from the clear state.
|
|
|
|
var states = new List<Bindable<TaikoMascotAnimationState>>();
|
|
|
|
|
|
|
|
AddStep("create mascot", () => SetContents(() =>
|
|
|
|
{
|
|
|
|
var state = new Bindable<TaikoMascotAnimationState>(TaikoMascotAnimationState.Clear);
|
|
|
|
states.Add(state);
|
|
|
|
return new DrawableTaikoMascot { State = { BindTarget = state } };
|
|
|
|
}));
|
|
|
|
|
|
|
|
AddStep("set clear state", () => states.ForEach(state => state.Value = TaikoMascotAnimationState.Clear));
|
|
|
|
AddStep("miss", () => mascots.ForEach(mascot => mascot.OnNewResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Miss })));
|
|
|
|
AddAssert("skins with animations remain in clear state", () => mascots.Any(mascot => mascot.State.Value == TaikoMascotAnimationState.Clear));
|
|
|
|
AddUntilStep("state reverts to fail", () => someMascotsIn(TaikoMascotAnimationState.Fail));
|
|
|
|
|
|
|
|
AddStep("set clear state again", () => states.ForEach(state => state.Value = TaikoMascotAnimationState.Clear));
|
|
|
|
AddAssert("skins with animations change to clear", () => someMascotsIn(TaikoMascotAnimationState.Clear));
|
|
|
|
}
|
|
|
|
|
2020-04-24 12:59:05 +08:00
|
|
|
[Test]
|
2020-05-01 03:41:57 +08:00
|
|
|
public void TestIdleState()
|
2020-04-24 12:59:05 +08:00
|
|
|
{
|
2020-04-30 02:28:46 +08:00
|
|
|
AddStep("set beatmap", () => setBeatmap());
|
2020-04-27 07:40:57 +08:00
|
|
|
|
2020-05-01 03:41:57 +08:00
|
|
|
createDrawableRuleset();
|
2020-04-24 12:59:05 +08:00
|
|
|
|
2020-05-01 03:41:57 +08:00
|
|
|
assertStateAfterResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Great }, TaikoMascotAnimationState.Idle);
|
|
|
|
assertStateAfterResult(new JudgementResult(new StrongHitObject(), new TaikoStrongJudgement()) { Type = HitResult.Miss }, TaikoMascotAnimationState.Idle);
|
|
|
|
}
|
2020-04-27 07:40:57 +08:00
|
|
|
|
2020-05-01 03:41:57 +08:00
|
|
|
[Test]
|
|
|
|
public void TestKiaiState()
|
|
|
|
{
|
|
|
|
AddStep("set beatmap", () => setBeatmap(true));
|
|
|
|
|
|
|
|
createDrawableRuleset();
|
2020-04-30 03:42:28 +08:00
|
|
|
|
2020-05-01 03:41:57 +08:00
|
|
|
assertStateAfterResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Good }, TaikoMascotAnimationState.Kiai);
|
|
|
|
assertStateAfterResult(new JudgementResult(new Hit(), new TaikoStrongJudgement()) { Type = HitResult.Miss }, TaikoMascotAnimationState.Kiai);
|
|
|
|
assertStateAfterResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Miss }, TaikoMascotAnimationState.Fail);
|
2020-04-27 07:40:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2020-05-01 03:41:57 +08:00
|
|
|
public void TestMissState()
|
2020-04-27 07:40:57 +08:00
|
|
|
{
|
2020-05-01 03:41:57 +08:00
|
|
|
AddStep("set beatmap", () => setBeatmap());
|
2020-04-27 07:40:57 +08:00
|
|
|
|
2020-05-01 03:41:57 +08:00
|
|
|
createDrawableRuleset();
|
2020-04-27 07:40:57 +08:00
|
|
|
|
2020-05-01 03:41:57 +08:00
|
|
|
assertStateAfterResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Great }, TaikoMascotAnimationState.Idle);
|
|
|
|
assertStateAfterResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Miss }, TaikoMascotAnimationState.Fail);
|
|
|
|
assertStateAfterResult(new JudgementResult(new DrumRoll(), new TaikoDrumRollJudgement()) { Type = HitResult.Great }, TaikoMascotAnimationState.Fail);
|
|
|
|
assertStateAfterResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Good }, TaikoMascotAnimationState.Idle);
|
|
|
|
}
|
2020-04-27 07:40:57 +08:00
|
|
|
|
2020-05-01 03:41:57 +08:00
|
|
|
[TestCase(true)]
|
|
|
|
[TestCase(false)]
|
|
|
|
public void TestClearStateOnComboMilestone(bool kiai)
|
|
|
|
{
|
|
|
|
AddStep("set beatmap", () => setBeatmap(kiai));
|
|
|
|
|
|
|
|
createDrawableRuleset();
|
|
|
|
|
|
|
|
AddRepeatStep("reach 49 combo", () => applyNewResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Great }), 49);
|
|
|
|
|
|
|
|
assertStateAfterResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Good }, TaikoMascotAnimationState.Clear);
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase(true)]
|
|
|
|
[TestCase(false)]
|
|
|
|
public void TestClearStateOnClearedSwell(bool kiai)
|
|
|
|
{
|
|
|
|
AddStep("set beatmap", () => setBeatmap(kiai));
|
2020-04-24 12:59:05 +08:00
|
|
|
|
2020-05-01 03:41:57 +08:00
|
|
|
createDrawableRuleset();
|
2020-04-24 12:59:05 +08:00
|
|
|
|
2020-05-01 03:41:57 +08:00
|
|
|
assertStateAfterResult(new JudgementResult(new Swell(), new TaikoSwellJudgement()) { Type = HitResult.Great }, TaikoMascotAnimationState.Clear);
|
2020-04-27 07:40:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void setBeatmap(bool kiai = false)
|
|
|
|
{
|
|
|
|
var controlPointInfo = new ControlPointInfo();
|
|
|
|
controlPointInfo.Add(0, new TimingControlPoint { BeatLength = 90 });
|
|
|
|
|
|
|
|
if (kiai)
|
|
|
|
controlPointInfo.Add(0, new EffectControlPoint { KiaiMode = true });
|
|
|
|
|
2020-04-29 05:24:21 +08:00
|
|
|
Beatmap.Value = CreateWorkingBeatmap(new Beatmap
|
2020-04-27 07:40:57 +08:00
|
|
|
{
|
|
|
|
HitObjects = new List<HitObject> { new Hit { Type = HitType.Centre } },
|
|
|
|
BeatmapInfo = new BeatmapInfo
|
|
|
|
{
|
|
|
|
BaseDifficulty = new BeatmapDifficulty(),
|
|
|
|
Metadata = new BeatmapMetadata
|
|
|
|
{
|
2020-05-01 03:41:57 +08:00
|
|
|
Artist = "Unknown",
|
|
|
|
Title = "Sample Beatmap",
|
|
|
|
AuthorString = "Craftplacer",
|
2020-04-27 07:40:57 +08:00
|
|
|
},
|
|
|
|
Ruleset = new TaikoRuleset().RulesetInfo
|
|
|
|
},
|
|
|
|
ControlPointInfo = controlPointInfo
|
|
|
|
});
|
2020-05-01 03:41:57 +08:00
|
|
|
|
|
|
|
scoreProcessor.ApplyBeatmap(Beatmap.Value.Beatmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void createDrawableRuleset()
|
|
|
|
{
|
|
|
|
AddUntilStep("wait for beatmap to be loaded", () => Beatmap.Value.Track.IsLoaded);
|
|
|
|
|
|
|
|
AddStep("create drawable ruleset", () =>
|
|
|
|
{
|
|
|
|
Beatmap.Value.Track.Start();
|
|
|
|
|
|
|
|
SetContents(() =>
|
|
|
|
{
|
|
|
|
var ruleset = new TaikoRuleset();
|
|
|
|
return new DrawableTaikoRuleset(ruleset, Beatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private void assertStateAfterResult(JudgementResult judgementResult, TaikoMascotAnimationState expectedState)
|
|
|
|
{
|
|
|
|
AddStep($"{judgementResult.Type.ToString().ToLower()} result for {judgementResult.Judgement.GetType().Name.Humanize(LetterCasing.LowerCase)}",
|
|
|
|
() => applyNewResult(judgementResult));
|
|
|
|
|
|
|
|
AddAssert($"state is {expectedState.ToString().ToLower()}", () => allMascotsIn(expectedState));
|
2020-04-27 07:40:57 +08:00
|
|
|
}
|
|
|
|
|
2020-05-01 03:41:57 +08:00
|
|
|
private void applyNewResult(JudgementResult judgementResult)
|
2020-04-27 07:40:57 +08:00
|
|
|
{
|
2020-05-01 03:58:05 +08:00
|
|
|
scoreProcessor.ApplyResult(judgementResult);
|
|
|
|
|
2020-04-27 07:40:57 +08:00
|
|
|
foreach (var playfield in playfields)
|
|
|
|
{
|
2020-05-01 03:41:57 +08:00
|
|
|
var hit = new DrawableTestHit(new Hit(), judgementResult.Type);
|
2020-04-29 05:51:34 +08:00
|
|
|
Add(hit);
|
2020-04-27 07:40:57 +08:00
|
|
|
|
2020-05-01 03:41:57 +08:00
|
|
|
playfield.OnNewResult(hit, judgementResult);
|
2020-04-27 07:40:57 +08:00
|
|
|
}
|
2020-04-24 12:59:05 +08:00
|
|
|
}
|
|
|
|
|
2020-04-30 06:14:27 +08:00
|
|
|
private bool allMascotsIn(TaikoMascotAnimationState state) => mascots.All(d => d.State.Value == state);
|
|
|
|
private bool someMascotsIn(TaikoMascotAnimationState state) => mascots.Any(d => d.State.Value == state);
|
2020-04-24 12:59:05 +08:00
|
|
|
}
|
|
|
|
}
|