mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-12 23:14:34 +01:00
add remaining commands to admin panel
This commit is contained in:
@@ -86,6 +86,44 @@ namespace EpinelPS.Controllers
|
||||
if (user == null) return new RunCmdResponse() { error = "invalid user ID" };
|
||||
return AdminCommands.AddAllMaterials(user, int.Parse(req.p2));
|
||||
}
|
||||
case "SetLevel":
|
||||
{
|
||||
var user = JsonDb.Instance.Users.FirstOrDefault(x => x.ID == ulong.Parse(req.p1));
|
||||
if (user == null) return new RunCmdResponse() { error = "invalid user ID" };
|
||||
return AdminCommands.SetCharacterLevel(user, int.Parse(req.p2));
|
||||
}
|
||||
case "SetSkillLevel":
|
||||
{
|
||||
var user = JsonDb.Instance.Users.FirstOrDefault(x => x.ID == ulong.Parse(req.p1));
|
||||
if (user == null) return new RunCmdResponse() { error = "invalid user ID" };
|
||||
return AdminCommands.SetSkillLevel(user, int.Parse(req.p2));
|
||||
}
|
||||
case "SetCoreLevel":
|
||||
{
|
||||
var user = JsonDb.Instance.Users.FirstOrDefault(x => x.ID == ulong.Parse(req.p1));
|
||||
if (user == null) return new RunCmdResponse() { error = "invalid user ID" };
|
||||
return AdminCommands.SetCoreLevel(user, int.Parse(req.p2));
|
||||
}
|
||||
case "finishalltutorials":
|
||||
{
|
||||
var user = JsonDb.Instance.Users.FirstOrDefault(x => x.ID == ulong.Parse(req.p1));
|
||||
if (user == null) return new RunCmdResponse() { error = "invalid user ID" };
|
||||
return AdminCommands.FinishAllTutorials(user);
|
||||
}
|
||||
case "AddCharacter":
|
||||
{
|
||||
var user = JsonDb.Instance.Users.FirstOrDefault(x => x.ID == ulong.Parse(req.p1));
|
||||
if (user == null) return new RunCmdResponse() { error = "invalid user ID" };
|
||||
return AdminCommands.AddCharacter(user, int.Parse(req.p2));
|
||||
}
|
||||
case "AddItem":
|
||||
{
|
||||
var user = JsonDb.Instance.Users.FirstOrDefault(x => x.ID == ulong.Parse(req.p1));
|
||||
if (user == null) return new RunCmdResponse() { error = "invalid user ID" };
|
||||
|
||||
var s = req.p2.Split("-");
|
||||
return AdminCommands.AddItem(user, int.Parse(s[0]), int.Parse(s[1]));
|
||||
}
|
||||
}
|
||||
return new RunCmdResponse() { error = "Not implemented" };
|
||||
}
|
||||
|
||||
@@ -331,16 +331,8 @@ namespace EpinelPS
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var tutorial in GameData.Instance.TutorialTable.Values)
|
||||
{
|
||||
if (!user.ClearedTutorialData.ContainsKey(tutorial.id))
|
||||
{
|
||||
user.ClearedTutorialData.Add(tutorial.id, tutorial);
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("Finished all tutorials for user " + user.Username);
|
||||
JsonDb.Save();
|
||||
var rsp = AdminCommands.FinishAllTutorials(user);
|
||||
if (!rsp.ok) Console.WriteLine(rsp.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -361,76 +353,8 @@ namespace EpinelPS
|
||||
}
|
||||
else if (args.Length == 2 && int.TryParse(args[1], out int inputGrade) && inputGrade >= 0 && inputGrade <= 11)
|
||||
{
|
||||
foreach (var character in user.Characters)
|
||||
{
|
||||
// Get current character's Tid
|
||||
int tid = character.Tid;
|
||||
|
||||
// Get the character data from the character table
|
||||
if (!GameData.Instance.CharacterTable.TryGetValue(tid, out var charData))
|
||||
{
|
||||
Console.WriteLine($"Character data not found for Tid {tid}");
|
||||
continue;
|
||||
}
|
||||
|
||||
int currentGradeCoreId = charData.grade_core_id;
|
||||
int nameCode = charData.name_code;
|
||||
string originalRare = charData.original_rare;
|
||||
|
||||
// Skip characters with original_rare == "R"
|
||||
if (originalRare == "R" || nameCode == 3999)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Now handle normal SR and SSR characters
|
||||
int maxGradeCoreId = 0;
|
||||
|
||||
// If the character is "SSR", it can have a grade_core_id from 1 to 11
|
||||
if (originalRare == "SSR")
|
||||
{
|
||||
maxGradeCoreId = 11; // SSR characters can go from 1 to 11
|
||||
|
||||
// Calculate the new grade_core_id within the bounds
|
||||
int newGradeCoreId = Math.Min(inputGrade + 1, maxGradeCoreId); // +1 because inputGrade starts from 0 for SSRs
|
||||
|
||||
// Find the character with the same name_code and new grade_core_id
|
||||
var newCharData = GameData.Instance.CharacterTable.Values.FirstOrDefault(c =>
|
||||
c.name_code == nameCode && c.grade_core_id == newGradeCoreId);
|
||||
|
||||
if (newCharData != null)
|
||||
{
|
||||
// Update the character's Tid and Grade
|
||||
character.Tid = newCharData.id;
|
||||
character.Grade = inputGrade;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If the character is "SR", it can have a grade_core_id from 101 to 103
|
||||
else if (originalRare == "SR")
|
||||
{
|
||||
maxGradeCoreId = 103; // SR characters can go from 101 to 103
|
||||
|
||||
// Start from 101 and increment based on inputGrade (inputGrade 0 -> grade_core_id 101)
|
||||
int newGradeCoreId = Math.Min(101 + inputGrade, maxGradeCoreId); // Starts at 101
|
||||
|
||||
// Find the character with the same name_code and new grade_core_id
|
||||
var newCharData = GameData.Instance.CharacterTable.Values.FirstOrDefault(c =>
|
||||
c.name_code == nameCode && c.grade_core_id == newGradeCoreId);
|
||||
|
||||
if (newCharData != null)
|
||||
{
|
||||
// Update the character's Tid and Grade
|
||||
character.Tid = newCharData.id;
|
||||
character.Grade = inputGrade;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Console.WriteLine($"Core level of all characters have been set to {inputGrade}");
|
||||
JsonDb.Save();
|
||||
var rsp = AdminCommands.SetCoreLevel(user, inputGrade);
|
||||
if (!rsp.ok) Console.WriteLine(rsp.error);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -517,12 +441,8 @@ namespace EpinelPS
|
||||
}
|
||||
else if (args.Length == 2 && int.TryParse(args[1], out int level) && level >= 1 && level <= 999)
|
||||
{
|
||||
foreach (var character in user.Characters)
|
||||
{
|
||||
character.Level = level;
|
||||
}
|
||||
Console.WriteLine("Set all characters' level to " + level);
|
||||
JsonDb.Save();
|
||||
var rsp = AdminCommands.SetCharacterLevel(user, level);
|
||||
if (!rsp.ok) Console.WriteLine(rsp.error);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -573,14 +493,8 @@ namespace EpinelPS
|
||||
}
|
||||
else if (args.Length == 2 && int.TryParse(args[1], out int skillLevel) && skillLevel >= 1 && skillLevel <= 10)
|
||||
{
|
||||
foreach (var character in user.Characters)
|
||||
{
|
||||
character.UltimateLevel = skillLevel;
|
||||
character.Skill1Lvl = skillLevel;
|
||||
character.Skill2Lvl = skillLevel;
|
||||
}
|
||||
Console.WriteLine("Set all characters' skill levels to " + skillLevel);
|
||||
JsonDb.Save();
|
||||
var rsp = AdminCommands.SetSkillLevel(user, skillLevel);
|
||||
if (!rsp.ok) Console.WriteLine(rsp.error);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -664,31 +578,8 @@ namespace EpinelPS
|
||||
{
|
||||
if (int.TryParse(args[1], out int itemId) && int.TryParse(args[2], out int amount))
|
||||
{
|
||||
ItemData? item = user.Items.FirstOrDefault(i => i.ItemType == itemId);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
user.Items.Add(new ItemData
|
||||
{
|
||||
Isn = user.GenerateUniqueItemId(),
|
||||
ItemType = itemId,
|
||||
Level = 1,
|
||||
Exp = 1,
|
||||
Count = amount
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Count += amount;
|
||||
|
||||
if (item.Count < 0)
|
||||
{
|
||||
item.Count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"Added {amount} of item {itemId} to user {user.Username}");
|
||||
JsonDb.Save();
|
||||
var rsp = AdminCommands.AddItem(user, itemId, amount);
|
||||
if (!rsp.ok) Console.WriteLine(rsp.error);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -723,27 +614,8 @@ namespace EpinelPS
|
||||
{
|
||||
if (int.TryParse(args[1], out int characterId))
|
||||
{
|
||||
if (!user.HasCharacter(characterId))
|
||||
{
|
||||
user.Characters.Add(new Database.Character()
|
||||
{
|
||||
CostumeId = 0,
|
||||
Csn = user.GenerateUniqueCharacterId(),
|
||||
Grade = 0,
|
||||
Level = 1,
|
||||
Skill1Lvl = 1,
|
||||
Skill2Lvl = 1,
|
||||
Tid = characterId,
|
||||
UltimateLevel = 1
|
||||
});
|
||||
|
||||
Console.WriteLine($"Added character {characterId} to user {user.Username}");
|
||||
JsonDb.Save();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"User {user.Username} already has character {characterId}");
|
||||
}
|
||||
var rsp = AdminCommands.AddCharacter(user, characterId);
|
||||
if (!rsp.ok) Console.WriteLine(rsp.error);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -151,5 +151,181 @@ namespace EpinelPS.Utils
|
||||
JsonDb.Save();
|
||||
return RunCmdResponse.OK;
|
||||
}
|
||||
|
||||
public static RunCmdResponse FinishAllTutorials(User user)
|
||||
{
|
||||
foreach (var tutorial in GameData.Instance.TutorialTable.Values)
|
||||
{
|
||||
if (!user.ClearedTutorialData.ContainsKey(tutorial.id))
|
||||
{
|
||||
user.ClearedTutorialData.Add(tutorial.id, tutorial);
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("Finished all tutorials for user " + user.Username);
|
||||
JsonDb.Save();
|
||||
return RunCmdResponse.OK;
|
||||
}
|
||||
|
||||
public static RunCmdResponse SetCoreLevel(User user, int inputGrade)
|
||||
{
|
||||
if (!(inputGrade >= 0 && inputGrade <= 11)) return new RunCmdResponse() { error = "core level out of range, must be between 0-12" };
|
||||
|
||||
foreach (var character in user.Characters)
|
||||
{
|
||||
// Get current character's Tid
|
||||
int tid = character.Tid;
|
||||
|
||||
// Get the character data from the character table
|
||||
if (!GameData.Instance.CharacterTable.TryGetValue(tid, out var charData))
|
||||
{
|
||||
Console.WriteLine($"Character data not found for Tid {tid}");
|
||||
continue;
|
||||
}
|
||||
|
||||
int currentGradeCoreId = charData.grade_core_id;
|
||||
int nameCode = charData.name_code;
|
||||
string originalRare = charData.original_rare;
|
||||
|
||||
// Skip characters with original_rare == "R"
|
||||
if (originalRare == "R" || nameCode == 3999)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Now handle normal SR and SSR characters
|
||||
int maxGradeCoreId = 0;
|
||||
|
||||
// If the character is "SSR", it can have a grade_core_id from 1 to 11
|
||||
if (originalRare == "SSR")
|
||||
{
|
||||
maxGradeCoreId = 11; // SSR characters can go from 1 to 11
|
||||
|
||||
// Calculate the new grade_core_id within the bounds
|
||||
int newGradeCoreId = Math.Min(inputGrade + 1, maxGradeCoreId); // +1 because inputGrade starts from 0 for SSRs
|
||||
|
||||
// Find the character with the same name_code and new grade_core_id
|
||||
var newCharData = GameData.Instance.CharacterTable.Values.FirstOrDefault(c =>
|
||||
c.name_code == nameCode && c.grade_core_id == newGradeCoreId);
|
||||
|
||||
if (newCharData != null)
|
||||
{
|
||||
// Update the character's Tid and Grade
|
||||
character.Tid = newCharData.id;
|
||||
character.Grade = inputGrade;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If the character is "SR", it can have a grade_core_id from 101 to 103
|
||||
else if (originalRare == "SR")
|
||||
{
|
||||
maxGradeCoreId = 103; // SR characters can go from 101 to 103
|
||||
|
||||
// Start from 101 and increment based on inputGrade (inputGrade 0 -> grade_core_id 101)
|
||||
int newGradeCoreId = Math.Min(101 + inputGrade, maxGradeCoreId); // Starts at 101
|
||||
|
||||
// Find the character with the same name_code and new grade_core_id
|
||||
var newCharData = GameData.Instance.CharacterTable.Values.FirstOrDefault(c =>
|
||||
c.name_code == nameCode && c.grade_core_id == newGradeCoreId);
|
||||
|
||||
if (newCharData != null)
|
||||
{
|
||||
// Update the character's Tid and Grade
|
||||
character.Tid = newCharData.id;
|
||||
character.Grade = inputGrade;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"Core level of all characters have been set to {inputGrade}");
|
||||
JsonDb.Save();
|
||||
|
||||
return RunCmdResponse.OK;
|
||||
}
|
||||
|
||||
|
||||
public static RunCmdResponse SetCharacterLevel(User user, int level)
|
||||
{
|
||||
if (level > 999 || level <= 0) return new RunCmdResponse() { error = "level must be between 1-999" };
|
||||
foreach (var character in user.Characters)
|
||||
{
|
||||
character.Level = level;
|
||||
}
|
||||
Console.WriteLine("Set all characters' level to " + level);
|
||||
JsonDb.Save();
|
||||
return RunCmdResponse.OK;
|
||||
}
|
||||
|
||||
public static RunCmdResponse SetSkillLevel(User user, int skillLevel)
|
||||
{
|
||||
if (skillLevel > 10 || skillLevel < 0) return new RunCmdResponse() { error = "level must be between 1-10" };
|
||||
foreach (var character in user.Characters)
|
||||
{
|
||||
character.UltimateLevel = skillLevel;
|
||||
character.Skill1Lvl = skillLevel;
|
||||
character.Skill2Lvl = skillLevel;
|
||||
}
|
||||
Console.WriteLine("Set all characters' skill levels to " + skillLevel);
|
||||
JsonDb.Save();
|
||||
return RunCmdResponse.OK;
|
||||
}
|
||||
|
||||
public static RunCmdResponse AddCharacter(User user, int characterId)
|
||||
{
|
||||
if (!user.HasCharacter(characterId))
|
||||
{
|
||||
user.Characters.Add(new Database.Character()
|
||||
{
|
||||
CostumeId = 0,
|
||||
Csn = user.GenerateUniqueCharacterId(),
|
||||
Grade = 0,
|
||||
Level = 1,
|
||||
Skill1Lvl = 1,
|
||||
Skill2Lvl = 1,
|
||||
Tid = characterId,
|
||||
UltimateLevel = 1
|
||||
});
|
||||
|
||||
Console.WriteLine($"Added character {characterId} to user {user.Username}");
|
||||
JsonDb.Save();
|
||||
return RunCmdResponse.OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new RunCmdResponse() { error = $"User {user.Username} already has character {characterId}" };
|
||||
}
|
||||
}
|
||||
|
||||
public static RunCmdResponse AddItem(User user, int itemId, int amount)
|
||||
{
|
||||
ItemData? item = user.Items.FirstOrDefault(i => i.ItemType == itemId);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
user.Items.Add(new ItemData
|
||||
{
|
||||
Isn = user.GenerateUniqueItemId(),
|
||||
ItemType = itemId,
|
||||
Level = 1,
|
||||
Exp = 1,
|
||||
Count = amount
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Count += amount;
|
||||
|
||||
if (item.Count < 0)
|
||||
{
|
||||
item.Count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"Added {amount} of item {itemId} to user {user.Username}");
|
||||
JsonDb.Save();
|
||||
return RunCmdResponse.OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
ViewData["Title"] = "Modify user";
|
||||
}
|
||||
|
||||
<h1>Modify</h1>
|
||||
<h1>Change user info</h1>
|
||||
|
||||
<h4>User</h4>
|
||||
<h3>User info</h3>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
@@ -38,9 +38,15 @@
|
||||
<span asp-validation-for="Nickname" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Save" class="btn btn-primary" />
|
||||
<input type="submit" value="Save" class="btn btn-primary" style="margin-top:10px;" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<hr>
|
||||
<h3>Cheats</h3>
|
||||
|
||||
<p>Campaign:</p>
|
||||
<button class="btn btn-secondary" onclick="runSimpleCmdWithPr('completestage', '@Model.ID', 'Enter chapter number and stage number seperated by -')">Skip stages</button>
|
||||
@@ -49,8 +55,8 @@
|
||||
<button class="btn btn-secondary" onclick="runSimpleCmd('addallcharacters', '@Model.ID')">Add all characters</button>
|
||||
<button class="btn btn-secondary" onclick="runSimpleCmdWithPr('AddCharacter', '@Model.ID', 'Enter character ID. Wrong ID may cause game not to boot.')">Add character</button>
|
||||
<button class="btn btn-secondary" onclick="runSimpleCmdWithPr('SetLevel', '@Model.ID', 'Enter level (1-999) to apply to all characters')">Set character levels</button>
|
||||
<button class="btn btn-secondary" onclick="runSimpleCmdWithPr('SetLevel', '@Model.ID', 'Enter skill level (1-10) to apply to all characters')">Set character skill levels</button>
|
||||
<button class="btn btn-secondary" onclick="runSimpleCmdWithPr('finishalltutorials', '@Model.ID', 'core level / 0-3 sets stars')">Set core level</button>
|
||||
<button class="btn btn-secondary" onclick="runSimpleCmdWithPr('SetSkillLevel', '@Model.ID', 'Enter skill level (1-10) to apply to all characters')">Set character skill levels</button>
|
||||
<button class="btn btn-secondary" onclick="runSimpleCmdWithPr('SetCoreLevel', '@Model.ID', 'core level / 0-3 sets stars')">Set core level</button>
|
||||
<p>Inventory:</p>
|
||||
<button class="btn btn-secondary" onclick="runSimpleCmdWithPr('addallmaterials', '@Model.ID', 'Enter material amount:')">Add all equipment</button>
|
||||
<button class="btn btn-secondary" onclick="runSimpleCmdWithPr('AddItem', '@Model.ID', 'Enter item ID and amount seperated by -')">Add item</button>
|
||||
|
||||
Reference in New Issue
Block a user