From 201dd84ed2ae0068bfd84944818e91e059fa10d4 Mon Sep 17 00:00:00 2001 From: Simon <63975668+Simyon264@users.noreply.github.com> Date: Sat, 13 Jul 2024 13:14:01 +0200 Subject: [PATCH] Support multiple maps --- ReplayBrowser/Data/Models/Replay.cs | 5 ++++- ReplayBrowser/Helpers/ReplayHelper.cs | 5 +---- ReplayBrowser/Pages/Shared/ReplayDetails.razor | 9 ++++++++- ReplayBrowser/Pages/Shared/ReplayDisplay.razor | 9 ++++++++- .../Services/ReplayParser/ReplayParserService.cs | 2 +- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ReplayBrowser/Data/Models/Replay.cs b/ReplayBrowser/Data/Models/Replay.cs index fe09687..055dbc8 100644 --- a/ReplayBrowser/Data/Models/Replay.cs +++ b/ReplayBrowser/Data/Models/Replay.cs @@ -19,7 +19,10 @@ public class Replay public DateTime? Date { get; set; } [YamlMember(Alias = "map")] - public string Map { get; set; } + public string? Map { get; set; } + + [YamlMember(Alias = "maps")] + public List? Maps { get; set; } [YamlMember(Alias = "gamemode")] public string Gamemode { get; set; } [YamlMember(Alias = "roundEndPlayers")] diff --git a/ReplayBrowser/Helpers/ReplayHelper.cs b/ReplayBrowser/Helpers/ReplayHelper.cs index 49002c2..570f244 100644 --- a/ReplayBrowser/Helpers/ReplayHelper.cs +++ b/ReplayBrowser/Helpers/ReplayHelper.cs @@ -447,9 +447,6 @@ public async Task SearchReplays(List searchItems, /// /// Searches a list of replays for a specific query. /// - /// The search mode. - /// The search query. - /// The list of replays to search. /// /// A list of replays that match the search query. /// @@ -479,7 +476,7 @@ public async Task SearchReplays(List searchItems, switch (searchItem.SearchModeEnum) { case SearchMode.Map: - queryable = queryable.Where(x => x.Map.ToLower().Contains(searchItem.SearchValue.ToLower())); + queryable = queryable.Where(x => x.Map.ToLower().Contains(searchItem.SearchValue.ToLower()) || x.Maps.Contains(searchItem.SearchValue.ToLower())); break; case SearchMode.Gamemode: queryable = queryable.Where(x => x.Gamemode.ToLower().Contains(searchItem.SearchValue.ToLower())); diff --git a/ReplayBrowser/Pages/Shared/ReplayDetails.razor b/ReplayBrowser/Pages/Shared/ReplayDetails.razor index e17ad2b..262037b 100644 --- a/ReplayBrowser/Pages/Shared/ReplayDetails.razor +++ b/ReplayBrowser/Pages/Shared/ReplayDetails.razor @@ -8,7 +8,14 @@ @if(Replay != null) {

@NameFormatted

-

Map: @Replay.Map

+ @if (Replay.Map == null) + { +

Maps: @string.Join(',', Replay.Maps)

+ } + else + { +

Map: @Replay.Map

+ }

Duration: @Replay.Duration

Date: @DateFormatted

Server ID: @Replay.ServerId

diff --git a/ReplayBrowser/Pages/Shared/ReplayDisplay.razor b/ReplayBrowser/Pages/Shared/ReplayDisplay.razor index 8e89fcf..1ae4d03 100644 --- a/ReplayBrowser/Pages/Shared/ReplayDisplay.razor +++ b/ReplayBrowser/Pages/Shared/ReplayDisplay.razor @@ -12,7 +12,14 @@
@_nameFormatted
-

Map: @ReplayData.Map

+ @if (ReplayData.Map == null) + { +

Maps: @string.Join(',', ReplayData.Maps)

+ } + else + { +

Map: @ReplayData.Map

+ }

Gamemode: @ReplayData.Gamemode

@if (ReplayData.RoundEndPlayers == null || ReplayData.RoundEndText == null) { diff --git a/ReplayBrowser/Services/ReplayParser/ReplayParserService.cs b/ReplayBrowser/Services/ReplayParser/ReplayParserService.cs index bd24d14..8053682 100644 --- a/ReplayBrowser/Services/ReplayParser/ReplayParserService.cs +++ b/ReplayBrowser/Services/ReplayParser/ReplayParserService.cs @@ -239,7 +239,7 @@ private Replay ParseReplay(Stream stream, string replayLink) .IgnoreUnmatchedProperties() .Build(); var replay = deserializer.Deserialize(reader); - if (replay.Map == null) + if (replay.Map == null && replay.Maps == null) { throw new Exception("Replay is not valid."); }