using System.Text.Json;
using XFEEDToolBox.Core.Native;
namespace XFEEDToolBox.Core.Execution;
public static class NativeTradeCapabilities
{
public static bool SupportsDockedTrade(JsonElement description) =>
description.ValueKind == JsonValueKind.Object
&& description.TryGetProperty("schema", out var schema) && schema.ValueKind == JsonValueKind.Number && schema.TryGetInt32(out var version) && version == 1
&& Text(description, "name") == "XFEEDToolBox.Navigation"
&& Flag(description, "verified")
&& Text(description, "gameSha256") == NativeSystemLocationReader.GameSha256
&& Flag(description, "commerceDockedReadiness")
&& Flag(description, "cgCommodityBatches");
public static void RequireProductionFlight(JsonElement description)
{
if (!SupportsDockedTrade(description))
throw new NotSupportedException("当前游戏的原生交易接口尚未验证,采购尚未启动。");
if (!Flag(description, "supercruiseOverchargeControl") || !Flag(description, "interdictionEscapeControl"))
throw new NotSupportedException("SCO温控、燃油控制和原始逃逸矢量尚未全部就绪,采购尚未启动。");
}
private static bool Flag(JsonElement value, string name) => value.TryGetProperty(name, out var flag) && flag.ValueKind == JsonValueKind.True;
private static string? Text(JsonElement value, string name) => value.TryGetProperty(name, out var text) && text.ValueKind == JsonValueKind.String ? text.GetString() : null;
}
using System.Text.Json;
using XFEEDToolBox.Core.Native;
namespace XFEEDToolBox.Core.Execution;
public static class NativeTradeCapabilities
{
public static bool SupportsDockedTrade(JsonElement description) =>
description.ValueKind == JsonValueKind.Object
&& description.TryGetProperty("schema", out var schema) && schema.ValueKind == JsonValueKind.Number && schema.TryGetInt32(out var version) && version == 1
&& Text(description, "name") == "XFEEDToolBox.Navigation"
&& Flag(description, "verified")
&& Text(description, "gameSha256") == NativeSystemLocationReader.GameSha256
&& Flag(description, "commerceDockedReadiness")
&& Flag(description, "cgCommodityBatches");
public static void RequireProductionFlight(JsonElement description)
{
if (!SupportsDockedTrade(description))
throw new NotSupportedException("当前游戏的原生交易接口尚未验证,采购尚未启动。");
if (!Flag(description, "supercruiseOverchargeControl") || !Flag(description, "interdictionEscapeControl"))
throw new NotSupportedException("SCO温控、燃油控制和原始逃逸矢量尚未全部就绪,采购尚未启动。");
}
private static bool Flag(JsonElement value, string name) => value.TryGetProperty(name, out var flag) && flag.ValueKind == JsonValueKind.True;
private static string? Text(JsonElement value, string name) => value.TryGetProperty(name, out var text) && text.ValueKind == JsonValueKind.String ? text.GetString() : null;
}