openac-mosswartmassacre/tests/OpenAC.MosswartMassacre.Tests/Fakes/FakeNetwork.cs
Erik ec22348ebc Radar: nearby_objects every second and dungeon_map per dungeon landblock
start_radar/stop_radar from the backend drive it, as before. nearby_objects
keeps the original's shape: map coordinates on the surface, landblock-local
raw positions with zero map coordinates in a dungeon, ids as signed ints, the
same eight object classes, no wielded items or self. dungeon_map is built the
original's way from the landblock's cells (x a multiple of 10, whole metres,
6-metre floors, rotation = the orientation's stored W) and sent once per
landblock per session; the cells come through a small reader that the
plugin API's dungeon-cell data will fill (until then the map is not sent).

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

54 lines
1.8 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);
}