refactor(arena-colosseum): dedup colosseum_info source-of-truth

/mypage/index data.colosseum_info and /arena_colosseum/{top,get_fee_info}
now both project through ColosseumLobbyInfoBuilder.Build(ColosseumSeasonConfig).
One source of truth for the home-tab gating and the lobby reads — admins
flip the season on by writing to GameConfigs (per the runbook), no second
table to keep in sync.

* New ColosseumLobbyInfoBuilder — static projection from ColosseumSeasonConfig
  to the wire ColosseumLobbyInfo. Replaces ArenaColosseumController's private
  BuildColosseumInfo and MyPageController's BuildColosseumInfo(ColosseumConfig).
* MyPageController reads ColosseumSeasonConfig via IGameConfigService; the
  IGlobalsRepository.GetCurrentColosseum() call goes away.
* MyPageIndexResponse.ColosseumInfo retyped to the new ColosseumLobbyInfo.
* ColosseumSalesPeriodInfo relocated into the ArenaColosseum namespace
  alongside the rest of the family DTOs.
* Drops: Colosseums DB table (migration DropColosseumsTable), ColosseumConfig
  entity, the captured-shape Models.Dtos.ColosseumInfo DTO, ColosseumSeed,
  MyPageGlobalsImporter.ImportColosseumAsync + seed file colosseum.json,
  IGlobalsRepository.GetCurrentColosseum + impl, the two related tests.

Net: home-screen Grand Prix tab now hidden by default because the season
ships with IsColosseumPeriod=false. Full suite: 1345/1345 (was 1347 — the
2 dropped tests covered the now-dead surface).
This commit is contained in:
gamer147
2026-06-13 13:31:03 -04:00
parent 114e3da81f
commit 43a3665775
22 changed files with 4924 additions and 413 deletions

View File

@@ -688,33 +688,8 @@ public class ArenaColosseumController : SVSimController
// --- helpers ---
private static ColosseumLobbyInfo BuildColosseumInfo(ColosseumSeasonConfig season)
{
if (!season.IsColosseumPeriod)
{
return new ColosseumLobbyInfo { IsColosseumPeriod = false };
}
return new ColosseumLobbyInfo
{
IsColosseumPeriod = true,
DeckFormat = (int)season.DeckFormat,
IsNormalTwoPick = season.IsNormalTwoPick ? "1" : "0",
ColosseumName = season.ColosseumName,
IsRoundPeriod = true,
IsSpecialMode = season.IsSpecialMode,
CardPoolName = string.IsNullOrEmpty(season.CardPoolName) ? null : season.CardPoolName,
NowRound = 1,
StartTime = FormatTime(season.EventStartTime),
EndTime = FormatTime(season.EventEndTime),
IsAllCardEnabled = season.IsAllCardEnabled ? 1 : 0,
SalesPeriodInfo = new SVSim.EmulatedEntrypoint.Models.Dtos.ColosseumSalesPeriodInfo
{
SalesPeriodTime = FormatTime(season.SalesPeriodEnd),
},
StrategyPickNum = season.StrategyPickNum > 0 ? season.StrategyPickNum : null,
};
}
private static ColosseumLobbyInfo BuildColosseumInfo(ColosseumSeasonConfig season) =>
ColosseumLobbyInfoBuilder.Build(season);
/// <summary>Builds the <c>colosseum_status</c> block. When the viewer has no run, every
/// property is null and global WhenWritingNull renders <c>{}</c> — the client

View File

