using AcDream.Plugin.Abstractions; namespace OpenAC.MosswartMassacre.Tests.Fakes; /// /// A peer network that records what a plugin imports and hands back the casts /// this client announced. /// public sealed class FakeNetwork : INetworkAutomation { public bool IsAvailable { get; set; } = true; public List ImportedClients { get; } = []; public List<(uint Caster, uint Target, uint Spell, int Skill, double Seconds, bool Landed)> ImportedCasts { get; } = []; /// What this client announced, as reports it. public List OwnCasts { get; } = []; /// Whether an import is accepted. public bool AcceptImports { get; set; } = true; public IReadOnlyList CaptureClients() => ImportedClients; public IReadOnlyList CaptureOwnCasts(long afterSequence) => [.. OwnCasts.Where(cast => cast.Sequence > afterSequence)]; public bool ImportRemoteClient(PluginNetworkClient client) { ImportedClients.Add(client); return AcceptImports; } public bool ImportRemoteCast( uint casterObjectId, uint targetObjectId, uint spellId, int effectiveSkill, double secondsRemaining, bool landed) { ImportedCasts.Add((casterObjectId, targetObjectId, spellId, effectiveSkill, secondsRemaining, landed)); return AcceptImports; } } /// A dungeon-map surface whose sealed landblocks a test names. public sealed class FakeDungeonMap : IDungeonMapAutomation { public HashSet SealedLandblocks { get; } = []; public bool IsSealedDungeon(uint cellId) => (cellId & 0xFFFFu) >= 0x100u && SealedLandblocks.Contains(cellId & 0xFFFF0000u); } /// An allegiance surface a test fills in. public sealed class FakeAllegiance : IAllegianceAutomation { public bool IsAvailable { get; set; } = true; public PluginAllegianceSnapshot Snapshot { get; set; } } /// A status board whose lines a test sets. public sealed class FakeStatusBoard : IPluginStatusBoard { public Dictionary<(string PluginId, string Key), string> Lines { get; } = []; public bool IsAvailable => true; public bool Publish(string key, string? value) { if (value is null) Lines.Remove(("openac.mosswartmassacre", key)); else Lines[("openac.mosswartmassacre", key)] = value; return true; } public bool TryRead(string pluginId, string key, out string value) => Lines.TryGetValue((pluginId, key), out value!); }