using Newtonsoft.Json.Linq;
using XFEWarframe.Core.Data;
namespace XFEWarframe.Core.Services;
public sealed partial class AccountEditor
{
// These are the bulk-add sections exposed by the audited WebUI. Modular
// equipment needs chosen parts and therefore uses the assembly form instead.
private static readonly HashSet<string> BulkAcquisitionCategories = ["Suits", "LongGuns", "Pistols", "Melee", "SpaceSuits", "SpaceGuns", "SpaceMelee", "MechSuits", "Sentinels", "KubrowPets", "SentinelWeapons", "OperatorAmps", "QuestKeys", "FlavourItems", "ShipDecorations", "WeaponSkins"];
private sealed record MissingItem(string Type, string Name, int Count);
private MissingItem[] MissingItems(JObject inv, string category)
{
var owned = inv.Array(category).Select(AsItem).Where(x => (x.Value<long?>("ItemCount") ?? 1) > 0).Select(x => x.Value<string>("ItemType")).ToHashSet(StringComparer.Ordinal);
return catalog.Entries.Where(x => !owned.Contains(x.Type) && (category == "QuestKeys" ? x.Category == "LevelKeys" && x.Meta["chainStages"] is JArray : x.Category == category))
.Where(x => WorldData.Get("modularWeaponTypes")[x.Type] is null && x.Meta["partType"] is null && x.Meta["upgradeEntries"] is null && !(x.Meta["bayonetOtherWeaponType"] is not null && x.Meta.Value<bool>("excludeFromMarket")))
.Where(x => category != "RawUpgrades" || x.Type != InfestationKing.Type && x.Type != XFEWarframe.Mods.PetFetchMod.Type && LegacyMods.Find(x.Type) is null && !x.Type.StartsWith("/Lotus/Upgrades/Mods/Fusers/", StringComparison.Ordinal))
.OrderBy(x => x.Type, StringComparer.Ordinal)
.Select(x => new MissingItem(x.Type, catalog.Name(x.Meta, x.Type), category == "ShipDecorations" ? 999999 : category == "RawUpgrades" && x.Type.StartsWith("/Lotus/Upgrades/CosmeticEnhancers/", StringComparison.Ordinal) ? checked((x.Meta.Value<int>("fusionLimit") + 1) * (x.Meta.Value<int>("fusionLimit") + 2) / 2) : 1)).ToArray();
}
private void AddAcquisitionActions(JArray actions, JObject inv, string category)
{
if (!BulkAcquisitionCategories.Contains(category) && category != "RawUpgrades") return;
var missing = MissingItems(inv, category);
if (missing.Length == 0) return;
var action = Action(category == "RawUpgrades" ? "batch.mods.missing" : "batch.acquire.missing", category == "RawUpgrades" ? "补齐未升级 MOD" : "补齐当前分类缺失物品");
action["affectedCount"] = missing.Length;
action["description"] = $"将补齐 {missing.Length:N0} 种缺失物品,共 {missing.Sum(x => (long)x.Count):N0} 件;已有物品不重复添加。" +
(category == "ShipDecorations" ? "每种缺失的飞船装饰添加 999,999 件,与原版一致。" : category == "RawUpgrades" ? "赋能按合成满级所需的数量添加;不添加融合核心、已揭示紫卡或 U5 MOD。" : "需要部件的模块化装备请使用组装功能。");
action["preview"] = new JArray(missing.Take(20).Select(x => new JObject { ["name"] = x.Name, ["count"] = x.Count }));
actions.Add(action);
}
private void AcquireMissing(JObject account, string category)
{
var inv = account.Obj("Inventory"); var acquisition = new ItemAcquisition(catalog, clock, account);
foreach (var missing in MissingItems(inv, category))
{
// An earlier acquisition can grant an exalted/paired/default item.
if (inv.Array(category).Select(AsItem).Any(x => x.Value<string>("ItemType") == missing.Type && (x.Value<long?>("ItemCount") ?? 1) > 0)) continue;
for (var remaining = missing.Count; remaining > 0;)
{
var count = Math.Min(remaining, 100000);
acquisition.Add(inv, missing.Type, count, premium: true);
remaining -= count;
}
}
}
private static JObject? ModMetadata(string type)
{
if (LegacyMods.Find(type) is JObject legacy) return legacy;
try { return ModApi.Metadata(type); } catch (ApiException) { return null; }
}
}
using Newtonsoft.Json.Linq;
using XFEWarframe.Core.Data;
namespace XFEWarframe.Core.Services;
public sealed partial class AccountEditor
{
// These are the bulk-add sections exposed by the audited WebUI. Modular
// equipment needs chosen parts and therefore uses the assembly form instead.
private static readonly HashSet<string> BulkAcquisitionCategories = ["Suits", "LongGuns", "Pistols", "Melee", "SpaceSuits", "SpaceGuns", "SpaceMelee", "MechSuits", "Sentinels", "KubrowPets", "SentinelWeapons", "OperatorAmps", "QuestKeys", "FlavourItems", "ShipDecorations", "WeaponSkins"];
private sealed record MissingItem(string Type, string Name, int Count);
private MissingItem[] MissingItems(JObject inv, string category)
{
var owned = inv.Array(category).Select(AsItem).Where(x => (x.Value<long?>("ItemCount") ?? 1) > 0).Select(x => x.Value<string>("ItemType")).ToHashSet(StringComparer.Ordinal);
return catalog.Entries.Where(x => !owned.Contains(x.Type) && (category == "QuestKeys" ? x.Category == "LevelKeys" && x.Meta["chainStages"] is JArray : x.Category == category))
.Where(x => WorldData.Get("modularWeaponTypes")[x.Type] is null && x.Meta["partType"] is null && x.Meta["upgradeEntries"] is null && !(x.Meta["bayonetOtherWeaponType"] is not null && x.Meta.Value<bool>("excludeFromMarket")))
.Where(x => category != "RawUpgrades" || x.Type != InfestationKing.Type && x.Type != XFEWarframe.Mods.PetFetchMod.Type && LegacyMods.Find(x.Type) is null && !x.Type.StartsWith("/Lotus/Upgrades/Mods/Fusers/", StringComparison.Ordinal))
.OrderBy(x => x.Type, StringComparer.Ordinal)
.Select(x => new MissingItem(x.Type, catalog.Name(x.Meta, x.Type), category == "ShipDecorations" ? 999999 : category == "RawUpgrades" && x.Type.StartsWith("/Lotus/Upgrades/CosmeticEnhancers/", StringComparison.Ordinal) ? checked((x.Meta.Value<int>("fusionLimit") + 1) * (x.Meta.Value<int>("fusionLimit") + 2) / 2) : 1)).ToArray();
}
private void AddAcquisitionActions(JArray actions, JObject inv, string category)
{
if (!BulkAcquisitionCategories.Contains(category) && category != "RawUpgrades") return;
var missing = MissingItems(inv, category);
if (missing.Length == 0) return;
var action = Action(category == "RawUpgrades" ? "batch.mods.missing" : "batch.acquire.missing", category == "RawUpgrades" ? "补齐未升级 MOD" : "补齐当前分类缺失物品");
action["affectedCount"] = missing.Length;
action["description"] = $"将补齐 {missing.Length:N0} 种缺失物品,共 {missing.Sum(x => (long)x.Count):N0} 件;已有物品不重复添加。" +
(category == "ShipDecorations" ? "每种缺失的飞船装饰添加 999,999 件,与原版一致。" : category == "RawUpgrades" ? "赋能按合成满级所需的数量添加;不添加融合核心、已揭示紫卡或 U5 MOD。" : "需要部件的模块化装备请使用组装功能。");
action["preview"] = new JArray(missing.Take(20).Select(x => new JObject { ["name"] = x.Name, ["count"] = x.Count }));
actions.Add(action);
}
private void AcquireMissing(JObject account, string category)
{
var inv = account.Obj("Inventory"); var acquisition = new ItemAcquisition(catalog, clock, account);
foreach (var missing in MissingItems(inv, category))
{
// An earlier acquisition can grant an exalted/paired/default item.
if (inv.Array(category).Select(AsItem).Any(x => x.Value<string>("ItemType") == missing.Type && (x.Value<long?>("ItemCount") ?? 1) > 0)) continue;
for (var remaining = missing.Count; remaining > 0;)
{
var count = Math.Min(remaining, 100000);
acquisition.Add(inv, missing.Type, count, premium: true);
remaining -= count;
}
}
}
private static JObject? ModMetadata(string type)
{
if (LegacyMods.Find(type) is JObject legacy) return legacy;
try { return ModApi.Metadata(type); } catch (ApiException) { return null; }
}
}