feat(sleeve): shop catalog + /sleeve/{info,buy} endpoints
Schema: SleeveShopSeries -> SleeveShopProducts -> Rewards (owned).
Migration AddSleeveShop creates 3 tables with FK cascade.
Importer mirrors BuildDeck pattern: find-or-create per series/product,
rewards replaced wholesale on rerun (owned collection). 10 series,
270 products imported from seeds/sleeve-shop.json.
Controller:
- /sleeve/info returns wire-faithful dict-keyed shape
({sleeve_list: {<series_id>: {product_info: {<product_id>: ...}}}}).
is_purchased_product derived from viewer.Sleeves.Contains(sleeve_id).
- /sleeve/buy: sales_type 0=free / 1=crystal / 2=rupy / 3=ticket(501).
Validates series_product mismatch, currency, already-purchased.
Currency debited with post-state-total reward_list entry; cosmetic
grants dispatched through RewardGrantService.ApplyAsync (covers
sleeve + emblem bundled grants per product).
476 tests pass (was 466; +10 sleeve tests).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using MessagePack;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests.Sleeve;
|
||||
|
||||
/// <summary>
|
||||
/// /sleeve/buy request body. sales_type is ShopCommonUtility.SalesType:
|
||||
/// 0=free, 1=crystal, 2=rupy, 3=ticket (v1: 3 returns 501, no ticket-priced sleeve captured).
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public class SleeveBuyRequest : BaseRequest
|
||||
{
|
||||
[JsonPropertyName("series_id")]
|
||||
[Key("series_id")]
|
||||
public int SeriesId { get; set; }
|
||||
|
||||
[JsonPropertyName("product_id")]
|
||||
[Key("product_id")]
|
||||
public int ProductId { get; set; }
|
||||
|
||||
[JsonPropertyName("sales_type")]
|
||||
[Key("sales_type")]
|
||||
public int SalesType { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using MessagePack;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses.Sleeve;
|
||||
|
||||
/// <summary>
|
||||
/// /sleeve/buy response. <c>reward_list</c> items use reward_id/reward_num
|
||||
/// (POST-STATE-TOTAL for currencies, grant id+count for cosmetics) — driven by
|
||||
/// <c>PlayerStaticData.UpdateHaveUserGoodsNumByJsonData</c>. Mirrors the /pack/open +
|
||||
/// /build_deck/buy reward_list semantics.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public class SleeveBuyResponse
|
||||
{
|
||||
[JsonPropertyName("reward_list")]
|
||||
[Key("reward_list")]
|
||||
public List<RewardListEntry> RewardList { get; set; } = new();
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using MessagePack;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses.Sleeve;
|
||||
|
||||
/// <summary>
|
||||
/// /sleeve/info response. Wire shape: <c>{sleeve_list: {<series_id_str>: SleeveSeriesDto}}</c>.
|
||||
/// Dict-keyed (not array) to match the prod capture exactly — LitJson's numeric indexer in
|
||||
/// <c>SleevePurchaseInfoTask.Parse()</c> iterates dict values by inserted order, so either
|
||||
/// shape would work, but mirroring the wire avoids surprise.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public class SleeveInfoResponse
|
||||
{
|
||||
[JsonPropertyName("sleeve_list")]
|
||||
[Key("sleeve_list")]
|
||||
public Dictionary<string, SleeveSeriesDto> SleeveList { get; set; } = new();
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class SleeveSeriesDto
|
||||
{
|
||||
[JsonPropertyName("series_id")]
|
||||
[Key("series_id")]
|
||||
public int SeriesId { get; set; }
|
||||
|
||||
[JsonPropertyName("is_new")]
|
||||
[Key("is_new")]
|
||||
public bool IsNew { get; set; }
|
||||
|
||||
/// <summary>Dict keyed by product_id string — same iteration convention as sleeve_list.</summary>
|
||||
[JsonPropertyName("product_info")]
|
||||
[Key("product_info")]
|
||||
public Dictionary<string, SleeveProductDto> ProductInfo { get; set; } = new();
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class SleeveProductDto
|
||||
{
|
||||
[JsonPropertyName("product_id")]
|
||||
[Key("product_id")]
|
||||
public int ProductId { get; set; }
|
||||
|
||||
/// <summary>SystemText key (e.g. "sleeve_138") — client resolves via GetSleeveProductText.</summary>
|
||||
[JsonPropertyName("name")]
|
||||
[Key("name")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("rewards")]
|
||||
[Key("rewards")]
|
||||
public List<SleeveProductRewardDto> Rewards { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("sales_period_info")]
|
||||
[Key("sales_period_info")]
|
||||
public List<object> SalesPeriodInfo { get; set; } = new(); // always [] in v1
|
||||
|
||||
[JsonPropertyName("is_purchased_product")]
|
||||
[Key("is_purchased_product")]
|
||||
public bool IsPurchasedProduct { get; set; }
|
||||
|
||||
[JsonPropertyName("price_crystal")]
|
||||
[Key("price_crystal")]
|
||||
public int? PriceCrystal { get; set; }
|
||||
|
||||
[JsonPropertyName("price_rupy")]
|
||||
[Key("price_rupy")]
|
||||
public int? PriceRupy { get; set; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class SleeveProductRewardDto
|
||||
{
|
||||
[JsonPropertyName("reward_type")]
|
||||
[Key("reward_type")]
|
||||
public int RewardType { get; set; }
|
||||
|
||||
[JsonPropertyName("reward_detail_id")]
|
||||
[Key("reward_detail_id")]
|
||||
public long RewardDetailId { get; set; }
|
||||
|
||||
[JsonPropertyName("reward_number")]
|
||||
[Key("reward_number")]
|
||||
public int RewardNumber { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user