From dea8d98db47cbd609eb6c347e47d8473d28ddf1e Mon Sep 17 00:00:00 2001 From: Mikhail Date: Sat, 20 Jul 2024 11:02:19 -0400 Subject: [PATCH] add additional messages --- nksrv/LobbyServer/LobbyHandler.cs | 1 - .../Msgs/Liberate/ChooseCharacter.cs | 30 ++++++++++++++++ .../Msgs/Liberate/GetProgressList.cs | 26 ++++++++++++++ nksrv/LobbyServer/Msgs/Shop/GetProductList.cs | 2 +- nksrv/LobbyServer/Msgs/Shop/GetShop.cs | 25 +++++++++++++ nksrv/Protos/liberate.proto | 34 ++++++++++++++++++ nksrv/Protos/shop.proto | 35 +++++++++++++++++++ nksrv/Utils/JsonDb.cs | 8 ++--- nksrv/nksrv.csproj | 5 +++ 9 files changed, 160 insertions(+), 6 deletions(-) create mode 100644 nksrv/LobbyServer/Msgs/Liberate/ChooseCharacter.cs create mode 100644 nksrv/LobbyServer/Msgs/Liberate/GetProgressList.cs create mode 100644 nksrv/LobbyServer/Msgs/Shop/GetShop.cs create mode 100644 nksrv/Protos/liberate.proto create mode 100644 nksrv/Protos/shop.proto diff --git a/nksrv/LobbyServer/LobbyHandler.cs b/nksrv/LobbyServer/LobbyHandler.cs index 0168588..8da0c38 100644 --- a/nksrv/LobbyServer/LobbyHandler.cs +++ b/nksrv/LobbyServer/LobbyHandler.cs @@ -114,7 +114,6 @@ namespace nksrv.LobbyServer LobbyJukebox = 2, InfraCoreExp = user.InfraCoreExp, InfraCoreLv = user.InfraCoreLvl, - }; diff --git a/nksrv/LobbyServer/Msgs/Liberate/ChooseCharacter.cs b/nksrv/LobbyServer/Msgs/Liberate/ChooseCharacter.cs new file mode 100644 index 0000000..552b8b4 --- /dev/null +++ b/nksrv/LobbyServer/Msgs/Liberate/ChooseCharacter.cs @@ -0,0 +1,30 @@ +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.Liberate +{ + [PacketPath("/liberate/choosecharacter")] + public class ChooseCharacter : LobbyMsgHandler + { + protected override async Task HandleAsync() + { + var req = await ReadData(); + var user = GetUser(); + + var response = new ChooseLiberateCharacterResponse(); + + // TODO + response.Data = new NetLiberateData() { CharacterId = req.CharacterId }; + response.Data.MissionData.Add(new NetLiberateMissionData() { MissionState = LiberateMissionState.Running, Id = 1 }); + response.Data.MissionData.Add(new NetLiberateMissionData() { MissionState = LiberateMissionState.Running, Id = 2 }); + response.Data.MissionData.Add(new NetLiberateMissionData() { MissionState = LiberateMissionState.Running, Id = 3 }); + + await WriteDataAsync(response); + } + } +} diff --git a/nksrv/LobbyServer/Msgs/Liberate/GetProgressList.cs b/nksrv/LobbyServer/Msgs/Liberate/GetProgressList.cs new file mode 100644 index 0000000..63f9877 --- /dev/null +++ b/nksrv/LobbyServer/Msgs/Liberate/GetProgressList.cs @@ -0,0 +1,26 @@ +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.Liberate +{ + [PacketPath("/liberate/getprogresslist")] + public class GetProgressList : LobbyMsgHandler + { + protected override async Task HandleAsync() + { + var req = await ReadData(); + var user = GetUser(); + + var response = new GetLiberateProgressListResponse(); + + // TODO + + await WriteDataAsync(response); + } + } +} diff --git a/nksrv/LobbyServer/Msgs/Shop/GetProductList.cs b/nksrv/LobbyServer/Msgs/Shop/GetProductList.cs index 4c739e7..8781a7a 100644 --- a/nksrv/LobbyServer/Msgs/Shop/GetProductList.cs +++ b/nksrv/LobbyServer/Msgs/Shop/GetProductList.cs @@ -10,7 +10,7 @@ namespace nksrv.LobbyServer.Msgs.Shop { try { - var x = await ReadData(); //todo: causes crash + var x = await ReadData(); var response = new ResGetJupiterProductList(); foreach (var item in x.ProductIdList) diff --git a/nksrv/LobbyServer/Msgs/Shop/GetShop.cs b/nksrv/LobbyServer/Msgs/Shop/GetShop.cs new file mode 100644 index 0000000..d0f5782 --- /dev/null +++ b/nksrv/LobbyServer/Msgs/Shop/GetShop.cs @@ -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.Shop +{ + [PacketPath("/shop/get")] + public class GetShop : LobbyMsgHandler + { + protected override async Task HandleAsync() + { + var x = await ReadData(); + + var response = new GetShopResponse(); + + // TODO + + await WriteDataAsync(response); + } + } +} diff --git a/nksrv/Protos/liberate.proto b/nksrv/Protos/liberate.proto new file mode 100644 index 0000000..6d49de2 --- /dev/null +++ b/nksrv/Protos/liberate.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; + +option csharp_namespace = "nksrv.Net"; + +import "google/protobuf/timestamp.proto"; +import "google/protobuf/Duration.proto"; +import "Protos/allmsgs.proto"; + +enum LiberateDataExpiredError { + LIBERATE_DATA_EXPIRED_ERROR_SUCCESS = 0; + LIBERATE_DATA_EXPIRED_ERROR_EXPIRED = 1; +} + +message NetLiberateProgressData { + int32 CharacterId = 1; + int32 Step = 2; + int32 ProgressPoint = 3; + int32 RewardedCount = 4; + bool IsCompleted = 5; +} + +message GetLiberateProgressListRequest {} +message GetLiberateProgressListResponse { + repeated NetLiberateProgressData ProgressData = 1; +} + +message ChooseLiberateCharacterRequest { + int32 CharacterId = 2; +} + +message ChooseLiberateCharacterResponse { + NetLiberateData data = 1; + LiberateDataExpiredError Error = 2; +} \ No newline at end of file diff --git a/nksrv/Protos/shop.proto b/nksrv/Protos/shop.proto new file mode 100644 index 0000000..f50c590 --- /dev/null +++ b/nksrv/Protos/shop.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; + +option csharp_namespace = "nksrv.Net"; + +import "google/protobuf/timestamp.proto"; +import "google/protobuf/Duration.proto"; + +message NetShopProductInfoData { + int32 Order = 1; + int32 ProductId = 2; + int32 BuyLimitCount = 3; + int32 BuyCount = 4; + int32 CorpType = 5; + int32 Discount = 6; + int64 EndAt = 7; + bool UseDateCondition = 8; +} + +message NetShopProductData { + int32 ShopTid = 1; + int32 ShopCategory = 2; + int32 RenewCount = 3; + int64 RenewAt = 4; + int64 NextRenewAt = 5; + int32 FreeRenewCount = 6; + repeated NetShopProductInfoData List = 7; +} + +message GetShopRequest { + int32 ShopCategory = 1; +} + +message GetShopResponse { + NetShopProductData Shop = 1; +} \ No newline at end of file diff --git a/nksrv/Utils/JsonDb.cs b/nksrv/Utils/JsonDb.cs index 41e4941..77bb557 100644 --- a/nksrv/Utils/JsonDb.cs +++ b/nksrv/Utils/JsonDb.cs @@ -25,7 +25,6 @@ namespace nksrv.Utils public class Character { - // TODO public int Csn = 0; public int Tid = 0; public int CostumeId = 0; @@ -86,8 +85,7 @@ namespace nksrv.Utils public Dictionary FieldInfoNew = []; public Dictionary MapJson = []; public Dictionary Currency = new() { - { CurrencyType.ContentStamina, 2 }, - { CurrencyType.CharPremiumTicket, 999999 } + { CurrencyType.ContentStamina, 2 } }; public List Items = new(); @@ -206,8 +204,10 @@ namespace nksrv.Utils internal class JsonDb { public static CoreInfo Instance { get; internal set; } + + // Note: change this in sodium public static byte[] ServerPrivateKey = Convert.FromBase64String("FSUY8Ohd942n5LWAfxn6slK3YGwc8OqmyJoJup9nNos="); - public static byte[] ServerPublicKey = Convert.FromBase64String("04hFDd1e/BOEF2h4b0MdkX2h6W5REeqyW+0r9+eSeh0="); // Note: change this in sodium + public static byte[] ServerPublicKey = Convert.FromBase64String("04hFDd1e/BOEF2h4b0MdkX2h6W5REeqyW+0r9+eSeh0="); static JsonDb() { diff --git a/nksrv/nksrv.csproj b/nksrv/nksrv.csproj index 2d6a807..f2c8ffe 100644 --- a/nksrv/nksrv.csproj +++ b/nksrv/nksrv.csproj @@ -29,6 +29,11 @@ + + + + + Always