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