Skip to content

Commit

Permalink
Support multiple maps
Browse files Browse the repository at this point in the history
  • Loading branch information
Simyon264 committed Jul 13, 2024
1 parent fe891f2 commit 201dd84
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
5 changes: 4 additions & 1 deletion ReplayBrowser/Data/Models/Replay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>? Maps { get; set; }
[YamlMember(Alias = "gamemode")]
public string Gamemode { get; set; }
[YamlMember(Alias = "roundEndPlayers")]
Expand Down
5 changes: 1 addition & 4 deletions ReplayBrowser/Helpers/ReplayHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,6 @@ public async Task<SearchResult> SearchReplays(List<SearchQueryItem> searchItems,
/// <summary>
/// Searches a list of replays for a specific query.
/// </summary>
/// <param name="mode">The search mode.</param>
/// <param name="query">The search query.</param>
/// <param name="replays">The list of replays to search.</param>
/// <returns>
/// A list of replays that match the search query.
/// </returns>
Expand Down Expand Up @@ -479,7 +476,7 @@ public async Task<SearchResult> SearchReplays(List<SearchQueryItem> 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()));
Expand Down
9 changes: 8 additions & 1 deletion ReplayBrowser/Pages/Shared/ReplayDetails.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
@if(Replay != null)
{
<h2>@NameFormatted</h2>
<p>Map: @Replay.Map</p>
@if (Replay.Map == null)
{
<p>Maps: @string.Join(',', Replay.Maps)</p>
}
else
{
<p>Map: @Replay.Map</p>
}
<p>Duration: @Replay.Duration</p>
<p>Date: @DateFormatted</p>
<p>Server ID: @Replay.ServerId</p>
Expand Down
9 changes: 8 additions & 1 deletion ReplayBrowser/Pages/Shared/ReplayDisplay.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
<div class="card" style="width: 18rem; margin-top: 1rem">
<div class="card-body">
<h5 class="card-title">@_nameFormatted</h5>
<p class="card-text">Map: @ReplayData.Map</p>
@if (ReplayData.Map == null)
{
<p>Maps: @string.Join(',', ReplayData.Maps)</p>
}
else
{
<p>Map: @ReplayData.Map</p>
}
<p class="card-text">Gamemode: @ReplayData.Gamemode</p>
@if (ReplayData.RoundEndPlayers == null || ReplayData.RoundEndText == null)
{
Expand Down
2 changes: 1 addition & 1 deletion ReplayBrowser/Services/ReplayParser/ReplayParserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private Replay ParseReplay(Stream stream, string replayLink)
.IgnoreUnmatchedProperties()
.Build();
var replay = deserializer.Deserialize<Replay>(reader);
if (replay.Map == null)
if (replay.Map == null && replay.Maps == null)
{
throw new Exception("Replay is not valid.");
}
Expand Down

0 comments on commit 201dd84

Please sign in to comment.