More fixes and migrate away from costume json string
This commit is contained in:
parent
53b8d8c65e
commit
6f177ee2ff
@ -10,7 +10,7 @@ namespace GameDatabase.Entities
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public uint TitlePlateId { get; set; }
|
||||
public List<uint> FavoriteSongsArray { get; set; } = [];
|
||||
public List<uint> ToneFlgArray { get; set; } = [];
|
||||
public List<uint> ToneFlgArray { get; set; } = [0];
|
||||
public List<uint> TitleFlgArray { get; set; } = [];
|
||||
public string CostumeFlgArray { get; set; } = "[[],[],[],[],[]]";
|
||||
public List<uint> UnlockedKigurumi { get; set; } = [0];
|
||||
|
@ -51,27 +51,4 @@ public static class JsonHelper
|
||||
|
||||
return costumeData;
|
||||
}
|
||||
|
||||
public static List<List<uint>> GetCostumeUnlockDataFromUserData(UserDatum userData, ILogger logger)
|
||||
{
|
||||
var costumeUnlockData = new List<List<uint>> { new(), new(), new(), new(), new() };
|
||||
try
|
||||
{
|
||||
costumeUnlockData = JsonSerializer.Deserialize<List<List<uint>>>(userData.CostumeFlgArray);
|
||||
}
|
||||
catch (JsonException e)
|
||||
{
|
||||
logger.LogError(e, "Parsing costume json data failed");
|
||||
}
|
||||
|
||||
if (costumeUnlockData != null && costumeUnlockData.Count >= 5)
|
||||
{
|
||||
return costumeUnlockData;
|
||||
}
|
||||
|
||||
logger.LogWarning("Costume unlock data is null or count less than 5!");
|
||||
costumeUnlockData = new List<List<uint>> { new(), new(), new(), new(), new() };
|
||||
|
||||
return costumeUnlockData;
|
||||
}
|
||||
}
|
@ -30,9 +30,10 @@ public class UserSettingsController : BaseController<UserSettingsController>
|
||||
|
||||
var costumeData = JsonHelper.GetCostumeDataFromUserData(user, Logger);
|
||||
|
||||
var costumeUnlockData = JsonHelper.GetCostumeUnlockDataFromUserData(user, Logger);
|
||||
List<List<uint>> costumeUnlockData =
|
||||
[user.UnlockedKigurumi, user.UnlockedHead, user.UnlockedBody, user.UnlockedFace, user.UnlockedPuchi];
|
||||
|
||||
var unlockedTitle = user.TitleFlgArray//JsonHelper.GetUIntArrayFromJson(user.TitleFlgArray, 0, Logger, nameof(user.TitleFlgArray))
|
||||
var unlockedTitle = user.TitleFlgArray
|
||||
.ToList();
|
||||
|
||||
for (var i = 0; i < 5; i++)
|
||||
@ -125,15 +126,6 @@ public class UserSettingsController : BaseController<UserSettingsController>
|
||||
|
||||
// If a locked tone is selected, unlock it
|
||||
var toneFlg = user.ToneFlgArray;
|
||||
/*try
|
||||
{
|
||||
toneFlg = JsonSerializer.Deserialize<uint[]>(user.ToneFlgArray)!;
|
||||
}
|
||||
catch (JsonException e)
|
||||
{
|
||||
Logger.LogError(e, "Parsing tone flg json data failed");
|
||||
}
|
||||
toneFlg.ThrowIfNull("Tone flg should never be null!");*/
|
||||
toneFlg = toneFlg.Append(0u).Append(userSetting.ToneId).Distinct().ToList();
|
||||
|
||||
user.ToneFlgArray = toneFlg;
|
||||
|
@ -27,7 +27,11 @@ public class AddMyDonEntryCommandHandler(TaikoDbContext context, ILogger<AddMyDo
|
||||
FavoriteSongsArray = [],
|
||||
ToneFlgArray = [0],
|
||||
TitleFlgArray = [],
|
||||
CostumeFlgArray = "[[0],[0],[0],[0],[0]]",
|
||||
UnlockedKigurumi = [0],
|
||||
UnlockedBody = [0],
|
||||
UnlockedFace = [0],
|
||||
UnlockedHead = [0],
|
||||
UnlockedPuchi = [0],
|
||||
GenericInfoFlgArray = [],
|
||||
UnlockedSongIdList = []
|
||||
};
|
||||
|
@ -6,21 +6,12 @@ namespace TaikoLocalServer.Handlers;
|
||||
|
||||
public record BaidQuery(string AccessCode) : IRequest<CommonBaidResponse>;
|
||||
|
||||
public class BaidQueryHandler : IRequestHandler<BaidQuery, CommonBaidResponse>
|
||||
public class BaidQueryHandler(
|
||||
TaikoDbContext context,
|
||||
ILogger<BaidQueryHandler> logger,
|
||||
IGameDataService gameDataService)
|
||||
: IRequestHandler<BaidQuery, CommonBaidResponse>
|
||||
{
|
||||
private readonly TaikoDbContext context;
|
||||
|
||||
private readonly ILogger<BaidQueryHandler> logger;
|
||||
|
||||
private readonly IGameDataService gameDataService;
|
||||
|
||||
public BaidQueryHandler(TaikoDbContext context, ILogger<BaidQueryHandler> logger, IGameDataService gameDataService)
|
||||
{
|
||||
this.context = context;
|
||||
this.logger = logger;
|
||||
this.gameDataService = gameDataService;
|
||||
}
|
||||
|
||||
public async Task<CommonBaidResponse> Handle(BaidQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var card = await context.Cards.FindAsync(request.AccessCode);
|
||||
@ -30,12 +21,12 @@ public class BaidQueryHandler : IRequestHandler<BaidQuery, CommonBaidResponse>
|
||||
return new CommonBaidResponse
|
||||
{
|
||||
IsNewUser = true,
|
||||
Baid = context.Cards.Any() ? context.Cards.ToList().Max(c => c.Baid) + 1 : 1
|
||||
Baid = context.Cards.Any() ? context.Cards.AsEnumerable().Max(c => c.Baid) + 1 : 1
|
||||
};
|
||||
}
|
||||
|
||||
var baid = card.Baid;
|
||||
var userData = await context.UserData.FindAsync(baid);
|
||||
var userData = await context.UserData.FindAsync(baid, cancellationToken);
|
||||
userData.ThrowIfNull($"User not found for card with Baid {baid}!");
|
||||
|
||||
var songBestData = context.SongBestData.Where(datum => datum.Baid == baid).ToList();
|
||||
@ -77,7 +68,8 @@ public class BaidQueryHandler : IRequestHandler<BaidQuery, CommonBaidResponse>
|
||||
|
||||
var costumeData = JsonHelper.GetCostumeDataFromUserData(userData, logger);
|
||||
|
||||
var costumeArrays = JsonHelper.GetCostumeUnlockDataFromUserData(userData, logger);
|
||||
List<List<uint>> costumeArrays =
|
||||
[userData.UnlockedKigurumi, userData.UnlockedHead, userData.UnlockedBody, userData.UnlockedFace, userData.UnlockedPuchi];
|
||||
|
||||
var costumeFlagArrays = gameDataService.GetCostumeFlagArraySizes()
|
||||
.Select((size, index) => FlagCalculator.GetBitArrayFromIds(costumeArrays[index], size, logger))
|
||||
|
Loading…
x
Reference in New Issue
Block a user