Add support for user titles

This commit is contained in:
SELEKCJONER
2024-11-18 21:51:23 +01:00
parent 34ce89446e
commit c8649335f6
8 changed files with 64 additions and 5 deletions

View File

@@ -148,6 +148,7 @@ namespace EpinelPS.Database
public bool IsAdmin = false;
public bool sickpulls = false;
public bool IsBanned = false;
public int TitleId = 1;
public DateTime BanStart;
public DateTime BanEnd;
public int BanId = 0;

View File

@@ -52,6 +52,7 @@ namespace EpinelPS.StaticInfo
public Dictionary<int, ArchiveEventStoryRecord> archiveEventStoryRecords = new Dictionary<int, ArchiveEventStoryRecord>();
public Dictionary<int, ArchiveEventQuestRecord> archiveEventQuestRecords = new Dictionary<int, ArchiveEventQuestRecord>();
public Dictionary<int, ArchiveEventDungeonStageRecord> archiveEventDungeonStageRecords = new Dictionary<int, ArchiveEventDungeonStageRecord>();
public Dictionary<int, UserTitleRecord> userTitleRecords = new Dictionary<int, UserTitleRecord>();
@@ -423,6 +424,12 @@ namespace EpinelPS.StaticInfo
{
archiveEventDungeonStageRecords.Add(obj.id, obj);
}
var userTitleTable = await LoadZip<UserTitleTable>("UserTitleTable.json", progress);
foreach (var obj in userTitleTable.records)
{
userTitleRecords.Add(obj.id, obj);
}
// Load and parse ArchiveEventStoryTable.json
var archiveEventStoryTable = await LoadZip<ArchiveEventStoryTable>("ArchiveEventStoryTable.json", progress);

View File

@@ -389,5 +389,21 @@
{
public List<ArchiveEventDungeonStageRecord> records;
}
public class UserTitleRecord
{
public int id;
public int order;
public string user_title_production_type = "";
public int user_title_production_id;
public string icon_resource_id = "";
public string name_locale_key = "";
public string desc_locale_key = "";
public int reward_id;
public bool not_acquired_is_visible;
}
public class UserTitleTable
{
public List<UserTitleRecord> records;
}
}

View File

@@ -138,6 +138,7 @@ namespace EpinelPS.LobbyServer
Frame = user.ProfileFrame,
Icon = user.ProfileIconId,
IconPrism = user.ProfileIconIsPrism,
UserTitleId = user.TitleId,
Nickname = user.Nickname,
Usn = (long)user.ID,
LastActionAt = DateTimeOffset.UtcNow.Ticks,

View File

@@ -62,7 +62,8 @@ namespace EpinelPS.LobbyServer.Msgs.Event
EventSystemType = 1
},
JoinAt = 0
});
});
// cinderella banner
response.EventWithJoinData.Add(new NetEventWithJoinData()
{
EventData = new NetEventData()
@@ -75,6 +76,20 @@ namespace EpinelPS.LobbyServer.Msgs.Event
EventDisableDate = DateTime.Now.AddDays(20).Ticks
},
JoinAt = 0
});
//cinderella free pull
response.EventWithJoinData.Add(new NetEventWithJoinData()
{
EventData = new NetEventData()
{
Id = 80004,
EventSystemType = 21,
EventVisibleDate = DateTime.UtcNow.Subtract(TimeSpan.FromDays(7)).Ticks,
EventStartDate = DateTime.UtcNow.Subtract(TimeSpan.FromDays(1)).Ticks,
EventEndDate = DateTime.Now.AddDays(20).Ticks,
EventDisableDate = DateTime.Now.AddDays(20).Ticks
},
JoinAt = 0
});
await WriteDataAsync(response);

View File

@@ -215,6 +215,16 @@ namespace EpinelPS.LobbyServer.Msgs.Event
EventStartDate = DateTime.UtcNow.Subtract(TimeSpan.FromDays(1)).Ticks,
EventEndDate = DateTime.Now.AddDays(20).Ticks,
EventDisableDate = DateTime.Now.AddDays(20).Ticks,
});
// free pull for cinderella
response.EventList.Add(new NetEventData()
{
Id = 80004,
EventSystemType = 21,
EventVisibleDate = DateTime.UtcNow.Subtract(TimeSpan.FromDays(7)).Ticks,
EventStartDate = DateTime.UtcNow.Subtract(TimeSpan.FromDays(1)).Ticks,
EventEndDate = DateTime.Now.AddDays(20).Ticks,
EventDisableDate = DateTime.Now.AddDays(20).Ticks,
});

View File

@@ -1,4 +1,5 @@
using EpinelPS.Utils;
using EpinelPS.StaticInfo; // For GameData access
namespace EpinelPS.LobbyServer.Msgs.User
{
@@ -8,9 +9,15 @@ namespace EpinelPS.LobbyServer.Msgs.User
protected override async Task HandleAsync()
{
var req = await ReadData<ReqGetUserTitleList>();
var r = new ResGetUserTitleList();
r.UserTitleList.Add(new NetUserTitle() { UserTitleId = 1 });
// Access GameData and get all UserTitle IDs
var userTitleRecords = GameData.Instance.userTitleRecords;
foreach (var titleId in userTitleRecords.Keys)
{
r.UserTitleList.Add(new NetUserTitle() { UserTitleId = titleId });
}
await WriteDataAsync(r);
}

View File

@@ -1,5 +1,5 @@
using EpinelPS.Utils;
using EpinelPS.Database;
namespace EpinelPS.LobbyServer.Msgs.User
{
[PacketPath("/lobby/usertitle/set")]
@@ -8,7 +8,9 @@ namespace EpinelPS.LobbyServer.Msgs.User
protected override async Task HandleAsync()
{
var req = await ReadData<ReqSetUserTitle>();
var user = GetUser();
user.TitleId = req.UserTitleId;
JsonDb.Save();
var response = new ResSetUserTitle();
await WriteDataAsync(response);