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:
@@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SVSim.Bootstrap.Importers;
|
||||
using SVSim.Database;
|
||||
using SVSim.Database.Enums;
|
||||
using SVSim.UnitTests.Infrastructure;
|
||||
|
||||
namespace SVSim.UnitTests.Importers;
|
||||
@@ -40,7 +41,7 @@ public class AchievementCatalogImporterTests
|
||||
{
|
||||
AchievementType = 12, Level = 99,
|
||||
Name = "Reach level 999 in Swordcraft (synthetic)", RequireNumber = 999,
|
||||
RewardType = 5, RewardDetailId = 100211062, RewardNumber = 3, OrderNum = 10,
|
||||
RewardType = (UserGoodsType)5, RewardDetailId = 100211062, RewardNumber = 3, OrderNum = 10,
|
||||
EventType = "class_level_up:swordcraft", EventArg = null,
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
@@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SVSim.Bootstrap.Importers;
|
||||
using SVSim.Database;
|
||||
using SVSim.Database.Enums;
|
||||
using SVSim.UnitTests.Infrastructure;
|
||||
|
||||
namespace SVSim.UnitTests.Importers;
|
||||
@@ -32,12 +33,12 @@ public class ArenaTwoPickRewardImporterTests
|
||||
|
||||
var w0 = rows.Where(r => r.WinCount == 0).ToList();
|
||||
Assert.That(w0.Count, Is.EqualTo(2));
|
||||
Assert.That(w0.Single(r => r.RewardType == 4).RewardNum, Is.EqualTo(1));
|
||||
Assert.That(w0.Single(r => r.RewardType == 9).RewardNum, Is.EqualTo(100));
|
||||
Assert.That(w0.Single(r => r.RewardType == (UserGoodsType)4).RewardNum, Is.EqualTo(1));
|
||||
Assert.That(w0.Single(r => r.RewardType == (UserGoodsType)9).RewardNum, Is.EqualTo(100));
|
||||
|
||||
var w5 = rows.Where(r => r.WinCount == 5).ToList();
|
||||
Assert.That(w5.Single(r => r.RewardType == 4).RewardNum, Is.EqualTo(1));
|
||||
Assert.That(w5.Single(r => r.RewardType == 9).RewardNum, Is.EqualTo(1000));
|
||||
Assert.That(w5.Single(r => r.RewardType == (UserGoodsType)4).RewardNum, Is.EqualTo(1));
|
||||
Assert.That(w5.Single(r => r.RewardType == (UserGoodsType)9).RewardNum, Is.EqualTo(1000));
|
||||
|
||||
// New columns: all rows should have weight=1 and win5 should span 2 distinct groups.
|
||||
Assert.That(w5.All(r => r.Weight == 1), "all win5 rows should have Weight=1");
|
||||
|
||||
@@ -65,7 +65,7 @@ public class BattlePassRewardImporterTests
|
||||
db.BattlePassRewards.Add(new SVSim.Database.Models.BattlePassRewardEntry
|
||||
{
|
||||
Id = 230_099, // MakeId(23, Normal=0, 99) == 23*10_000 + 0*1_000 + 99
|
||||
SeasonId = 23, Track = BattlePassTrack.Normal, Level = 99, RewardType = 9,
|
||||
SeasonId = 23, Track = BattlePassTrack.Normal, Level = 99, RewardType = (UserGoodsType)9,
|
||||
RewardDetailId = 0, RewardNumber = 9999, IsAppealExclusion = false,
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
@@ -93,7 +93,7 @@ public class BattlePassRewardImporterTests
|
||||
});
|
||||
db.BattlePassRewards.Add(new SVSim.Database.Models.BattlePassRewardEntry
|
||||
{
|
||||
SeasonId = 22, Track = BattlePassTrack.Normal, Level = 1, RewardType = 9,
|
||||
SeasonId = 22, Track = BattlePassTrack.Normal, Level = 1, RewardType = (UserGoodsType)9,
|
||||
RewardDetailId = 0, RewardNumber = 100, IsAppealExclusion = false,
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
@@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SVSim.Bootstrap.Importers;
|
||||
using SVSim.Database;
|
||||
using SVSim.Database.Enums;
|
||||
using SVSim.UnitTests.Infrastructure;
|
||||
|
||||
namespace SVSim.UnitTests.Importers;
|
||||
@@ -58,7 +59,7 @@ public class MissionCatalogImporterTests
|
||||
db.MissionCatalog.Add(new SVSim.Database.Models.MissionCatalogEntry
|
||||
{
|
||||
Id = 99999, Name = "preserved", LotType = 2,
|
||||
RequireNumber = 1, RewardType = 9, RewardDetailId = 0, RewardNumber = 10,
|
||||
RequireNumber = 1, RewardType = (UserGoodsType)9, RewardDetailId = 0, RewardNumber = 10,
|
||||
BattlePassPoint = 0, DefaultFlag = false, StartTime = 0,
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
@@ -53,7 +53,7 @@ public class PuzzleSeedingPipelineTests
|
||||
Assert.That(round1.TargetPuzzleGroupId, Is.EqualTo(301));
|
||||
Assert.That(round1.AchievedMessage, Is.EqualTo("Cleared all Round 1 puzzles"));
|
||||
Assert.That(round1.RequireNumber, Is.EqualTo(3));
|
||||
Assert.That(round1.RewardType, Is.EqualTo(10)); // LeaderSkin
|
||||
Assert.That((int)round1.RewardType, Is.EqualTo(10)); // LeaderSkin
|
||||
Assert.That(round1.RewardDetailId, Is.EqualTo(3704L)); // chara_id matching group 301
|
||||
Assert.That(round1.RewardNumber, Is.EqualTo(1));
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SVSim.Bootstrap.Importers;
|
||||
using SVSim.Database;
|
||||
using SVSim.Database.Enums;
|
||||
using SVSim.Database.Models;
|
||||
using SVSim.UnitTests.Infrastructure;
|
||||
|
||||
@@ -72,7 +73,7 @@ public class SleeveShopImporterTests
|
||||
int originalCount = product.Rewards.Count;
|
||||
product.Rewards.Add(new SleeveShopProductRewardEntry
|
||||
{
|
||||
OrderIndex = 99, RewardType = 99, RewardDetailId = 99, RewardNumber = 99,
|
||||
OrderIndex = 99, RewardType = (UserGoodsType)99, RewardDetailId = 99, RewardNumber = 99,
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
@@ -82,6 +83,6 @@ public class SleeveShopImporterTests
|
||||
.Include(p => p.Rewards)
|
||||
.FirstAsync(p => p.Id == product.Id);
|
||||
Assert.That(reloaded.Rewards.Count, Is.EqualTo(originalCount), "extra reward should be wiped on re-import");
|
||||
Assert.That(reloaded.Rewards.Any(r => r.RewardType == 99), Is.False);
|
||||
Assert.That(reloaded.Rewards.Any(r => r.RewardType == (UserGoodsType)99), Is.False);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user