update event data and improve event code

This commit is contained in:
Mikhail
2024-10-30 17:47:47 -04:00
parent 6ca8f00368
commit f368e36c69
5 changed files with 140 additions and 99 deletions

View File

@@ -43,10 +43,10 @@ namespace EpinelPS.StaticInfo
public Dictionary<int, OutpostBattleTableRecord> OutpostBattle = new Dictionary<int, OutpostBattleTableRecord>(); // Fixed initialization public Dictionary<int, OutpostBattleTableRecord> OutpostBattle = new Dictionary<int, OutpostBattleTableRecord>(); // Fixed initialization
public Dictionary<int, JukeboxListRecord> jukeboxListDataRecords; public Dictionary<int, JukeboxListRecord> jukeboxListDataRecords;
private Dictionary<int, JukeboxThemeRecord> jukeboxThemeDataRecords; private Dictionary<int, JukeboxThemeRecord> jukeboxThemeDataRecords;
public Dictionary<int, GachaType> gachaTypes = new Dictionary<int, GachaType>(); // Fixed initialization public Dictionary<int, GachaType> gachaTypes = new Dictionary<int, GachaType>(); // Fixed initialization
public Dictionary<int, EventManager> eventManagers = new Dictionary<int, EventManager>(); public Dictionary<int, EventManager> eventManagers = new Dictionary<int, EventManager>();
public Dictionary<int, LiveWallpaperRecord> lwptablemgrs = new Dictionary<int, LiveWallpaperRecord>(); // Fixed initialization public Dictionary<int, LiveWallpaperRecord> lwptablemgrs = new Dictionary<int, LiveWallpaperRecord>(); // Fixed initialization
private Dictionary<int, AlbumResourceRecord> albumResourceRecords = new Dictionary<int, AlbumResourceRecord>(); private Dictionary<int, AlbumResourceRecord> albumResourceRecords = new Dictionary<int, AlbumResourceRecord>();
@@ -349,61 +349,63 @@ namespace EpinelPS.StaticInfo
foreach (ZipEntry item in MainZip) foreach (ZipEntry item in MainZip)
{ {
if (item.Name.StartsWith("CampaignMap/")) if (item.Name.StartsWith("CampaignMap/") || item.Name.StartsWith("EventMap/"))
{ {
var x = await LoadZip(item.Name, progress); var x = await LoadZip(item.Name, progress);
var items = x[0]["ItemSpawner"]; var items = x[0]["ItemSpawner"];
foreach (var item2 in items)
{
var id = item2["positionId"].ToObject<string>();
var reward = item2["itemId"].ToObject<int>();
if (!PositionReward.ContainsKey(id)) if (items != null)
PositionReward.Add(id, reward); foreach (var item2 in items)
} {
var id = item2["positionId"].ToObject<string>();
var reward = item2["itemId"].ToObject<int>();
if (!PositionReward.ContainsKey(id))
PositionReward.Add(id, reward);
}
} }
} }
var fieldItems = await LoadZip<FieldItemTable>("FieldItemTable.json", progress); var fieldItems = await LoadZip<FieldItemTable>("FieldItemTable.json", progress);
foreach (var obj in fieldItems.records) foreach (var obj in fieldItems.records)
{ {
FieldItems.Add(obj.id, obj); FieldItems.Add(obj.id, obj);
} }
var battleOutpostTable = await LoadZip<OutpostBattleTable>("OutpostBattleTable.json", progress); var battleOutpostTable = await LoadZip<OutpostBattleTable>("OutpostBattleTable.json", progress);
foreach (var obj in battleOutpostTable.records) foreach (var obj in battleOutpostTable.records)
{ {
OutpostBattle.Add(obj.id, obj); OutpostBattle.Add(obj.id, obj);
} }
var gachaTypeTable = await LoadZip<GachaTypeTable>("GachaTypeTable.json", progress); var gachaTypeTable = await LoadZip<GachaTypeTable>("GachaTypeTable.json", progress);
// Add the records to the dictionary // Add the records to the dictionary
foreach (var obj in gachaTypeTable.records) foreach (var obj in gachaTypeTable.records)
{ {
gachaTypes.Add(obj.id, obj); // Use obj.id as the key and obj (the GachaType) as the value gachaTypes.Add(obj.id, obj); // Use obj.id as the key and obj (the GachaType) as the value
} }
var eventManagerTable = await LoadZip<EventManagerTable>("EventManagerTable.json", progress); var eventManagerTable = await LoadZip<EventManagerTable>("EventManagerTable.json", progress);
// Add the records to the dictionary // Add the records to the dictionary
foreach (var obj in eventManagerTable.records) foreach (var obj in eventManagerTable.records)
{ {
eventManagers.Add(obj.id, obj); // Use obj.id as the key and obj (the EventManager) as the value eventManagers.Add(obj.id, obj); // Use obj.id as the key and obj (the EventManager) as the value
} }
var lwptable = await LoadZip<LiveWallpaperTable>("LiveWallpaperTable.json", progress); var lwptable = await LoadZip<LiveWallpaperTable>("LiveWallpaperTable.json", progress);
// Add the records to the dictionary // Add the records to the dictionary
foreach (var obj in lwptable.records) foreach (var obj in lwptable.records)
{ {
lwptablemgrs.Add(obj.id, obj); // Use obj.id as the key and obj (the LiveWallpaperRecord) as the value lwptablemgrs.Add(obj.id, obj); // Use obj.id as the key and obj (the LiveWallpaperRecord) as the value
} }
var albumResourceTable = await LoadZip<AlbumResourceTable>("AlbumResourceTable.json", progress); var albumResourceTable = await LoadZip<AlbumResourceTable>("AlbumResourceTable.json", progress);
foreach (var obj in albumResourceTable.records) foreach (var obj in albumResourceTable.records)
{ {
albumResourceRecords.Add(obj.id, obj); // Now refers to the class-level field albumResourceRecords.Add(obj.id, obj); // Now refers to the class-level field
} }
// Load Jukebox data // Load Jukebox data
await LoadJukeboxListData(progress); await LoadJukeboxListData(progress);
await LoadJukeboxThemeData(progress); await LoadJukeboxThemeData(progress);
@@ -422,10 +424,10 @@ namespace EpinelPS.StaticInfo
} }
} }
public Dictionary<int, JukeboxListRecord> GetJukeboxListDataRecords() public Dictionary<int, JukeboxListRecord> GetJukeboxListDataRecords()
{ {
return jukeboxListDataRecords; return jukeboxListDataRecords;
} }
public async Task LoadJukeboxThemeData(ProgressBar bar) public async Task LoadJukeboxThemeData(ProgressBar bar)
{ {
@@ -599,63 +601,63 @@ namespace EpinelPS.StaticInfo
return record; return record;
} }
public IEnumerable<string> GetScenarioStageIdsForChapter(int chapterNumber) public IEnumerable<string> GetScenarioStageIdsForChapter(int chapterNumber)
{ {
return albumResourceRecords.Values.Where(record => record.target_chapter == chapterNumber && !string.IsNullOrEmpty(record.scenario_group_id)).Select(record => record.scenario_group_id); return albumResourceRecords.Values.Where(record => record.target_chapter == chapterNumber && !string.IsNullOrEmpty(record.scenario_group_id)).Select(record => record.scenario_group_id);
} }
public bool IsValidScenarioStage(string scenarioGroupId, int targetChapter, int targetStage) public bool IsValidScenarioStage(string scenarioGroupId, int targetChapter, int targetStage)
{ {
// Only process stages that belong to the main quest // Only process stages that belong to the main quest
if (!scenarioGroupId.StartsWith("d_main_")) if (!scenarioGroupId.StartsWith("d_main_"))
{ {
return false; // Exclude stages that don't belong to the main quest return false; // Exclude stages that don't belong to the main quest
} }
// Example regular stage format: "d_main_26_08" // Example regular stage format: "d_main_26_08"
// Example bonus stage format: "d_main_18af_06" // Example bonus stage format: "d_main_18af_06"
// Example stage with suffix format: "d_main_01_01_s" or "d_main_01_01_e" // Example stage with suffix format: "d_main_01_01_s" or "d_main_01_01_e"
var parts = scenarioGroupId.Split('_'); var parts = scenarioGroupId.Split('_');
if (parts.Length < 4) if (parts.Length < 4)
{ {
return false; // If it doesn't have at least 4 parts, it's not a valid stage return false; // If it doesn't have at least 4 parts, it's not a valid stage
} }
string chapterPart = parts[2]; // This could be "26", "18af", "01" string chapterPart = parts[2]; // This could be "26", "18af", "01"
string stagePart = parts[3]; // This is the stage part, e.g., "08", "01_s", or "01_e" string stagePart = parts[3]; // This is the stage part, e.g., "08", "01_s", or "01_e"
// Remove any suffixes like "_s", "_e" from the stage part for comparison // Remove any suffixes like "_s", "_e" from the stage part for comparison
string cleanedStagePart = stagePart.Split('_')[0]; // Removes "_s", "_e", etc. string cleanedStagePart = stagePart.Split('_')[0]; // Removes "_s", "_e", etc.
// Handle bonus stages (ending in "af" or having "_s", "_e" suffix) // Handle bonus stages (ending in "af" or having "_s", "_e" suffix)
bool isBonusStage = chapterPart.EndsWith("af") || stagePart.Contains("_s") || stagePart.Contains("_e"); bool isBonusStage = chapterPart.EndsWith("af") || stagePart.Contains("_s") || stagePart.Contains("_e");
// Extract chapter number (remove "af" if present) // Extract chapter number (remove "af" if present)
string chapterNumberStr = isBonusStage && chapterPart.EndsWith("af") string chapterNumberStr = isBonusStage && chapterPart.EndsWith("af")
? chapterPart.Substring(0, chapterPart.Length - 2) // Remove "af" ? chapterPart.Substring(0, chapterPart.Length - 2) // Remove "af"
: chapterPart; : chapterPart;
// Parse chapter and stage numbers // Parse chapter and stage numbers
if (int.TryParse(chapterNumberStr, out int chapter) && int.TryParse(cleanedStagePart, out int stage)) if (int.TryParse(chapterNumberStr, out int chapter) && int.TryParse(cleanedStagePart, out int stage))
{ {
// Check if it's a bonus stage with a suffix // Check if it's a bonus stage with a suffix
bool isSpecialStage = stagePart.Contains("_s") || stagePart.Contains("_e"); bool isSpecialStage = stagePart.Contains("_s") || stagePart.Contains("_e");
// Only accept stages if they are: // Only accept stages if they are:
// 1. In a chapter less than the target chapter // 1. In a chapter less than the target chapter
// 2. OR in the target chapter but with a stage number less than or equal to the target stage // 2. OR in the target chapter but with a stage number less than or equal to the target stage
// 3. OR it's a special stage (with "_s" or "_e") in the target chapter and target stage // 3. OR it's a special stage (with "_s" or "_e") in the target chapter and target stage
if (chapter < targetChapter || if (chapter < targetChapter ||
(chapter == targetChapter && (stage < targetStage || (stage == targetStage && isSpecialStage)))) (chapter == targetChapter && (stage < targetStage || (stage == targetStage && isSpecialStage))))
{ {
return true; return true;
} }
} }
return false; return false;
} }
} }

