mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Add loser progressions
This commit is contained in:
@ -64,6 +64,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
pairing.Grouping.BindValueChanged(_ => updateWinConditions());
|
||||
pairing.Completed.BindValueChanged(_ => updateProgression());
|
||||
pairing.Progression.BindValueChanged(_ => updateProgression());
|
||||
pairing.LosersProgression.BindValueChanged(_ => updateProgression());
|
||||
|
||||
updateTeams();
|
||||
}
|
||||
@ -102,12 +103,21 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
{
|
||||
var progression = Pairing.Progression?.Value;
|
||||
|
||||
if (progression == null) return;
|
||||
if (progression != null)
|
||||
{
|
||||
bool progressionAbove = progression.ID < Pairing.ID;
|
||||
|
||||
bool progressionAbove = progression.ID < Pairing.ID;
|
||||
var destinationForWinner = progressionAbove || progression.Team1.Value != null && progression.Team1.Value != Pairing.Winner ? progression.Team2 : progression.Team1;
|
||||
destinationForWinner.Value = Pairing.Winner;
|
||||
}
|
||||
|
||||
var destinationForWinner = progressionAbove ? progression.Team2 : progression.Team1;
|
||||
destinationForWinner.Value = Pairing.Winner;
|
||||
if ((progression = Pairing.LosersProgression?.Value) != null)
|
||||
{
|
||||
bool progressionAbove = progression.ID < Pairing.ID;
|
||||
|
||||
var destinationForLoser = progressionAbove || progression.Team1.Value != null && progression.Team1.Value != Pairing.Winner ? progression.Team2 : progression.Team1;
|
||||
destinationForLoser.Value = Pairing.Loser;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateWinConditions()
|
||||
@ -197,6 +207,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
{
|
||||
Selected = false;
|
||||
Pairing.Progression.Value = null;
|
||||
Pairing.LosersProgression.Value = null;
|
||||
|
||||
Expire();
|
||||
}
|
||||
|
@ -141,6 +141,10 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pairing.Progression.Value.Completed)
|
||||
// don't allow changing scores if the match has a progression. can cause large data loss
|
||||
return false;
|
||||
|
||||
if (score.Value > 0)
|
||||
score.Value--;
|
||||
else
|
||||
@ -168,7 +172,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
|
||||
return new MenuItem[]
|
||||
{
|
||||
new OsuMenuItem("Join with", MenuItemType.Standard, () => manager.RequestJoin(pairing)),
|
||||
new OsuMenuItem("Join with", MenuItemType.Standard, () => manager.RequestJoin(pairing, false)),
|
||||
new OsuMenuItem("Join with (loser)", MenuItemType.Standard, () => manager.RequestJoin(pairing, true)),
|
||||
new OsuMenuItem("Remove", MenuItemType.Destructive, () => manager.Remove(pairing)),
|
||||
};
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
public class LadderInfo
|
||||
{
|
||||
public List<MatchPairing> Pairings = new List<MatchPairing>();
|
||||
public List<(int, int)> Progressions = new List<(int, int)>();
|
||||
public List<TournamentProgression> Progressions = new List<TournamentProgression>();
|
||||
public List<TournamentGrouping> Groupings = new List<TournamentGrouping>();
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
private OsuTextBox textboxTeam1;
|
||||
private OsuTextBox textboxTeam2;
|
||||
private SettingsDropdown<TournamentGrouping> groupingDropdown;
|
||||
private PlayerCheckbox losersCheckbox;
|
||||
|
||||
[Resolved]
|
||||
private LadderEditorInfo editorInfo { get; set; } = null;
|
||||
@ -32,7 +33,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
{
|
||||
var teamEntries = editorInfo.Teams;
|
||||
|
||||
var groupingOptions = editorInfo.Groupings.Select(g => new KeyValuePair<string, TournamentGrouping>(g.Name, g)).Prepend(new KeyValuePair<string, TournamentGrouping>("None", new TournamentGrouping()));
|
||||
var groupingOptions = editorInfo.Groupings.Select(g => new KeyValuePair<string, TournamentGrouping>(g.Name, g))
|
||||
.Prepend(new KeyValuePair<string, TournamentGrouping>("None", new TournamentGrouping()));
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -78,6 +80,11 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
Bindable = new Bindable<TournamentGrouping>(),
|
||||
Items = groupingOptions
|
||||
},
|
||||
losersCheckbox = new PlayerCheckbox
|
||||
{
|
||||
LabelText = "Losers Bracket",
|
||||
Bindable = new Bindable<bool>()
|
||||
}
|
||||
// new Container
|
||||
// {
|
||||
// RelativeSizeAxes = Axes.X,
|
||||
@ -111,6 +118,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
textboxTeam1.Text = selection?.Team1.Value?.Acronym;
|
||||
textboxTeam2.Text = selection?.Team2.Value?.Acronym;
|
||||
groupingDropdown.Bindable.Value = selection?.Grouping.Value ?? groupingOptions.First().Value;
|
||||
losersCheckbox.Current.Value = selection?.Losers.Value ?? false;
|
||||
};
|
||||
|
||||
textboxTeam1.OnCommit = (val, newText) =>
|
||||
@ -131,6 +139,12 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
editorInfo.Selected.Value.Grouping.Value = grouping;
|
||||
};
|
||||
|
||||
losersCheckbox.Current.ValueChanged += losers =>
|
||||
{
|
||||
if (editorInfo.Selected.Value != null)
|
||||
editorInfo.Selected.Value.Losers.Value = losers;
|
||||
};
|
||||
|
||||
// sliderBestOf.Bindable.ValueChanged += val =>
|
||||
// {
|
||||
// if (editorInfo.Selected.Value != null) editorInfo.Selected.Value.BestOf.Value = (int)val;
|
||||
|
@ -25,12 +25,17 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
|
||||
public readonly Bindable<bool> Completed = new Bindable<bool>();
|
||||
|
||||
public readonly Bindable<bool> Losers = new Bindable<bool>();
|
||||
|
||||
[JsonIgnore]
|
||||
public readonly Bindable<TournamentGrouping> Grouping = new Bindable<TournamentGrouping>();
|
||||
|
||||
[JsonIgnore]
|
||||
public readonly Bindable<MatchPairing> Progression = new Bindable<MatchPairing>();
|
||||
|
||||
[JsonIgnore]
|
||||
public readonly Bindable<MatchPairing> LosersProgression = new Bindable<MatchPairing>();
|
||||
|
||||
[JsonProperty]
|
||||
public Point Position;
|
||||
|
||||
@ -47,6 +52,9 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
[JsonIgnore]
|
||||
public TournamentTeam Winner => !Completed.Value ? null : Team1Score.Value > Team2Score.Value ? Team1.Value : Team2.Value;
|
||||
|
||||
[JsonIgnore]
|
||||
public TournamentTeam Loser => !Completed.Value ? null : Team1Score.Value > Team2Score.Value ? Team2.Value : Team1.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Remove scores from the match, in case of a false click or false start.
|
||||
/// </summary>
|
||||
|
@ -0,0 +1,20 @@
|
||||
// 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 TournamentProgression
|
||||
{
|
||||
public int Item1;
|
||||
public int Item2;
|
||||
|
||||
public bool Losers;
|
||||
|
||||
public TournamentProgression(int item1, int item2, bool losers = false)
|
||||
{
|
||||
Item1 = item1;
|
||||
Item2 = item2;
|
||||
Losers = losers;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user