outpost kind of works

This commit is contained in:
Mikhail Thompson
2024-07-02 13:38:18 -04:00
parent e81893c8f2
commit 76ecf031b5
10 changed files with 230 additions and 28 deletions

View File

@@ -1,4 +1,5 @@
using nksrv.LobbyServer.Msgs.Stage; using nksrv.LobbyServer.Msgs.Stage;
using nksrv.StaticInfo;
using nksrv.Utils; using nksrv.Utils;
using Swan.Logging; using Swan.Logging;
using System; using System;
@@ -20,7 +21,7 @@ namespace nksrv.LobbyServer.Msgs.Campaign
Console.WriteLine("Map ID: " + req.MapId); Console.WriteLine("Map ID: " + req.MapId);
var response = new ResGetCampaignFieldData(); var response = new ResGetCampaignFieldData();
response.Field = GetStage.CreateFieldInfo(user, GetChapterFromMapId(req.MapId)); response.Field = GetStage.CreateFieldInfo(user, StaticDataParser.Instance.GetNormalChapterNumberFromFieldName(req.MapId));
// todo save this data // todo save this data
response.Team = new NetUserTeamData() { LastContentsTeamNumber = 1, Type = 1 }; response.Team = new NetUserTeamData() { LastContentsTeamNumber = 1, Type = 1 };
@@ -53,21 +54,5 @@ namespace nksrv.LobbyServer.Msgs.Campaign
WriteData(response); WriteData(response);
} }
public static int GetChapterFromMapId(string mapId)
{
switch (mapId)
{
case "fcbg_cityforest_000":
return 0;
case "fcbg_cityforest_003":
return 1;
case "fcbg_cityforest_001":
return 2;
default:
Logger.Warn("TODO: I don't know what chapter mapid " + mapId + " is");
return 101;
}
}
} }
} }

View File

@@ -0,0 +1,23 @@
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("/infracore/check")]
public class CheckInfracore : LobbyMsgHandler
{
protected override async Task HandleAsync()
{
var req = await ReadData<ReqCheckReceiveInfraCoreReward>();
var response = new ResCheckReceiveInfraCoreReward();
// TODO
WriteData(response);
}
}
}

View File

