1
0
mirror of synced 2025-01-31 04:13:50 +01:00
This commit is contained in:
asesidaa 2024-03-18 01:16:51 +08:00
parent 0042f9afce
commit 891adfaaa1
64 changed files with 39 additions and 188 deletions

View File

@ -1,28 +1,9 @@
using GameDatabase.Entities;
using SharedProject.Utils;
using TaikoLocalServer.Models.Application;
using SharedProject.Utils;
namespace TaikoLocalServer.Common.Utils;
public static class Extensions
{
public static void UpdateBest(this AiSectionScoreDatum datum, PlayResultDataRequest.StageData.AiStageSectionData sectionData)
{
var crown = (CrownType)sectionData.Crown;
if (crown == CrownType.Gold && sectionData.OkCnt == 0)
{
crown = CrownType.Dondaful;
}
datum.IsWin = sectionData.IsWin ? sectionData.IsWin : datum.IsWin;
datum.Crown = ValueHelpers.Max(crown, datum.Crown);
datum.Score = ValueHelpers.Max(sectionData.Score, datum.Score);
datum.GoodCount = ValueHelpers.Max(sectionData.GoodCnt, datum.GoodCount);
datum.OkCount = ValueHelpers.Min(sectionData.OkCnt, datum.OkCount);
datum.MissCount = ValueHelpers.Min(sectionData.NgCnt, datum.MissCount);
datum.DrumrollCount = ValueHelpers.Max(sectionData.PoundCnt, datum.DrumrollCount);
}
public static void UpdateBest(this AiSectionScoreDatum datum,CommonPlayResultData.AiStageSectionData sectionData)
{
var crown = (CrownType)sectionData.Crown;

View File

@ -1,7 +1,6 @@
using System.Collections;
using System.Collections.Specialized;
using System.Runtime.InteropServices;
using GameDatabase.Entities;
namespace TaikoLocalServer.Common.Utils;

View File

@ -1,30 +0,0 @@
using GameDatabase.Entities;
using System.Text.Json;
namespace TaikoLocalServer.Common.Utils;
public static class JsonHelper
{
public static uint[] GetUIntArrayFromJson(string data, int length, ILogger logger, string fieldName)
{
var array = new uint[length];
try
{
array = JsonSerializer.Deserialize<uint[]>(data);
}
catch (JsonException e)
{
logger.LogError(e, "Parsing {FieldName} json data failed", fieldName);
}
if (array != null && array.Length >= length)
{
return array;
}
logger.LogWarning("{FieldName} is null or length less than {Length}!", fieldName, length);
array = new uint[length];
return array;
}
}

View File

@ -1,26 +0,0 @@
using GameDatabase.Entities;
using Swan.Mapping;
namespace TaikoLocalServer.Common.Utils;
using DanScoreDataStage = GetDanScoreResponse.DanScoreData.DanScoreDataStage;
public static class ObjectMappers
{
public static readonly IObjectMap<DanStageScoreDatum, DanScoreDataStage> DanStageDbToResponseMap;
static ObjectMappers()
{
var mapper = new ObjectMapper();
DanStageDbToResponseMap = mapper.AddMap<DanStageScoreDatum, DanScoreDataStage>()
.Add(t => t.ComboCnt, s => s.ComboCount)
.Add(t => t.GoodCnt, s => s.GoodCount)
.Add(t => t.OkCnt, s => s.OkCount)
.Add(t => t.NgCnt, s => s.BadCount)
.Add(t => t.HitCnt, s => s.TotalHitCount)
.Add(t => t.PoundCnt, s => s.DrumrollCount)
.Add(t => t.PlayScore, s => s.PlayScore)
.Add(t => t.HighScore, s => s.HighScore);
}
}

View File

@ -1,5 +1,4 @@
using GameDatabase.Entities;
using SharedProject.Models.Requests;
using SharedProject.Models.Requests;
namespace TaikoLocalServer.Controllers.Api;

View File

@ -1,6 +1,5 @@
using SharedProject.Models;
using SharedProject.Utils;
using System.Text.Json;
namespace TaikoLocalServer.Controllers.Api;
@ -85,13 +84,6 @@ public class UserSettingsController : BaseController<UserSettingsController>
return NotFound();
}
var difficultySettings = new List<uint>
{
userSetting.DifficultySettingCourse,
userSetting.DifficultySettingStar,
userSetting.DifficultySettingSort
};
user.IsSkipOn = userSetting.IsSkipOn;
user.IsVoiceOn = userSetting.IsVoiceOn;
user.DisplayAchievement = userSetting.IsDisplayAchievement;
@ -110,7 +102,6 @@ public class UserSettingsController : BaseController<UserSettingsController>
user.ColorBody = userSetting.BodyColor;
user.ColorFace = userSetting.FaceColor;
user.ColorLimb = userSetting.LimbColor;
// user.CostumeData = JsonSerializer.Serialize(costumes);
user.CurrentKigurumi = userSetting.Kigurumi;
user.CurrentHead = userSetting.Head;
user.CurrentBody = userSetting.Body;

View File

@ -1,5 +1,4 @@
using TaikoLocalServer.Handlers;
using AddTokenCountRequestMapper = TaikoLocalServer.Mappers.AddTokenCountRequestMapper;
using AddTokenCountRequestMapper = TaikoLocalServer.Mappers.AddTokenCountRequestMapper;
namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,6 +1,4 @@
using TaikoLocalServer.Handlers;
namespace TaikoLocalServer.Controllers.Game;
namespace TaikoLocalServer.Controllers.Game;
[ApiController]
public class BaidController : BaseController<BaidController>

View File

@ -1,6 +1,4 @@
using TaikoLocalServer.Handlers;
namespace TaikoLocalServer.Controllers.Game;
namespace TaikoLocalServer.Controllers.Game;
[ApiController]
public class GetAiDataController : BaseController<GetAiDataController>

View File

@ -1,5 +1,4 @@
using TaikoLocalServer.Handlers;
using TaikoLocalServer.Mappers;
using TaikoLocalServer.Mappers;
namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,5 +1,4 @@
using TaikoLocalServer.Handlers;
using TaikoLocalServer.Mappers;
using TaikoLocalServer.Mappers;
namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,5 +1,4 @@
using TaikoLocalServer.Handlers;
using TaikoLocalServer.Mappers;
using TaikoLocalServer.Mappers;
namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,5 +1,4 @@
using TaikoLocalServer.Handlers;
using TaikoLocalServer.Mappers;
using TaikoLocalServer.Mappers;
namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,5 +1,4 @@
using TaikoLocalServer.Handlers;
using TaikoLocalServer.Mappers;
using TaikoLocalServer.Mappers;
namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,5 +1,4 @@
using TaikoLocalServer.Handlers;
using TaikoLocalServer.Mappers;
using TaikoLocalServer.Mappers;
namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,5 +1,4 @@
using TaikoLocalServer.Handlers;
using TaikoLocalServer.Mappers;
using TaikoLocalServer.Mappers;
namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,5 +1,4 @@
using TaikoLocalServer.Handlers;
using TaikoLocalServer.Mappers;
using TaikoLocalServer.Mappers;
namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,5 +1,4 @@
using TaikoLocalServer.Handlers;
using TaikoLocalServer.Mappers;
using TaikoLocalServer.Mappers;
namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,5 +1,4 @@
using TaikoLocalServer.Handlers;
using TaikoLocalServer.Mappers;
using TaikoLocalServer.Mappers;
namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,5 +1,4 @@
using TaikoLocalServer.Handlers;
using TaikoLocalServer.Mappers;
using TaikoLocalServer.Mappers;
namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,5 +1,4 @@
using TaikoLocalServer.Handlers;
using TaikoLocalServer.Mappers;
using TaikoLocalServer.Mappers;
namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,13 +1,17 @@
// Global using directives
global using GameDatabase.Entities;
global using Microsoft.AspNetCore.Mvc;
global using Microsoft.EntityFrameworkCore;
global using ProtoBuf;
global using MediatR;
global using Swan.Formatters;
global using SharedProject.Enums;
global using TaikoLocalServer.Models.v3906;
global using TaikoLocalServer.Common;
global using TaikoLocalServer.Common.Utils;
global using TaikoLocalServer.Handlers;
global using TaikoLocalServer.Models;
global using TaikoLocalServer.Models.Application;
global using TaikoLocalServer.Models.v3906;
global using TaikoLocalServer.Services;
global using TaikoLocalServer.Services.Interfaces;

View File

@ -1,11 +1,11 @@
using GameDatabase.Context;
using GameDatabase.Entities;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Handlers;
public record AddMyDonEntryCommand(string AccessCode, string Name, uint Language) : IRequest<CommonMyDonEntryResponse>;
#pragma warning disable CS9113 // Parameter is unread.
public class AddMyDonEntryCommandHandler(TaikoDbContext context, ILogger<AddMyDonEntryCommandHandler> logger)
#pragma warning restore CS9113 // Parameter is unread.
: IRequestHandler<AddMyDonEntryCommand, CommonMyDonEntryResponse>
{
public async Task<CommonMyDonEntryResponse> Handle(AddMyDonEntryCommand request, CancellationToken cancellationToken)

View File

@ -1,6 +1,4 @@
using GameDatabase.Context;
using GameDatabase.Entities;
using TaikoLocalServer.Models.Application;
using Throw;
namespace TaikoLocalServer.Handlers;

View File

@ -1,5 +1,4 @@
using GameDatabase.Context;
using TaikoLocalServer.Models.Application;
using Throw;
namespace TaikoLocalServer.Handlers;

View File

@ -1,5 +1,4 @@
using GameDatabase.Context;
using TaikoLocalServer.Models.Application;
using Throw;
namespace TaikoLocalServer.Handlers;

View File

@ -1,13 +1,14 @@
using GameDatabase.Context;
using TaikoLocalServer.Mappers;
using TaikoLocalServer.Models.Application;
using Throw;
namespace TaikoLocalServer.Handlers;
public record GetAiScoreQuery(uint Baid, uint SongId, uint Level) : IRequest<CommonAiScoreResponse>;
#pragma warning disable CS9113 // Parameter is unread.
public class GetAiScoreQueryHandler(TaikoDbContext context, ILogger<GetAiScoreQueryHandler> logger)
#pragma warning restore CS9113 // Parameter is unread.
: IRequestHandler<GetAiScoreQuery, CommonAiScoreResponse>
{
public async Task<CommonAiScoreResponse> Handle(GetAiScoreQuery request, CancellationToken cancellationToken)

View File

@ -1,6 +1,4 @@
using GameDatabase.Context;
using GameDatabase.Entities;
using TaikoLocalServer.Models.Application;
using Throw;
namespace TaikoLocalServer.Handlers;

View File

@ -1,6 +1,4 @@
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Handlers;
namespace TaikoLocalServer.Handlers;
public record GetFolderQuery(uint[] FolderIds) : IRequest<CommonGetFolderResponse>;

View File

@ -1,7 +1,6 @@
using System.Collections.Immutable;
using Microsoft.Extensions.Options;
using SharedProject.Models;
using TaikoLocalServer.Models.Application;
using TaikoLocalServer.Settings;
namespace TaikoLocalServer.Handlers;

View File

@ -1,5 +1,4 @@
using GameDatabase.Context;
using TaikoLocalServer.Models.Application;
using Throw;
namespace TaikoLocalServer.Handlers;

View File

@ -1,6 +1,4 @@
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Handlers;
namespace TaikoLocalServer.Handlers;
public record GetShopFolderQuery : IRequest<CommonGetShopFolderResponse>;

View File

@ -1,6 +1,4 @@
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Handlers;
namespace TaikoLocalServer.Handlers;
public record GetSongIntroductionQuery(uint[] SetIds) : IRequest<CommonGetSongIntroductionResponse>;

View File

@ -1,6 +1,4 @@
using GameDatabase.Context;
using GameDatabase.Entities;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Handlers;
@ -8,7 +6,9 @@ public record GetTokenCountQuery(uint Baid) : IRequest<CommonGetTokenCountRespon
public class GetTokenCountQueryHandler(IGameDataService gameDataService,
TaikoDbContext context,
#pragma warning disable CS9113 // Parameter is unread.
ILogger<GetTokenCountQueryHandler> logger)
#pragma warning restore CS9113 // Parameter is unread.
: IRequestHandler<GetTokenCountQuery, CommonGetTokenCountResponse>
{
public async Task<CommonGetTokenCountResponse> Handle(GetTokenCountQuery request, CancellationToken cancellationToken)

View File

@ -1,5 +1,4 @@
using GameDatabase.Context;
using TaikoLocalServer.Models.Application;
using Throw;
namespace TaikoLocalServer.Handlers;

View File

@ -1,7 +1,4 @@
using System.Text.Json;
using GameDatabase.Context;
using GameDatabase.Entities;
using TaikoLocalServer.Models.Application;
using GameDatabase.Context;
using Throw;
namespace TaikoLocalServer.Handlers;

View File

@ -1,6 +1,5 @@
using System.Buffers.Binary;
using GameDatabase.Context;
using TaikoLocalServer.Models.Application;
using Throw;
namespace TaikoLocalServer.Handlers;

View File

@ -1,5 +1,4 @@
using Riok.Mapperly.Abstractions;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Mappers;

View File

@ -1,5 +1,4 @@
using Riok.Mapperly.Abstractions;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Mappers;

View File

@ -1,6 +1,4 @@
using GameDatabase.Entities;
using Riok.Mapperly.Abstractions;
using TaikoLocalServer.Models.Application;
using Riok.Mapperly.Abstractions;
namespace TaikoLocalServer.Mappers;

View File

@ -1,5 +1,4 @@
using Riok.Mapperly.Abstractions;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Mappers;

View File

@ -1,5 +1,4 @@
using Riok.Mapperly.Abstractions;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Mappers;

View File

@ -1,5 +1,4 @@
using Riok.Mapperly.Abstractions;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Mappers;

View File

@ -1,5 +1,4 @@
using Riok.Mapperly.Abstractions;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Mappers;

View File

@ -1,5 +1,4 @@
using Riok.Mapperly.Abstractions;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Mappers;

View File

@ -1,5 +1,4 @@
using Riok.Mapperly.Abstractions;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Mappers;

View File

@ -1,5 +1,4 @@
using Riok.Mapperly.Abstractions;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Mappers;

View File

@ -1,5 +1,4 @@
using Riok.Mapperly.Abstractions;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Mappers;

View File

@ -1,5 +1,4 @@
using Riok.Mapperly.Abstractions;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Mappers;

View File

@ -1,6 +1,4 @@
using Riok.Mapperly.Abstractions;
using TaikoLocalServer.Handlers;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Mappers;

View File

@ -1,5 +1,4 @@
using Riok.Mapperly.Abstractions;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Mappers;

View File

@ -1,5 +1,4 @@
using Riok.Mapperly.Abstractions;
using TaikoLocalServer.Models.Application;
namespace TaikoLocalServer.Mappers;

View File

@ -1,5 +1,4 @@
using GameDatabase.Context;
using GameDatabase.Entities;
using SharedProject.Models;
namespace TaikoLocalServer.Services;

View File

@ -1,5 +1,4 @@
using GameDatabase.Context;
using GameDatabase.Entities;
using SharedProject.Models;
using Swan.Mapping;

View File

@ -1,5 +1,4 @@
using GameDatabase.Context;
using GameDatabase.Entities;
namespace TaikoLocalServer.Services;

View File

@ -1,5 +1,4 @@
using GameDatabase.Entities;
using SharedProject.Models;
using SharedProject.Models;
namespace TaikoLocalServer.Services.Interfaces;

View File

@ -1,5 +1,4 @@
using GameDatabase.Entities;
using SharedProject.Models;
using SharedProject.Models;
namespace TaikoLocalServer.Services.Interfaces;

View File

@ -1,6 +1,4 @@
using GameDatabase.Entities;
namespace TaikoLocalServer.Services.Interfaces;
namespace TaikoLocalServer.Services.Interfaces;
public interface IDanScoreDatumService
{

View File

@ -1,5 +1,4 @@
using GameDatabase.Entities;
using SharedProject.Models;
using SharedProject.Models;
namespace TaikoLocalServer.Services.Interfaces;

View File

@ -1,6 +1,4 @@
using GameDatabase.Entities;
namespace TaikoLocalServer.Services.Interfaces;
namespace TaikoLocalServer.Services.Interfaces;
public interface ISongPlayDatumService
{

View File

@ -1,6 +1,4 @@
using GameDatabase.Entities;
namespace TaikoLocalServer.Services.Interfaces;
namespace TaikoLocalServer.Services.Interfaces;
public interface IUserDatumService
{

View File

@ -1,5 +1,4 @@
using GameDatabase.Context;
using GameDatabase.Entities;
using SharedProject.Models;
using Swan.Mapping;
using Throw;

View File

@ -1,5 +1,4 @@
using GameDatabase.Context;
using GameDatabase.Entities;
namespace TaikoLocalServer.Services;

View File

@ -1,5 +1,4 @@
using GameDatabase.Context;
using GameDatabase.Entities;
using Throw;
namespace TaikoLocalServer.Services;