2019-03-04 04:24:19 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2018-10-16 07:07:59 +00:00
|
|
|
|
using System;
|
2020-03-03 09:12:42 +00:00
|
|
|
|
using System.Linq;
|
2018-10-16 07:07:59 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2019-06-17 07:28:58 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-09-09 19:51:38 +00:00
|
|
|
|
|
2019-06-18 05:51:48 +00:00
|
|
|
|
namespace osu.Game.Tournament.Models
|
2017-05-02 04:02:14 +00:00
|
|
|
|
{
|
2019-06-18 06:00:33 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// A team representation. For official tournaments this is generally a country.
|
|
|
|
|
/// </summary>
|
2018-10-16 07:07:59 +00:00
|
|
|
|
[Serializable]
|
2018-08-25 12:40:40 +00:00
|
|
|
|
public class TournamentTeam
|
2017-05-02 04:02:14 +00:00
|
|
|
|
{
|
2017-05-02 07:54:43 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The name of this team.
|
|
|
|
|
/// </summary>
|
2019-06-17 07:28:58 +00:00
|
|
|
|
public Bindable<string> FullName = new Bindable<string>(string.Empty);
|
2018-09-09 19:51:38 +00:00
|
|
|
|
|
2017-05-02 04:02:14 +00:00
|
|
|
|
/// <summary>
|
2018-08-25 12:40:40 +00:00
|
|
|
|
/// Name of the file containing the flag.
|
2017-05-02 04:02:14 +00:00
|
|
|
|
/// </summary>
|
2019-06-17 07:28:58 +00:00
|
|
|
|
public Bindable<string> FlagName = new Bindable<string>(string.Empty);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-05-02 07:54:43 +00:00
|
|
|
|
/// <summary>
|
2018-08-25 12:40:40 +00:00
|
|
|
|
/// Short acronym which appears in the group boxes post-selection.
|
2017-05-02 07:54:43 +00:00
|
|
|
|
/// </summary>
|
2019-06-17 07:28:58 +00:00
|
|
|
|
public Bindable<string> Acronym = new Bindable<string>(string.Empty);
|
2018-09-09 19:51:38 +00:00
|
|
|
|
|
2020-03-03 09:12:42 +00:00
|
|
|
|
public BindableList<SeedingResult> SeedingResults = new BindableList<SeedingResult>();
|
|
|
|
|
|
|
|
|
|
public double AverageRank
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2022-06-17 18:03:33 +00:00
|
|
|
|
int[] ranks = Players.Select(p => p.Rank)
|
2021-10-27 04:04:41 +00:00
|
|
|
|
.Where(i => i.HasValue)
|
|
|
|
|
.Select(i => i.Value)
|
|
|
|
|
.ToArray();
|
2020-03-03 09:12:42 +00:00
|
|
|
|
|
|
|
|
|
if (ranks.Length == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return ranks.Average();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Bindable<string> Seed = new Bindable<string>(string.Empty);
|
|
|
|
|
|
|
|
|
|
public Bindable<int> LastYearPlacing = new BindableInt
|
|
|
|
|
{
|
|
|
|
|
MinValue = 1,
|
|
|
|
|
MaxValue = 64
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 07:07:59 +00:00
|
|
|
|
[JsonProperty]
|
2022-06-17 23:33:26 +00:00
|
|
|
|
public BindableList<TournamentUser> Players { get; set; } = new BindableList<TournamentUser>();
|
2019-06-17 07:28:58 +00:00
|
|
|
|
|
|
|
|
|
public TournamentTeam()
|
|
|
|
|
{
|
|
|
|
|
Acronym.ValueChanged += val =>
|
|
|
|
|
{
|
|
|
|
|
// use a sane default flag name based on acronym.
|
|
|
|
|
if (val.OldValue.StartsWith(FlagName.Value, StringComparison.InvariantCultureIgnoreCase))
|
2022-06-20 12:39:47 +00:00
|
|
|
|
FlagName.Value = val.NewValue.Length >= 2 ? val.NewValue?.Substring(0, 2).ToUpperInvariant() : string.Empty;
|
2019-06-17 07:28:58 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FullName.ValueChanged += val =>
|
|
|
|
|
{
|
|
|
|
|
// use a sane acronym based on full name.
|
|
|
|
|
if (val.OldValue.StartsWith(Acronym.Value, StringComparison.InvariantCultureIgnoreCase))
|
2022-06-20 12:39:47 +00:00
|
|
|
|
Acronym.Value = val.NewValue.Length >= 3 ? val.NewValue?.Substring(0, 3).ToUpperInvariant() : string.Empty;
|
2019-06-17 07:28:58 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
2018-09-21 20:52:25 +00:00
|
|
|
|
|
2019-06-17 07:28:58 +00:00
|
|
|
|
public override string ToString() => FullName.Value ?? Acronym.Value;
|
2017-05-02 04:02:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|