@@ -0,0 +1,48 @@
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/getoutpostdata")]
public class GetOutpostData : LobbyMsgHandler
{
protected override async Task HandleAsync()
{
var req = await ReadData<ReqGetOutpostData>();
var user = GetUser();
var battleTime = DateTime.UtcNow - user.BattleTime;
var battleTimeMs = (long)(battleTime.TotalNanoseconds / 100);
var response = new ResGetOutpostData
{
OutpostBattleLevel = new NetOutpostBattleLevel() { Level = 1 },
CommanderBgm = new NetUserJukeboxDataV2(),
BattleTime = 864000000000, Jukebox = new(), MaxBattleTime = 864000000000
};
response.OutpostBattleLevel = user.OutpostBattleLevel;
response.OutpostBattleTime = new NetOutpostBattleTime() { MaxBattleTime = 864000000000, MaxOverBattleTime = 12096000000000, BattleTime = battleTimeMs };
// todo dont hardcode this
response.Data.Add(new NetUserOutpostData() { SlotId = 1, BuildingId = 22401, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Data.Add(new NetUserOutpostData() { SlotId = 4, BuildingId = 22701, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Data.Add(new NetUserOutpostData() { SlotId = 5, BuildingId = 22801, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Data.Add(new NetUserOutpostData() { SlotId = 6, BuildingId = 22901, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Data.Add(new NetUserOutpostData() { SlotId = 7, BuildingId = 23001, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Data.Add(new NetUserOutpostData() { SlotId = 3, BuildingId = 23101, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Data.Add(new NetUserOutpostData() { SlotId = 2, BuildingId = 23201, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Data.Add(new NetUserOutpostData() { SlotId = 9, BuildingId = 23301, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Data.Add(new NetUserOutpostData() { SlotId = 8, BuildingId = 23401, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Data.Add(new NetUserOutpostData() { SlotId = 10, BuildingId = 23501, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Data.Add(new NetUserOutpostData() { SlotId = 38, BuildingId = 33601, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
// TODO
WriteData(response);
}
}
}

View File

@@ -0,0 +1,27 @@
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/showoutpostbattlereward")]
public class ShowBattleReward : LobbyMsgHandler
{
protected override async Task HandleAsync()
{
var req = await ReadData<ReqShowOutpostBattleReward>();
var user = GetUser();
var battleTime = DateTime.UtcNow - user.BattleTime;
var battleTimeMs = (long)(battleTime.TotalNanoseconds / 100);
var response = new ResShowOutpostBattleReward();
response.OutpostBattleLevel = user.OutpostBattleLevel;
response.OutpostBattleTime = new NetOutpostBattleTime() { MaxBattleTime = 864000000000, MaxOverBattleTime = 12096000000000, BattleTime = battleTimeMs };
WriteData(response);
}
}
}

View File

@@ -77,7 +77,8 @@ namespace nksrv.LobbyServer.Msgs.Stage
{ {
if (item.reward_id != 0) if (item.reward_id != 0)
{ {
if (item.reward_type == "Currency") if (string.IsNullOrEmpty(item.reward_type)) { }
else if (item.reward_type == "Currency")
{ {
Dictionary<CurrencyType, int> current = new Dictionary<CurrencyType, int>(); Dictionary<CurrencyType, int> current = new Dictionary<CurrencyType, int>();

View File

@@ -15,6 +15,9 @@ namespace nksrv.LobbyServer.Msgs.User
var req = await ReadData<ReqEnterLobbyServer>(); var req = await ReadData<ReqEnterLobbyServer>();
var user = GetUser(); var user = GetUser();
var battleTime = DateTime.UtcNow - user.BattleTime;
var battleTimeMs = (long)(battleTime.TotalNanoseconds / 100);
// NOTE: Keep this in sync with GetUser code // NOTE: Keep this in sync with GetUser code
var response = new ResEnterLobbyServer(); var response = new ResEnterLobbyServer();
@@ -22,8 +25,8 @@ namespace nksrv.LobbyServer.Msgs.User
response.ResetHour = 20; response.ResetHour = 20;
response.Nickname = user.Nickname; response.Nickname = user.Nickname;
response.SynchroLv = 1; response.SynchroLv = 1;
response.OutpostBattleLevel = new NetOutpostBattleLevel() { Level = 1 }; response.OutpostBattleLevel = user.OutpostBattleLevel;
response.OutpostBattleTime = new NetOutpostBattleTime() { MaxBattleTime = 864000000000, MaxOverBattleTime = 12096000000000 }; response.OutpostBattleTime = new NetOutpostBattleTime() { MaxBattleTime = 864000000000, MaxOverBattleTime = 12096000000000, BattleTime = battleTimeMs };
// Add default slot data // Add default slot data
if (user.RepresentationTeamData.Slots.Count == 0) if (user.RepresentationTeamData.Slots.Count == 0)

View File

@@ -13,15 +13,16 @@ namespace nksrv.LobbyServer.Msgs.User
protected override async Task HandleAsync() protected override async Task HandleAsync()
{ {
var req = await ReadData<ReqGetUserData>(); var req = await ReadData<ReqGetUserData>();
var response = new ResGetUserData(); var response = new ResGetUserData();
var user = GetUser(); var user = GetUser();
var battleTime = DateTime.UtcNow - user.BattleTime;
var battleTimeMs = (long)(battleTime.TotalNanoseconds / 100);
response.User = LobbyHandler.CreateNetUserDataFromUser(user); response.User = LobbyHandler.CreateNetUserDataFromUser(user);
response.ResetHour = 20; response.ResetHour = 20;
response.OutpostBattleTime = new NetOutpostBattleTime() { MaxBattleTime = 864000000000, MaxOverBattleTime = 12096000000000 }; response.OutpostBattleTime = new NetOutpostBattleTime() { MaxBattleTime = 864000000000, MaxOverBattleTime = 12096000000000, BattleTime = battleTimeMs };
response.IsSimple = req.IsSimple; response.IsSimple = req.IsSimple;
foreach (var item in user.Currency) foreach (var item in user.Currency)

View File

@@ -1673,3 +1673,82 @@ message ReqShopProductList{}
message ResShopProductList { message ResShopProductList {
repeated NetShopProductData shops = 2; repeated NetShopProductData shops = 2;
} }
enum NetJukeboxLocation {
NetJukeboxLocation_CommanderRoom = 0;
NetJukeboxLocation_Lobby = 1;
}
enum NetJukeboxBgmType {
NetJukeboxBgmType_JukeboxTableId = 0;
NetJukeboxBgmType_JukeboxPlaylist = 1;
NetJukeboxBgmType_JukeboxFavorite = 2;
}
message NetJukeboxPlaylistSong {
int32 order = 1;
int32 jukeboxTableId = 2;
}
message NetJukeboxPlaylist {
int64 jukeboxPlaylistUid = 1;
string title = 2;
repeated NetJukeboxPlaylistSong songs = 3;
}
message NetJukeboxFavorite {
repeated NetJukeboxPlaylistSong songs = 1;
}
message NetJukeboxBgm {
NetJukeboxLocation location = 1;
NetJukeboxBgmType type = 2;
oneof jukeboxBgm {
int32 JukeboxTableId = 3;
NetJukeboxPlaylist JukeboxPlaylist = 4;
NetJukeboxFavorite JukeboxFavorite = 5;
}
bool IsShuffle = 6;
}
message NetUserJukeboxData {
int32 selectTid = 1;
repeated int32 list = 2;
}
message NetUserJukeboxDataV2 {
NetJukeboxBgm commandBgm = 1;
repeated int32 jukeboxTableIds = 2;
}
message ReqGetOutpostData {}
message ResGetOutpostData {
int32 skinGroupId = 2;
repeated NetUserOutpostData data = 3;
int64 battleTime = 4;
int64 maxBattleTime = 5;
repeated int32 conditionTriggerTidList = 6;
repeated int32 dispatchClearCountList = 7;
NetUserJukeboxData jukebox = 8;
repeated NetTimeReward timeRewardBuffs = 9;
NetOutpostBattleLevel outpostBattleLevel = 10;
bool isDispatchRefreshed = 11;
NetOutpostBattleTime outpostBattleTime = 12;
NetUserJukeboxDataV2 commanderBgm = 13;
}
message ReqCheckReceiveInfraCoreReward {}
message ResCheckReceiveInfraCoreReward {
bool isReceived = 2;
}
message ReqShowOutpostBattleReward {}
message ResShowOutpostBattleReward {
int64 battleTime = 1;
int64 maxBattleTime = 2;
int32 fastBattleCount = 3;
NetRewardData reward = 5;
repeated NetTimeReward timeRewardBuffs = 6;
NetOutpostBattleLevel outpostBattleLevel = 7;
NetOutpostBattleTime outpostBattleTime = 8;
}

View File

@@ -45,6 +45,7 @@ namespace nksrv.StaticInfo
private JArray stageDataRecords; private JArray stageDataRecords;
private JArray rewardDataRecords; private JArray rewardDataRecords;
private JArray userExpDataRecords; private JArray userExpDataRecords;
private JArray chapterCampaignData;
public StaticDataParser(string filePath) public StaticDataParser(string filePath)
{ {
if (!File.Exists(filePath)) throw new ArgumentException("Static data file must exist", nameof(filePath)); if (!File.Exists(filePath)) throw new ArgumentException("Static data file must exist", nameof(filePath));
@@ -203,12 +204,13 @@ namespace nksrv.StaticInfo
var campaignStageData = MainZip.GetEntry("CampaignStageTable.json"); var campaignStageData = MainZip.GetEntry("CampaignStageTable.json");
var rewardDataEntry = MainZip.GetEntry("RewardTable.json"); var rewardDataEntry = MainZip.GetEntry("RewardTable.json");
var userExpTable = MainZip.GetEntry("UserExpTable.json"); var userExpTable = MainZip.GetEntry("UserExpTable.json");
var chapterCampaignEntry = MainZip.GetEntry("CampaignChapterTable.json");
if (mainQuestData == null) throw new Exception("MainQuestTable.json does not exist in static data"); if (mainQuestData == null) throw new Exception("MainQuestTable.json does not exist in static data");
if (campaignStageData == null) throw new Exception("CampaignStageTable.json does not exist in static data"); if (campaignStageData == null) throw new Exception("CampaignStageTable.json does not exist in static data");
if (rewardDataEntry == null) throw new Exception("RewardTable.json does not exist in static data"); if (rewardDataEntry == null) throw new Exception("RewardTable.json does not exist in static data");
if (userExpTable == null) throw new Exception("UserExpTable.json does not exist in static data"); if (userExpTable == null) throw new Exception("UserExpTable.json does not exist in static data");
if (chapterCampaignEntry == null) throw new Exception("CampaignChapterTable.json does not exist in static data");
using StreamReader mainQuestReader = new StreamReader(MainZip.GetInputStream(mainQuestData)); using StreamReader mainQuestReader = new StreamReader(MainZip.GetInputStream(mainQuestData));
var mainQuestDataString = await mainQuestReader.ReadToEndAsync(); var mainQuestDataString = await mainQuestReader.ReadToEndAsync();
@@ -222,20 +224,26 @@ namespace nksrv.StaticInfo
using StreamReader userExpTableReader = new StreamReader(MainZip.GetInputStream(userExpTable)); using StreamReader userExpTableReader = new StreamReader(MainZip.GetInputStream(userExpTable));
var userExpTableString = await userExpTableReader.ReadToEndAsync(); var userExpTableString = await userExpTableReader.ReadToEndAsync();
using StreamReader chapterCampaignReader = new StreamReader(MainZip.GetInputStream(chapterCampaignEntry));
var chapterCampaignString = await chapterCampaignReader.ReadToEndAsync();
var questdata = JObject.Parse(mainQuestDataString); var questdata = JObject.Parse(mainQuestDataString);
var stagedata = JObject.Parse(campaignStageDataString); var stagedata = JObject.Parse(campaignStageDataString);
var rewardData = JObject.Parse(rewardJsonString); var rewardData = JObject.Parse(rewardJsonString);
var userExpTableData = JObject.Parse(userExpTableString); var userExpTableData = JObject.Parse(userExpTableString);
var chapterCampaignData = JObject.Parse(chapterCampaignString);
questDataRecords = (JArray?)questdata["records"]; questDataRecords = (JArray?)questdata["records"];
stageDataRecords = (JArray?)stagedata["records"]; stageDataRecords = (JArray?)stagedata["records"];
rewardDataRecords = (JArray?)rewardData["records"]; rewardDataRecords = (JArray?)rewardData["records"];
userExpDataRecords = (JArray?)userExpTableData["records"]; userExpDataRecords = (JArray?)userExpTableData["records"];
this.chapterCampaignData = (JArray?)chapterCampaignData["records"];
if (questDataRecords == null) throw new Exception("MainQuestTable.json does not contain records array"); if (questDataRecords == null) throw new Exception("MainQuestTable.json does not contain records array");
if (stageDataRecords == null) throw new Exception("CampaignStageTable.json does not contain records array"); if (stageDataRecords == null) throw new Exception("CampaignStageTable.json does not contain records array");
if (rewardDataRecords == null) throw new Exception("CampaignChapterTable.json does not contain records array"); if (rewardDataRecords == null) throw new Exception("RewardTable.json does not contain records array");
if (userExpDataRecords == null) throw new Exception("UserExpTable.json does not contain records array"); if (userExpDataRecords == null) throw new Exception("UserExpTable.json does not contain records array");
if (this.chapterCampaignData == null) throw new Exception("CampaignChapterTable.json does not contain records array");
} }
public MainQuestCompletionData? GetMainQuestForStageClearCondition(int stage) public MainQuestCompletionData? GetMainQuestForStageClearCondition(int stage)
@@ -292,7 +300,6 @@ namespace nksrv.StaticInfo
return null; return null;
} }
public RewardTableRecord? GetRewardTableEntry(int rewardId) public RewardTableRecord? GetRewardTableEntry(int rewardId)
{ {
foreach (JObject item in rewardDataRecords) foreach (JObject item in rewardDataRecords)
@@ -311,7 +318,6 @@ namespace nksrv.StaticInfo
return null; return null;
} }
public int GetUserLevelFromUserExp(int targetExp) public int GetUserLevelFromUserExp(int targetExp)
{ {
int prevLevel = 0; int prevLevel = 0;
@@ -342,5 +348,30 @@ namespace nksrv.StaticInfo
} }
return -1; return -1;
} }
public int GetNormalChapterNumberFromFieldName(string field)
{
foreach (JObject item in chapterCampaignData)
{
var id = item["field_id"];
if (id == null)
{
throw new Exception("expected id field in reward data");
}
string value = id.ToObject<string>();
if (value == field)
{
var chapter = item["chapter"];
if (chapter == null)
{
throw new Exception("expected id field in reward data");
}
return chapter.ToObject<int>();
}
}
return -1;
}
} }
} }

View File

@@ -83,6 +83,10 @@ namespace nksrv.Utils
public int InfraCoreExp = 0; public int InfraCoreExp = 0;
public int InfraCoreLvl = 1; public int InfraCoreLvl = 1;
public UserPointData userPointData = new(); public UserPointData userPointData = new();
public DateTime LastLogin = DateTime.UtcNow;
public DateTime BattleTime = DateTime.UtcNow;
public NetOutpostBattleLevel OutpostBattleLevel = new() { Level = 1 };
public void SetQuest(int tid, bool recieved) public void SetQuest(int tid, bool recieved)
{ {