neon-sprawl/server/NeonSprawl.Server/Game/Targeting/TargetStateDtos.cs

64 lines
2.3 KiB
C#

using System.Text.Json.Serialization;
namespace NeonSprawl.Server.Game.Targeting;
/// <summary>JSON body for <c>GET /game/players/{{id}}/target</c> and nested <c>targetState</c> on select (NEO-23).</summary>
public sealed class PlayerTargetStateResponse
{
public const int CurrentSchemaVersion = 1;
[JsonPropertyName("schemaVersion")]
public int SchemaVersion { get; init; } = CurrentSchemaVersion;
[JsonPropertyName("playerId")]
public required string PlayerId { get; init; }
/// <summary>Lowercase registry id when locked; JSON <c>null</c> when no lock (key always serialized).</summary>
[JsonPropertyName("lockedTargetId")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public string? LockedTargetId { get; init; }
/// <summary>One of <see cref="TargetValidity"/> string constants.</summary>
[JsonPropertyName("validity")]
public required string Validity { get; init; }
[JsonPropertyName("sequence")]
public int Sequence { get; init; }
}
/// <summary>POST body for <c>POST /game/players/{{id}}/target/select</c> (NEO-23).</summary>
/// <remarks>
/// Omit <c>targetId</c> or send JSON <c>null</c> to clear the lock. Whitespace-only after trim → HTTP 400.
/// </remarks>
public sealed class TargetSelectRequest
{
public const int CurrentSchemaVersion = 1;
[JsonPropertyName("schemaVersion")]
public int SchemaVersion { get; init; }
/// <summary>Registry key after trim + case-insensitive lookup; <c>null</c> or omitted ⇒ clear intent.</summary>
[JsonPropertyName("targetId")]
public string? TargetId { get; init; }
}
/// <summary>POST response for target selection (NEO-23).</summary>
public sealed class TargetSelectResponse
{
public const int CurrentSchemaVersion = 1;
[JsonPropertyName("schemaVersion")]
public int SchemaVersion { get; init; } = CurrentSchemaVersion;
[JsonPropertyName("selectionApplied")]
public bool SelectionApplied { get; init; }
[JsonPropertyName("targetState")]
public required PlayerTargetStateResponse TargetState { get; init; }
/// <summary>Required when <see cref="SelectionApplied"/> is <c>false</c>; omitted on success.</summary>
[JsonPropertyName("reasonCode")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? ReasonCode { get; init; }
}