Add conditional match support

This commit is contained in:
Dean Herbert
2018-12-01 15:32:11 +09:00
parent 03e416cda9
commit 61ca79a8b2
5 changed files with 65 additions and 9 deletions

View File

@ -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
{
}
}

View File

@ -199,6 +199,18 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
if (Pairing.Team1.Value == null || Pairing.Team2.Value == null)
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[]
{
new DrawableMatchTeam(Pairing.Team1, Pairing, Pairing.Losers),
@ -226,7 +238,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
protected override bool OnClick(ClickEvent e)
{
if (editorInfo == null)
if (editorInfo == null || Pairing is ConditionalMatchPairing)
return false;
Selected = true;

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Newtonsoft.Json;
using osu.Framework.Configuration;
@ -17,6 +18,17 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
{
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]
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 BindableCollection<ConditionalMatchPairing> ConditionalPairings = new BindableCollection<ConditionalMatchPairing>();
public readonly Bindable<Point> Position = new Bindable<Point>();
public MatchPairing()
@ -74,7 +88,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
[JsonIgnore]
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>
/// Remove scores from the match, in case of a false click or false start.