refactor(campaign): delegate gift-reward-type check to GiftRewardTypes

Delete local IsSupportedGiftRewardType and replace its single call site with
GiftRewardTypes.IsSupported — Card (5) and Sleeve (6) are now accepted.
Update unsupported-type test sentinel from 5 (Card) to 11 (SpotCard).
Add Card and Sleeve success-path tests; full suite 1152/1152.
This commit is contained in:
gamer147
2026-06-09 20:52:47 -04:00
parent b2a5b69423
commit 742058403c
2 changed files with 58 additions and 11 deletions

View File

@@ -4,6 +4,7 @@ using SVSim.Database;
using SVSim.Database.Enums;
using SVSim.Database.Models;
using SVSim.EmulatedEntrypoint.Models.Dtos.Campaign;
using SVSim.EmulatedEntrypoint.Services;
namespace SVSim.EmulatedEntrypoint.Controllers;
@@ -41,7 +42,7 @@ public sealed class CampaignController : SVSimController
.AnyAsync(r => r.ViewerId == viewerId && r.SerialCodeId == code.Id, ct);
if (alreadyRedeemed) return Fail();
if (code.Rewards.Any(r => !IsSupportedGiftRewardType(r.RewardType))) return Fail();
if (code.Rewards.Any(r => !GiftRewardTypes.IsSupported(r.RewardType))) return Fail();
try
{
@@ -82,12 +83,4 @@ public sealed class CampaignController : SVSimController
private IActionResult Fail() => Ok(new { result_code = FailureResultCode });
/// <summary>
/// Gift wire types per <c>GiftController.WireRewardTypeToUserGoodsType</c>:
/// 1=Crystal, 4=Item, 9=Rupy. Codes with unsupported types fail-fast at redemption.
/// Note: wire "1" means Crystal (not RedEther), following the gift wire convention
/// rather than the <see cref="UserGoodsType"/> enum order.
/// </summary>
private static bool IsSupportedGiftRewardType(int rewardType) =>
rewardType is 1 or 4 or 9;
}