using Newtonsoft.Json.Linq;
using XFEWarframe.Core.Data;
namespace XFEWarframe.Core.Services;
public static class TutorialProgress
{
private static readonly string[] Quests = ["/Lotus/Types/Keys/VorsPrize/VorsPrizeQuestKeyChain", "/Lotus/Types/Keys/ModQuest/ModQuestKeyChain"];
public static void Apply(JObject account, ItemCatalog catalog, TimeProvider clock)
{
var inv = account.Obj("Inventory");
var acquire = new ItemAcquisition(catalog, clock, account);
// Imported equipment and currencies belong to the player. Only supply
// missing starter slots when an administrator skips a fresh account.
foreach (var (category, type) in new[] {
("Suits", "/Lotus/Powersuits/Excalibur/Excalibur"),
("LongGuns", "/Lotus/Weapons/Tenno/Rifle/Rifle"),
("Pistols", "/Lotus/Weapons/Tenno/Pistol/Pistol"),
("Melee", "/Lotus/Weapons/Tenno/Melee/LongSword/LongSword"),
("DataKnives", "/Lotus/Weapons/Tenno/HackingDevices/TnHackingDevice/TnHackingDeviceWeapon") })
if (inv.Array(category).Count == 0) acquire.Add(inv, type, premium: true);
inv["ReceivedStartingGear"] = true;
inv["MadeStoryModeDecision"] = true;
inv["PlayedParkourTutorial"] = true;
if (string.IsNullOrEmpty(inv.Value<string>("StoryModeChoice"))) inv["StoryModeChoice"] = "WARFRAME";
var normal = account.Obj("Loadouts").Array("NORMAL");
if (normal.Count == 0)
{
var preset = new JObject { ["ItemId"] = Wire.Oid(Wire.NewId()), ["n"] = "XFEWarframe", ["s"] = Slot("Suits"), ["l"] = Slot("LongGuns"), ["p"] = Slot("Pistols"), ["m"] = Slot("Melee") };
normal.Add(preset);
}
if (inv.Array("CurrentLoadOutIds").Count == 0) inv.Array("CurrentLoadOutIds").Add(normal[0]!["ItemId"]!.DeepClone());
var questApi = new QuestApi(catalog, clock);
foreach (var type in Quests)
{
var quest = inv.Array("QuestKeys").OfType<JObject>().FirstOrDefault(x => x.Value<string>("ItemType") == type);
if (quest?.Value<bool>("Completed") == true) continue;
if (quest is null) inv.Array("QuestKeys").Add(new JObject { ["ItemType"] = type, ["Progress"] = new JArray() });
var stages = (JArray)(GameData.Find("Keys", type)?["chainStages"] ?? throw new InvalidDataException("Missing tutorial quest stages."));
questApi.Update(account, new JArray(new JObject {
["ItemType"] = type, ["Completed"] = true,
["Progress"] = new JArray(stages.Select(_ => new JObject { ["c"] = 0, ["i"] = true, ["m"] = true, ["b"] = new JArray() })) }));
}
foreach (var tag in new[] { "SolNode27", "SolNode89", "SolNode63", "SolNode85", "SolNode15", "SolNode79" })
{
var mission = inv.Array("Missions").OfType<JObject>().FirstOrDefault(x => x.Value<string>("Tag") == tag);
if (mission is null) inv.Array("Missions").Add(new JObject { ["Tag"] = tag, ["Completes"] = 1 });
else if (mission.Value<int>("Completes") == 0) mission["Completes"] = 1;
}
PersonalRoomsApi.Ensure(account);
JObject Slot(string category) => new() { ["ItemId"] = inv.Array(category)[0]!["ItemId"]!.DeepClone() };
}
}
using Newtonsoft.Json.Linq;
using XFEWarframe.Core.Data;
namespace XFEWarframe.Core.Services;
public static class TutorialProgress
{
private static readonly string[] Quests = ["/Lotus/Types/Keys/VorsPrize/VorsPrizeQuestKeyChain", "/Lotus/Types/Keys/ModQuest/ModQuestKeyChain"];
public static void Apply(JObject account, ItemCatalog catalog, TimeProvider clock)
{
var inv = account.Obj("Inventory");
var acquire = new ItemAcquisition(catalog, clock, account);
// Imported equipment and currencies belong to the player. Only supply
// missing starter slots when an administrator skips a fresh account.
foreach (var (category, type) in new[] {
("Suits", "/Lotus/Powersuits/Excalibur/Excalibur"),
("LongGuns", "/Lotus/Weapons/Tenno/Rifle/Rifle"),
("Pistols", "/Lotus/Weapons/Tenno/Pistol/Pistol"),
("Melee", "/Lotus/Weapons/Tenno/Melee/LongSword/LongSword"),
("DataKnives", "/Lotus/Weapons/Tenno/HackingDevices/TnHackingDevice/TnHackingDeviceWeapon") })
if (inv.Array(category).Count == 0) acquire.Add(inv, type, premium: true);
inv["ReceivedStartingGear"] = true;
inv["MadeStoryModeDecision"] = true;
inv["PlayedParkourTutorial"] = true;
if (string.IsNullOrEmpty(inv.Value<string>("StoryModeChoice"))) inv["StoryModeChoice"] = "WARFRAME";
var normal = account.Obj("Loadouts").Array("NORMAL");
if (normal.Count == 0)
{
var preset = new JObject { ["ItemId"] = Wire.Oid(Wire.NewId()), ["n"] = "XFEWarframe", ["s"] = Slot("Suits"), ["l"] = Slot("LongGuns"), ["p"] = Slot("Pistols"), ["m"] = Slot("Melee") };
normal.Add(preset);
}
if (inv.Array("CurrentLoadOutIds").Count == 0) inv.Array("CurrentLoadOutIds").Add(normal[0]!["ItemId"]!.DeepClone());
var questApi = new QuestApi(catalog, clock);
foreach (var type in Quests)
{
var quest = inv.Array("QuestKeys").OfType<JObject>().FirstOrDefault(x => x.Value<string>("ItemType") == type);
if (quest?.Value<bool>("Completed") == true) continue;
if (quest is null) inv.Array("QuestKeys").Add(new JObject { ["ItemType"] = type, ["Progress"] = new JArray() });
var stages = (JArray)(GameData.Find("Keys", type)?["chainStages"] ?? throw new InvalidDataException("Missing tutorial quest stages."));
questApi.Update(account, new JArray(new JObject {
["ItemType"] = type, ["Completed"] = true,
["Progress"] = new JArray(stages.Select(_ => new JObject { ["c"] = 0, ["i"] = true, ["m"] = true, ["b"] = new JArray() })) }));
}
foreach (var tag in new[] { "SolNode27", "SolNode89", "SolNode63", "SolNode85", "SolNode15", "SolNode79" })
{
var mission = inv.Array("Missions").OfType<JObject>().FirstOrDefault(x => x.Value<string>("Tag") == tag);
if (mission is null) inv.Array("Missions").Add(new JObject { ["Tag"] = tag, ["Completes"] = 1 });
else if (mission.Value<int>("Completes") == 0) mission["Completes"] = 1;
}
PersonalRoomsApi.Ensure(account);
JObject Slot(string category) => new() { ["ItemId"] = inv.Array(category)[0]!["ItemId"]!.DeepClone() };
}
}