mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-14 16:04:36 +01:00
45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using nksrv.Net;
|
|
using nksrv.StaticInfo;
|
|
using nksrv.Utils;
|
|
using Swan.Logging;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace nksrv.LobbyServer.Msgs.Outpost
|
|
{
|
|
[PacketPath("/outpost/tactic/clearlesson")]
|
|
public class ClearTacticAcademyLesson : LobbyMsgHandler
|
|
{
|
|
protected override async Task HandleAsync()
|
|
{
|
|
var req = await ReadData<TacticAcademyClearLessonRequest>();
|
|
var user = GetUser();
|
|
|
|
var response = new TacticAcademyClearLessonResponse();
|
|
response.LessonId = req.LessonId;
|
|
|
|
var x = StaticDataParser.Instance.GetTacticAcademyLesson(req.LessonId);
|
|
|
|
if (user.CanSubtractCurrency(x.CurrencyId, x.CurrencyValue))
|
|
{
|
|
user.SubtractCurrency(x.CurrencyId, x.CurrencyValue);
|
|
|
|
user.CompletedTacticAcademyLessons.Add(req.LessonId);
|
|
|
|
foreach (var currency in user.Currency)
|
|
{
|
|
response.RemainingCurrency.Add(new NetUserCurrencyData() { Type = (int)currency.Key, Value = currency.Value });
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Logger.Error($"User {user.PlayerName} tried to clear lesson {req.LessonId} without enough currency");
|
|
}
|
|
await WriteDataAsync(response);
|
|
}
|
|
}
|
|
}
|