using Newtonsoft.Json; using Newtonsoft.Json.Linq; using XFEWarframe.Core.Data; namespace XFEWarframe.Core.Services; public sealed partial class CustomApi { private ApiResponse Unlock(string controller, JObject account, ApiRequest request) { var inv = account.Obj("Inventory"); var acquire = new ItemAcquisition(catalog, clock, account); switch (controller) { case "unlockAllIntrinsicsController": foreach (var skill in GameData.Table("Intrinsics").Properties()) inv.Obj("PlayerSkills")[skill.Name] = Math.Min(10, (skill.Value["ranks"] as JArray ?? []).Count); foreach (var item in new[] { "/Lotus/Types/Restoratives/Consumable/CrewmateBall", "/Lotus/Types/Restoratives/ErsatzSummon" }) if (!inv.Array("Consumables").Any(x => x.Value("ItemType") == item)) acquire.Add(inv, item); break; case "addMissingMaxRankModsController": foreach (var item in catalog.Entries.Where(x => x.Category == "RawUpgrades" && x.Meta.Value("fusionLimit") > 0 && x.Meta.Value("type") != "PARAZON" && x.Meta.Value("name") != "/Lotus/Language/Items/GenericCosmeticEnhancerName")) if (!inv.Array("Upgrades").Any(x => x.Value("ItemType") == item.Type && JObject.Parse(x.Value("UpgradeFingerprint") ?? "{}").Value("lvl") >= item.Meta.Value("fusionLimit"))) inv.Array("Upgrades").Add(new JObject { ["ItemId"] = Wire.Oid(Wire.NewId()), ["ItemType"] = item.Type, ["UpgradeFingerprint"] = new JObject { ["lvl"] = item.Meta.Value("fusionLimit") }.ToString(Formatting.None) }); break; case "completeAllMissionsController": var rewards = new JArray(); long credits = 0; var hard = request.Q("normalOnly") != "1"; foreach (var node in GameData.Table("Regions").Properties()) { var mission = inv.Array("Missions").OfType().FirstOrDefault(x => x.Value("Tag") == node.Name); if (mission is null) { mission = new JObject { ["Tag"] = node.Name, ["Completes"] = 0, ["Tier"] = 0 }; inv.Array("Missions").Add(mission); } if (mission.Value("Completes") == 0) { mission["Completes"] = 1; if (node.Value["missionReward"] is JObject reward) credits += MissionApi.FixedRewards(reward, rewards); } if (hard) mission["Tier"] = 1; } Inventory.ChangeCurrency(inv, "RegularCredits", credits); foreach (var reward in rewards.OfType()) acquire.Add(inv, reward.RequiredString("StoreItem"), (int)reward.Integer("ItemCount", 1, 100000), premium: true); foreach (var name in new[] { "KillPhorid", "SaviourOfCeres", "SaviourOfEarth", "SaviourOfEuropa", "SaviourOfJupiter", "SaviourOfMars", "SaviourOfMercury", "SaviourOfNeptune", "SaviourOfPhobos", "SaviourOfPluto", "SaviourOfSaturn", "SaviourOfSedna", "SaviourOfUranus", "SaviourOfVenus" }) Inventory.Upsert(inv.Array("ChallengeProgress"), "Name", new JObject { ["Name"] = name, ["Progress"] = 1 }); if (hard) { inv.Array("NodeIntrosCompleted").UniqueAdd("TeshinHardModeUnlocked"); foreach (var system in WorldData.Get("steelPathSystems")) { var name = system[1]!.ToString(); var emote = "/Lotus/Types/Items/Emotes/Hardmode" + name + "Emote"; if (inv.Array("FlavourItems").Any(x => x.Value("ItemType") == emote)) continue; acquire.Add(inv, emote); acquire.Add(inv, "/Lotus/Types/Items/ShipDecos/PlanetTrophies/PlanetTrophy" + name + "Bronze"); acquire.Add(inv, "/Lotus/Types/Items/MiscItems/SteelEssence", 25); if (system[0]!.Value() == 16) { acquire.Add(inv, "/Lotus/Types/Items/Emotes/HardmodeDerelictEmote"); acquire.Add(inv, "/Lotus/Types/Items/ShipDecos/PlanetTrophies/PlanetTrophyDerelictBronze"); } } } foreach (var intro in new[] { "CetusInvasionNodeIntro", "CetusSyndicate_IntroJob" }) inv.Array("NodeIntrosCompleted").UniqueAdd(intro); if (!inv.Array("Affiliations").Any(x => x.Value("Tag") == "CetusSyndicate")) inv.Array("Affiliations").Add(new JObject { ["Tag"] = "CetusSyndicate", ["Standing"] = 250, ["Title"] = 0 }); break; case "addMissingHelminthBlueprintsController": foreach (var recipe in GameData.Table("Recipes").Properties().Where(x => x.Value.Value("secretIngredientAction") == "SIA_WARFRAME_ABILITY")) { if (inv.Array("Recipes").Any(x => x.Value("ItemType") == recipe.Name)) continue; Inventory.AddCount(inv, "Recipes", recipe.Name, 1); var suit = (recipe.Value["secretIngredients"] as JArray ?? []).FirstOrDefault(x => x.Value("ItemType")?.StartsWith("/Lotus/Powersuits/", StringComparison.Ordinal) == true)?.Value("ItemType"); if (suit is not null && !inv.Obj("InfestedFoundry").Array("ConsumedSuits").Any(x => x.Value("s") == suit)) inv.Obj("InfestedFoundry").Array("ConsumedSuits").Add(new JObject { ["s"] = suit }); } break; case "unlockAllJobChainBountiesController": foreach (var (tag, data) in new[] { ("EudicoHeists", "allEudicoHeistJobs"), ("NokkoColony", "allNokkoColonyJobs") }) Inventory.Upsert(inv.Array("CompletedJobChains"), "LocationTag", new JObject { ["LocationTag"] = tag, ["Jobs"] = WorldData.Get(data).DeepClone() }); break; case "unlockAllSimarisResearchEntriesController": inv.Remove("LibraryPersonalTarget"); inv["LibraryPersonalProgress"] = new JArray(Enumerable.Range(1, 7).Select(i => new JObject { ["TargetType"] = "/Lotus/Types/Game/Library/Targets/Research" + i + "Target", ["Scans"] = 10, ["Completed"] = true })); break; case "unlockAllShipFeaturesController": foreach (var feature in Assets.Json("fixed_responses/allShipFeatures.json")) account.Obj("PersonalRooms").Obj("Ship").Array("Features").UniqueAdd(feature); break; case "unlockAllCapturaScenesController": foreach (var resource in GameData.Table("Resources").Properties()) { var parent = resource.Value.Value("parentName"); var visited = new HashSet(); while (parent is not null && visited.Add(parent)) { if (parent == "/Lotus/Types/Items/MiscItems/PhotoboothTile") { if (!inv.Array("MiscItems").Any(x => x.Value("ItemType") == resource.Name)) acquire.Add(inv, resource.Name); break; } parent = (GameData.Find("Resources", parent) ?? GameData.Find("Virtuals", parent))?.Value("parentName"); } } break; case "unlockAllScansController": UnlockScans(account); break; default: throw new ApiException(400, "Unknown account management operation"); } return ApiResponse.Text(); } private void UnlockScans(JObject account) { var inv = account.Obj("Inventory"); var codex = GameData.Table("Codex"); var scans = Assets.Json("fixed_responses/allScans.json").Values().Concat(((JObject)GameData.Table("Enemies")["avatars"]!).Properties().Select(x => x.Name)).Concat(((JObject)codex["objects"]!).Properties().Select(x => x.Name)).Distinct(); account.Obj("Stats")["Scans"] = new JArray(scans.Select(x => new JObject { ["type"] = x, ["scans"] = 9999 })); Inventory.Upsert(inv.Array("ChallengeProgress"), "Name", new JObject { ["Name"] = "JSCodexScan", ["Progress"] = 1 }); Inventory.Upsert(inv.Array("ChallengeProgress"), "Name", new JObject { ["Name"] = "MPCephFragments", ["Progress"] = 3 }); foreach (var (type, count) in new[] { ("/Lotus/Objects/Orokin/Props/CollectibleSeriesOne", 56), ("/Lotus/Types/Lore/Fragments/DuviriFragments/DuviriCollectibleDeco", 90), ("/Lotus/Types/Lore/Fragments/DuviriMITWFragments/DuviriMITWCollectibleDeco", 15) }) { var series = inv.Array("CollectibleSeries").OfType().FirstOrDefault(x => x.Value("CollectibleType") == type); var complete = series?.Value("Count") >= count; if (series is null) { series = new JObject { ["CollectibleType"] = type, ["IncentiveStates"] = new JArray() }; inv.Array("CollectibleSeries").Add(series); } series["Count"] = count; series["ReqScans"] = count; series["Tracking"] = new string('1', 90); if (!complete && count == 56) { foreach (var (threshold, file) in new[] { (.5, "fiftyPercent"), (.75, "seventyFivePercent") }) { var gate = series.Array("IncentiveStates").OfType().FirstOrDefault(x => x.Value("threshold") == threshold); if (gate is null) { gate = new JObject { ["threshold"] = threshold }; series.Array("IncentiveStates").Add(gate); } if (!gate.Value("sent")) InboxApi.Create(account, (JObject)Assets.Json("fixed_responses/kuriaMessages/" + file + ".json"), clock.GetUtcNow()); gate["sent"] = true; gate["complete"] = true; } InboxApi.Create(account, (JObject)Assets.Json("fixed_responses/kuriaMessages/oneHundredPercent.json"), clock.GetUtcNow()); } if (!complete && count == 15) InboxApi.Create(account, new JObject { ["sub"] = "/Lotus/Language/Isleweaver/IsleweaverFragmentInboxMessageSender", ["sndr"] = "/Lotus/Language/Isleweaver/IsleweaverFragmentInboxMessageSubject", ["msg"] = "/Lotus/Language/Isleweaver/IsleweaverFragmentInboxMessageBody", ["icon"] = "/Lotus/Interface/Icons/Npcs/UnknownSource.png", ["highPriority"] = true, ["att"] = new JArray("/Lotus/Types/Items/ShipDecos/Duviri/Mitw/RusalkaHat", "/Lotus/Types/Items/ShipDecos/Duviri/Mitw/RusalkaMedals") }, clock.GetUtcNow()); } var existingPrex = inv.Array("LoreFragmentScans").Select(x => x.Value("ItemType")).ToHashSet(); inv["LoreFragmentScans"] = new JArray(); foreach (var group in new[] { "loreFragments", "songs", "fighterFrames" }) foreach (var fragment in ((JObject)codex[group]!).Properties()) { inv.Array("LoreFragmentScans").Add(new JObject { ["ItemType"] = fragment.Name, ["Progress"] = fragment.Value.Value("reqScans"), ["Region"] = "" }); if (group == "loreFragments" && fragment.Name.StartsWith("/Lotus/Types/Lore/Fragments/LoreCardFragments/", StringComparison.Ordinal) && !existingPrex.Contains(fragment.Name)) { var deco = catalog.Entries.FirstOrDefault(x => x.Category == "ShipDecorations" && x.Meta.Value("name") == fragment.Value.Value("name")); if (deco.Type is not null) new ItemAcquisition(catalog, clock, account).Add(inv, deco.Type); } } if (!inv.Value("receivedThousandYearFishDeco")) { inv["receivedThousandYearFishDeco"] = true; InboxApi.Create(account, new JObject { ["sndr"] = "/Lotus/Language/Npcs/Onkko", ["icon"] = "/Lotus/Interface/Icons/Npcs/Ostron/Onkko.png", ["sub"] = "/Lotus/Language/Messages/EidolonCollectibleRewardTitle", ["msg"] = "/Lotus/Language/Messages/EidolonCollectibleRewardBody", ["att"] = new JArray("/Lotus/Types/Items/ShipDecos/LisetPropOstStoneFish"), ["highPriority"] = true }, clock.GetUtcNow()); } } private ApiResponse ManageQuests(JObject account, ApiRequest request) => ApiResponse.Json(new QuestApi(catalog, clock).Manage(account, Query(request, "operation"), request.Q("itemType"))); }