mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-25 23:18:56 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
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<StorefrontConfig>() ?? new StorefrontConfig(),
|
||||
AutoMicMutingConfig = config.AutoMicMutingConfig.FromJson<MicMuting>() ?? new MicMuting(),
|
||||
RoomCurrencyConfig = config.RoomCurrencyConfig.FromJson<RoomCurrencyConfig>() ?? new RoomCurrencyConfig(),
|
||||
RoomKeyConfig = config.RoomKeyConfig.FromJson<RoomKeyConfig>() ?? new RoomKeyConfig(),
|
||||
DailyObjectives = config.DailyObjectives.FromJson<Objective[][]>() ?? Array.Empty<Objective[]>(),
|
||||
LevelProgressionMaps = config.LevelProgressionMaps.FromJson<LevelProgressionMap[]>() ?? Array.Empty<LevelProgressionMap>(),
|
||||
ServerMaintenance = config.ServerMaintenance.FromJson<ServerMaintenance>() ?? new ServerMaintenance { StartsInMinutes = 0 }
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user