public sealed class GuildStateOne guild's roster, as a state machine a test can drive.
Remarks
Grains over state machines, a fifth time. There is no lock here and there must never be one: what makes it correct is that GuildGrain takes one turn at a time.
⚠ It checks rank, never permission. Whether an officer may kick is a tag on a compiled charter and the realm answers it with the code the client greys the button with. What no local check can win is the race — two officers demoting each other at the same moment — so the grain re-checks the part that is arithmetic: you may not act on somebody at or above your own rank.
⚠ Rank 0 is the leader and there is always exactly one of them. Every rule below exists to keep that true, because a guild with no leader is one nobody can administer again and a guild with two is a state no rule here could resolve afterwards.
Fields and properties (8)
public Func<DateTimeOffset> NowThe clock.
public string CharterWhich charter, by address. Empty until founded.
public string NameWhat it is called.
public int CapacityHow many its charter allows.
public DateTimeOffset FoundedWhen it was founded.
public uint RevisionHow many times it has changed.
public int CountHow many are in it.
public bool ExistsWhether it has been founded.
Methods (9)
public GuildState(Func<DateTimeOffset>? now = null)Makes one that has not been founded.
public GuildRecord Read()What it looks like.
public int RankOf(PlayerKey player)What rank somebody holds, or −1.
public GuildOutcome Found(PlayerKey founder, string charter, string name, int capacity)Founds it.
public GuildOutcome Add(PlayerKey by, PlayerKey player, int rank)Adds somebody.
public GuildOutcome Remove(PlayerKey by, PlayerKey player)Removes somebody.
public GuildOutcome SetRank(PlayerKey by, PlayerKey player, int rank)Moves somebody.
public GuildOutcome RenameRank(PlayerKey by, int rank, string? name)Renames a rank, for this guild only.
public void Restore(GuildRecord saved, int capacity)Puts a saved guild back, as it was, with no checks.
Used by (2)
- GuildGrainVixen.Live.Orchestrator
- GuildStateTestsVixen.Live.Orchestrator.Tests