feat(tk2): weighted-group reward picking
Replaces the all-rows-granted reward model with per-group weighted pick. Each ArenaTwoPickReward row now belongs to a RewardGroup with a Weight; finish/retire groups the WinCount's rows by RewardGroup and picks exactly one row per group, weighted by Weight (excluding Weight==0). A RewardNum==0 outcome skips both the grant and the rewards[] emission. Empty WinCount catalogs emit empty arrays. Existing seed entries preserve deterministic behavior by living in single-option groups (each with weight 1). Future seasons can expand groups to multi-option for true randomized rewards (e.g. 200-280 rupies). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ namespace SVSim.Bootstrap.Importers;
|
||||
|
||||
/// <summary>
|
||||
/// Idempotent upsert of <see cref="ArenaTwoPickReward"/> rows from
|
||||
/// <c>arena-two-pick-rewards.json</c>. Key = (WinCount, RewardType, RewardId).
|
||||
/// <c>arena-two-pick-rewards.json</c>. Key = (WinCount, RewardGroup, RewardType, RewardId, RewardNum).
|
||||
/// </summary>
|
||||
public class ArenaTwoPickRewardImporter
|
||||
{
|
||||
@@ -22,23 +22,25 @@ public class ArenaTwoPickRewardImporter
|
||||
|
||||
var seeds = SeedLoader.LoadList<ArenaTwoPickRewardSeed>(path);
|
||||
var existing = await context.ArenaTwoPickRewards
|
||||
.ToDictionaryAsync(r => (r.WinCount, r.RewardType, r.RewardId));
|
||||
.ToDictionaryAsync(r => (r.WinCount, r.RewardGroup, r.RewardType, r.RewardId, r.RewardNum));
|
||||
|
||||
int upserted = 0;
|
||||
foreach (var s in seeds)
|
||||
{
|
||||
if (existing.TryGetValue((s.WinCount, s.RewardType, s.RewardId), out var row))
|
||||
if (existing.TryGetValue((s.WinCount, s.RewardGroup, s.RewardType, s.RewardId, s.RewardNum), out var row))
|
||||
{
|
||||
row.RewardNum = s.RewardNum;
|
||||
row.Weight = s.Weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.ArenaTwoPickRewards.Add(new ArenaTwoPickReward
|
||||
{
|
||||
WinCount = s.WinCount,
|
||||
RewardType = s.RewardType,
|
||||
RewardId = s.RewardId,
|
||||
RewardNum = s.RewardNum,
|
||||
WinCount = s.WinCount,
|
||||
RewardGroup = s.RewardGroup,
|
||||
Weight = s.Weight,
|
||||
RewardType = s.RewardType,
|
||||
RewardId = s.RewardId,
|
||||
RewardNum = s.RewardNum,
|
||||
});
|
||||
}
|
||||
upserted++;
|
||||
|
||||
Reference in New Issue
Block a user