Files
SVSimServer/SVSim.Database/Models/SpotCardExchangeEntry.cs
gamer147 7ef5f03eb3 feat(spot-card-exchange): /spot_card_exchange/{top,exchange} + SpotPoints currency
Final shop family. Schema additions:
- ViewerCurrency.SpotPoints (ulong) — new currency column on Viewers.
- SpotCardExchangeEntry — catalog (distinct from the pre-existing
  SpotCardEntry, which is the /load/index rental-cost concept).
- ViewerSpotCardExchange — standalone composite-PK table tracking
  (viewer, card, exchanged_at, is_pre_release_snapshot). Standalone
  avoids cartesian-explode on viewer-graph reads.

RewardGrantService gains a SpotCardPoint=12 currency case mirroring
the RedEther/Crystal pattern. Doc comment refreshed; SpotCard=11 and
SpotCardOnlyLatestCardPack=13 remain unimplemented with explanatory
NotSupportedException — captures show emitters always use Card=5 with
the spot-card-specific id.

Controller:
- /top: emits exactly 9 clan buckets [{"1": [cards]}, ...] matching
  prod's arbitrary single-key shape. exchange_status per-card (0=
  available, 1=already-exchanged, 2=LimitOver after pre-release cap).
  pre_relase_info WIRE TYPO PRESERVED ("relase" not "release").
- /exchange: server-authoritative price (client-supplied
  exchange_point ignored); debits SpotPoints with post-state-total
  reward_list entry; grants card via RewardGrantService.ApplyAsync
  (cosmetic cascade included); persists ViewerSpotCardExchange row.
  Insufficient points / already-exchanged / pre-release-limit all
  return 400 without partial state.

LoadController now populates /load/index spot_point from
viewer.Currency.SpotPoints (was always 0).

PreReleaseLimit hardcoded to 2 matching capture; promote to GameConfig
when captures show variance.

504 tests pass (was 496; +8 spot-card-exchange tests).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 23:23:07 -04:00

31 lines
1.1 KiB
C#

using SVSim.Database.Common;
namespace SVSim.Database.Models;
/// <summary>
/// One catalog entry of the /spot_card_exchange/top shop — a card the viewer can buy with
/// spot points. PK = wire card_id. Distinct from <see cref="SpotCardEntry"/> (which is the
/// /load/index data.spot_cards rental-cost list — a different concept).
/// <para>
/// <see cref="TsRotationId"/> matches the card_set_id; cards cycle out of the exchange when
/// their set rotates. <see cref="IsPreRelease"/> distinguishes the pre-release-pool subset
/// gated by <c>pre_release_spot_card_exchange_limit</c>.
/// </para>
/// </summary>
public class SpotCardExchangeEntry : BaseEntity<long>
{
public long CardId { get => Id; set => Id = value; }
/// <summary>Wire <c>class</c> field — clan id (0=Neutral, 1=Forestcraft, ..., 8).</summary>
public int ClassId { get; set; }
public int ExchangePoint { get; set; }
/// <summary>Wire <c>ts_rotation_id</c> — card_set_id this card belongs to.</summary>
public long TsRotationId { get; set; }
public bool IsPreRelease { get; set; }
public bool IsEnabled { get; set; }
}