feat(arena-colosseum): lobby + constructed entry (phase 1)
Closes 5 of arena-colosseum's 16 spec shapes (1/16 → 6/16). Lobby reads
(/top, /get_fee_info, /event_info) render an empty "no event scheduled"
payload by default; /entry + /register_deck activate via admin-flipped
ColosseumSeason + ColosseumRounds config sections.
* Schema: ViewerArenaColosseumRun standalone table (unique on ViewerId)
with jsonb run-state columns mirroring ViewerArenaTwoPickRun.
* Config sections: ColosseumSeasonConfig (event-level), ColosseumRoundsConfig
(the 3-round bracket). Empty defaults — IsColosseumPeriod=false.
* Migration AddArenaColosseumRun (DDL only; seed rows come from the section
ShippedDefaults via EnsureSeedDataAsync).
* DTOs: ColosseumLobbyInfo (round-level, /top + /get_fee_info), ColosseumEventInfo
(event-level, /event_info), ColosseumOwnStatus (shared status block),
ColosseumEntryRef, ColosseumFeeList, ColosseumUserDeck, ColosseumBattleResults,
ColosseumRoundDetail + ColosseumGroupRow. EventInfoResponse uses explicit
[JsonPropertyName("1"|"2"|"3")] for the string-keyed rounds shape per spec.
* Controller: ArenaColosseumController replaces the 1-action stub with
the five lifecycle endpoints. /top emits leader_skin_id even when 0
(project_wire_null_policy override).
* Tests: 11 controller-level tests + 6 config round-trip tests covering
empty-season payloads, run-seeded /top round-trip, crystal/rupy entry
debits, now_round_id mismatch rejection, deck_no_list round-trip + reject.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SVSim.Database.Models;
|
||||
|
||||
namespace SVSim.Database.Repositories.Viewer;
|
||||
|
||||
public class ArenaColosseumRunRepository : IArenaColosseumRunRepository
|
||||
{
|
||||
private readonly SVSimDbContext _db;
|
||||
public ArenaColosseumRunRepository(SVSimDbContext db) => _db = db;
|
||||
|
||||
public Task<ViewerArenaColosseumRun?> GetByViewerIdAsync(long viewerId) =>
|
||||
_db.ViewerArenaColosseumRuns.FirstOrDefaultAsync(r => r.ViewerId == viewerId);
|
||||
|
||||
public async Task UpsertAsync(ViewerArenaColosseumRun run)
|
||||
{
|
||||
run.UpdatedAt = DateTime.UtcNow;
|
||||
if (run.Id == 0)
|
||||
{
|
||||
run.CreatedAt = DateTime.UtcNow;
|
||||
_db.ViewerArenaColosseumRuns.Add(run);
|
||||
}
|
||||
else
|
||||
{
|
||||
_db.ViewerArenaColosseumRuns.Update(run);
|
||||
}
|
||||
await _db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(long viewerId)
|
||||
{
|
||||
var row = await _db.ViewerArenaColosseumRuns.FirstOrDefaultAsync(r => r.ViewerId == viewerId);
|
||||
if (row is null) return;
|
||||
_db.ViewerArenaColosseumRuns.Remove(row);
|
||||
await _db.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using SVSim.Database.Models;
|
||||
|
||||
namespace SVSim.Database.Repositories.Viewer;
|
||||
|
||||
public interface IArenaColosseumRunRepository
|
||||
{
|
||||
Task<ViewerArenaColosseumRun?> GetByViewerIdAsync(long viewerId);
|
||||
Task UpsertAsync(ViewerArenaColosseumRun run);
|
||||
Task DeleteAsync(long viewerId);
|
||||
}
|
||||
Reference in New Issue
Block a user