Vital sharing across computers through the backend
Outgoing, the original's share_* frames byte for byte: subscribe with the player id on start and without it after every reconnect, vitals on change or every 3 s, position on change or every 10 s, the item heartbeat every 5 s, unsubscribe on stop. Debuff casts come from the host's peer network: the attempts and landings the bot announces, plus the player's own completed casts, so a hand-cast debuff is shared once it lands (a plugin cannot see outgoing packets, so hand-cast attempts are not). Ids stay signed ints, skill a double, duration_ms the spell's duration. Incoming, another computer's characters and casts go into the host's peer network (the new relay imports), where the bot reads them exactly as it reads characters on this computer: vitals and position for heals, landed debuffs for target choice. Peers not heard from for 15 s drop out; the original kept them forever. Logoff now runs features in reverse so the unsubscribe leaves before the socket closes, and stopping the socket flushes what was queued. Builds against a preview of the plugin API with the peer relay (0.1.19-mmpreview.1, packed from the relay commit); switch to the released package when it exists. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5799ea956e
commit
78813cf861
9 changed files with 1042 additions and 4 deletions
|
|
@ -40,6 +40,8 @@ public sealed class FakeAutomation : IAutomationSurface
|
|||
|
||||
public FakeLogin Login { get; } = new();
|
||||
|
||||
public FakeNetwork Network { get; } = new();
|
||||
|
||||
ICharacterInfo IAutomationSurface.Character => Character;
|
||||
ISpellCatalog IAutomationSurface.Spells => Spells;
|
||||
IMagicCommands IAutomationSurface.Magic => Magic;
|
||||
|
|
@ -55,6 +57,7 @@ public sealed class FakeAutomation : IAutomationSurface
|
|||
ITradeAutomation IAutomationSurface.Trade => Trade;
|
||||
IVendorAutomation IAutomationSurface.Vendor => Vendor;
|
||||
ILoginAutomation IAutomationSurface.Login => Login;
|
||||
INetworkAutomation IAutomationSurface.Network => Network;
|
||||
}
|
||||
|
||||
/// <summary>A settable <see cref="ITradeAutomation"/>: a test drives <see cref="Raise*"/> and inspects <see cref="Calls"/>.</summary>
|
||||
|
|
@ -500,6 +503,8 @@ public sealed class FakeMagic : IMagicCommands
|
|||
{
|
||||
public bool IsCasting { get; set; }
|
||||
|
||||
public PluginCastCompletion LastCompletion { get; set; }
|
||||
|
||||
public List<(uint SpellId, uint TargetObjectId)> Casts { get; } = [];
|
||||
|
||||
/// <summary>What <see cref="RequestCast(uint)"/>/<see cref="RequestCast(uint,uint)"/> answer -- a test sets this to simulate a refusal that isn't a plain Cast()==false.</summary>
|
||||
|
|
|
|||
45
tests/OpenAC.MosswartMassacre.Tests/Fakes/FakeNetwork.cs
Normal file
45
tests/OpenAC.MosswartMassacre.Tests/Fakes/FakeNetwork.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue