Files
SVSimServer/SVSim.EmulatedEntrypoint/Services/IMatchContextBuilder.cs
gamer147 cbee0f9a50 feat(arena-colosseum): playable bracket + rank-match promotion (phase 2)
Closes 4 more arena-colosseum spec shapes (6/16 → 10/16): the dual-prefix
battle URLs (colosseum_battle/* and colosseum_rank_battle/*) for both
do_matching and per-match finish, plus the bracket-end /finish + /retire
pair on /arena_colosseum.

* ColosseumProgressionService: pure-logic decisions for win-threshold
  advancement, 3008 promotion trigger, and per-round reward bundles.
  Extends ColosseumRoundsConfig with FinishRewards/RetireRewards per
  round + a top-level ChampionRewards list.
* MatchContextBuilder.BuildForColosseumAsync: lifts the registered deck
  via IDeckRepository (NOT viewer-graph) per project_ef_nav_include_pitfall.
* ArenaColosseumBattleController: dual route prefixes off one controller
  via explicit absolute [HttpPost("/...")] routes — does NOT extend
  SVSimController's [Route("[controller]")]. Same pattern as FreeBattle.
  URL-vs-IsRankMatching mismatch returns 400 with a phase-mismatch error;
  no-deck triggers the standard 3001 matchmaking-illegal state. 3008
  flips run.IsRankMatching exactly once via the progression service.
* /arena_colosseum/finish + /retire share FinishResponse (rewards +
  reward_list + colosseum_status). Champion finish appends ChampionRewards
  and surfaces colosseum_status.is_champion = true. Both delete the run
  row after granting via IInventoryTransaction.GrantAsync.
* DI: ModePolicy entries for "colosseum_battle" and "colosseum_rank_battle".
* Tests: 8 progression-service unit tests (pure logic), 5 battle-controller
  HTTP tests, 5 bracket-terminate HTTP tests, 2 full-bracket E2E walks
  (champion path + retire mid-round). Full suite: 1331/1331.
2026-06-13 12:32:56 -04:00

37 lines
1.6 KiB
C#

using SVSim.BattleNode.Bridge;
using SVSim.Database.Enums;
namespace SVSim.EmulatedEntrypoint.Services;
/// <summary>
/// Per-mode assembler for the battle-node <c>MatchContext</c>. Each multiplayer mode that
/// fronts a <c>do_matching</c> endpoint adds one method here that reads its mode-specific
/// state (TK2 run, current-deck pointer, open-room set_deck, ...) and produces a
/// <c>MatchContext</c> for the bridge.
/// </summary>
public interface IMatchContextBuilder
{
/// <summary>
/// Build a context from the viewer's active TK2 run + viewer cosmetics + config.
/// Throws <see cref="ArenaTwoPickException"/> on missing run / incomplete draft.
/// </summary>
Task<MatchContext> BuildForTwoPickAsync(long viewerId);
/// <summary>
/// Build a context for a rank-battle viewer + format (rotation / unlimited) + the
/// caller-selected deck number (from <c>do_matching</c>'s <c>deck_no</c>). Pulls the
/// viewer's deck for that format/number + viewer cosmetics. Throws if the viewer has
/// no deck at that slot.
/// </summary>
Task<MatchContext> BuildForRankBattleAsync(long viewerId, Format format, int deckNo);
/// <summary>
/// Build a context for an Arena Colosseum bracket match — reads the active
/// <c>ViewerArenaColosseumRun</c>'s registered deck slot (single-deck v1) via
/// <c>IDeckRepository.GetDeck</c> (NOT viewer-graph traversal per
/// <c>project_ef_nav_include_pitfall</c>). Throws when the run is missing or no deck
/// has been registered yet.
/// </summary>
Task<MatchContext> BuildForColosseumAsync(long viewerId);
}