using System.Globalization; using SVSim.Database.Models.Config; namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; /// /// Single source of truth for projecting onto the wire /// block. Used by both /arena_colosseum/{top,get_fee_info} /// AND /mypage/index data.colosseum_info — the home-screen tab and the lobby reads /// must agree on the season state, so they go through one builder. When /// IsColosseumPeriod = false the minimal "no event" payload is emitted; the client /// gates every other field on that flag (Wizard/ColosseumEntryInfoTask.cs:100). /// 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); }