openac-mosswartmassacre/tests/OpenAC.MosswartMassacre.Tests/Fakes/FakeNetwork.cs
Erik 9b5371c2e4 Wire the host's new readings into the frames
vitals.vitae is the penalty percent computed exactly as the original's client
library did from the vitae multiplier; character_stats carries the titles (by
name, server order), the current title id and the allegiance (monarch,
patron, rank, followers); telemetry.vt_state reads the bot's published meta
state; dungeon_map reads the landblock's indoor cells; the main window's
Tools buttons reopen the Mossy Tracker and Metas windows even after the
player closed them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 13:00:03 +02:00

82 lines
2.7 KiB
C#

using AcDream.Plugin.Abstractions;
namespace OpenAC.MosswartMassacre.Tests.Fakes;
/// <summary>
/// A peer network that records what a plugin imports and hands back the casts
/// this client announced.
/// </summary>
public sealed class FakeNetwork : INetworkAutomation
{
public bool IsAvailable { get; set; } = true;
public List<PluginNetworkClient> ImportedClients { get; } = [];
public List<(uint Caster, uint Target, uint Spell, int Skill, double Seconds, bool Landed)> ImportedCasts { get; } = [];
/// <summary>What this client announced, as <see cref="CaptureOwnCasts"/> reports it.</summary>
public List<PluginPeerCast> OwnCasts { get; } = [];
/// <summary>Whether an import is accepted.</summary>
public bool AcceptImports { get; set; } = true;
public IReadOnlyList<PluginNetworkClient> CaptureClients() => ImportedClients;
public IReadOnlyList<PluginPeerCast> 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;
}
}
/// <summary>A dungeon-map surface whose sealed landblocks a test names.</summary>
public sealed class FakeDungeonMap : IDungeonMapAutomation
{
public HashSet<uint> SealedLandblocks { get; } = [];
public bool IsSealedDungeon(uint cellId) =>
(cellId & 0xFFFFu) >= 0x100u && SealedLandblocks.Contains(cellId & 0xFFFF0000u);
}
/// <summary>An allegiance surface a test fills in.</summary>
public sealed class FakeAllegiance : IAllegianceAutomation
{
public bool IsAvailable { get; set; } = true;
public PluginAllegianceSnapshot Snapshot { get; set; }
}
/// <summary>A status board whose lines a test sets.</summary>
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!);
}