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:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user