Files
EpinelPS/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishSmash.cs
User958568 793e55f9de soda! (#53)
* Add files via upload

* Add files via upload

* Add files via upload
2025-09-14 11:50:49 -04:00

40 lines
1.4 KiB
C#

using EpinelPS.Data;
using EpinelPS.Database;
using EpinelPS.Utils;
namespace EpinelPS.LobbyServer.Minigame.PlaySoda
{
[PacketPath("/arcade/play-soda/challenge/finish/smash")]
public class GetChallengeFinishSmash : LobbyMsgHandler
{
protected override async Task HandleAsync()
{
var request = await ReadData<ReqFinishArcadePlaySodaSmashChallenge>();
var user = GetUser();
var challengeStageId = GameData.Instance.EventPlaySodaChallengeModeTable.First(i => i.Value.game_type == EventPlaySodaGameType.Smash).Key;
var arcadePlaySodaInfo = user.ArcadePlaySodaInfoList.First(i => i.ChallengeStageId == challengeStageId);
if (arcadePlaySodaInfo.UserRank < request.Score)
{
arcadePlaySodaInfo.UserRank = request.Score;
}
arcadePlaySodaInfo.AccumulatedScore += request.Score;
var pointValues = GetChallengeObtainPointReward.GetPointValues(arcadePlaySodaInfo.ChallengeStageId);
if (pointValues.Length > arcadePlaySodaInfo.LastRewardStep && arcadePlaySodaInfo.AccumulatedScore >= pointValues[arcadePlaySodaInfo.LastRewardStep])
{
arcadePlaySodaInfo.CanReceivePointReward = true;
}
await WriteDataAsync(new ResFinishArcadePlaySodaSmashChallenge());
JsonDb.Save();
}
}
}