View File

@@ -18,7 +18,20 @@ namespace EpinelPS.LobbyServer.Msgs.Campaign
var chapter = GameData.Instance.GetNormalChapterNumberFromFieldName(req.MapId); var chapter = GameData.Instance.GetNormalChapterNumberFromFieldName(req.MapId);
var mod = req.MapId.Contains("hard") ? "Hard" : "Normal"; var mod = req.MapId.Contains("hard") ? "Hard" : "Normal";
var key = chapter + "_" + mod; var key = chapter + "_" + mod;
var field = user.FieldInfoNew[key];
if (chapter == -1)
{
Console.WriteLine("Warning: unknown chapter id for " + req.MapId);
key = req.MapId;
}
FieldInfoNew field;
if (!user.FieldInfoNew.TryGetValue(key, out field))
{
field = new FieldInfoNew();
user.FieldInfoNew.Add(key, field);
}
foreach (var item in field.CompletedObjects) foreach (var item in field.CompletedObjects)

View File

@@ -8,11 +8,19 @@ namespace EpinelPS.LobbyServer.Msgs.Event
protected override async Task HandleAsync() protected override async Task HandleAsync()
{ {
var req = await ReadData<ReqEnterEventField>(); var req = await ReadData<ReqEnterEventField>();
var user = GetUser();
var response = new ResEnterEventField(); var response = new ResEnterEventField();
// TOOD // TOOD
response.Field = new();
if (user.MapJson.TryGetValue(req.MapId, out string mapJson))
{
response.Json = mapJson;
}
await WriteDataAsync(response); await WriteDataAsync(response);
} }
} }

