From 4b299b525996baf48a0776d4148540e7c4cb6e29 Mon Sep 17 00:00:00 2001 From: S-Sebb?? Date: Sun, 24 Sep 2023 03:24:41 +0800 Subject: [PATCH] Remove auto sort of shop folder --- .../Controllers/Game/GetDanOdaiController.cs | 1 - .../Controllers/Game/GetShopFolderController.cs | 4 ++-- .../Controllers/Game/PlayResultController.cs | 9 +++++++-- TaikoLocalServer/Services/GameDataService.cs | 14 ++++++++------ .../Services/Interfaces/IGameDataService.cs | 3 ++- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/TaikoLocalServer/Controllers/Game/GetDanOdaiController.cs b/TaikoLocalServer/Controllers/Game/GetDanOdaiController.cs index a7ec853..3395fab 100644 --- a/TaikoLocalServer/Controllers/Game/GetDanOdaiController.cs +++ b/TaikoLocalServer/Controllers/Game/GetDanOdaiController.cs @@ -46,7 +46,6 @@ public class GetDanOdaiController : BaseController Logger.LogWarning("Requested dan id {Id} does not exist!", danId); continue; } - Logger.LogInformation(odaiData.Stringify()); response.AryOdaiDatas.Add(odaiData); } diff --git a/TaikoLocalServer/Controllers/Game/GetShopFolderController.cs b/TaikoLocalServer/Controllers/Game/GetShopFolderController.cs index e11486d..ec7cd53 100644 --- a/TaikoLocalServer/Controllers/Game/GetShopFolderController.cs +++ b/TaikoLocalServer/Controllers/Game/GetShopFolderController.cs @@ -19,7 +19,7 @@ public class GetShopFolderController : BaseController gameDataService.GetTokenDataDictionary().TryGetValue("shopTokenId", out var shopTokenId); - var shopFolderDictionary = gameDataService.GetShopFolderDictionary(); + var shopFolderList = gameDataService.GetShopFolderList(); var response = new GetShopFolderResponse { @@ -28,7 +28,7 @@ public class GetShopFolderController : BaseController VerupNo = 2 }; - foreach (var shopFolder in shopFolderDictionary) response.AryShopFolderDatas.Add(shopFolder.Value); + response.AryShopFolderDatas.AddRange(shopFolderList); return Ok(response); } diff --git a/TaikoLocalServer/Controllers/Game/PlayResultController.cs b/TaikoLocalServer/Controllers/Game/PlayResultController.cs index d71f9d0..6068d10 100644 --- a/TaikoLocalServer/Controllers/Game/PlayResultController.cs +++ b/TaikoLocalServer/Controllers/Game/PlayResultController.cs @@ -21,15 +21,19 @@ public class PlayResultController : BaseController private readonly IDanScoreDatumService danScoreDatumService; private readonly IAiDatumService aiDatumService; + + private readonly IGameDataService gameDataService; public PlayResultController(IUserDatumService userDatumService, ISongPlayDatumService songPlayDatumService, - ISongBestDatumService songBestDatumService, IDanScoreDatumService danScoreDatumService, IAiDatumService aiDatumService) + ISongBestDatumService songBestDatumService, IDanScoreDatumService danScoreDatumService, IAiDatumService aiDatumService, + IGameDataService gameDataService) { this.userDatumService = userDatumService; this.songPlayDatumService = songPlayDatumService; this.songBestDatumService = songBestDatumService; this.danScoreDatumService = danScoreDatumService; this.aiDatumService = aiDatumService; + this.gameDataService = gameDataService; } [HttpPost] @@ -74,10 +78,11 @@ public class PlayResultController : BaseController } var bestData = await songBestDatumService.GetAllSongBestData(request.BaidConf); + for (var songNumber = 0; songNumber < playResultData.AryStageInfoes.Count; songNumber++) { var stageData = playResultData.AryStageInfoes[songNumber]; - + if (stageData.IsSkipUse) { await UpdatePlayData(request, songNumber, stageData, lastPlayDatetime); diff --git a/TaikoLocalServer/Services/GameDataService.cs b/TaikoLocalServer/Services/GameDataService.cs index cdf9ca4..a440939 100644 --- a/TaikoLocalServer/Services/GameDataService.cs +++ b/TaikoLocalServer/Services/GameDataService.cs @@ -33,10 +33,9 @@ public class GameDataService : IGameDataService private ImmutableDictionary folderDictionary = ImmutableDictionary.Empty; - private ImmutableDictionary shopFolderDictionary = - ImmutableDictionary.Empty; - private ImmutableDictionary qrCodeDataDictionary = ImmutableDictionary.Empty; + + private List shopFolderList = new(); private List musics = new(); @@ -98,9 +97,9 @@ public class GameDataService : IGameDataService return folderDictionary; } - public ImmutableDictionary GetShopFolderDictionary() + public List GetShopFolderList() { - return shopFolderDictionary; + return shopFolderList; } public Dictionary GetTokenDataDictionary() @@ -270,7 +269,10 @@ public class GameDataService : IGameDataService private void InitializeShopFolderData(List? shopFolderData) { shopFolderData.ThrowIfNull("Shouldn't happen!"); - shopFolderDictionary = shopFolderData.ToImmutableDictionary(data => data.SongNo, ToResponseShopFolderData); + foreach (var folderData in shopFolderData) + { + shopFolderList.Add(ToResponseShopFolderData(folderData)); + } } private void InitializeTokenData(Dictionary? tokenData) diff --git a/TaikoLocalServer/Services/Interfaces/IGameDataService.cs b/TaikoLocalServer/Services/Interfaces/IGameDataService.cs index 40bce35..6bed601 100644 --- a/TaikoLocalServer/Services/Interfaces/IGameDataService.cs +++ b/TaikoLocalServer/Services/Interfaces/IGameDataService.cs @@ -1,4 +1,5 @@ using System.Collections.Immutable; +using SharedProject.Models; namespace TaikoLocalServer.Services.Interfaces; @@ -24,7 +25,7 @@ public interface IGameDataService public ImmutableDictionary GetFolderDictionary(); - public ImmutableDictionary GetShopFolderDictionary(); + public List GetShopFolderList(); public Dictionary GetTokenDataDictionary();