diff --git a/osu.Game.Tournament.Tests/TestCaseMapPool.cs b/osu.Game.Tournament.Tests/TestCaseMapPool.cs index 10ebd4e63c..e4637b8fc3 100644 --- a/osu.Game.Tournament.Tests/TestCaseMapPool.cs +++ b/osu.Game.Tournament.Tests/TestCaseMapPool.cs @@ -17,9 +17,10 @@ namespace osu.Game.Tournament.Tests [BackgroundDependencyLoader] private void load() { - var round = Ladder.Groupings.First(g => g.Name == "Finals"); + var round = Ladder.Groupings.FirstOrDefault(g => g.Name == "Finals"); - Add(new MapPoolScreen(round)); + if (round != null) + Add(new MapPoolScreen(round)); } } @@ -37,7 +38,7 @@ namespace osu.Game.Tournament.Tests Padding = new MarginPadding(50), Direction = FillDirection.Full, RelativeSizeAxes = Axes.Both, - }, + } }; foreach (var b in round.Beatmaps) diff --git a/osu.Game.Tournament.Tests/TestCaseTeamIntro.cs b/osu.Game.Tournament.Tests/TestCaseTeamIntro.cs index fff28ba900..845f5638a0 100644 --- a/osu.Game.Tournament.Tests/TestCaseTeamIntro.cs +++ b/osu.Game.Tournament.Tests/TestCaseTeamIntro.cs @@ -13,10 +13,10 @@ namespace osu.Game.Tournament.Tests [BackgroundDependencyLoader] private void load() { - var team1 = Ladder.Teams.First(t => t.Acronym == "USA"); - var team2 = Ladder.Teams.First(t => t.Acronym == "JPN"); + var team1 = Ladder.Teams.FirstOrDefault(t => t.Acronym == "USA"); + var team2 = Ladder.Teams.FirstOrDefault(t => t.Acronym == "JPN"); - var round = Ladder.Groupings.First(g => g.Name == "Finals"); + var round = Ladder.Groupings.FirstOrDefault(g => g.Name == "Finals"); Add(new TeamIntroScreen(team1, team2, round) { diff --git a/osu.Game.Tournament/Screens/TeamIntro/TeamIntro.cs b/osu.Game.Tournament/Screens/TeamIntro/TeamIntro.cs index f8820d570a..766feaa806 100644 --- a/osu.Game.Tournament/Screens/TeamIntro/TeamIntro.cs +++ b/osu.Game.Tournament/Screens/TeamIntro/TeamIntro.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Video; @@ -84,7 +85,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Colour = col, - Text = group.Name.Value, + Text = group?.Name.Value ?? "Unknown Grouping", Font = "Exo2.0-Light", Spacing = new Vector2(10, 0), TextSize = 50, @@ -94,7 +95,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Colour = col, - Text = group.StartDate.Value.ToString("dd MMMM HH:mm UTC"), + Text = (group?.StartDate.Value ?? DateTimeOffset.Now).ToString("dd MMMM HH:mm UTC"), TextSize = 20, }, } @@ -134,15 +135,18 @@ namespace osu.Game.Tournament.Screens.TeamIntro }, }; - foreach (var p in team.Players) - players.Add(new OsuSpriteText - { - Text = p.Username, - TextSize = 24, - Colour = colour, - Anchor = left ? Anchor.CentreRight : Anchor.CentreLeft, - Origin = left ? Anchor.CentreRight : Anchor.CentreLeft, - }); + if (team != null) + { + foreach (var p in team.Players) + players.Add(new OsuSpriteText + { + Text = p.Username, + TextSize = 24, + Colour = colour, + Anchor = left ? Anchor.CentreRight : Anchor.CentreLeft, + Origin = left ? Anchor.CentreRight : Anchor.CentreLeft, + }); + } } private class TeamDisplay : DrawableTournamentTeam @@ -168,7 +172,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro Flag, new OsuSpriteText { - Text = team.FullName.ToUpper(), + Text = team?.FullName.ToUpper() ?? "???", TextSize = 40, Colour = Color4.Black, Font = "Exo2.0-Light",