77 lines
2.6 KiB
C#
77 lines
2.6 KiB
C#
using System.Text.Json.Serialization;
|
|
|
|
namespace NeonSprawl.Server.Game.Items;
|
|
|
|
/// <summary>JSON body for <c>GET /game/players/{{id}}/inventory</c> (NEO-55).</summary>
|
|
public sealed class PlayerInventorySnapshotResponse
|
|
{
|
|
public const int CurrentSchemaVersion = 1;
|
|
|
|
[JsonPropertyName("schemaVersion")]
|
|
public int SchemaVersion { get; init; } = CurrentSchemaVersion;
|
|
|
|
[JsonPropertyName("playerId")]
|
|
public required string PlayerId { get; init; }
|
|
|
|
/// <summary>Fixed bag slots 0..23 in ascending order.</summary>
|
|
[JsonPropertyName("bagSlots")]
|
|
public required IReadOnlyList<InventorySlotStateJson> BagSlots { get; init; }
|
|
|
|
/// <summary>Fixed equipment slot index 0.</summary>
|
|
[JsonPropertyName("equipmentSlots")]
|
|
public required IReadOnlyList<InventorySlotStateJson> EquipmentSlots { get; init; }
|
|
}
|
|
|
|
/// <summary>POST body for inventory add/remove (NEO-55).</summary>
|
|
public sealed class PlayerInventoryMutationRequest
|
|
{
|
|
public const int CurrentSchemaVersion = 1;
|
|
|
|
[JsonPropertyName("schemaVersion")]
|
|
public int SchemaVersion { get; init; }
|
|
|
|
/// <remarks><c>add</c> or <c>remove</c> (ordinal ignore-case).</remarks>
|
|
[JsonPropertyName("mutationKind")]
|
|
public required string MutationKind { get; init; }
|
|
|
|
[JsonPropertyName("itemId")]
|
|
public required string ItemId { get; init; }
|
|
|
|
[JsonPropertyName("quantity")]
|
|
public int Quantity { get; init; }
|
|
}
|
|
|
|
/// <summary>POST response for inventory mutations — applied or structured deny (NEO-55).</summary>
|
|
public sealed class PlayerInventoryMutationResponse
|
|
{
|
|
public const int CurrentSchemaVersion = 1;
|
|
|
|
[JsonPropertyName("schemaVersion")]
|
|
public int SchemaVersion { get; init; } = CurrentSchemaVersion;
|
|
|
|
[JsonPropertyName("applied")]
|
|
public bool Applied { get; init; }
|
|
|
|
/// <remarks><c>null</c> on success; stable snake_case deny codes from <see cref="PlayerInventoryReasonCodes"/> on deny.</remarks>
|
|
[JsonPropertyName("reasonCode")]
|
|
public string? ReasonCode { get; init; }
|
|
|
|
[JsonPropertyName("inventory")]
|
|
public required PlayerInventorySnapshotResponse Inventory { get; init; }
|
|
}
|
|
|
|
/// <summary>Wire shape for one inventory slot in GET/POST responses.</summary>
|
|
public sealed class InventorySlotStateJson
|
|
{
|
|
[JsonPropertyName("slotIndex")]
|
|
public int SlotIndex { get; init; }
|
|
|
|
/// <summary>Omitted when the slot is empty.</summary>
|
|
[JsonPropertyName("itemId")]
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
public string? ItemId { get; init; }
|
|
|
|
[JsonPropertyName("quantity")]
|
|
public int Quantity { get; init; }
|
|
}
|