1
0
mirror of synced 2025-01-19 00:04:05 +01:00

Leaderboard card in progress

This commit is contained in:
shiibe 2024-06-02 19:55:44 -04:00
parent e806ae6588
commit e653e40e21
6 changed files with 45 additions and 6 deletions

View File

@ -83,6 +83,7 @@ try
builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly)); builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly));
builder.Services.AddOptions(); builder.Services.AddOptions();
builder.Services.AddSingleton<IGameDataService, GameDataService>(); builder.Services.AddSingleton<IGameDataService, GameDataService>();
builder.Services.AddScoped<ISongLeaderboardService, SongLeaderboardService>();
builder.Services.Configure<ServerSettings>(builder.Configuration.GetSection(nameof(ServerSettings))); builder.Services.Configure<ServerSettings>(builder.Configuration.GetSection(nameof(ServerSettings)));
builder.Services.Configure<DataSettings>(builder.Configuration.GetSection(nameof(DataSettings))); builder.Services.Configure<DataSettings>(builder.Configuration.GetSection(nameof(DataSettings)));
builder.Services.Configure<AuthSettings>(builder.Configuration.GetSection(nameof(AuthSettings))); builder.Services.Configure<AuthSettings>(builder.Configuration.GetSection(nameof(AuthSettings)));

View File

@ -27,7 +27,6 @@ public class SongLeaderboardService : ISongLeaderboardService
.ThenByDescending(x => x.BestRate) .ThenByDescending(x => x.BestRate)
.Take(limit) .Take(limit)
.ToListAsync(); .ToListAsync();
// get the user data for each score // get the user data for each score
var leaderboard = new List<SongLeaderboard>(); var leaderboard = new List<SongLeaderboard>();

View File

@ -3,12 +3,9 @@
<MudCard Outlined="true" Elevation="0"> <MudCard Outlined="true" Elevation="0">
<MudCardHeader> <MudCardHeader>
<MudGrid Spacing="2"> <MudGrid Spacing="2">
<MudItem xs="12" md="4"> <MudItem xs="12">
<MudText Typo="Typo.h6">@Localizer["Play History"]</MudText> <MudText Typo="Typo.h6">@Localizer["Play History"]</MudText>
</MudItem> </MudItem>
<MudItem xs="12" md="8">
<MudText Typo="Typo.h6">@Localizer["Total Credits Played"]:@Items.Count</MudText>
</MudItem>
</MudGrid> </MudGrid>
</MudCardHeader> </MudCardHeader>
@if (Items.Count > 0) @if (Items.Count > 0)

View File

@ -1,2 +1,12 @@
@using TaikoWebUI.Utilities; @inject HttpClient Client;
@using TaikoWebUI.Utilities;
<MudCard Outlined="true" Elevation="0">
<MudCardHeader>
<MudGrid Spacing="2">
<MudItem xs="12">
<MudText Typo="Typo.h6">@Localizer["Leaderboard"]</MudText>
</MudItem>
</MudGrid>
</MudCardHeader>
</MudCard>

View File

@ -0,0 +1,28 @@

namespace TaikoWebUI.Components.Song;
public partial class SongLeaderboardCard
{
private SongLeaderboardResponse? response;
[Parameter]
public int SongId { get; set; }
[Parameter]
public int Baid { get; set; }
[Parameter]
public Difficulty Difficulty { get; set; } = Difficulty.Easy;
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
response = await Client.GetFromJsonAsync<SongLeaderboardResponse>($"api/SongLeaderboardData/{(uint)Baid}/{(uint)SongId}/{(uint)Difficulty}");
response.ThrowIfNull();
// log the leaderboard
Console.WriteLine(response.Leaderboard);
}
}

View File

@ -24,6 +24,10 @@ else
<MudItem xs="12"> <MudItem xs="12">
<PlayHistoryCard Items="@songHistoryData" /> <PlayHistoryCard Items="@songHistoryData" />
</MudItem> </MudItem>
<MudItem xs="12">
<SongLeaderboardCard SongId="@SongId" Baid="@Baid" />
</MudItem>
</MudGrid> </MudGrid>
} }
} }