mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 21:07:18 +09:00
Add conditional match support
This commit is contained in:
parent
03e416cda9
commit
61ca79a8b2
@ -0,0 +1,12 @@
|
|||||||
|
// 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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A pairing that may not necessarily occur.
|
||||||
|
/// </summary>
|
||||||
|
public class ConditionalMatchPairing : MatchPairing
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -199,6 +199,18 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
if (Pairing.Team1.Value == null || Pairing.Team2.Value == null)
|
if (Pairing.Team1.Value == null || Pairing.Team2.Value == null)
|
||||||
Pairing.CancelMatchStart();
|
Pairing.CancelMatchStart();
|
||||||
|
|
||||||
|
if (Pairing.ConditionalPairings.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var conditional in Pairing.ConditionalPairings)
|
||||||
|
{
|
||||||
|
var team1Match = conditional.Acronyms.Contains(Pairing.Team1Acronym);
|
||||||
|
var team2Match = conditional.Acronyms.Contains(Pairing.Team2Acronym);
|
||||||
|
|
||||||
|
if (team1Match && team2Match)
|
||||||
|
Pairing.Date.Value = conditional.Date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Flow.Children = new[]
|
Flow.Children = new[]
|
||||||
{
|
{
|
||||||
new DrawableMatchTeam(Pairing.Team1, Pairing, Pairing.Losers),
|
new DrawableMatchTeam(Pairing.Team1, Pairing, Pairing.Losers),
|
||||||
@ -226,7 +238,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
if (editorInfo == null)
|
if (editorInfo == null || Pairing is ConditionalMatchPairing)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Selected = true;
|
Selected = true;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
@ -17,6 +18,17 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
{
|
{
|
||||||
public int ID;
|
public int ID;
|
||||||
|
|
||||||
|
public List<string> Acronyms
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
List<string> acronyms = new List<string>();
|
||||||
|
if (Team1Acronym != null) acronyms.Add(Team1Acronym);
|
||||||
|
if (Team2Acronym != null) acronyms.Add(Team2Acronym);
|
||||||
|
return acronyms;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public readonly Bindable<TournamentTeam> Team1 = new Bindable<TournamentTeam>();
|
public readonly Bindable<TournamentTeam> Team1 = new Bindable<TournamentTeam>();
|
||||||
|
|
||||||
@ -53,6 +65,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
|
|
||||||
public readonly Bindable<DateTimeOffset> Date = new Bindable<DateTimeOffset>();
|
public readonly Bindable<DateTimeOffset> Date = new Bindable<DateTimeOffset>();
|
||||||
|
|
||||||
|
public readonly BindableCollection<ConditionalMatchPairing> ConditionalPairings = new BindableCollection<ConditionalMatchPairing>();
|
||||||
|
|
||||||
public readonly Bindable<Point> Position = new Bindable<Point>();
|
public readonly Bindable<Point> Position = new Bindable<Point>();
|
||||||
|
|
||||||
public MatchPairing()
|
public MatchPairing()
|
||||||
@ -74,7 +88,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public TournamentTeam Loser => !Completed.Value ? null : Team1Score.Value > Team2Score.Value ? Team2.Value : Team1.Value;
|
public TournamentTeam Loser => !Completed.Value ? null : Team1Score.Value > Team2Score.Value ? Team2.Value : Team1.Value;
|
||||||
|
|
||||||
public int PointsToWin => Grouping.Value.BestOf / 2 + 1;
|
public int PointsToWin => Grouping.Value == null ? 0 : Grouping.Value.BestOf / 2 + 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove scores from the match, in case of a false click or false start.
|
/// Remove scores from the match, in case of a false click or false start.
|
||||||
|
@ -56,6 +56,13 @@ namespace osu.Game.Tournament.Screens.Schedule
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var upcoming = ladder.Pairings.Where(p => !p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4);
|
||||||
|
var conditionals = ladder.Pairings.Where(p => !p.Completed.Value && (p.Team1.Value == null || p.Team2.Value == null) && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4)
|
||||||
|
.SelectMany(m => m.ConditionalPairings.Where(cp => m.Acronyms.TrueForAll(a => cp.Acronyms.Contains(a))));
|
||||||
|
|
||||||
|
upcoming = upcoming.Concat(conditionals);
|
||||||
|
upcoming = upcoming.OrderBy(p => p.Date.Value).Take(12);
|
||||||
|
|
||||||
mainContainer.Child = new FillFlowContainer
|
mainContainer.Child = new FillFlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -77,7 +84,8 @@ namespace osu.Game.Tournament.Screens.Schedule
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Width = 0.4f,
|
Width = 0.4f,
|
||||||
ChildrenEnumerable = ladder.Pairings
|
ChildrenEnumerable = ladder.Pairings
|
||||||
.Where(p => p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4)
|
.Where(p => p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null
|
||||||
|
&& Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4)
|
||||||
.OrderByDescending(p => p.Date.Value)
|
.OrderByDescending(p => p.Date.Value)
|
||||||
.Take(8)
|
.Take(8)
|
||||||
.Select(p => new SchedulePairing(p))
|
.Select(p => new SchedulePairing(p))
|
||||||
@ -86,11 +94,7 @@ namespace osu.Game.Tournament.Screens.Schedule
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Width = 0.6f,
|
Width = 0.6f,
|
||||||
ChildrenEnumerable = ladder.Pairings
|
ChildrenEnumerable = upcoming.Select(p => new SchedulePairing(p))
|
||||||
.Where(p => !p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4)
|
|
||||||
.OrderBy(p => p.Date.Value)
|
|
||||||
.Take(8)
|
|
||||||
.Select(p => new SchedulePairing(p))
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,6 +133,11 @@ namespace osu.Game.Tournament.Screens.Schedule
|
|||||||
{
|
{
|
||||||
Flow.Direction = FillDirection.Horizontal;
|
Flow.Direction = FillDirection.Horizontal;
|
||||||
|
|
||||||
|
bool conditional = pairing is ConditionalMatchPairing;
|
||||||
|
|
||||||
|
if (conditional)
|
||||||
|
Colour = OsuColour.Gray(0.5f);
|
||||||
|
|
||||||
if (showTimestamp)
|
if (showTimestamp)
|
||||||
{
|
{
|
||||||
AddInternal(new DrawableDate(Pairing.Date.Value)
|
AddInternal(new DrawableDate(Pairing.Date.Value)
|
||||||
@ -136,6 +145,7 @@ namespace osu.Game.Tournament.Screens.Schedule
|
|||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopLeft,
|
Origin = Anchor.TopLeft,
|
||||||
Colour = Color4.Black,
|
Colour = Color4.Black,
|
||||||
|
Alpha = conditional ? 0.6f : 1,
|
||||||
Margin = new MarginPadding { Horizontal = 10, Vertical = 5 },
|
Margin = new MarginPadding { Horizontal = 10, Vertical = 5 },
|
||||||
});
|
});
|
||||||
AddInternal(new OsuSpriteText
|
AddInternal(new OsuSpriteText
|
||||||
@ -143,8 +153,9 @@ namespace osu.Game.Tournament.Screens.Schedule
|
|||||||
Anchor = Anchor.BottomRight,
|
Anchor = Anchor.BottomRight,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Colour = Color4.Black,
|
Colour = Color4.Black,
|
||||||
|
Alpha = conditional ? 0.6f : 1,
|
||||||
Margin = new MarginPadding { Horizontal = 10, Vertical = 5 },
|
Margin = new MarginPadding { Horizontal = 10, Vertical = 5 },
|
||||||
Text = pairing.Date.Value.ToUniversalTime().ToString("HH:mm UTC")
|
Text = pairing.Date.Value.ToUniversalTime().ToString("HH:mm UTC") + (conditional ? " (conditional)" : "")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,13 @@ namespace osu.Game.Tournament
|
|||||||
{
|
{
|
||||||
pairing.Team1.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym == pairing.Team1Acronym);
|
pairing.Team1.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym == pairing.Team1Acronym);
|
||||||
pairing.Team2.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym == pairing.Team2Acronym);
|
pairing.Team2.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym == pairing.Team2Acronym);
|
||||||
|
|
||||||
|
foreach (var conditional in pairing.ConditionalPairings)
|
||||||
|
{
|
||||||
|
conditional.Team1.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym == conditional.Team1Acronym);
|
||||||
|
conditional.Team2.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym == conditional.Team2Acronym);
|
||||||
|
conditional.Grouping.Value = pairing.Grouping.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign progressions
|
// assign progressions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user