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 @@ public DrawableMatchPairing(MatchPairing pairing)
pairing.Team2.BindValueChanged(_ => updateTeams());
pairing.Team1Score.BindValueChanged(_ => updateWinConditions());
pairing.Team2Score.BindValueChanged(_ => updateWinConditions());
pairing.BestOf.BindValueChanged(_ => updateWinConditions());
pairing.Grouping.BindValueChanged(_ => updateWinConditions());
pairing.Completed.BindValueChanged(_ => updateProgression());
pairing.Progression.BindValueChanged(_ => updateProgression());
@ -112,11 +112,11 @@ private void updateProgression()
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()

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

View File

@ -25,7 +25,7 @@ public class MatchPairing
public readonly Bindable<bool> Completed = new Bindable<bool>();
public readonly BindableInt BestOf = new BindableInt(11);
public readonly Bindable<TournamentGrouping> Grouping = new Bindable<TournamentGrouping>();
[JsonIgnore]
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;
}
}