diff --git a/TaikoWebUI/Pages/DaniDojo.razor b/TaikoWebUI/Pages/DaniDojo.razor index 196278f..d4cde03 100644 --- a/TaikoWebUI/Pages/DaniDojo.razor +++ b/TaikoWebUI/Pages/DaniDojo.razor @@ -28,10 +28,9 @@ else - @for (uint i = 1; i <= 19; i++) + @foreach (var danId in danMap.Keys) { - var danId = i; - var danData = GameDataService.GetDanDataById(danId); + var danData = danMap[danId]; @Localizer["Details"] diff --git a/TaikoWebUI/Pages/DaniDojo.razor.cs b/TaikoWebUI/Pages/DaniDojo.razor.cs index 0893a79..960629f 100644 --- a/TaikoWebUI/Pages/DaniDojo.razor.cs +++ b/TaikoWebUI/Pages/DaniDojo.razor.cs @@ -1,4 +1,5 @@ -using Microsoft.JSInterop; +using System.Collections.Immutable; +using Microsoft.JSInterop; namespace TaikoWebUI.Pages; @@ -14,6 +15,7 @@ public partial class DaniDojo private static Dictionary _bestDataMap = new(); private Dictionary musicDetailDictionary = new(); + private ImmutableDictionary danMap = ImmutableDictionary.Empty; private readonly List breadcrumbs = new(); @@ -32,6 +34,8 @@ public partial class DaniDojo .Sort((stageData, otherStageData) => stageData.SongNumber.CompareTo(otherStageData.SongNumber))); _bestDataMap = response.DanBestDataList.ToDictionary(data => data.DanId); + danMap = GameDataService.GetDanMap(); + SongNameLanguage = await LocalStorage.GetItemAsync("songNameLanguage"); userSetting = await Client.GetFromJsonAsync($"api/UserSettings/{Baid}"); diff --git a/TaikoWebUI/Services/GameDataService.cs b/TaikoWebUI/Services/GameDataService.cs index 83d6fea..6395d3d 100644 --- a/TaikoWebUI/Services/GameDataService.cs +++ b/TaikoWebUI/Services/GameDataService.cs @@ -116,11 +116,11 @@ public class GameDataService : IGameDataService return musicDetails.TryGetValue(songId, out var musicDetail) ? musicDetail.Index : int.MaxValue; } - public DanData GetDanDataById(uint danId) + public ImmutableDictionary GetDanMap() { - return danMap.GetValueOrDefault(danId, new DanData()); + return danMap; } - + public int GetMusicStarLevel(Dictionary musicDetails, uint songId, Difficulty difficulty) { var success = musicDetails.TryGetValue(songId, out var musicDetail); diff --git a/TaikoWebUI/Services/IGameDataService.cs b/TaikoWebUI/Services/IGameDataService.cs index c34effb..7cb6996 100644 --- a/TaikoWebUI/Services/IGameDataService.cs +++ b/TaikoWebUI/Services/IGameDataService.cs @@ -1,4 +1,6 @@ -namespace TaikoWebUI.Services; +using System.Collections.Immutable; + +namespace TaikoWebUI.Services; public interface IGameDataService { @@ -22,7 +24,7 @@ public interface IGameDataService public int GetMusicIndexBySongId(Dictionary musicDetails,uint songId); - public DanData GetDanDataById(uint danId); + public ImmutableDictionary GetDanMap(); public int GetMusicStarLevel(Dictionary musicDetails, uint songId, Difficulty difficulty);