mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-14 07:55:01 +01:00
Add experimental fix for completestage cmd
probably fixes completestage missing some entries like d_main_18af_06
This commit is contained in:
@@ -46,6 +46,8 @@ namespace EpinelPS.StaticInfo
|
|||||||
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>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -395,7 +397,13 @@ namespace EpinelPS.StaticInfo
|
|||||||
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);
|
||||||
|
foreach (var obj in albumResourceTable.records)
|
||||||
|
{
|
||||||
|
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);
|
||||||
@@ -590,5 +598,49 @@ namespace EpinelPS.StaticInfo
|
|||||||
jukeboxThemeDataRecords.TryGetValue(id, out var record);
|
jukeboxThemeDataRecords.TryGetValue(id, out var record);
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
public bool IsValidScenarioStage(string scenarioGroupId, int targetChapter, int targetStage)
|
||||||
|
{
|
||||||
|
// Example regular stage format: "d_main_26_08"
|
||||||
|
// Example scenario stage format: "d_main_18af_06"
|
||||||
|
|
||||||
|
var parts = scenarioGroupId.Split('_');
|
||||||
|
|
||||||
|
if (parts.Length != 4)
|
||||||
|
{
|
||||||
|
return false; // If it doesn't have 4 parts, it's not a valid stage
|
||||||
|
}
|
||||||
|
|
||||||
|
string chapterPart = parts[2]; // This could be "26" or "18af"
|
||||||
|
string stagePart = parts[3]; // This is the stage part, e.g., "08" or "06"
|
||||||
|
|
||||||
|
// Handle scenario stages (ending in "af")
|
||||||
|
bool isScenarioStage = chapterPart.EndsWith("af");
|
||||||
|
|
||||||
|
// Extract chapter number (remove "af" if present)
|
||||||
|
string chapterNumberStr = isScenarioStage ? chapterPart.Substring(0, chapterPart.Length - 2) : chapterPart;
|
||||||
|
|
||||||
|
// Parse chapter and stage numbers
|
||||||
|
if (int.TryParse(chapterNumberStr, out int chapter) && int.TryParse(stagePart, out int stage))
|
||||||
|
{
|
||||||
|
// Only accept stages if they are:
|
||||||
|
// 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
|
||||||
|
if (chapter < targetChapter || (chapter == targetChapter && stage <= targetStage))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,4 +283,21 @@
|
|||||||
{
|
{
|
||||||
public List<LiveWallpaperRecord> records;
|
public List<LiveWallpaperRecord> records;
|
||||||
}
|
}
|
||||||
|
public class AlbumResourceRecord
|
||||||
|
{
|
||||||
|
public int id;
|
||||||
|
public int sub_category_id;
|
||||||
|
public string scenario_name_localtable = "";
|
||||||
|
public string scenario_name_localkey = "";
|
||||||
|
public string scenario_group_id = "";
|
||||||
|
public int target_chapter;
|
||||||
|
public bool is_hidden;
|
||||||
|
public string dialogtype = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AlbumResourceTable
|
||||||
|
{
|
||||||
|
public List<AlbumResourceRecord> records;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -512,8 +512,8 @@ namespace EpinelPS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the updated data
|
// Save the updated data
|
||||||
JsonDb.Save();
|
JsonDb.Save();
|
||||||
}
|
}
|
||||||
else if (input.StartsWith("SetSkillLevel"))
|
else if (input.StartsWith("SetSkillLevel"))
|
||||||
{
|
{
|
||||||
@@ -582,71 +582,108 @@ namespace EpinelPS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (input.StartsWith("completestage"))
|
else if (input.StartsWith("completestage"))
|
||||||
{
|
{
|
||||||
if (selectedUser == 0)
|
if (selectedUser == 0)
|
||||||
{
|
{
|
||||||
Console.WriteLine("No user selected");
|
Console.WriteLine("No user selected");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var user = JsonDb.Instance.Users.FirstOrDefault(x => x.ID == selectedUser);
|
var user = JsonDb.Instance.Users.FirstOrDefault(x => x.ID == selectedUser);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Selected user does not exist");
|
Console.WriteLine("Selected user does not exist");
|
||||||
selectedUser = 0;
|
selectedUser = 0;
|
||||||
prompt = "# ";
|
prompt = "# ";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (args.Length == 2)
|
if (args.Length == 2)
|
||||||
{
|
{
|
||||||
var input2 = args[1];
|
var input2 = args[1];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var chapter = int.TryParse(input2.Split('-')[0], out int chapterNumber);
|
var chapterParsed = int.TryParse(input2.Split('-')[0], out int chapterNumber);
|
||||||
var stage = int.TryParse(input2.Split('-')[1], out int stageNumber);
|
var stageParsed = int.TryParse(input2.Split('-')[1], out int stageNumber);
|
||||||
|
|
||||||
|
if (chapterParsed && stageParsed)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Chapter number: {chapterNumber}, Stage number: {stageNumber}");
|
||||||
|
|
||||||
|
// Complete main stages
|
||||||
|
for (int i = 0; i <= chapterNumber; i++)
|
||||||
|
{
|
||||||
|
var stages = GameData.Instance.GetStageIdsForChapter(i, true);
|
||||||
|
int target = 1;
|
||||||
|
foreach (var item in stages)
|
||||||
|
{
|
||||||
|
if (!user.IsStageCompleted(item, true))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Completing stage " + item);
|
||||||
|
ClearStage.CompleteStage(user, item, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == chapterNumber && target == stageNumber)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
target++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process scenario and regular stages
|
||||||
|
Console.WriteLine($"Processing stages for chapters 0 to {chapterNumber}");
|
||||||
|
|
||||||
|
for (int chapter = 0; chapter <= chapterNumber; chapter++)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Processing chapter: {chapter}");
|
||||||
|
|
||||||
|
var stages = GameData.Instance.GetScenarioStageIdsForChapter(chapter)
|
||||||
|
.Where(stageId => GameData.Instance.IsValidScenarioStage(stageId, chapterNumber, stageNumber))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
Console.WriteLine($"Found {stages.Count} stages for chapter {chapter}");
|
||||||
|
|
||||||
|
foreach (var stage in stages)
|
||||||
|
{
|
||||||
|
if (!user.CompletedScenarios.Contains(stage))
|
||||||
|
{
|
||||||
|
user.CompletedScenarios.Add(stage);
|
||||||
|
Console.WriteLine($"Added stage {stage} to CompletedScenarios");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Stage {stage} is already completed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save changes to user data
|
||||||
|
JsonDb.Save();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Chapter and stage number must be valid integers");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Exception: " + ex.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Invalid argument length, must be 1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (chapter && stage)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < chapterNumber + 1; i++)
|
|
||||||
{
|
|
||||||
var stages = GameData.Instance.GetStageIdsForChapter(i, true);
|
|
||||||
int target = 1;
|
|
||||||
foreach (var item in stages)
|
|
||||||
{
|
|
||||||
if (!user.IsStageCompleted(item, true))
|
|
||||||
{
|
|
||||||
Console.WriteLine("Completing stage " + item);
|
|
||||||
ClearStage.CompleteStage(user, item, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == chapterNumber && target == stageNumber)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
target++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("chapter and stage number must be a 32 bit integer");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("exception:" + ex.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("invalid argument length, must be 1");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (input == "exit")
|
else if (input == "exit")
|
||||||
{
|
{
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user