// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using Newtonsoft.Json; using osu.Framework.Configuration; using osu.Game.Tournament.Components; using SixLabors.Primitives; namespace osu.Game.Tournament.Screens.Ladder.Components { /// /// A collection of two teams competing in a head-to-head match. /// public class MatchPairing { public int ID; public readonly Bindable Team1 = new Bindable(); public readonly Bindable Team1Score = new Bindable(); public readonly Bindable Team2 = new Bindable(); public readonly Bindable Team2Score = new Bindable(); public readonly Bindable Completed = new Bindable(); public readonly BindableInt BestOf = new BindableInt(11); [JsonIgnore] public readonly Bindable Progression = new Bindable(); [JsonProperty] public Point Position; public MatchPairing() { } public MatchPairing(TournamentTeam team1 = null, TournamentTeam team2 = null) { Team1.Value = team1; Team2.Value = team2; } [JsonIgnore] public TournamentTeam Winner => !Completed.Value ? null : Team1Score.Value > Team2Score.Value ? Team1.Value : Team2.Value; /// /// Remove scores from the match, in case of a false click or false start. /// public void CancelMatchStart() { Team1Score.Value = null; Team2Score.Value = null; } /// /// Initialise this match with zeroed scores. Will be a noop if either team is not present. /// public void StartMatch() { if (Team1.Value == null || Team2.Value == null) return; Team1Score.Value = 0; Team2Score.Value = 0; } } }