@@ -9,6 +9,7 @@ using SVSim.Database.Services;
using SVSim.EmulatedEntrypoint.Constants;
using SVSim.EmulatedEntrypoint.Infrastructure;
using SVSim.EmulatedEntrypoint.Models.Dtos;
using SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum;
using SVSim.EmulatedEntrypoint.Models.Dtos.Common;
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests;
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests.MyPage;
@@ -61,7 +62,7 @@ public class MyPageController : SVSimController
// Hydrate all the globals slices in parallel-ish — they're independent reads.
var rotation = _config.Get<RotationConfig>();
var colosseum = await _globalsRepository.GetCurrentColosseum();
var colosseumSeason = _config.Get<ColosseumSeasonConfig>();
var sealedSeason = await _globalsRepository.GetCurrentSealedSeason();
var masterPointPeriod = await _globalsRepository.GetCurrentMasterPointPeriod();
var bannerEntries = await _globalsRepository.GetBanners();
@@ -93,7 +94,7 @@ public class MyPageController : SVSimController
ArenaInfo = await BuildArenaInfosAsync(viewer.Id),
IsArenaChallengePeriod = false, // TODO(mypage-stub): globals/ArenaSeason flag
IsAvailableColosseumFreeEntry = false, // TODO(mypage-stub): viewer + globals free-entry quota
ColosseumInfo = BuildColosseumInfo(colosseum),
ColosseumInfo = ColosseumLobbyInfoBuilder.Build(colosseumSeason),
SealedInfo = BuildSealedInfo(sealedSeason),
Banner = bannerEntries.Select(BuildBannerInfo).ToList(),
RoomTypeInSession = new RoomTypeInSession
@@ -237,37 +238,6 @@ public class MyPageController : SVSimController
};
}
private ColosseumInfo BuildColosseumInfo(ColosseumConfig? row)
{
if (row is null) return new ColosseumInfo();
ColosseumSalesPeriodInfo sales = new();
if (!string.IsNullOrEmpty(row.SalesPeriodInfo) && row.SalesPeriodInfo != "{}")
{
sales = JsonSerializer.Deserialize<ColosseumSalesPeriodInfo>(row.SalesPeriodInfo, JsonbReadOptions.Instance)
?? new ColosseumSalesPeriodInfo();
}
return new ColosseumInfo
{
ColosseumId = row.ColosseumId,
IsDisplayTips = row.IsDisplayTips,
TipsId = row.TipsId,
CardPoolName = row.CardPoolName,
IsColosseumPeriod = row.IsColosseumPeriod,
IsRoundPeriod = row.IsRoundPeriod,
DeckFormat = row.DeckFormat,
IsNormalTwoPick = row.IsNormalTwoPick,
IsSpecialMode = row.IsSpecialMode,
IsAllCardEnabled = row.IsAllCardEnabled,
StartTime = row.StartTime.ToString(WireDateFormat, CultureInfo.InvariantCulture),
ColosseumName = row.ColosseumName,
NowRound = row.NowRound,
EndTime = row.EndTime.ToString(WireDateFormat, CultureInfo.InvariantCulture),
SalesPeriodInfo = sales,
};
}
private SealedInfo BuildSealedInfo(SealedConfig? row)
{
if (row is null) return new SealedInfo();

View File

@@ -1,6 +1,5 @@
using System.Text.Json.Serialization;
using MessagePack;
using SVSim.EmulatedEntrypoint.Models.Dtos;
namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum;
@@ -10,10 +9,11 @@ namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum;
/// <see cref="IsColosseumPeriod"/> is <c>false</c>, the client skips parsing every other
/// field — server still emits this minimal payload so the lobby renders cleanly.
/// <para>
/// Distinct from <see cref="SVSim.EmulatedEntrypoint.Models.Dtos.ColosseumInfo"/> (the
/// captured prod <c>/mypage/index</c> shape — stringly-typed and read-only). This is the
/// per-endpoint Colosseum-family shape. <c>/event_info</c> uses yet a third shape —
/// <see cref="ColosseumEventInfo"/>.
/// Also drives <c>/mypage/index data.colosseum_info</c> — the home-screen tab gating and
/// the per-endpoint lobby reads share one source of truth (the
/// <see cref="ColosseumSeasonConfig"/> POCO) projected via
/// <see cref="ColosseumLobbyInfoBuilder"/>. <c>/event_info</c> uses a different,
/// event-level shape — <see cref="ColosseumEventInfo"/>.
/// </para>
/// </summary>
[MessagePackObject]

View File

@@ -0,0 +1,48 @@
using System.Globalization;
using SVSim.Database.Models.Config;
namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum;
/// <summary>
/// Single source of truth for projecting <see cref="ColosseumSeasonConfig"/> onto the wire
/// <see cref="ColosseumLobbyInfo"/> block. Used by both <c>/arena_colosseum/{top,get_fee_info}</c>
/// AND <c>/mypage/index data.colosseum_info</c> — the home-screen tab and the lobby reads
/// must agree on the season state, so they go through one builder. When
/// <c>IsColosseumPeriod = false</c> the minimal "no event" payload is emitted; the client
/// gates every other field on that flag (<c>Wizard/ColosseumEntryInfoTask.cs:100</c>).
/// </summary>
public static class ColosseumLobbyInfoBuilder
{
private const string WireDateFormat = "yyyy-MM-dd HH:mm:ss";
public static ColosseumLobbyInfo Build(ColosseumSeasonConfig season)
{
if (!season.IsColosseumPeriod)
{
return new ColosseumLobbyInfo { IsColosseumPeriod = false };
}
return new ColosseumLobbyInfo
{
IsColosseumPeriod = true,
DeckFormat = (int)season.DeckFormat,
IsNormalTwoPick = season.IsNormalTwoPick ? "1" : "0",
ColosseumName = season.ColosseumName,
IsRoundPeriod = true,
IsSpecialMode = season.IsSpecialMode,
CardPoolName = string.IsNullOrEmpty(season.CardPoolName) ? null : season.CardPoolName,
NowRound = 1,
StartTime = FormatTime(season.EventStartTime),
EndTime = FormatTime(season.EventEndTime),
IsAllCardEnabled = season.IsAllCardEnabled ? 1 : 0,
SalesPeriodInfo = new ColosseumSalesPeriodInfo
{
SalesPeriodTime = FormatTime(season.SalesPeriodEnd),
},
StrategyPickNum = season.StrategyPickNum > 0 ? season.StrategyPickNum : null,
};
}
private static string FormatTime(DateTime t) =>
t == default ? "" : t.ToString(WireDateFormat, CultureInfo.InvariantCulture);
}

View File

@@ -0,0 +1,16 @@
using System.Text.Json.Serialization;
using MessagePack;
namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum;
/// <summary>
/// Nested under <c>colosseum_info.sales_period_info</c>. Captured prod shape — single
/// <c>sales_period_time</c> field carrying the wall-clock end of the cup's sales window.
/// Format <c>"yyyy-MM-dd HH:mm:ss"</c> (PHP convention, not ISO).
/// </summary>
[MessagePackObject]
public sealed class ColosseumSalesPeriodInfo
{
[JsonPropertyName("sales_period_time")] [Key("sales_period_time")]
public string SalesPeriodTime { get; set; } = string.Empty;
}

View File

@@ -1,97 +0,0 @@
using MessagePack;
using System.Text.Json.Serialization;
namespace SVSim.EmulatedEntrypoint.Models.Dtos;
/// <summary>
/// colosseum_info on /mypage/index, consumed by ColosseumEntryInfoTask.SetColosseumInfo
/// (Wizard/ColosseumEntryInfoTask.cs:99). The outer object is read unconditionally, and
/// is_colosseum_period gates everything else. When a cup IS active, the client reads
/// many more sub-fields inside the gate (deck_format, now_round, start_time, end_time,
/// sales_period_info, etc.) — we now mirror the full prod shape so the gate-true branch
/// works once we have colosseum data seeded.
///
/// Prod-captured shape (15 fields):
/// <code>
/// {"colosseum_id":"165","is_display_tips":"0","tips_id":"0",
/// "card_pool_name":"Take Two (DragonbladeRivenbrandt)",
/// "is_colosseum_period":true,"is_round_period":true,"deck_format":"3",
/// "is_normal_two_pick":"1","is_special_mode":"10","is_all_card_enabled":0,
/// "start_time":"2026-05-21 06:00:00","colosseum_name":"Rivenbrandt Take Two Cup",
/// "now_round":"1","end_time":"2026-05-25 19:59:59",
/// "sales_period_info":{"sales_period_time":"2026-05-25 19:59:59"}}
/// </code>
/// </summary>
[MessagePackObject]
public class ColosseumInfo
{
[JsonPropertyName("colosseum_id")]
[Key("colosseum_id")]
public string ColosseumId { get; set; } = string.Empty;
/// <summary>Wire is "0"/"1" string. Client compares with == "1" (GetValueOrDefault-guarded).</summary>
[JsonPropertyName("is_display_tips")]
[Key("is_display_tips")]
public string IsDisplayTips { get; set; } = "0";
[JsonPropertyName("tips_id")]
[Key("tips_id")]
public string TipsId { get; set; } = "0";
[JsonPropertyName("card_pool_name")]
[Key("card_pool_name")]
public string CardPoolName { get; set; } = string.Empty;
[JsonPropertyName("is_colosseum_period")]
[Key("is_colosseum_period")]
public bool IsColosseumPeriod { get; set; }
[JsonPropertyName("is_round_period")]
[Key("is_round_period")]
public bool IsRoundPeriod { get; set; }
/// <summary>
/// Wire is a stringified int in prod (e.g. "3"). DB stores as string. Client calls
/// <c>jsonData["deck_format"].ToInt()</c> inside the IsColosseumPeriod gate.
/// </summary>
[JsonPropertyName("deck_format")]
[Key("deck_format")]
public string DeckFormat { get; set; } = "0";
/// <summary>Wire is "1"/"0" string. Client compares with == "1".</summary>
[JsonPropertyName("is_normal_two_pick")]
[Key("is_normal_two_pick")]
public string IsNormalTwoPick { get; set; } = "0";
/// <summary>Used as ColorCodeId (stringified int).</summary>
[JsonPropertyName("is_special_mode")]
[Key("is_special_mode")]
public string IsSpecialMode { get; set; } = "0";
[JsonPropertyName("is_all_card_enabled")]
[Key("is_all_card_enabled")]
public int IsAllCardEnabled { get; set; }
/// <summary>"yyyy-MM-dd HH:mm:ss" wire format.</summary>
[JsonPropertyName("start_time")]
[Key("start_time")]
public string StartTime { get; set; } = string.Empty;
[JsonPropertyName("colosseum_name")]
[Key("colosseum_name")]
public string ColosseumName { get; set; } = string.Empty;
/// <summary>Round number as string (e.g. "1"). Client casts to int.</summary>
[JsonPropertyName("now_round")]
[Key("now_round")]
public string NowRound { get; set; } = "0";
/// <summary>"yyyy-MM-dd HH:mm:ss" wire format.</summary>
[JsonPropertyName("end_time")]
[Key("end_time")]
public string EndTime { get; set; } = string.Empty;
[JsonPropertyName("sales_period_info")]
[Key("sales_period_info")]
public ColosseumSalesPeriodInfo SalesPeriodInfo { get; set; } = new();
}

View File

@@ -1,18 +0,0 @@
using MessagePack;
using System.Text.Json.Serialization;
namespace SVSim.EmulatedEntrypoint.Models.Dtos;
/// <summary>
/// Nested under /mypage/index data.colosseum_info.sales_period_info. Carries the wall-clock end of
/// the current cup's sales window. Captured from prod:
/// <c>"sales_period_info": { "sales_period_time": "2026-05-25 19:59:59" }</c>.
/// </summary>
[MessagePackObject]
public class ColosseumSalesPeriodInfo
{
/// <summary>Wire format is "yyyy-MM-dd HH:mm:ss" (prod's PHP convention, not ISO).</summary>
[JsonPropertyName("sales_period_time")]
[Key("sales_period_time")]
public string SalesPeriodTime { get; set; } = string.Empty;
}

View File

@@ -1,5 +1,6 @@
using MessagePack;
using SVSim.Database.Enums;
using SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum;
using System.Text.Json.Serialization;
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses;
@@ -134,11 +135,13 @@ public class MyPageIndexResponse
/// <summary>
/// Required — ColosseumEntryInfoTask.SetColosseumInfo indexes this key
/// directly (Wizard/ColosseumEntryInfoTask.cs:102) and reads
/// is_colosseum_period without a guard.
/// is_colosseum_period without a guard. Built by
/// <see cref="ColosseumLobbyInfoBuilder"/> from <c>ColosseumSeasonConfig</c> —
/// shared with <c>/arena_colosseum/{top,get_fee_info}</c>.
/// </summary>
[JsonPropertyName("colosseum_info")]
[Key("colosseum_info")]
public ColosseumInfo ColosseumInfo { get; set; } = new();
public ColosseumLobbyInfo ColosseumInfo { get; set; } = new();
// ── Convention / offline event ─────────────────────────────────────────