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);
}