View File

@@ -9,8 +9,10 @@ namespace EpinelPS.LobbyServer.Msgs.Event
{ {
var req = await ReadData<ReqGetEventList>(); var req = await ReadData<ReqGetEventList>();
var response = new ResGetEventList(); // 10: FieldHubEvent
var response = new ResGetEventList();
/*
response.EventList.Add(new NetEventData() response.EventList.Add(new NetEventData()
{ {
Id = 81301, Id = 81301,
@@ -117,6 +119,20 @@ namespace EpinelPS.LobbyServer.Msgs.Event
EventEndDate = DateTime.Now.AddDays(20).Ticks, EventEndDate = DateTime.Now.AddDays(20).Ticks,
EventDisableDate = DateTime.Now.AddDays(20).Ticks, EventDisableDate = DateTime.Now.AddDays(20).Ticks,
}); });
*/
// Old tales
response.EventList.Add(new NetEventData()
{
Id = 81600,
EventSystemType = 10,
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,
});
//response.EventList.Add(new NetEventData() //response.EventList.Add(new NetEventData()
//{ //{
// Id = 40054, // Id = 40054,

View File

@@ -73,6 +73,8 @@ namespace EpinelPS.Utils
Console.ForegroundColor = config.LogLevelToColorMap[logLevel]; Console.ForegroundColor = config.LogLevelToColorMap[logLevel];
Console.Write($"{msg}"); Console.Write($"{msg}");
if (exception != null)
Console.WriteLine(exception.ToString());
Console.ForegroundColor = originalColor; Console.ForegroundColor = originalColor;
Console.WriteLine(); Console.WriteLine();