using Newtonsoft.Json.Linq;
namespace XFEWarframe.Core.Services;
public sealed partial class AccountEditor
{
private static string ShardName(string type) => Choices.Value["shards"]?.Value<string>(type) ?? type.Split('/').Last();
private static IEnumerable<IGrouping<string, string>> ShardGroups(JObject item) =>
(item["ArchonCrystalUpgrades"] as JArray ?? []).OfType<JObject>()
.Select(x => x.Value<string>("UpgradeType")).OfType<string>().GroupBy(x => x);
private static string SuitSummary(JObject item)
{
var shards = ShardGroups(item).Select(x => $"{x.Count()} × {ShardName(x.Key)}");
return $"经验 {item.Value<long>("XP"):N0} · 极化 {item.Value<int>("Polarized")} 次\n" +
string.Join("\n", shards.Prepend("源力石词条:"));
}
private void AddSuitActions(JArray actions, JObject item)
{
var summary = SuitSummary(item);
var add = Action("shards.add", "添加源力石词条", KnownChoice("type", "升级词条", "shards"), Number("count", "数量", 1, 1, 10000));
add["description"] = summary;
actions.Add(add);
var shards = ShardGroups(item).ToArray();
if (shards.Length > 0)
{
var remove = Action("shards.remove", "移除源力石词条", Choice("type", "已安装词条", shards[0].Key,
shards.Select(x => (x.Key, $"{x.Count()} × {ShardName(x.Key)}")).ToArray()));
remove["description"] = "与原版相同,移除所选类型的全部词条;其他类型保持不变。";
actions.Add(remove);
}
var now = clock.GetUtcNow();
if (item.Value<string>("ItemType") != "/Lotus/Powersuits/Excalibur/ExcaliburUmbra")
{
var expiry = Wire.DateMs(item["UmbraDate"]);
var umbra = Action("umbra", "Umbra 回响", Expiry(expiry > 0 ? expiry : now.AddDays(1).ToUnixTimeMilliseconds()));
umbra["description"] = "未启用时默认持续 1 天。可单独移除回响。";
actions.Add(umbra);
if (expiry > 0) actions.Add(Action("umbra.remove", "移除 Umbra 回响"));
}
var invigorationExpiry = Wire.DateMs(item["UpgradesExpiry"]);
var invigoration = Action("invigoration", "Helminth 活力注入",
InvigorationChoice("offensive", "进攻词条", "invigoration-offensive", item.Value<string>("OffensiveUpgrade")),
InvigorationChoice("defensive", "防御词条", "invigoration-defensive", item.Value<string>("DefensiveUpgrade")),
Expiry(invigorationExpiry > 0 ? invigorationExpiry : now.AddDays(7).ToUnixTimeMilliseconds()));
invigoration["description"] = "选择一项进攻词条和一项防御词条;未启用时默认持续 7 天。";
actions.Add(invigoration);
if (invigorationExpiry > 0 || item["OffensiveUpgrade"] is not null || item["DefensiveUpgrade"] is not null)
actions.Add(Action("invigoration.remove", "移除活力注入"));
// Original WebUI exposes A–C plus purchased configurations, capped at F.
for (var i = 0; i < 3 + Math.Clamp(item.Value<int>("ModSlotPurchases"), 0, 3); i++)
{
var config = (item["Configs"] as JArray)?.ElementAtOrDefault(i) as JObject;
var name = config?.Value<string>("Name")?.Trim();
var label = "配置 " + (char)('A' + i) + (string.IsNullOrEmpty(name) ? "" : " · " + name) + " · 移植技能";
var ability = Action("ability." + i, label, AbilityChoice(config?["AbilityOverride"]?.Value<string>("Ability")),
Number("slot", "替换技能槽(1–4)", (config?["AbilityOverride"]?.Value<int>("Index") ?? 0) + 1, 1, 4));
ability["description"] = "仅修改此配装的移植技能,保留 MOD、外观及其他配装。选择移除选项可恢复原技能。";
if (config?[ExperimentalAbilities.Field] is JObject)
ability["description"] = "此配置已保存多技能实验方案。在这里保存会切换回单技能模式。";
actions.Add(ability);
var selected = ExperimentalAbilities.ReadBanks(config);
var fields = Enumerable.Range(0, 4).SelectMany(slot => Enumerable.Range(0, 3).Select(index =>
{
var field = AbilityChoice(selected[slot.ToString()]?.Value<string>(index.ToString()));
field["key"] = "ability" + (slot + 1) + (index == 0 ? "" : "_" + (index + 1));
field["label"] = "技能槽 " + (slot + 1) + " · 技能 " + (index + 1);
((JArray)field["options"]!)[0]!["label"] = index == 0 ? "不替换(本槽全部留空时保留原技能)" : "不装载额外技能";
return field;
})).ToArray();
var multiple = Action("ability.multiple." + i,
"配置 " + (char)('A' + i) + (string.IsNullOrEmpty(name) ? "" : " · " + name), fields);
multiple["description"] = "每个槽位最多装载 3 个技能,以 Xaku 式轮盘显示;短按切换、长按 350 毫秒施放。只有一个技能时保持原有操作。需要 1.4.1 或更新的兼容组件。";
actions.Add(multiple);
}
}
private static JObject Expiry(long value) { var field = Date("expiry", "到期时间", value); field["min"] = 1; return field; }
private static JObject InvigorationChoice(string key, string label, string group, string? current)
{
var choice = KnownChoice(key, label, group, current ?? "");
foreach (var option in ((JArray)choice["options"]!).Where(x => x.Value<string>("value") == "").ToArray()) option.Remove();
return choice;
}
}
using Newtonsoft.Json.Linq;
namespace XFEWarframe.Core.Services;
public sealed partial class AccountEditor
{
private static string ShardName(string type) => Choices.Value["shards"]?.Value<string>(type) ?? type.Split('/').Last();
private static IEnumerable<IGrouping<string, string>> ShardGroups(JObject item) =>
(item["ArchonCrystalUpgrades"] as JArray ?? []).OfType<JObject>()
.Select(x => x.Value<string>("UpgradeType")).OfType<string>().GroupBy(x => x);
private static string SuitSummary(JObject item)
{
var shards = ShardGroups(item).Select(x => $"{x.Count()} × {ShardName(x.Key)}");
return $"经验 {item.Value<long>("XP"):N0} · 极化 {item.Value<int>("Polarized")} 次\n" +
string.Join("\n", shards.Prepend("源力石词条:"));
}
private void AddSuitActions(JArray actions, JObject item)
{
var summary = SuitSummary(item);
var add = Action("shards.add", "添加源力石词条", KnownChoice("type", "升级词条", "shards"), Number("count", "数量", 1, 1, 10000));
add["description"] = summary;
actions.Add(add);
var shards = ShardGroups(item).ToArray();
if (shards.Length > 0)
{
var remove = Action("shards.remove", "移除源力石词条", Choice("type", "已安装词条", shards[0].Key,
shards.Select(x => (x.Key, $"{x.Count()} × {ShardName(x.Key)}")).ToArray()));
remove["description"] = "与原版相同,移除所选类型的全部词条;其他类型保持不变。";
actions.Add(remove);
}
var now = clock.GetUtcNow();
if (item.Value<string>("ItemType") != "/Lotus/Powersuits/Excalibur/ExcaliburUmbra")
{
var expiry = Wire.DateMs(item["UmbraDate"]);
var umbra = Action("umbra", "Umbra 回响", Expiry(expiry > 0 ? expiry : now.AddDays(1).ToUnixTimeMilliseconds()));
umbra["description"] = "未启用时默认持续 1 天。可单独移除回响。";
actions.Add(umbra);
if (expiry > 0) actions.Add(Action("umbra.remove", "移除 Umbra 回响"));
}
var invigorationExpiry = Wire.DateMs(item["UpgradesExpiry"]);
var invigoration = Action("invigoration", "Helminth 活力注入",
InvigorationChoice("offensive", "进攻词条", "invigoration-offensive", item.Value<string>("OffensiveUpgrade")),
InvigorationChoice("defensive", "防御词条", "invigoration-defensive", item.Value<string>("DefensiveUpgrade")),
Expiry(invigorationExpiry > 0 ? invigorationExpiry : now.AddDays(7).ToUnixTimeMilliseconds()));
invigoration["description"] = "选择一项进攻词条和一项防御词条;未启用时默认持续 7 天。";
actions.Add(invigoration);
if (invigorationExpiry > 0 || item["OffensiveUpgrade"] is not null || item["DefensiveUpgrade"] is not null)
actions.Add(Action("invigoration.remove", "移除活力注入"));
// Original WebUI exposes A–C plus purchased configurations, capped at F.
for (var i = 0; i < 3 + Math.Clamp(item.Value<int>("ModSlotPurchases"), 0, 3); i++)
{
var config = (item["Configs"] as JArray)?.ElementAtOrDefault(i) as JObject;
var name = config?.Value<string>("Name")?.Trim();
var label = "配置 " + (char)('A' + i) + (string.IsNullOrEmpty(name) ? "" : " · " + name) + " · 移植技能";
var ability = Action("ability." + i, label, AbilityChoice(config?["AbilityOverride"]?.Value<string>("Ability")),
Number("slot", "替换技能槽(1–4)", (config?["AbilityOverride"]?.Value<int>("Index") ?? 0) + 1, 1, 4));
ability["description"] = "仅修改此配装的移植技能,保留 MOD、外观及其他配装。选择移除选项可恢复原技能。";
if (config?[ExperimentalAbilities.Field] is JObject)
ability["description"] = "此配置已保存多技能实验方案。在这里保存会切换回单技能模式。";
actions.Add(ability);
var selected = ExperimentalAbilities.ReadBanks(config);
var fields = Enumerable.Range(0, 4).SelectMany(slot => Enumerable.Range(0, 3).Select(index =>
{
var field = AbilityChoice(selected[slot.ToString()]?.Value<string>(index.ToString()));
field["key"] = "ability" + (slot + 1) + (index == 0 ? "" : "_" + (index + 1));
field["label"] = "技能槽 " + (slot + 1) + " · 技能 " + (index + 1);
((JArray)field["options"]!)[0]!["label"] = index == 0 ? "不替换(本槽全部留空时保留原技能)" : "不装载额外技能";
return field;
})).ToArray();
var multiple = Action("ability.multiple." + i,
"配置 " + (char)('A' + i) + (string.IsNullOrEmpty(name) ? "" : " · " + name), fields);
multiple["description"] = "每个槽位最多装载 3 个技能,以 Xaku 式轮盘显示;短按切换、长按 350 毫秒施放。只有一个技能时保持原有操作。需要 1.4.1 或更新的兼容组件。";
actions.Add(multiple);
}
}
private static JObject Expiry(long value) { var field = Date("expiry", "到期时间", value); field["min"] = 1; return field; }
private static JObject InvigorationChoice(string key, string label, string group, string? current)
{
var choice = KnownChoice(key, label, group, current ?? "");
foreach (var option in ((JArray)choice["options"]!).Where(x => x.Value<string>("value") == "").ToArray()) option.Remove();
return choice;
}
}