diff --git a/SVSim.EmulatedEntrypoint/Controllers/CardController.cs b/SVSim.EmulatedEntrypoint/Controllers/CardController.cs index 131d67c..ab01bb4 100644 --- a/SVSim.EmulatedEntrypoint/Controllers/CardController.cs +++ b/SVSim.EmulatedEntrypoint/Controllers/CardController.cs @@ -132,6 +132,24 @@ public class CardController : SVSimController _ => "malformed_request", }; + [HttpPost("protect")] + public async Task> Protect(CardProtectRequest request) + { + if (!TryGetViewerId(out long viewerId)) return Unauthorized(); + + var outcome = await _inventory.SetProtected(viewerId, request.CardId, request.IsProtected); + if (!outcome.IsSuccess) + { + return outcome.Error switch + { + ProtectError.UnknownCard => BadRequest(new { error = "unknown_card" }), + _ => BadRequest(new { error = "malformed_request" }), + }; + } + + return new CardProtectResponse(); + } + private static string ErrorKey(DestructError error) => error switch { DestructError.UnknownCard => "unknown_card", diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/Card/CardProtectRequest.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/Card/CardProtectRequest.cs new file mode 100644 index 0000000..2d99cac --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/Card/CardProtectRequest.cs @@ -0,0 +1,21 @@ +using MessagePack; +using System.Text.Json.Serialization; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests.Card; + +/// +/// POST /card/protect. Toggles the protected-card flag for a single card. The client (see +/// Wizard/CardProtectTask.cs) sends is_protected as a real boolean — the 0|1 int inconsistency +/// noted in the spec lives on the /load/index response side and is out of scope here. +/// +[MessagePackObject] +public class CardProtectRequest : BaseRequest +{ + [JsonPropertyName("card_id")] + [Key("card_id")] + public long CardId { get; set; } + + [JsonPropertyName("is_protected")] + [Key("is_protected")] + public bool IsProtected { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/Card/CardProtectResponse.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/Card/CardProtectResponse.cs new file mode 100644 index 0000000..eefd99b --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/Card/CardProtectResponse.cs @@ -0,0 +1,12 @@ +using MessagePack; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses.Card; + +/// +/// /card/protect response data — empty. The client just needs result_code=1 in the envelope's +/// data_headers; it mutates its own FavoriteCardList from its request-side knowledge. +/// +[MessagePackObject] +public class CardProtectResponse +{ +}