mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-14 16:04:36 +01:00
implement tactic academy
This commit is contained in:
44
nksrv/LobbyServer/Msgs/Outpost/ClearTacticAcademyLesson.cs
Normal file
44
nksrv/LobbyServer/Msgs/Outpost/ClearTacticAcademyLesson.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
nksrv/LobbyServer/Msgs/Outpost/GetTacticAcademyData.cs
Normal file
25
nksrv/LobbyServer/Msgs/Outpost/GetTacticAcademyData.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using nksrv.Net;
|
||||
using nksrv.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace nksrv.LobbyServer.Msgs.Outpost
|
||||
{
|
||||
[PacketPath("/outpost/tactic/get")]
|
||||
public class GetTacticAcademyData : LobbyMsgHandler
|
||||
{
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
var req = await ReadData<GetTacticAcademyDataRequest>();
|
||||
var user = GetUser();
|
||||
|
||||
var response = new GetTacticAcademyDataResponse();
|
||||
response.CompletedLessons.AddRange(user.CompletedTacticAcademyLessons);
|
||||
|
||||
await WriteDataAsync(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
nksrv/Protos/outpost.proto
Normal file
22
nksrv/Protos/outpost.proto
Normal file
@@ -0,0 +1,22 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option csharp_namespace = "nksrv.Net";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/Duration.proto";
|
||||
import "Protos/allmsgs.proto";
|
||||
|
||||
// Get Tactic Academy data
|
||||
message GetTacticAcademyDataRequest {}
|
||||
message GetTacticAcademyDataResponse {
|
||||
repeated int32 CompletedLessons = 2;
|
||||
}
|
||||
|
||||
// Clear Tactic Academy lesson
|
||||
message TacticAcademyClearLessonRequest {
|
||||
int32 LessonId = 2;
|
||||
}
|
||||
message TacticAcademyClearLessonResponse {
|
||||
int32 LessonId = 2;
|
||||
repeated NetUserCurrencyData RemainingCurrency = 4;
|
||||
}
|
||||
@@ -81,4 +81,12 @@ namespace nksrv.StaticInfo
|
||||
/// </summary>
|
||||
public int character_exp2 = 0;
|
||||
}
|
||||
|
||||
public class TacticAcademyLessonRecord
|
||||
{
|
||||
public CurrencyType CurrencyId;
|
||||
public int CurrencyValue;
|
||||
public int Id;
|
||||
public int GroupId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ using Newtonsoft.Json.Linq;
|
||||
using Swan.Parsers;
|
||||
using Newtonsoft.Json;
|
||||
using System.Drawing;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
namespace nksrv.StaticInfo
|
||||
{
|
||||
@@ -56,6 +57,7 @@ namespace nksrv.StaticInfo
|
||||
private JArray tutorialTable;
|
||||
private JArray itemEquipTable;
|
||||
private Dictionary<int, CharacterLevelData> LevelData = [];
|
||||
private Dictionary<int, TacticAcademyLessonRecord> TacticAcademyLessons = [];
|
||||
|
||||
public byte[] Sha256Hash;
|
||||
public int Size;
|
||||
@@ -256,6 +258,29 @@ namespace nksrv.StaticInfo
|
||||
else
|
||||
Logger.Warn("failed to read character level table entry");
|
||||
}
|
||||
|
||||
var tacticLessonTable = await LoadZip("TacticAcademyFunctionTable.json");
|
||||
|
||||
foreach (JToken item in tacticLessonTable)
|
||||
{
|
||||
var idRaw = item["id"];
|
||||
var groupidRaw = item["group_id"];
|
||||
var currencyIdRaw = item["currency_id"];
|
||||
var currencyValueRaw = item["currency_value"];
|
||||
|
||||
if (idRaw == null) throw new InvalidDataException();
|
||||
if (groupidRaw == null) throw new InvalidDataException();
|
||||
if (currencyIdRaw == null) throw new InvalidDataException();
|
||||
if (currencyValueRaw == null) throw new InvalidDataException();
|
||||
|
||||
var id = idRaw.ToObject<int>();
|
||||
var currencyId = currencyIdRaw.ToObject<int>();
|
||||
var currencyValue = currencyValueRaw.ToObject<int>();
|
||||
var groupid = groupidRaw.ToObject<int>();
|
||||
|
||||
var fullId = int.Parse(groupid.ToString() + id.ToString());
|
||||
TacticAcademyLessons.Add(id, new TacticAcademyLessonRecord() { CurrencyId = (CurrencyType)currencyId, CurrencyValue = currencyValue, GroupId = groupid, Id = id });
|
||||
}
|
||||
}
|
||||
|
||||
public MainQuestCompletionData? GetMainQuestForStageClearCondition(int stage)
|
||||
@@ -481,5 +506,10 @@ namespace nksrv.StaticInfo
|
||||
{
|
||||
return LevelData;
|
||||
}
|
||||
|
||||
public TacticAcademyLessonRecord GetTacticAcademyLesson(int lessonId)
|
||||
{
|
||||
return TacticAcademyLessons[lessonId];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ namespace nksrv.Utils
|
||||
|
||||
public NetOutpostBattleLevel OutpostBattleLevel = new() { Level = 1 };
|
||||
public int GachaTutorialPlayCount = 0;
|
||||
public List<int> CompletedTacticAcademyLessons = [];
|
||||
|
||||
// Event data
|
||||
public Dictionary<int, EventData> EventInfo = new();
|
||||
|
||||
Reference in New Issue
Block a user