Vixen
c7401864
csharp
public sealed class InstanceState

One saved instance, as a state machine a test can drive.

Read the guide page for this →

Remarks

Grains over state machines, a sixth time. No lock, because InstanceGrain takes one turn at a time.

⚠ There is no clock in this type. Every method that needs to know whether the lockout has lifted is handed the time, for HousePlot's reason one tier up: a grain that ticked would be a grain the cluster has to keep activated, and an instance nobody has asked about for a week is one whose reset can be noticed the next time somebody does.

⚠ The expiry is an absolute boundary the caller computed. Doc 28's LockoutPolicy.NextResetAfter is the only place a reset time comes from — a timer from when somebody entered would drift every player's reset to wherever their first run happened to fall, and a guild that raids on Wednesdays would find half its roster locked.

Fields and properties (9)

  • public string Instance

    Which instance, by address. Empty until opened.

  • public string Difficulty

    Which difficulty.

  • public int Capacity

    How many may be bound.

  • public DateTimeOffset Opened

    When it was opened.

  • public DateTimeOffset Expires

    When the lockout lifts.

  • public bool Closed

    Whether it has ended.

  • public uint Revision

    How many times it has changed.

  • public int Count

    How many are bound.

  • public bool Exists

    Whether it has been opened.

Methods (8)

  • public InstanceRecord Read()

    What it looks like.

  • public bool IsBound(PlayerKey player)

    Whether somebody is saved to it.

  • public bool IsDefeated(string encounter)

    Whether something is dead.

  • public InstanceOutcome Open(string instance, string difficulty, ImmutableArray<PlayerKey> access, int capacity, DateTimeOffset now, DateTimeOffset expires)

    Opens it.

  • public InstanceOutcome Bind(PlayerKey player, DateTimeOffset now)

    Saves somebody to it.

  • public InstanceOutcome Defeat(string encounter, DateTimeOffset now)

    Records that something is dead.

  • public InstanceOutcome Close()

    Ends it early.

  • public void Restore(InstanceRecord saved, int capacity, ImmutableArray<PlayerKey> access)

    Puts a saved instance back, as it was, with no checks.

Used by (2)

  • InstanceGrainVixen.Live.Orchestrator
  • InstanceStateTestsVixen.Live.Orchestrator.Tests