// ConquestFeature.cs - What RynthConquest does on Conquest, without the host (ConquestPlugin.cs wires it // to the engine, ConquestPages.cs draws it). Moved out of RynthOracle on 2026-10-20 so that only players // who installed RynthConquest get Conquest's features, and the automatic /bank deposit with them: // * reads the replies of Conquest's own commands (ConquestData: /b, /augs, /enl augs, /bonus, // /fship list, /top) and the quest flags (/myquests, for the custom quest worklist), and hides // the replies to its own requests when HideOwnReplies is on; // * reads the advanced augmentations once after login (the Void DoT rule needs the Duration augs); // * deposits everything at each ten-minute mark when AutoDeposit is on (off unless the player // turned it on, in RynthOracle before or here); // * works out the Void DoT duration rule for this character, which RynthOracle's Void timers read // from the server profile ("voidDotDurationScale") instead of knowing about Conquest. // Settings: rynthconquest.json (ServerPackSettings), taken over once from rynthoracle.json. // Threads: everything here runs under Gate. Chat and tick come from the pump, the pages draw on the // render thread holding it too; nothing in here calls the host. // Pure: RynthServerPack.Tests covers it. using System; using RynthCore.Plugin.RynthOracle.Data; using RynthCore.Plugin.ServerPack; namespace RynthCore.Plugin.RynthConquest; internal sealed class ConquestFeature { public const string SettingAutoDeposit = "autoDeposit"; public const string SettingHideOwnReplies = "hideOwnReplies"; /// Set once rynthoracle.json's Conquest settings were taken over (they're never read again). public const string MigrationMarker = "migratedFromRynthOracle"; /// The profile value RynthOracle's Void timers apply ("RynthServer.Profile" values). public const string VoidScaleKey = "voidDotDurationScale"; /// After login, before the hidden /augs (RynthOracle's old timing: its quest read plus 4 s). public const long AugsReadDelayMs = 10_000; /// The character's level, XP and augmentation are read this often. public const long CharacterReadMs = 1000; /// RynthConquest's pages (ConquestPages draws them): id, label, tooltip. public static readonly (string Id, string Label, string Tooltip)[] PageList = { ("main", "Conquest", "Conquest: bank and auto-deposit, augmentations, levels past 275, fellowships and custom quests (RynthConquest)."), ("boards", "Leaderboards", "Conquest's /top boards (RynthConquest)."), }; /// Held for everything below (pump and render thread). public readonly object Gate = new(); public readonly ConquestData Data = new(); public readonly QuestFlagStore Flags = new(); /// "/bank deposit" at every ten-minute mark (upstream's auto-deposit). Off by default. public bool AutoDeposit; /// Hide the replies to RynthConquest's own requests (a command typed by hand always shows). public bool HideOwnReplies = true; // The character (ConquestPlugin reads them every CharacterReadMs). public bool CharacterKnown; public int Level, Enlightenment, ArchmagesEndurance; public long TotalXp; private long _loginMs; private bool _augsAsked; private long _lastDepositBlock = -1; /// /// Takes over the settings RynthOracle had for Conquest (rynthoracle.json at ), /// once per settings file; a value that isn't there keeps this plugin's default (auto-deposit off, /// hiding on, as they were in RynthOracle). True when it ran now. /// public static bool Migrate(ServerPackSettings settings, string oraclePath) => settings.MigrateOnce(MigrationMarker, s => { if (ServerPackSettings.ReadBoolFrom(oraclePath, "conquestAutoDeposit") is bool deposit) s.SetBool(SettingAutoDeposit, deposit); if (ServerPackSettings.ReadBoolFrom(oraclePath, "hideOwnQuestReplies") is bool hide) s.SetBool(SettingHideOwnReplies, hide); }); public void LoadSettings(ServerPackSettings s) { AutoDeposit = s.GetBool(SettingAutoDeposit, false); HideOwnReplies = s.GetBool(SettingHideOwnReplies, true); } public void SaveSettings(ServerPackSettings s) { bool changed = s.SetBool(SettingAutoDeposit, AutoDeposit); changed |= s.SetBool(SettingHideOwnReplies, HideOwnReplies); if (changed) s.Save(); } /// A character logged in (or the plugin loaded in game): everything is read fresh. public void Login(long nowMs) { _loginMs = nowMs; _augsAsked = false; Data.Clear(); Flags.Clear(); CharacterKnown = false; Level = Enlightenment = ArchmagesEndurance = 0; TotalXp = 0; } public void Logout() { Data.Clear(); Flags.Clear(); CharacterKnown = false; } /// /// An incoming chat line on Conquest. True when it should be hidden: a reply to one of /// RynthConquest's own requests, with HideOwnReplies on. /// public bool OnChatLine(string text, long nowMs) { string line = text.TrimEnd('\r', '\n'); MyQuestsLine kind = Flags.OnChatLine(line, nowMs); if (kind != MyQuestsLine.None) return Flags.AwaitingOurs && HideOwnReplies && kind is MyQuestsLine.Quest or MyQuestsLine.Empty; return Data.OnChatLine(line, nowMs, out bool ours) && ours && HideOwnReplies; } /// The once-after-login /augs: the command to send now, or null. public string? LoginAugsDue(long nowMs) { if (_augsAsked || nowMs - _loginMs <= AugsReadDelayMs) return null; _augsAsked = true; return Data.RequestAugs(nowMs); } /// The automatic deposit: "/bank deposit" when one is due now, else null. public string? AutoDepositDue(DateTime local, long nowMs) => AutoDeposit && DepositDue(local, ref _lastDepositBlock) ? Data.AutoDeposit(nowMs) : null; /// /// True once in each ten-minute block, at its first minute (:00, :10, :20 ... local time), as /// upstream does; remembers the block already done. /// public static bool DepositDue(DateTime local, ref long lastBlock) { long block = local.Ticks / TimeSpan.TicksPerMinute / 10; if (local.Minute % 10 != 0 || block == lastBlock) return false; lastBlock = block; return true; } /// This character's Void DoT duration multiplier on Conquest (Archmage's Endurance and the Duration augs). public double VoidScale => Data.VoidDurationMultiplier(ArchmagesEndurance); }