using Microsoft.EntityFrameworkCore; using Rubidium2018.Utils.Objectives; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using RadicadeServer.Extensions; using RadicadeServer.RecNet.Leveling; using RadicadeServer.RecNet.Maintenance; using RadicadeServer.RecNet.Progression.Objectives; namespace RadicadeServer.RecNet.Config { public class MainConfig { [Key] public string FUCKYOUMICROSOFT { get; set; } = null!; public string ShareBaseUrl { get; set; } = null!; public string CdnBaseUri { get; set; } = null!; public string LevelProgressionMaps { get; set; } = null!; public string ServerMaintenance { get; set; } = null!; public string DailyObjectives { get; set; } = null!; public string AutoMicMutingConfig { get; set; } = null!; public string StorefrontConfig { get; set; } = null!; public string RoomKeyConfig { get; set; } = null!; public string RoomCurrencyConfig { get; set; } = null!; public string GiftDropStoreItems { get; set; } = null!; public bool ExpectingReload { get; set; } public DateTime LastRefresh_DailyObjectives { get; set; } = DateTime.Now; public static MainConfig? ActiveConfig = null; internal void SetAsActive() { ActiveConfig = this; } } public static class MainConfigExt { public static bool RefreshConfig(this MainConfig config, bool force = false) { if (config == null) return false; bool changed = false; if (DateTime.Now >= config.LastRefresh_DailyObjectives || force) { changed = true; Objective[][] dailys = [ [RbPresetDailys.CreateRandomObjective(), RbPresetDailys.CreateRandomObjective(), RbPresetDailys.CreateRandomObjective()], [RbPresetDailys.CreateRandomObjective(), RbPresetDailys.CreateRandomObjective(), RbPresetDailys.CreateRandomObjective()], [RbPresetDailys.CreateRandomObjective(), RbPresetDailys.CreateRandomObjective(), RbPresetDailys.CreateRandomObjective()], [RbPresetDailys.CreateRandomObjective(), RbPresetDailys.CreateRandomObjective(), RbPresetDailys.CreateRandomObjective()], [RbPresetDailys.CreateRandomObjective(), RbPresetDailys.CreateRandomObjective(), RbPresetDailys.CreateRandomObjective()], [RbPresetDailys.CreateRandomObjective(), RbPresetDailys.CreateRandomObjective(), RbPresetDailys.CreateRandomObjective()], [RbPresetDailys.CreateRandomObjective(), RbPresetDailys.CreateRandomObjective(), RbPresetDailys.CreateRandomObjective()] ]; config.DailyObjectives = dailys.ToJson(); config.LastRefresh_DailyObjectives = DateTime.Now.AddDays(7); } return changed; } public static RealMainConfig ToActualConfig(this MainConfig config) { return new RealMainConfig { ShareBaseUrl = config.ShareBaseUrl ?? string.Empty, CdnBaseUri = config.CdnBaseUri ?? string.Empty, StorefrontConfig = config.StorefrontConfig.FromJson() ?? new StorefrontConfig(), AutoMicMutingConfig = config.AutoMicMutingConfig.FromJson() ?? new MicMuting(), RoomCurrencyConfig = config.RoomCurrencyConfig.FromJson() ?? new RoomCurrencyConfig(), RoomKeyConfig = config.RoomKeyConfig.FromJson() ?? new RoomKeyConfig(), DailyObjectives = config.DailyObjectives.FromJson() ?? Array.Empty(), LevelProgressionMaps = config.LevelProgressionMaps.FromJson() ?? Array.Empty(), ServerMaintenance = config.ServerMaintenance.FromJson() ?? new ServerMaintenance { StartsInMinutes = 0 } }; } } }