2018-08-26 00:14:18 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
2018-10-14 04:19:50 +08:00
|
|
|
using System;
|
2018-11-08 05:29:04 +08:00
|
|
|
using System.Collections.ObjectModel;
|
2018-09-10 03:51:38 +08:00
|
|
|
using Newtonsoft.Json;
|
2018-08-26 00:14:18 +08:00
|
|
|
using osu.Framework.Configuration;
|
2018-08-26 00:24:19 +08:00
|
|
|
using osu.Game.Tournament.Components;
|
2018-09-10 03:51:38 +08:00
|
|
|
using SixLabors.Primitives;
|
2018-08-26 00:14:18 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Screens.Ladder.Components
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A collection of two teams competing in a head-to-head match.
|
|
|
|
/// </summary>
|
|
|
|
public class MatchPairing
|
|
|
|
{
|
2018-09-16 04:35:51 +08:00
|
|
|
public int ID;
|
|
|
|
|
2018-09-25 02:14:30 +08:00
|
|
|
[JsonIgnore]
|
2018-09-10 03:51:38 +08:00
|
|
|
public readonly Bindable<TournamentTeam> Team1 = new Bindable<TournamentTeam>();
|
2018-08-26 00:14:18 +08:00
|
|
|
|
2018-09-25 02:14:30 +08:00
|
|
|
public string Team1Acronym;
|
|
|
|
|
2018-09-10 03:51:38 +08:00
|
|
|
public readonly Bindable<int?> Team1Score = new Bindable<int?>();
|
2018-08-26 00:14:18 +08:00
|
|
|
|
2018-09-25 02:14:30 +08:00
|
|
|
[JsonIgnore]
|
2018-09-10 03:51:38 +08:00
|
|
|
public readonly Bindable<TournamentTeam> Team2 = new Bindable<TournamentTeam>();
|
|
|
|
|
2018-09-25 02:14:30 +08:00
|
|
|
public string Team2Acronym;
|
|
|
|
|
2018-09-10 03:51:38 +08:00
|
|
|
public readonly Bindable<int?> Team2Score = new Bindable<int?>();
|
|
|
|
|
|
|
|
public readonly Bindable<bool> Completed = new Bindable<bool>();
|
|
|
|
|
2018-09-25 01:31:48 +08:00
|
|
|
public readonly Bindable<bool> Losers = new Bindable<bool>();
|
|
|
|
|
2018-11-08 05:29:04 +08:00
|
|
|
public readonly ObservableCollection<BeatmapChoice> PicksBans = new ObservableCollection<BeatmapChoice>();
|
|
|
|
|
2018-09-24 22:30:37 +08:00
|
|
|
[JsonIgnore]
|
2018-09-24 04:19:03 +08:00
|
|
|
public readonly Bindable<TournamentGrouping> Grouping = new Bindable<TournamentGrouping>();
|
2018-09-16 04:35:51 +08:00
|
|
|
|
2018-09-21 18:58:47 +08:00
|
|
|
[JsonIgnore]
|
2018-09-22 04:52:25 +08:00
|
|
|
public readonly Bindable<MatchPairing> Progression = new Bindable<MatchPairing>();
|
2018-09-21 18:58:47 +08:00
|
|
|
|
2018-09-25 01:31:48 +08:00
|
|
|
[JsonIgnore]
|
|
|
|
public readonly Bindable<MatchPairing> LosersProgression = new Bindable<MatchPairing>();
|
|
|
|
|
2018-11-07 00:20:32 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Should not be set directly. Use LadderInfo.CurrentMatch.Value = this instead.
|
|
|
|
/// </summary>
|
|
|
|
public readonly Bindable<bool> Current = new Bindable<bool>();
|
|
|
|
|
2018-10-14 04:19:50 +08:00
|
|
|
public readonly Bindable<DateTimeOffset> Date = new Bindable<DateTimeOffset>();
|
|
|
|
|
2018-09-10 03:51:38 +08:00
|
|
|
public Point Position;
|
|
|
|
|
|
|
|
public MatchPairing()
|
|
|
|
{
|
2018-09-25 02:14:30 +08:00
|
|
|
Team1.BindValueChanged(t => Team1Acronym = t?.Acronym, true);
|
|
|
|
Team2.BindValueChanged(t => Team2Acronym = t?.Acronym, true);
|
2018-09-10 03:51:38 +08:00
|
|
|
}
|
2018-08-26 00:14:18 +08:00
|
|
|
|
2018-11-08 05:29:04 +08:00
|
|
|
public MatchPairing(TournamentTeam team1 = null, TournamentTeam team2 = null)
|
|
|
|
: this()
|
2018-08-26 00:14:18 +08:00
|
|
|
{
|
|
|
|
Team1.Value = team1;
|
|
|
|
Team2.Value = team2;
|
|
|
|
}
|
2018-08-26 17:37:46 +08:00
|
|
|
|
2018-09-16 04:35:51 +08:00
|
|
|
[JsonIgnore]
|
|
|
|
public TournamentTeam Winner => !Completed.Value ? null : Team1Score.Value > Team2Score.Value ? Team1.Value : Team2.Value;
|
2018-08-26 17:37:46 +08:00
|
|
|
|
2018-09-25 01:31:48 +08:00
|
|
|
[JsonIgnore]
|
|
|
|
public TournamentTeam Loser => !Completed.Value ? null : Team1Score.Value > Team2Score.Value ? Team2.Value : Team1.Value;
|
|
|
|
|
2018-11-10 06:31:06 +08:00
|
|
|
public int PointsToWin => Grouping.Value.BestOf / 2 + 1;
|
|
|
|
|
2018-08-26 18:11:46 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Remove scores from the match, in case of a false click or false start.
|
|
|
|
/// </summary>
|
|
|
|
public void CancelMatchStart()
|
2018-08-26 17:37:46 +08:00
|
|
|
{
|
2018-08-26 18:11:46 +08:00
|
|
|
Team1Score.Value = null;
|
|
|
|
Team2Score.Value = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initialise this match with zeroed scores. Will be a noop if either team is not present.
|
|
|
|
/// </summary>
|
|
|
|
public void StartMatch()
|
|
|
|
{
|
|
|
|
if (Team1.Value == null || Team2.Value == null)
|
|
|
|
return;
|
|
|
|
|
2018-08-26 17:37:46 +08:00
|
|
|
Team1Score.Value = 0;
|
|
|
|
Team2Score.Value = 0;
|
|
|
|
}
|
2018-08-26 00:14:18 +08:00
|
|
|
}
|
|
|
|
}
|