Collapse trade item details surface state
This commit is contained in:
parent
4087095128
commit
97aeba7304
2 changed files with 28 additions and 113 deletions
|
|
@ -6176,7 +6176,6 @@ static void RequireTradeItemDetailsUseEveSurface(string root)
|
|||
"private static EveSurfaceComponent",
|
||||
"new EveSurfaceComponent(",
|
||||
"string.Equals(request.Command, AetheriaRuntimeTradeItemDetailsSurfaceBuilder.Close",
|
||||
"new AetheriaRuntimeTradeItemDetailsSurfaceState(",
|
||||
"ProjectTradeItemDetailsSurface(",
|
||||
"ProjectTradeItemDetailsSurfaceState(",
|
||||
"AetheriaRuntimeTradeItemDetailsSurfaceBuilder.Project(",
|
||||
|
|
@ -6204,10 +6203,11 @@ static void RequireTradeItemDetailsUseEveSurface(string root)
|
|||
"public readonly struct AetheriaRuntimeTradeItemDetailsCommand",
|
||||
"public static class AetheriaRuntimeTradeItemDetailsSurfaceCommands",
|
||||
"public static bool TryRead(",
|
||||
"AetheriaRuntimeTradeItemDetailsSurfaceState",
|
||||
"AetheriaRuntimeTradeItemSection",
|
||||
"AetheriaRuntimeTradeItemMetric",
|
||||
"private static AetheriaRuntimeTradeItemDetailsSurfaceState ComposeState(",
|
||||
"var itemName = item?.Name ?? \"\"",
|
||||
"var behaviorSections = Array.Empty<AetheriaRuntimeTradeItemSection>()",
|
||||
"var hasEquipmentStatus = !string.IsNullOrWhiteSpace(durability)",
|
||||
"ProjectBehaviorSections(",
|
||||
"ProjectBehaviorMetric(",
|
||||
"public static AetheriaRuntimeSurfaceDocument Build(",
|
||||
|
|
@ -6224,13 +6224,15 @@ static void RequireTradeItemDetailsUseEveSurface(string root)
|
|||
string.Join(", ", missingBuilderSymbols));
|
||||
}
|
||||
|
||||
if (tradeItemDetailsSurfaceBuilder.Contains("public static AetheriaRuntimeTradeItemDetailsSurfaceState Project(", StringComparison.Ordinal) ||
|
||||
if (tradeItemDetailsSurfaceBuilder.Contains("AetheriaRuntimeTradeItemDetailsSurfaceState", StringComparison.Ordinal) ||
|
||||
tradeItemDetailsSurfaceBuilder.Contains("ComposeState(", StringComparison.Ordinal) ||
|
||||
tradeItemDetailsSurfaceBuilder.Contains("public static AetheriaRuntimeTradeItemDetailsSurfaceState Project(", StringComparison.Ordinal) ||
|
||||
tradeItemDetailsSurfaceBuilder.Contains("public static AetheriaRuntimeTradeItemDetailsSurfaceState Compose(", StringComparison.Ordinal) ||
|
||||
tradeItemDetailsSurfaceBuilder.Contains("private static AetheriaRuntimeTradeItemDetailsSurfaceState ProjectState(", StringComparison.Ordinal) ||
|
||||
tradeItemDetailsSurfaceBuilder.Contains("Build(ProjectState(", StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Runtime trade item detail composition must stay behind Build(...); do not re-expose Project/Compose or restore ProjectState handoffs.");
|
||||
"Runtime trade item details must emit the typed surface document directly; do not rebuild a shadow SurfaceState projection layer.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,44 +37,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
public IReadOnlyList<AetheriaRuntimeTradeItemMetric> Metrics { get; }
|
||||
}
|
||||
|
||||
public sealed class AetheriaRuntimeTradeItemDetailsSurfaceState
|
||||
{
|
||||
public AetheriaRuntimeTradeItemDetailsSurfaceState(
|
||||
string itemName,
|
||||
string description,
|
||||
string manufacturer,
|
||||
string mass,
|
||||
int price,
|
||||
string durability,
|
||||
string thermalRange,
|
||||
IReadOnlyList<AetheriaRuntimeTradeItemSection> behaviorSections,
|
||||
string updatedAtUtc)
|
||||
{
|
||||
ItemName = itemName ?? "";
|
||||
Description = description ?? "";
|
||||
Manufacturer = manufacturer ?? "";
|
||||
Mass = mass ?? "";
|
||||
Price = price;
|
||||
Durability = durability ?? "";
|
||||
ThermalRange = thermalRange ?? "";
|
||||
BehaviorSections = behaviorSections ?? Array.Empty<AetheriaRuntimeTradeItemSection>();
|
||||
UpdatedAtUtc = updatedAtUtc ?? "";
|
||||
}
|
||||
|
||||
public string ItemName { get; }
|
||||
public string Description { get; }
|
||||
public string Manufacturer { get; }
|
||||
public string Mass { get; }
|
||||
public int Price { get; }
|
||||
public string Durability { get; }
|
||||
public string ThermalRange { get; }
|
||||
public IReadOnlyList<AetheriaRuntimeTradeItemSection> BehaviorSections { get; }
|
||||
public string UpdatedAtUtc { get; }
|
||||
public bool HasEquipmentStatus => !string.IsNullOrWhiteSpace(Durability) ||
|
||||
!string.IsNullOrWhiteSpace(ThermalRange) ||
|
||||
BehaviorSections.Count > 0;
|
||||
}
|
||||
|
||||
public static class AetheriaRuntimeTradeItemDetailsSurfaceBuilder
|
||||
{
|
||||
public const string SurfaceId = "aetheria.trade.item_details";
|
||||
|
|
@ -87,106 +49,57 @@ namespace GameCult.Aetheria.State.Verse
|
|||
Func<float, string> formatTemperature,
|
||||
DateTime updatedAtUtc = default(DateTime),
|
||||
long version = 1)
|
||||
{
|
||||
return Build(
|
||||
ComposeState(
|
||||
item,
|
||||
manufacturer,
|
||||
formatValue,
|
||||
formatTemperature,
|
||||
updatedAtUtc),
|
||||
version);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeTradeItemDetailsSurfaceState ComposeState(
|
||||
AetheriaRuntimeCatalogItem item,
|
||||
string manufacturer,
|
||||
Func<float, string> formatValue,
|
||||
Func<float, string> formatTemperature,
|
||||
DateTime updatedAtUtc = default(DateTime))
|
||||
{
|
||||
if (updatedAtUtc == default(DateTime))
|
||||
updatedAtUtc = DateTime.UtcNow;
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
return new AetheriaRuntimeTradeItemDetailsSurfaceState(
|
||||
"",
|
||||
"",
|
||||
manufacturer ?? "",
|
||||
"",
|
||||
0,
|
||||
"",
|
||||
"",
|
||||
Array.Empty<AetheriaRuntimeTradeItemSection>(),
|
||||
updatedAtUtc.ToString("O", CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
var itemName = item?.Name ?? "";
|
||||
var description = item?.Description ?? "";
|
||||
manufacturer ??= "";
|
||||
var mass = item == null ? "" : FormatValue(item.Mass, formatValue);
|
||||
var price = item?.Price ?? 0;
|
||||
var durability = "";
|
||||
var thermalRange = "";
|
||||
var behaviorSections = Array.Empty<AetheriaRuntimeTradeItemSection>();
|
||||
if (!string.IsNullOrWhiteSpace(item.HardpointType))
|
||||
if (!string.IsNullOrWhiteSpace(item?.HardpointType))
|
||||
{
|
||||
durability = FormatValue(item.Durability, formatValue);
|
||||
thermalRange = FormatTemperatureRange(item, formatTemperature);
|
||||
behaviorSections = ProjectBehaviorSections(item, formatValue, formatTemperature).ToArray();
|
||||
}
|
||||
|
||||
return new AetheriaRuntimeTradeItemDetailsSurfaceState(
|
||||
item.Name,
|
||||
item.Description ?? "",
|
||||
manufacturer ?? "",
|
||||
FormatValue(item.Mass, formatValue),
|
||||
item.Price,
|
||||
durability,
|
||||
thermalRange,
|
||||
behaviorSections,
|
||||
updatedAtUtc.ToString("O", CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeSurfaceDocument Build(
|
||||
AetheriaRuntimeTradeItemDetailsSurfaceState state,
|
||||
long version = 1)
|
||||
{
|
||||
state ??= new AetheriaRuntimeTradeItemDetailsSurfaceState(
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
"",
|
||||
"",
|
||||
Array.Empty<AetheriaRuntimeTradeItemSection>(),
|
||||
"");
|
||||
var hasEquipmentStatus = !string.IsNullOrWhiteSpace(durability) ||
|
||||
!string.IsNullOrWhiteSpace(thermalRange) ||
|
||||
behaviorSections.Length > 0;
|
||||
var updated = updatedAtUtc.ToString("O", CultureInfo.InvariantCulture);
|
||||
|
||||
var children = new List<AetheriaRuntimeSurfaceComponent>
|
||||
{
|
||||
Card(
|
||||
$"{SurfaceId}.summary",
|
||||
state.ItemName,
|
||||
itemName,
|
||||
Text(
|
||||
$"{SurfaceId}.description",
|
||||
string.IsNullOrWhiteSpace(state.Description)
|
||||
string.IsNullOrWhiteSpace(description)
|
||||
? "No typed item description is available."
|
||||
: state.Description),
|
||||
: description),
|
||||
Text(
|
||||
$"{SurfaceId}.note",
|
||||
"The observing client supplies the selected market row; the shared runtime surface owns trade item inspection layout."),
|
||||
Metric($"{SurfaceId}.manufacturer", "Manufacturer", state.Manufacturer),
|
||||
Metric($"{SurfaceId}.mass", "Mass", state.Mass),
|
||||
Metric($"{SurfaceId}.price", "Price", state.Price.ToString("N0")))
|
||||
Metric($"{SurfaceId}.manufacturer", "Manufacturer", manufacturer),
|
||||
Metric($"{SurfaceId}.mass", "Mass", mass),
|
||||
Metric($"{SurfaceId}.price", "Price", price.ToString("N0")))
|
||||
};
|
||||
|
||||
if (state.HasEquipmentStatus)
|
||||
if (hasEquipmentStatus)
|
||||
{
|
||||
children.Add(Card(
|
||||
$"{SurfaceId}.durability.card",
|
||||
"Durability",
|
||||
Metric($"{SurfaceId}.durability", "Max Durability", state.Durability),
|
||||
Metric($"{SurfaceId}.temperature_range", "Thermal Range", state.ThermalRange)));
|
||||
Metric($"{SurfaceId}.durability", "Max Durability", durability),
|
||||
Metric($"{SurfaceId}.temperature_range", "Thermal Range", thermalRange)));
|
||||
}
|
||||
|
||||
foreach (var section in state.BehaviorSections)
|
||||
foreach (var section in behaviorSections)
|
||||
{
|
||||
if (section?.Metrics == null || section.Metrics.Count == 0)
|
||||
continue;
|
||||
|
|
@ -210,7 +123,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
providerKind: "trade.menu",
|
||||
title: "Trade Item Details",
|
||||
version: version,
|
||||
updatedAtUtc: state.UpdatedAtUtc,
|
||||
updatedAtUtc: updated,
|
||||
surface: new AetheriaRuntimeSurfaceTree(
|
||||
SurfaceId,
|
||||
Node(
|
||||
|
|
|
|||
Loading…
Reference in a new issue