1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 06:12:58 +08:00

Add grouping and move BestOf out of pairing

This commit is contained in:
Dean Herbert 2018-09-24 05:19:03 +09:00
parent a3a2a149ca
commit 68cef76468
5 changed files with 54 additions and 39 deletions

View File

@ -61,7 +61,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
pairing.Team2.BindValueChanged(_ => updateTeams()); pairing.Team2.BindValueChanged(_ => updateTeams());
pairing.Team1Score.BindValueChanged(_ => updateWinConditions()); pairing.Team1Score.BindValueChanged(_ => updateWinConditions());
pairing.Team2Score.BindValueChanged(_ => updateWinConditions()); pairing.Team2Score.BindValueChanged(_ => updateWinConditions());
pairing.BestOf.BindValueChanged(_ => updateWinConditions()); pairing.Grouping.BindValueChanged(_ => updateWinConditions());
pairing.Completed.BindValueChanged(_ => updateProgression()); pairing.Completed.BindValueChanged(_ => updateProgression());
pairing.Progression.BindValueChanged(_ => updateProgression()); pairing.Progression.BindValueChanged(_ => updateProgression());
@ -112,11 +112,11 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
private void updateWinConditions() private void updateWinConditions()
{ {
if (conditions.Value == null) return; if (conditions.Value == null || Pairing.Grouping.Value == null) return;
var instaWinAmount = Pairing.BestOf.Value / 2; var instaWinAmount = Pairing.Grouping.Value.BestOf / 2;
Pairing.Completed.Value = Pairing.Team1Score + Pairing.Team2Score >= Pairing.BestOf || Pairing.Team1Score > instaWinAmount || Pairing.Team2Score > instaWinAmount; Pairing.Completed.Value = Pairing.Grouping.Value.BestOf > 0 && (Pairing.Team1Score + Pairing.Team2Score >= Pairing.Grouping.Value.BestOf || Pairing.Team1Score > instaWinAmount || Pairing.Team2Score > instaWinAmount);
} }
protected override void LoadComplete() protected override void LoadComplete()

View File

@ -1,3 +1,6 @@
// 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.Collections.Generic; using System.Collections.Generic;
namespace osu.Game.Tournament.Screens.Ladder.Components namespace osu.Game.Tournament.Screens.Ladder.Components
@ -6,5 +9,6 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
{ {
public List<MatchPairing> Pairings = new List<MatchPairing>(); public List<MatchPairing> Pairings = new List<MatchPairing>();
public List<(int, int)> Progressions = new List<(int, int)>(); public List<(int, int)> Progressions = new List<(int, int)>();
public List<TournamentGrouping> Groupings = new List<TournamentGrouping>();
} }
} }

View File

@ -3,7 +3,6 @@
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
@ -18,8 +17,6 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
protected override string Title => @"ladder"; protected override string Title => @"ladder";
private PlayerSliderBar<double> sliderBestOf;
private OsuTextBox textboxTeam1; private OsuTextBox textboxTeam1;
private OsuTextBox textboxTeam2; private OsuTextBox textboxTeam2;
@ -70,39 +67,38 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
}, },
}, },
textboxTeam2 = new OsuTextBox { RelativeSizeAxes = Axes.X, Height = 20 }, textboxTeam2 = new OsuTextBox { RelativeSizeAxes = Axes.X, Height = 20 },
new Container // new Container
{ // {
RelativeSizeAxes = Axes.X, // RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, // AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Horizontal = padding }, // Padding = new MarginPadding { Horizontal = padding },
Children = new Drawable[] // Children = new Drawable[]
{ // {
new OsuSpriteText // new OsuSpriteText
{ // {
Anchor = Anchor.CentreLeft, // Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, // Origin = Anchor.CentreLeft,
Text = "Best of", // Text = "Best of",
}, // },
}, // },
}, // },
sliderBestOf = new PlayerSliderBar<double> // sliderBestOf = new PlayerSliderBar<double>
{ // {
Bindable = new BindableDouble // Bindable = new BindableDouble
{ // {
Default = 11, // Default = 11,
Value = 11, // Value = 11,
MinValue = 1, // MinValue = 1,
MaxValue = 21, // MaxValue = 21,
Precision = 1, // Precision = 1,
}, // },
} // }
}; };
editorInfo.Selected.ValueChanged += selection => editorInfo.Selected.ValueChanged += selection =>
{ {
textboxTeam1.Text = selection?.Team1.Value?.Acronym; textboxTeam1.Text = selection?.Team1.Value?.Acronym;
textboxTeam2.Text = selection?.Team2.Value?.Acronym; textboxTeam2.Text = selection?.Team2.Value?.Acronym;
sliderBestOf.Bindable.Value = selection?.BestOf ?? sliderBestOf.Bindable.Default;
}; };
textboxTeam1.OnCommit = (val, newText) => textboxTeam1.OnCommit = (val, newText) =>
@ -117,10 +113,10 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
editorInfo.Selected.Value.Team2.Value = teamEntries.FirstOrDefault(t => t.Acronym == val.Text); editorInfo.Selected.Value.Team2.Value = teamEntries.FirstOrDefault(t => t.Acronym == val.Text);
}; };
sliderBestOf.Bindable.ValueChanged += val => // sliderBestOf.Bindable.ValueChanged += val =>
{ // {
if (editorInfo.Selected.Value != null) editorInfo.Selected.Value.BestOf.Value = (int)val; // if (editorInfo.Selected.Value != null) editorInfo.Selected.Value.BestOf.Value = (int)val;
}; // };
editorInfo.EditingEnabled.ValueChanged += enabled => editorInfo.EditingEnabled.ValueChanged += enabled =>
{ {

View File

@ -25,7 +25,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
public readonly Bindable<bool> Completed = new Bindable<bool>(); public readonly Bindable<bool> Completed = new Bindable<bool>();
public readonly BindableInt BestOf = new BindableInt(11); public readonly Bindable<TournamentGrouping> Grouping = new Bindable<TournamentGrouping>();
[JsonIgnore] [JsonIgnore]
public readonly Bindable<MatchPairing> Progression = new Bindable<MatchPairing>(); public readonly Bindable<MatchPairing> Progression = new Bindable<MatchPairing>();

View File

@ -0,0 +1,15 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Tournament.Screens.Ladder.Components
{
public class TournamentGrouping
{
public int ID;
public string Name;
public string Description;
public int BestOf;
}
}