diff --git a/TaikoLocalServer/Controllers/Api/SongLeaderboardData.cs b/TaikoLocalServer/Controllers/Api/SongLeaderboardData.cs index 905ef91..4bec3ed 100644 --- a/TaikoLocalServer/Controllers/Api/SongLeaderboardData.cs +++ b/TaikoLocalServer/Controllers/Api/SongLeaderboardData.cs @@ -34,7 +34,7 @@ public class SongLeaderboardData(ISongLeaderboardService songLeaderboardService, } var leaderboard = await songLeaderboardService.GetSongLeaderboard(songId, (Difficulty)difficulty, (int)baid); - + return Ok(new SongLeaderboardResponse { Leaderboard = leaderboard diff --git a/TaikoLocalServer/Services/SongLeaderboardService.cs b/TaikoLocalServer/Services/SongLeaderboardService.cs index 2d65e26..7d1a8e5 100644 --- a/TaikoLocalServer/Services/SongLeaderboardService.cs +++ b/TaikoLocalServer/Services/SongLeaderboardService.cs @@ -79,6 +79,12 @@ public class SongLeaderboardService : ISongLeaderboardService }); } } + Console.WriteLine("Leaderboard:"); + // log the leaderboard to the console + foreach (var entry in leaderboard) + { + Console.WriteLine($"Rank: {entry.Rank}, Baid: {entry.Baid}, UserName: {entry.UserName}, BestScore: {entry.BestScore}, BestRate: {entry.BestRate}, BestCrown: {entry.BestCrown}, BestScoreRank: {entry.BestScoreRank}"); + } return leaderboard; } diff --git a/TaikoWebUI/Components/Song/SongLeaderboardCard.razor b/TaikoWebUI/Components/Song/SongLeaderboardCard.razor index b4e3015..d3486c5 100644 --- a/TaikoWebUI/Components/Song/SongLeaderboardCard.razor +++ b/TaikoWebUI/Components/Song/SongLeaderboardCard.razor @@ -1,12 +1,67 @@ @inject HttpClient Client; +@inject Blazored.LocalStorage.ILocalStorageService LocalStorage; + @using TaikoWebUI.Utilities; - - + + @Localizer["Leaderboard"] + + + + @foreach (var difficulty in Enum.GetValues(typeof(Difficulty))) + { + var difficultyValue = (Difficulty)difficulty; + + @ScoreUtils.GetDifficultyTitle(difficultyValue) + + } + + + + @if (response == null) + { + + } + else + { + + + @Localizer["Rank"] + @Localizer["Player"] + @Localizer["Score"] + @Localizer["Rank"] + @Localizer["Crown"] + + + @context.Rank + + + @context.UserName + (@Localizer["ID"]: @context.Baid) + + + @context.BestScore + + @if (context.BestScoreRank is not ScoreRank.None) + { + @(ScoreUtils.GetRankText(context.BestScoreRank)) + } + else + { + + } + + + @(ScoreUtils.GetCrownText(context.BestCrown)) + + + + } + \ No newline at end of file diff --git a/TaikoWebUI/Components/Song/SongLeaderboardCard.razor.cs b/TaikoWebUI/Components/Song/SongLeaderboardCard.razor.cs index 777824f..4a48ad0 100644 --- a/TaikoWebUI/Components/Song/SongLeaderboardCard.razor.cs +++ b/TaikoWebUI/Components/Song/SongLeaderboardCard.razor.cs @@ -1,10 +1,10 @@  - namespace TaikoWebUI.Components.Song; public partial class SongLeaderboardCard { - private SongLeaderboardResponse? response; + private SongLeaderboardResponse? response = null; + private const string IconStyle = "width:25px; height:25px;"; [Parameter] public int SongId { get; set; } @@ -13,7 +13,9 @@ public partial class SongLeaderboardCard public int Baid { get; set; } [Parameter] - public Difficulty Difficulty { get; set; } = Difficulty.Easy; + public Difficulty Difficulty { get; set; } = Difficulty.Hard; + + private string SelectedDifficulty { get; set; } = "Hard"; protected override async Task OnInitializedAsync() { @@ -21,8 +23,13 @@ public partial class SongLeaderboardCard response = await Client.GetFromJsonAsync($"api/SongLeaderboardData/{(uint)Baid}/{(uint)SongId}/{(uint)Difficulty}"); response.ThrowIfNull(); - - // log the leaderboard - Console.WriteLine(response.Leaderboard); + } + + private async Task OnDifficultyChange(string difficulty) + { + SelectedDifficulty = difficulty; + Difficulty = Enum.Parse(SelectedDifficulty); + response = await Client.GetFromJsonAsync($"api/SongLeaderboardData/{(uint)Baid}/{(uint)SongId}/{(uint)Difficulty}"); + response.ThrowIfNull(); } } \ No newline at end of file diff --git a/TaikoWebUI/Components/UserCard.razor b/TaikoWebUI/Components/UserCard.razor index beda880..a2799e3 100644 --- a/TaikoWebUI/Components/UserCard.razor +++ b/TaikoWebUI/Components/UserCard.razor @@ -26,7 +26,7 @@ @Localizer["Admin"] } - @Localizer["User"] BAID: @User?.Baid + @Localizer["User ID"]: @User?.Baid @songTitle @songArtist - - - - + + + } } diff --git a/TaikoWebUI/Pages/SongList.razor.cs b/TaikoWebUI/Pages/SongList.razor.cs index b866e80..d750956 100644 --- a/TaikoWebUI/Pages/SongList.razor.cs +++ b/TaikoWebUI/Pages/SongList.razor.cs @@ -32,8 +32,6 @@ public partial class SongList musicDetailDictionary = await GameDataService.GetMusicDetailDictionary(); SongNameLanguage = await LocalStorage.GetItemAsync("songNameLanguage"); - - Console.WriteLine("Language: " + SongNameLanguage); if (AuthService.IsLoggedIn && !AuthService.IsAdmin) {