feat(CS): persist owner/phase/registrations across restarts via plugin config JSON
Some checks failed
.NET Core / build (push) Has been cancelled
Some checks failed
.NET Core / build (push) Has been cancelled
Castle Siege state was in-memory, so the castle owner (and thus the P4 hunting-map reward) reset on every server restart/redeploy. Now the context marks itself dirty on any persistable change (phase transition, registration, owner set); the plugin's periodic tick writes a snapshot into its own PlugInConfiguration CustomConfiguration (a JSON blob already stored in PostgreSQL - no schema migration) and restores it on startup. Battle state (defenses/switches/occupier) stays transient. +2 unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,23 @@ public class CastleSiegeConfiguration
|
||||
/// </summary>
|
||||
public int RegistrationFee { get; set; } = 100000;
|
||||
|
||||
// --- Persisted runtime state (P4 persistence) ---
|
||||
// These ride on the plugin's custom-configuration JSON (already stored in PostgreSQL), so the castle
|
||||
// owner and the current cycle survive server restarts without a dedicated database table/migration.
|
||||
// Written by CastleSiegeEventPlugIn whenever the state changes; read back on startup to restore it.
|
||||
|
||||
/// <summary>Gets or sets the persisted castle owner guild name (null = unowned).</summary>
|
||||
public string? PersistedOwnerGuildName { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the persisted current phase, so the cycle resumes after a restart.</summary>
|
||||
public CastleSiegePhase PersistedPhase { get; set; } = CastleSiegePhase.Ownership;
|
||||
|
||||
/// <summary>Gets or sets when the persisted phase started (UTC), or null if never persisted.</summary>
|
||||
public DateTime? PersistedPhaseStartedUtc { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the persisted registered guild names for the current cycle.</summary>
|
||||
public IList<string> PersistedRegisteredGuilds { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if <paramref name="now"/> falls within a 5-second window of any configured
|
||||
/// registration-open time.
|
||||
|
||||
Reference in New Issue
Block a user