1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 00:47:24 +08:00
osu-lazer/osu.Game.Tournament.Tests/TestSceneMatchPairings.cs

95 lines
3.6 KiB
C#
Raw Normal View History

2019-03-04 12:24:19 +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 osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Tests.Visual;
2018-08-26 00:24:19 +08:00
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Screens.Ladder.Components;
namespace osu.Game.Tournament.Tests
{
2019-06-14 16:25:07 +08:00
public class TestSceneMatchPairings : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(MatchPairing),
typeof(DrawableMatchPairing),
typeof(DrawableMatchTeam),
typeof(DrawableTournamentTeam),
};
2019-06-14 16:25:07 +08:00
public TestSceneMatchPairings()
{
Container<DrawableMatchPairing> level1;
Container<DrawableMatchPairing> level2;
2018-08-26 17:37:46 +08:00
var pairing1 = new MatchPairing(
new TournamentTeam { FlagName = "AU", FullName = "Australia", },
new TournamentTeam { FlagName = "JP", FullName = "Japan", Acronym = "JPN" })
{
Team1Score = { Value = 4 },
Team2Score = { Value = 1 },
};
var pairing2 = new MatchPairing(
new TournamentTeam
{
FlagName = "RO",
FullName = "Romania",
}
);
2018-09-21 17:52:00 +08:00
Child = new FillFlowContainer
{
2018-09-21 17:52:00 +08:00
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
2018-09-21 17:52:00 +08:00
level1 = new FillFlowContainer<DrawableMatchPairing>
2018-08-26 17:37:46 +08:00
{
2018-09-21 17:52:00 +08:00
AutoSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
2018-08-26 17:37:46 +08:00
Children = new[]
{
new DrawableMatchPairing(pairing1),
new DrawableMatchPairing(pairing2),
new DrawableMatchPairing(new MatchPairing()),
}
},
2018-09-21 17:52:00 +08:00
level2 = new FillFlowContainer<DrawableMatchPairing>
2018-08-26 17:37:46 +08:00
{
2018-09-21 17:52:00 +08:00
AutoSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
2018-08-26 17:37:46 +08:00
Margin = new MarginPadding(20),
Children = new[]
{
new DrawableMatchPairing(new MatchPairing()),
new DrawableMatchPairing(new MatchPairing())
}
}
}
};
2018-09-16 04:35:51 +08:00
level1.Children[0].Pairing.Progression.Value = level2.Children[0].Pairing;
level1.Children[1].Pairing.Progression.Value = level2.Children[0].Pairing;
2018-08-26 17:37:46 +08:00
AddRepeatStep("change scores", () => pairing1.Team2Score.Value++, 4);
2018-08-26 17:37:46 +08:00
AddStep("add new team", () => pairing2.Team2.Value = new TournamentTeam { FlagName = "PT", FullName = "Portugal" });
2018-09-16 04:35:51 +08:00
AddStep("Add progression", () => level1.Children[2].Pairing.Progression.Value = level2.Children[1].Pairing);
AddStep("start match", () => pairing2.StartMatch());
2018-08-26 17:37:46 +08:00
AddRepeatStep("change scores", () => pairing2.Team1Score.Value++, 10);
2018-08-26 17:37:46 +08:00
AddStep("start submatch", () => level2.Children[0].Pairing.StartMatch());
2018-08-26 17:37:46 +08:00
AddRepeatStep("change scores", () => level2.Children[0].Pairing.Team1Score.Value++, 5);
AddRepeatStep("change scores", () => level2.Children[0].Pairing.Team2Score.Value++, 4);
}
}
}