Score saving working
This commit is contained in:
parent
f9c6ed8c1a
commit
4907466774
@ -96,6 +96,9 @@ public class BaidController:ControllerBase
|
||||
costumeData = new List<uint> { 0, 1, 1, 1, 1 };
|
||||
}
|
||||
|
||||
var costumeFlag = new byte[10];
|
||||
Array.Fill(costumeFlag, byte.MaxValue);
|
||||
|
||||
response = new BAIDResponse
|
||||
{
|
||||
Result = 1,
|
||||
@ -112,22 +115,22 @@ public class BaidController:ControllerBase
|
||||
MydonName = userData.MyDonName,
|
||||
Title = userData.Title,
|
||||
TitleplateId = userData.TitlePlateId,
|
||||
ColorFace = userData.ColorFace,
|
||||
ColorBody = userData.ColorBody,
|
||||
ColorLimb = userData.ColorLimb,
|
||||
ColorFace = 1,
|
||||
ColorBody = 1,
|
||||
ColorLimb = 1,
|
||||
AryCostumedata = new BAIDResponse.CostumeData
|
||||
{
|
||||
Costume1 = costumeData[0],
|
||||
Costume2 = costumeData[1],
|
||||
Costume3 = costumeData[2],
|
||||
Costume4 = costumeData[3],
|
||||
Costume5 = costumeData[4]
|
||||
Costume1 = ValueHelpers.GetNonZeroValue(costumeData[0]),
|
||||
Costume2 = ValueHelpers.GetNonZeroValue(costumeData[1]),
|
||||
Costume3 = ValueHelpers.GetNonZeroValue(costumeData[2]),
|
||||
Costume4 = ValueHelpers.GetNonZeroValue(costumeData[3]),
|
||||
Costume5 = ValueHelpers.GetNonZeroValue(costumeData[4])
|
||||
},
|
||||
CostumeFlg1 = new byte[10],
|
||||
CostumeFlg2 = new byte[10],
|
||||
CostumeFlg3 = new byte[10],
|
||||
CostumeFlg4 = new byte[10],
|
||||
CostumeFlg5 = new byte[10],
|
||||
CostumeFlg1 = costumeFlag,
|
||||
CostumeFlg2 = costumeFlag,
|
||||
CostumeFlg3 = costumeFlag,
|
||||
CostumeFlg4 = costumeFlag,
|
||||
CostumeFlg5 = costumeFlag,
|
||||
LastPlayDatetime = userData.LastPlayDatetime.ToString(Constants.DATE_TIME_FORMAT),
|
||||
IsDispDanOn = userData.DisplayDan,
|
||||
GotDanMax = 1,
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using TaikoLocalServer.Common.Enums;
|
||||
using TaikoLocalServer.Context;
|
||||
using TaikoLocalServer.Entities;
|
||||
using TaikoLocalServer.Utils;
|
||||
@ -35,7 +36,9 @@ public class MyDonEntryController : ControllerBase
|
||||
{
|
||||
Baid = newId,
|
||||
MyDonName = request.MydonName,
|
||||
|
||||
DisplayDan = false,
|
||||
DisplayAchievement = true,
|
||||
AchievementDisplayDifficulty = Difficulty.Easy
|
||||
});
|
||||
context.SaveChanges();
|
||||
|
||||
|
@ -48,45 +48,61 @@ public class PlayResultController : ControllerBase
|
||||
userdata.TitlePlateId = playResultData.TitleplateId;
|
||||
var costumeData = new List<uint>
|
||||
{
|
||||
playResultData.AryCurrentCostume.Costume1,
|
||||
playResultData.AryCurrentCostume.Costume2,
|
||||
playResultData.AryCurrentCostume.Costume3,
|
||||
playResultData.AryCurrentCostume.Costume4,
|
||||
playResultData.AryCurrentCostume.Costume5
|
||||
ValueHelpers.GetNonZeroValue(playResultData.AryCurrentCostume.Costume1),
|
||||
ValueHelpers.GetNonZeroValue(playResultData.AryCurrentCostume.Costume2),
|
||||
ValueHelpers.GetNonZeroValue(playResultData.AryCurrentCostume.Costume3),
|
||||
ValueHelpers.GetNonZeroValue(playResultData.AryCurrentCostume.Costume4),
|
||||
ValueHelpers.GetNonZeroValue(playResultData.AryCurrentCostume.Costume5)
|
||||
};
|
||||
userdata.CostumeData = JsonSerializer.Serialize(costumeData);
|
||||
|
||||
var lastPlayDatetime = DateTime.ParseExact(playResultData.PlayDatetime, Constants.DATE_TIME_FORMAT, CultureInfo.InvariantCulture);
|
||||
userdata.LastPlayDatetime = lastPlayDatetime;
|
||||
context.UserData.Update(userdata);
|
||||
|
||||
var bestData = context.SongBestData.Where(datum => datum.Baid == request.BaidConf).ToList();
|
||||
foreach (var stageData in playResultData.AryStageInfoes)
|
||||
{
|
||||
var bestData = context.SongBestData
|
||||
.FirstOrDefault(datum => datum.Baid == request.BaidConf &&
|
||||
datum.SongId == stageData.SongNo &&
|
||||
datum.Difficulty == (Difficulty)stageData.Level,
|
||||
new SongBestDatum
|
||||
{
|
||||
Baid = request.BaidConf,
|
||||
SongId = stageData.SongNo,
|
||||
Difficulty = (Difficulty)stageData.Level
|
||||
});
|
||||
if ((uint)bestData.BestCrown < stageData.PlayResult)
|
||||
var insert = false;
|
||||
var bestDatum = bestData
|
||||
.FirstOrDefault(datum => datum.SongId == stageData.SongNo &&
|
||||
datum.Difficulty == (Difficulty)stageData.Level);
|
||||
if (bestDatum is null)
|
||||
{
|
||||
bestData.BestCrown = (CrownType)stageData.PlayResult;
|
||||
insert = true;
|
||||
bestDatum = new SongBestDatum
|
||||
{
|
||||
Baid = request.BaidConf,
|
||||
SongId = stageData.SongNo,
|
||||
Difficulty = (Difficulty)stageData.Level
|
||||
};
|
||||
}
|
||||
if ((uint)bestData.BestScoreRank < stageData.ScoreRank)
|
||||
if ((uint)bestDatum.BestCrown < stageData.PlayResult)
|
||||
{
|
||||
bestData.BestScoreRank = (ScoreRank)stageData.ScoreRank;
|
||||
bestDatum.BestCrown = (CrownType)stageData.PlayResult;
|
||||
}
|
||||
if (bestData.BestScore < stageData.PlayScore)
|
||||
if ((uint)bestDatum.BestScoreRank < stageData.ScoreRank)
|
||||
{
|
||||
bestData.BestScore = stageData.PlayScore;
|
||||
bestDatum.BestScoreRank = (ScoreRank)stageData.ScoreRank;
|
||||
}
|
||||
if (bestData.BestRate < stageData.ScoreRate)
|
||||
if (bestDatum.BestScore < stageData.PlayScore)
|
||||
{
|
||||
bestData.BestRate = stageData.ScoreRate;
|
||||
bestDatum.BestScore = stageData.PlayScore;
|
||||
}
|
||||
if (bestDatum.BestRate < stageData.ScoreRate)
|
||||
{
|
||||
bestDatum.BestRate = stageData.ScoreRate;
|
||||
}
|
||||
|
||||
if (insert)
|
||||
{
|
||||
context.SongBestData.Add(bestDatum);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.SongBestData.Update(bestDatum);
|
||||
}
|
||||
|
||||
context.SongBestData.Update(bestData);
|
||||
var playData = new SongPlayDatum
|
||||
{
|
||||
Baid = request.BaidConf,
|
||||
@ -101,7 +117,7 @@ public class PlayResultController : ControllerBase
|
||||
ScoreRank = (ScoreRank)stageData.ScoreRank,
|
||||
Skipped = stageData.IsSkipUse,
|
||||
SongId = stageData.SongNo,
|
||||
PlayTime = DateTime.ParseExact(playResultData.PlayDatetime, Constants.DATE_TIME_FORMAT, CultureInfo.InvariantCulture)
|
||||
PlayTime = lastPlayDatetime
|
||||
};
|
||||
context.SongPlayData.Add(playData);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class UserDataController : ControllerBase
|
||||
UraReleaseSongFlg = uraSongArray,
|
||||
DefaultOptionSetting = new byte[] {0},
|
||||
IsVoiceOn = true,
|
||||
IsSkipOn = true
|
||||
IsSkipOn = false
|
||||
};
|
||||
|
||||
|
||||
|
9
TaikoLocalServer/Utils/ValueHelpers.cs
Normal file
9
TaikoLocalServer/Utils/ValueHelpers.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace TaikoLocalServer.Utils;
|
||||
|
||||
public static class ValueHelpers
|
||||
{
|
||||
public static uint GetNonZeroValue(uint val)
|
||||
{
|
||||
return val == 0 ? 1 : val;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user