refactor: type reward_type columns as UserGoodsType enum
Replace bare `int RewardType` on 12 catalog/reward entities and GrantedReward
with the existing UserGoodsType enum. Verified against the decompiled client:
every wire reward_type decodes through the single Wizard.UserGoods.Type enum, so
one enum is correct across all endpoint families (item_type is a separate
Item.Type axis, left untouched). EF stores the enum as the same int column, so
there is no migration.
- Importers cast seed int -> UserGoodsType at the ingest boundary.
- New GrantedReward.ToRewardList() extension replaces 8 copy-pasted
GrantedReward -> RewardListEntry projections.
- Fix 3 .ToString() sites that would otherwise emit enum names ("Crystal")
instead of the int wire value ("2").
- Wire DTOs keep int; the enum is widened to int at the wire boundary only.
Build green; 962/962 tests pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -110,11 +110,11 @@ public class ArenaTwoPickServiceWeightedRewardsTests
|
||||
// Seed catalog: two rows, same group, same WinCount=3.
|
||||
db.ArenaTwoPickRewards.Add(new ArenaTwoPickReward
|
||||
{
|
||||
WinCount = 3, RewardGroup = 1, Weight = 1, RewardType = 9, RewardId = 0, RewardNum = 100
|
||||
WinCount = 3, RewardGroup = 1, Weight = 1, RewardType = (UserGoodsType)9, RewardId = 0, RewardNum = 100
|
||||
});
|
||||
db.ArenaTwoPickRewards.Add(new ArenaTwoPickReward
|
||||
{
|
||||
WinCount = 3, RewardGroup = 1, Weight = 9, RewardType = 9, RewardId = 0, RewardNum = 999
|
||||
WinCount = 3, RewardGroup = 1, Weight = 9, RewardType = (UserGoodsType)9, RewardId = 0, RewardNum = 999
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
@@ -134,11 +134,11 @@ public class ArenaTwoPickServiceWeightedRewardsTests
|
||||
|
||||
db.ArenaTwoPickRewards.Add(new ArenaTwoPickReward
|
||||
{
|
||||
WinCount = 2, RewardGroup = 1, Weight = 0, RewardType = 9, RewardId = 0, RewardNum = 9999
|
||||
WinCount = 2, RewardGroup = 1, Weight = 0, RewardType = (UserGoodsType)9, RewardId = 0, RewardNum = 9999
|
||||
});
|
||||
db.ArenaTwoPickRewards.Add(new ArenaTwoPickReward
|
||||
{
|
||||
WinCount = 2, RewardGroup = 1, Weight = 1, RewardType = 9, RewardId = 0, RewardNum = 500
|
||||
WinCount = 2, RewardGroup = 1, Weight = 1, RewardType = (UserGoodsType)9, RewardId = 0, RewardNum = 500
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
@@ -158,7 +158,7 @@ public class ArenaTwoPickServiceWeightedRewardsTests
|
||||
|
||||
db.ArenaTwoPickRewards.Add(new ArenaTwoPickReward
|
||||
{
|
||||
WinCount = 1, RewardGroup = 1, Weight = 1, RewardType = 9, RewardId = 0, RewardNum = 0
|
||||
WinCount = 1, RewardGroup = 1, Weight = 1, RewardType = (UserGoodsType)9, RewardId = 0, RewardNum = 0
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
@@ -189,7 +189,7 @@ public class ArenaTwoPickServiceWeightedRewardsTests
|
||||
// still satisfies the >=5 check so Retire works regardless).
|
||||
db.ArenaTwoPickRewards.Add(new ArenaTwoPickReward
|
||||
{
|
||||
WinCount = 0, RewardGroup = 1, Weight = 1, RewardType = 9, RewardId = 0, RewardNum = 50
|
||||
WinCount = 0, RewardGroup = 1, Weight = 1, RewardType = (UserGoodsType)9, RewardId = 0, RewardNum = 50
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
|
||||
@@ -40,13 +40,13 @@ public class BattlePassServiceTests
|
||||
db.BattlePassRewards.Add(new BattlePassRewardEntry
|
||||
{
|
||||
Id = MakeRewardId(23, BattlePassTrack.Normal, 2),
|
||||
SeasonId = 23, Track = BattlePassTrack.Normal, Level = 2, RewardType = 9,
|
||||
SeasonId = 23, Track = BattlePassTrack.Normal, Level = 2, RewardType = (UserGoodsType)9,
|
||||
RewardDetailId = 0, RewardNumber = 50, IsAppealExclusion = false,
|
||||
});
|
||||
db.BattlePassRewards.Add(new BattlePassRewardEntry
|
||||
{
|
||||
Id = MakeRewardId(23, BattlePassTrack.Premium, 2),
|
||||
SeasonId = 23, Track = BattlePassTrack.Premium, Level = 2, RewardType = 9,
|
||||
SeasonId = 23, Track = BattlePassTrack.Premium, Level = 2, RewardType = (UserGoodsType)9,
|
||||
RewardDetailId = 0, RewardNumber = 20, IsAppealExclusion = false,
|
||||
});
|
||||
if (isPremium)
|
||||
@@ -75,7 +75,7 @@ public class BattlePassServiceTests
|
||||
Assert.That(grant.AfterLevel, Is.EqualTo(2));
|
||||
Assert.That(grant.PointAdd, Is.EqualTo(500));
|
||||
Assert.That(grant.NewlyClaimed.Count, Is.EqualTo(1), "premium level-2 must be skipped");
|
||||
Assert.That(grant.NewlyClaimed[0].RewardType, Is.EqualTo((int)UserGoodsType.Rupy));
|
||||
Assert.That(grant.NewlyClaimed[0].RewardType, Is.EqualTo(UserGoodsType.Rupy));
|
||||
Assert.That(grant.NewlyClaimed[0].RewardNum, Is.EqualTo(50), "post-state rupy total");
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public class InventoryCommitTests
|
||||
await tx.GrantAsync(UserGoodsType.Crystal, 0, 200);
|
||||
var result = await tx.CommitAsync();
|
||||
|
||||
var crystals = result.RewardList.Where(r => r.RewardType == (int)UserGoodsType.Crystal).ToList();
|
||||
var crystals = result.RewardList.Where(r => r.RewardType == UserGoodsType.Crystal).ToList();
|
||||
Assert.That(crystals, Has.Count.EqualTo(1));
|
||||
Assert.That(crystals[0].RewardNum, Is.EqualTo(700), "spend 500 then grant 200 → 1000-500+200=700, grant's post-state wins");
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class InventoryCommitTests
|
||||
await tx.TrySpendAsync(SpendCurrency.Crystal, 500);
|
||||
var result = await tx.CommitAsync();
|
||||
|
||||
var crystals = result.RewardList.Where(r => r.RewardType == (int)UserGoodsType.Crystal).ToList();
|
||||
var crystals = result.RewardList.Where(r => r.RewardType == UserGoodsType.Crystal).ToList();
|
||||
Assert.That(crystals, Has.Count.EqualTo(1));
|
||||
Assert.That(crystals[0].RewardNum, Is.EqualTo(700));
|
||||
}
|
||||
@@ -97,8 +97,8 @@ public class InventoryCommitTests
|
||||
var result = await tx.CommitAsync();
|
||||
|
||||
Assert.That(result.Deltas, Has.Count.EqualTo(1), "verbatim — card only, no cascade");
|
||||
Assert.That(result.Deltas[0].RewardType, Is.EqualTo((int)UserGoodsType.Card));
|
||||
Assert.That(result.RewardList.Any(e => e.RewardType == (int)UserGoodsType.Sleeve), Is.True,
|
||||
Assert.That(result.Deltas[0].RewardType, Is.EqualTo(UserGoodsType.Card));
|
||||
Assert.That(result.RewardList.Any(e => e.RewardType == UserGoodsType.Sleeve), Is.True,
|
||||
"cascade appears in RewardList but not Deltas");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class InventoryGrantCardTests
|
||||
var granted = await tx.GrantAsync(UserGoodsType.Card, cardId, 2);
|
||||
|
||||
Assert.That(granted, Has.Count.EqualTo(1));
|
||||
Assert.That(granted[0].RewardType, Is.EqualTo((int)UserGoodsType.Card));
|
||||
Assert.That(granted[0].RewardType, Is.EqualTo(UserGoodsType.Card));
|
||||
Assert.That(granted[0].RewardId, Is.EqualTo(cardId));
|
||||
Assert.That(granted[0].RewardNum, Is.EqualTo(2));
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class InventoryGrantCardTests
|
||||
var granted = await tx.GrantAsync(UserGoodsType.Card, cardId, 1);
|
||||
|
||||
Assert.That(granted, Has.Count.EqualTo(2));
|
||||
Assert.That(granted[1].RewardType, Is.EqualTo((int)UserGoodsType.Sleeve));
|
||||
Assert.That(granted[1].RewardType, Is.EqualTo(UserGoodsType.Sleeve));
|
||||
Assert.That(granted[1].RewardId, Is.EqualTo(sleeveId));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class InventoryGrantCosmeticTests
|
||||
var granted = await tx.GrantAsync(UserGoodsType.Sleeve, sleeveId, 1);
|
||||
|
||||
Assert.That(granted, Has.Count.EqualTo(1));
|
||||
Assert.That(granted[0].RewardType, Is.EqualTo((int)UserGoodsType.Sleeve));
|
||||
Assert.That(granted[0].RewardType, Is.EqualTo(UserGoodsType.Sleeve));
|
||||
Assert.That(granted[0].RewardId, Is.EqualTo(sleeveId));
|
||||
Assert.That(granted[0].RewardNum, Is.EqualTo(1));
|
||||
Assert.That(tx.Viewer.Sleeves.Any(s => s.Id == sleeveId), Is.True);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class InventoryGrantCurrencyTests
|
||||
var granted = await tx.GrantAsync(type, detailId: 0, num: 50);
|
||||
|
||||
Assert.That(granted, Has.Count.EqualTo(1));
|
||||
Assert.That(granted[0].RewardType, Is.EqualTo((int)type));
|
||||
Assert.That(granted[0].RewardType, Is.EqualTo(type));
|
||||
Assert.That(granted[0].RewardNum, Is.EqualTo(150));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SVSim.Database;
|
||||
using SVSim.Database.Enums;
|
||||
using SVSim.Database.Models;
|
||||
using SVSim.EmulatedEntrypoint.Services;
|
||||
using SVSim.UnitTests.Infrastructure;
|
||||
@@ -95,7 +96,7 @@ public class MissionProgressServiceTests
|
||||
db.AchievementCatalog.Add(new AchievementCatalogEntry
|
||||
{
|
||||
AchievementType = 31, Level = 3, Name = "Win 50 ranked matches",
|
||||
RequireNumber = 50, RewardType = 9, RewardDetailId = 0, RewardNumber = 20,
|
||||
RequireNumber = 50, RewardType = (UserGoodsType)9, RewardDetailId = 0, RewardNumber = 20,
|
||||
OrderNum = 18, EventType = "ranked_win", EventArg = null,
|
||||
});
|
||||
// Set viewer's current level to 3.
|
||||
|
||||
Reference in New Issue
Block a user