feat(arena-colosseum): 2-pick + curated deck sources (phase 3)
Closes the family. arena-colosseum 10/16 → 15/16 zero stubs (the 16th —
finish_load — is dead per project_dead_battle_endpoints).
* 2-Pick draft lift onto ArenaColosseumController:
- get_candidate_classes samples from ArenaTwoPickConfig.AllowedClassIds
and persists the slate onto the run.
- class_choose accepts class_id XOR chaos_id; both populate run.ClassId,
chaos branch stores ChaosId for replay.
- get_candidate_cards is the idempotent draft-resume snapshot.
- card_choose appends both cards from the picked pair, advances turn 1..15.
- Pool override: ArenaTwoPickCardPoolService gets a non-breaking
GeneratePickSetsForTurn(..., poolCardSetIds) overload; Colosseum routes
pass ColosseumSeasonConfig.PoolCardSetIds (falls back to challenge →
rotation when empty).
* Curated-deck schema: ColosseumHofDeck / ColosseumWindFallDeck /
ColosseumAvatarDeck — three identical tables (separate per per-pool
operational lifecycle), unique on DeckNo. Migration AddColosseumCuratedDecks.
* IColosseumCuratedDeck interface + a generic ColosseumCuratedDeckImporterBase<T>
with three concrete subclasses (HOF / WindFall / Avatar), registered in
Bootstrap. Seed files ship empty.
* 6 curated endpoints on ArenaColosseumController: get_{hof|windfall|avatar}_deck_list
return BARE-ARRAY data per spec; register_{hof|windfall|avatar}_deck share
one generic RegisterCuratedAsync<T> dispatcher. Cross-pool register
rejected via per-pool lookup. Curated register has no is_published flag
(constructed-only) — clears the run's flag for state consistency.
* Tests: 5 draft HTTP tests + 11 curated-deck HTTP tests (4 parameterized
3 ways across HOF/WindFall/Avatar + a cross-pool isolation test + an
is_published clear test). Existing TwoPick service tests updated for the
new pool overload. Full suite: 1347/1347.
Phase 3 ship gate met. Branch ready for merge.
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SVSim.Database;
|
||||
using SVSim.Database.Models;
|
||||
|
||||
namespace SVSim.Bootstrap.Importers;
|
||||
|
||||
/// <summary>
|
||||
/// Shared upsert path for the three Colosseum curated-deck pools. Each subclass binds the
|
||||
/// EF entity type + the seed filename; the load + key + diff logic lives here. Empty seed
|
||||
/// files are non-fatal — the pools ship empty by default per the plan (admins fill them
|
||||
/// per-event).
|
||||
/// </summary>
|
||||
public abstract class ColosseumCuratedDeckImporterBase<TEntity>
|
||||
where TEntity : class, IColosseumCuratedDeck, new()
|
||||
{
|
||||
protected abstract string SeedFileName { get; }
|
||||
|
||||
public async Task<int> ImportAsync(SVSimDbContext context, string seedDir)
|
||||
{
|
||||
var path = Path.Combine(seedDir, SeedFileName);
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Console.WriteLine($"[{GetType().Name}] missing {path}; skipping.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
var seeds = SeedLoader.LoadList<ColosseumCuratedDeckSeed>(path);
|
||||
var set = context.Set<TEntity>();
|
||||
var existing = await set.ToDictionaryAsync(d => d.DeckNo);
|
||||
|
||||
int upserted = 0;
|
||||
foreach (var s in seeds)
|
||||
{
|
||||
if (existing.TryGetValue(s.DeckNo, out var row))
|
||||
{
|
||||
row.ClassId = s.ClassId;
|
||||
row.CardListJson = s.CardListJson;
|
||||
row.SleeveId = s.SleeveId;
|
||||
row.LeaderSkinId = s.LeaderSkinId;
|
||||
row.DisplayOrder = s.DisplayOrder;
|
||||
}
|
||||
else
|
||||
{
|
||||
set.Add(new TEntity
|
||||
{
|
||||
DeckNo = s.DeckNo,
|
||||
ClassId = s.ClassId,
|
||||
CardListJson = s.CardListJson,
|
||||
SleeveId = s.SleeveId,
|
||||
LeaderSkinId = s.LeaderSkinId,
|
||||
DisplayOrder = s.DisplayOrder,
|
||||
});
|
||||
}
|
||||
upserted++;
|
||||
}
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
Console.WriteLine($"[{GetType().Name}] upserted={upserted}");
|
||||
return upserted;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ColosseumCuratedDeckSeed
|
||||
{
|
||||
public int DeckNo { get; set; }
|
||||
public int ClassId { get; set; }
|
||||
public string CardListJson { get; set; } = "[]";
|
||||
public long SleeveId { get; set; }
|
||||
public long LeaderSkinId { get; set; }
|
||||
public int DisplayOrder { get; set; }
|
||||
}
|
||||
|
||||
public sealed class ColosseumHofDecksImporter : ColosseumCuratedDeckImporterBase<ColosseumHofDeck>
|
||||
{
|
||||
protected override string SeedFileName => "colosseum-hof-decks.json";
|
||||
}
|
||||
|
||||
public sealed class ColosseumWindFallDecksImporter : ColosseumCuratedDeckImporterBase<ColosseumWindFallDeck>
|
||||
{
|
||||
protected override string SeedFileName => "colosseum-windfall-decks.json";
|
||||
}
|
||||
|
||||
public sealed class ColosseumAvatarDecksImporter : ColosseumCuratedDeckImporterBase<ColosseumAvatarDeck>
|
||||
{
|
||||
protected override string SeedFileName => "colosseum-avatar-decks.json";
|
||||
}
|
||||
@@ -85,6 +85,9 @@ public static class Program
|
||||
await new AvatarAbilityImporter().ImportAsync(context, opts.SeedDir);
|
||||
await new ArenaSeasonImporter().ImportAsync(context, opts.SeedDir);
|
||||
await new ArenaTwoPickRewardImporter().ImportAsync(context, opts.SeedDir);
|
||||
await new ColosseumHofDecksImporter().ImportAsync(context, opts.SeedDir);
|
||||
await new ColosseumWindFallDecksImporter().ImportAsync(context, opts.SeedDir);
|
||||
await new ColosseumAvatarDecksImporter().ImportAsync(context, opts.SeedDir);
|
||||
await new BattlePassImporter().ImportAsync(context, opts.SeedDir);
|
||||
await new BattlePassSeasonImporter().ImportAsync(context, opts.SeedDir);
|
||||
await new BattlePassRewardImporter().ImportAsync(context, opts.SeedDir);
|
||||
|
||||
Reference in New Issue
Block a user