mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-14 07:55:01 +01:00
Various bug fixes
Fix sim room system error Added stub for obtain item in field Properly save tutorial data
This commit is contained in:
@@ -123,12 +123,13 @@ namespace nksrv.LobbyServer
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Restore completed tutorials. GroupID is the first 4 digits of the Table ID.
|
// Restore completed tutorials.
|
||||||
foreach (var item in user.ClearedTutorials)
|
foreach (var item in user.ClearedTutorialData)
|
||||||
{
|
{
|
||||||
var groupId = int.Parse(item.ToString().Substring(0, 4));
|
int groupId = item.Value.GroupId;
|
||||||
int tutorialVersion = item == 1020101 ? 1 : 0; // TODO: Read from static data
|
int version = item.Value.VersionGroup;
|
||||||
ret.Tutorials.Add(new NetTutorialData() { GroupId = groupId, LastClearedTid = item, LastClearedVersion = tutorialVersion });
|
|
||||||
|
ret.Tutorials.Add(new NetTutorialData() { GroupId = groupId, LastClearedTid = groupId, LastClearedVersion = version });
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
26
nksrv/LobbyServer/Msgs/Campaign/ObtainItem.cs
Normal file
26
nksrv/LobbyServer/Msgs/Campaign/ObtainItem.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using nksrv.Utils;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace nksrv.LobbyServer.Msgs.Campaign
|
||||||
|
{
|
||||||
|
[PacketPath("/campaign/obtain/item")]
|
||||||
|
public class ObtainItem : LobbyMsgHandler
|
||||||
|
{
|
||||||
|
protected override async Task HandleAsync()
|
||||||
|
{
|
||||||
|
var req = await ReadData<ReqObtainCampaignItem>();
|
||||||
|
var user = GetUser();
|
||||||
|
|
||||||
|
var response = new ResObtainCampaignItem();
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
response.Reward = new();
|
||||||
|
|
||||||
|
WriteData(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
nksrv/LobbyServer/Msgs/Simroom/GetSimRoomData.cs
Normal file
22
nksrv/LobbyServer/Msgs/Simroom/GetSimRoomData.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using nksrv.Utils;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace nksrv.LobbyServer.Msgs.Simroom
|
||||||
|
{
|
||||||
|
[PacketPath("/simroom/get")]
|
||||||
|
public class GetSimRoomData : LobbyMsgHandler
|
||||||
|
{
|
||||||
|
protected override async Task HandleAsync()
|
||||||
|
{
|
||||||
|
var req = await ReadData<ReqGetSimRoom>();
|
||||||
|
|
||||||
|
var response = new ResGetSimRoom();
|
||||||
|
// TODO
|
||||||
|
WriteData(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,12 +34,14 @@ namespace nksrv.LobbyServer.Msgs.User
|
|||||||
response.LastClearedNormalMainStageId = user.LastNormalStageCleared;
|
response.LastClearedNormalMainStageId = user.LastNormalStageCleared;
|
||||||
|
|
||||||
// Restore completed tutorials. GroupID is the first 4 digits of the Table ID.
|
// Restore completed tutorials. GroupID is the first 4 digits of the Table ID.
|
||||||
foreach (var item in user.ClearedTutorials)
|
foreach (var item in user.ClearedTutorialData)
|
||||||
{
|
{
|
||||||
var groupId = int.Parse(item.ToString().Substring(0, 4));
|
int groupId = item.Value.GroupId;
|
||||||
int tutorialVersion = item == 1020101 ? 1 : 0; // TODO
|
int version = item.Value.VersionGroup;
|
||||||
response.User.Tutorials.Add(new NetTutorialData() { GroupId = groupId, LastClearedTid = item, LastClearedVersion = tutorialVersion });
|
|
||||||
|
response.User.Tutorials.Add(new NetTutorialData() { GroupId = groupId, LastClearedTid = groupId, LastClearedVersion = version });
|
||||||
}
|
}
|
||||||
|
|
||||||
response.CommanderRoomJukeboxBgm = new NetJukeboxBgm() { JukeboxTableId = 2, Type = NetJukeboxBgmType.JukeboxTableId, Location = NetJukeboxLocation.CommanderRoom };
|
response.CommanderRoomJukeboxBgm = new NetJukeboxBgm() { JukeboxTableId = 2, Type = NetJukeboxBgmType.JukeboxTableId, Location = NetJukeboxLocation.CommanderRoom };
|
||||||
response.LobbyJukeboxBgm = new NetJukeboxBgm() { JukeboxTableId = 2, Type = NetJukeboxBgmType.JukeboxTableId, Location = NetJukeboxLocation.Lobby };
|
response.LobbyJukeboxBgm = new NetJukeboxBgm() { JukeboxTableId = 2, Type = NetJukeboxBgmType.JukeboxTableId, Location = NetJukeboxLocation.Lobby };
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using nksrv.Utils;
|
using nksrv.StaticInfo;
|
||||||
|
using nksrv.Utils;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -14,8 +15,12 @@ namespace nksrv.LobbyServer.Msgs.User.Tutorial
|
|||||||
{
|
{
|
||||||
var req = await ReadData<ReqSetTutorial>();
|
var req = await ReadData<ReqSetTutorial>();
|
||||||
var user = GetUser();
|
var user = GetUser();
|
||||||
if (!user.ClearedTutorials.Contains(req.LastClearedTid))
|
|
||||||
user.ClearedTutorials.Add(req.LastClearedTid);
|
if (!user.ClearedTutorialData.ContainsKey(req.LastClearedTid))
|
||||||
|
{
|
||||||
|
var cleared = StaticDataParser.Instance.GetTutorialDataById(req.LastClearedTid);
|
||||||
|
user.ClearedTutorialData.Add(req.LastClearedTid, cleared);
|
||||||
|
}
|
||||||
JsonDb.Save();
|
JsonDb.Save();
|
||||||
|
|
||||||
var response = new ResSetTutorial();
|
var response = new ResSetTutorial();
|
||||||
|
|||||||
@@ -1873,3 +1873,18 @@ message ReqWearEquipment {
|
|||||||
int64 Csn = 3;
|
int64 Csn = 3;
|
||||||
}
|
}
|
||||||
message ResWearEquipment {}
|
message ResWearEquipment {}
|
||||||
|
|
||||||
|
message NetCampaignFieldObject {
|
||||||
|
string PositionID = 1;
|
||||||
|
int32 Type = 2;
|
||||||
|
repeated NetCampaignTeamPosition TeamPositions = 3;
|
||||||
|
string Json = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ReqObtainCampaignItem {
|
||||||
|
string MapId = 2;
|
||||||
|
NetCampaignFieldObject FieldObject = 3;
|
||||||
|
}
|
||||||
|
message ResObtainCampaignItem {
|
||||||
|
NetRewardData Reward = 2;
|
||||||
|
}
|
||||||
@@ -42,4 +42,14 @@ namespace nksrv.StaticInfo
|
|||||||
public int reward_value;
|
public int reward_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class ClearedTutorialData
|
||||||
|
{
|
||||||
|
public int id;
|
||||||
|
public int VersionGroup = 0;
|
||||||
|
public int GroupId;
|
||||||
|
public int ClearedStageId;
|
||||||
|
public int NextId;
|
||||||
|
public bool SaveTutorial;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ namespace nksrv.StaticInfo
|
|||||||
private JArray chapterCampaignData;
|
private JArray chapterCampaignData;
|
||||||
private JArray characterCostumeTable;
|
private JArray characterCostumeTable;
|
||||||
private JArray characterTable;
|
private JArray characterTable;
|
||||||
|
private JArray tutorialTable;
|
||||||
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));
|
||||||
@@ -230,6 +231,7 @@ namespace nksrv.StaticInfo
|
|||||||
chapterCampaignData = await LoadZip("CampaignChapterTable.json");
|
chapterCampaignData = await LoadZip("CampaignChapterTable.json");
|
||||||
characterCostumeTable = await LoadZip("CharacterCostumeTable.json");
|
characterCostumeTable = await LoadZip("CharacterCostumeTable.json");
|
||||||
characterTable = await LoadZip("CharacterTable.json");
|
characterTable = await LoadZip("CharacterTable.json");
|
||||||
|
tutorialTable = await LoadZip("ContentsTutorialTable.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainQuestCompletionData? GetMainQuestForStageClearCondition(int stage)
|
public MainQuestCompletionData? GetMainQuestForStageClearCondition(int stage)
|
||||||
@@ -382,5 +384,27 @@ namespace nksrv.StaticInfo
|
|||||||
yield return value;
|
yield return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal ClearedTutorialData GetTutorialDataById(int TableId)
|
||||||
|
{
|
||||||
|
foreach (JObject item in tutorialTable)
|
||||||
|
{
|
||||||
|
var id = item["id"];
|
||||||
|
if (id == null)
|
||||||
|
{
|
||||||
|
throw new Exception("expected id field in reward data");
|
||||||
|
}
|
||||||
|
|
||||||
|
int idValue = id.ToObject<int>();
|
||||||
|
if (idValue == TableId)
|
||||||
|
{
|
||||||
|
ClearedTutorialData? data = JsonConvert.DeserializeObject<ClearedTutorialData>(item.ToString());
|
||||||
|
if (data == null) throw new Exception("failed to deserialize reward data");
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Exception("tutorial not found: " + TableId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using ASodium;
|
using ASodium;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using nksrv.LobbyServer;
|
using nksrv.LobbyServer;
|
||||||
|
using nksrv.StaticInfo;
|
||||||
using Swan.Logging;
|
using Swan.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -78,7 +79,7 @@ namespace nksrv.Utils
|
|||||||
public List<ItemData> Items = new();
|
public List<ItemData> Items = new();
|
||||||
public List<Character> Characters = [];
|
public List<Character> Characters = [];
|
||||||
public NetWholeUserTeamData RepresentationTeamData = new();
|
public NetWholeUserTeamData RepresentationTeamData = new();
|
||||||
public List<int> ClearedTutorials = [];
|
public Dictionary<int, ClearedTutorialData> ClearedTutorialData = [];
|
||||||
public NetWallpaperData[] WallpaperList = [];
|
public NetWallpaperData[] WallpaperList = [];
|
||||||
public Dictionary<int, NetUserTeamData> UserTeams = new Dictionary<int, NetUserTeamData>();
|
public Dictionary<int, NetUserTeamData> UserTeams = new Dictionary<int, NetUserTeamData>();
|
||||||
public Dictionary<int, bool> MainQuestData = new()
|
public Dictionary<int, bool> MainQuestData = new()
|
||||||
|
|||||||
Reference in New Issue
Block a user