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.
This commit is contained in:
gamer147
2026-06-13 12:32:56 -04:00
parent 110867358c
commit cbee0f9a50
16 changed files with 1436 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
using System.Text.Json.Serialization;
using MessagePack;
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests;
namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum;
/// <summary>
/// <c>POST /colosseum_battle/do_matching</c> + <c>POST /colosseum_rank_battle/do_matching</c>.
/// Standard <c>DoMatchingParam</c> wire shape — same fields as rank/free-battle's variant.
/// Per do-matching.md, post-promotion the client forces <c>need_init = 0</c>, but the
/// server tolerates either value (URL is the routing signal).
/// </summary>
[MessagePackObject]
public sealed class ColosseumDoMatchingRequestDto : BaseRequest
{
[JsonPropertyName("need_init")] [Key("need_init")]
public int NeedInit { get; set; }
[JsonPropertyName("card_master_hash")] [Key("card_master_hash")]
public string? CardMasterHash { get; set; }
[JsonPropertyName("log")] [Key("log")]
public int Log { get; set; }
[JsonPropertyName("use_stage_select")] [Key("use_stage_select")]
public int UseStageSelect { get; set; }
[JsonPropertyName("excluded_field_id_list")] [Key("excluded_field_id_list")]
public List<long> ExcludedFieldIdList { get; set; } = new();
[JsonPropertyName("is_default_skin")] [Key("is_default_skin")]
public int IsDefaultSkin { get; set; }
}

View File

@@ -0,0 +1,49 @@
using System.Text.Json.Serialization;
using MessagePack;
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests;
namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum;
/// <summary>
/// <c>POST /colosseum_battle/finish</c> + <c>POST /colosseum_rank_battle/finish</c> request
/// body — the per-match finish, NOT the bracket-end <c>/arena_colosseum/finish</c>.
/// Standard <c>BattleFinishParam</c> shape inherited from <c>FinishTaskBase</c>.
/// </summary>
[MessagePackObject]
public sealed class ColosseumBattleFinishRequestDto : BaseRequest
{
[JsonPropertyName("battle_result")] [Key("battle_result")]
public int BattleResult { get; set; }
[JsonPropertyName("is_retire")] [Key("is_retire")]
public int IsRetire { get; set; }
[JsonPropertyName("recovery_data")] [Key("recovery_data")]
public string? RecoveryData { get; set; }
[JsonPropertyName("class_id")] [Key("class_id")]
public int ClassId { get; set; }
[JsonPropertyName("total_turn")] [Key("total_turn")]
public int TotalTurn { get; set; }
[JsonPropertyName("evolve_count")] [Key("evolve_count")]
public int EvolveCount { get; set; }
[JsonPropertyName("enemy_evolve_count")] [Key("enemy_evolve_count")]
public int EnemyEvolveCount { get; set; }
}
/// <summary>
/// <c>colosseum_battle/finish</c> response. Per battle-finish.md, the client maps this to
/// <c>ColosseumBattleFinishDetail</c> which is an empty <c>MatchFinishBase</c> subclass —
/// no Colosseum-specific fields beyond the shared rank-battle-finish superset. Phase 2 v1
/// emits the minimum required to keep the client's <c>BattleFinishResponsProcessing</c>
/// happy.
/// </summary>
[MessagePackObject(keyAsPropertyName: true)]
public sealed class ColosseumBattleFinishResponseDto
{
[JsonPropertyName("battle_result")] [Key("battle_result")]
public int BattleResult { get; set; }
}

View File

@@ -0,0 +1,26 @@
using System.Text.Json.Serialization;
using MessagePack;
namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum;
/// <summary>
/// Per-entry shape for the <c>rewards</c> array on <c>/finish</c> + <c>/retire</c>. Richer
/// than <c>RewardEntryDto</c> (which is the <c>reward_list</c> shape) — carries a display
/// name. Distinct from the wallet-delta block: client renders <c>rewards</c> in the
/// post-bracket popup while <c>reward_list</c> drives the silent wallet update.
/// </summary>
[MessagePackObject]
public sealed class ColosseumReceivedReward
{
[JsonPropertyName("reward_number")] [Key("reward_number")]
public int RewardNumber { get; set; }
[JsonPropertyName("reward_type")] [Key("reward_type")]
public int RewardType { get; set; }
[JsonPropertyName("reward_detail_id")] [Key("reward_detail_id")]
public long RewardDetailId { get; set; }
[JsonPropertyName("name")] [Key("name")]
public string Name { get; set; } = "";
}

View File

@@ -0,0 +1,27 @@
using System.Text.Json.Serialization;
using MessagePack;
using SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum;
using SVSim.EmulatedEntrypoint.Models.Dtos.Common.ArenaTwoPick;
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses.ArenaColosseum;
/// <summary>
/// <c>POST /arena_colosseum/finish</c> and <c>POST /arena_colosseum/retire</c>. Wire-identical
/// shape per finish.md §"Wire-shared with /retire" — endpoints differ in side-effects only:
/// /finish emits per-round-completion + champion bonus and marks the entry champion;
/// /retire emits the round-capped consolation. The client renders <c>rewards</c> in the
/// post-bracket popup, applies wallet deltas via <c>reward_list</c>, and updates the
/// status block via <c>colosseum_status</c>.
/// </summary>
[MessagePackObject]
public sealed class FinishResponse
{
[JsonPropertyName("rewards")] [Key("rewards")]
public List<ColosseumReceivedReward> Rewards { get; set; } = new();
[JsonPropertyName("reward_list")] [Key("reward_list")]
public List<RewardEntryDto> RewardList { get; set; } = new();
[JsonPropertyName("colosseum_status")] [Key("colosseum_status")]
public ColosseumOwnStatus ColosseumStatus { get; set; } = new();
}