acdream/src/AcDream.Plugins.MossTank/MossTankPlugin.cs
Erik 54005a864c feat(mosstank): cast back-to-back, and a settings view for the thresholds
Three things from the first working buff pass.

**Pacing.** Casts were three seconds apart because of a fixed interval I added
before there was a real busy signal. There is one now -- the shared busy count,
incremented by the cast and decremented by the server's UseDone -- so the
interval is gone and the server is the only throttle. MossTank casts the moment
the previous action is acknowledged, which is the spam behaviour VTank has. The
stall timeout moved 25s -> 30s so a slow server does not read as a stall.

**Stamina to Mana was surprising.** VTank does convert vitals by default
(Recharge-*-Mana), so the behaviour is right, but a buff pass quietly spending
your stamina is not something to discover by watching. It is now a setting,
with its own thresholds, and can be turned off outright.

**Settings view.** Spell difficulty margin, rebuff time, the three vital
thresholds, and three toggles. Two details worth recording:

* The difficulty margin is SIGNED, per the VTank wiki: "a positive number
  raises the skill necessary to cast spells, a negative number lowers it. To
  attempt higher spells at a low level use a negative number." So the range
  spans -100..+100 rather than starting at zero.
* It is a second registered panel with a complementary visible binding rather
  than a tab control. Two panels and an Action need no new markup vocabulary,
  and only one is ever on screen.

Adjuster buttons rather than typed fields: buttons are proven in plugin markup,
while an editable UiField would need keyboard routing plumbed through to plugin
panels first. Worth doing, but not as a side quest inside this change.

Also fixed: the App copy target names plugin files explicitly, so the new
markup would have been left out of the plugin directory and the settings panel
would have failed to load at runtime with the build perfectly green. Caught by
listing the output rather than trusting the build.

Solution builds clean; 14,438 tests pass on the standard hermetic lane filter,
0 failures.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 18:51:15 +02:00

61 lines
2.1 KiB
C#

using AcDream.Plugin.Abstractions;
namespace AcDream.Plugins.MossTank;
/// <summary>
/// MossTank — a self-buffing plugin, and the first consumer of acdream's
/// plugin automation surface.
/// </summary>
/// <remarks>
/// Named for the mosswart, and for the Virindi Tank lineage this milestone is
/// modelled on. The buff policy lives here rather than in the host on purpose:
/// the host publishes spell data and a cast primitive, the plugin decides what
/// to cast. See <c>docs/research/2026-07-29-vtank-plugin-automation-requirements.md</c>.
/// </remarks>
public sealed class MossTankPlugin : IAcDreamPlugin
{
private IPluginHost? _host;
private MossTankPanel? _panel;
private Action<double>? _tick;
public void Initialize(IPluginHost host)
{
_host = host;
_panel = new MossTankPanel(host);
host.Log.Info("MossTank initialized");
}
public void Enable()
{
if (_host is null || _panel is null)
return;
// Markup ships beside the plugin assembly, so it is found relative to
// this DLL rather than the host's working directory -- plugins are
// loaded from their own directory and the two are not the same.
string directory =
Path.GetDirectoryName(typeof(MossTankPlugin).Assembly.Location) ?? ".";
// Two panels with complementary visible bindings stand in for a tab
// control: only one is ever on screen, and switching is just an Action.
_host.Ui.AddMarkupPanel(Path.Combine(directory, "mosstank.xml"), _panel);
_host.Ui.AddMarkupPanel(Path.Combine(directory, "mosstank-settings.xml"), _panel);
_tick = _panel.OnTick;
_host.Events.Tick += _tick;
_host.Log.Info(
_host.Automation.IsAvailable
? "MossTank enabled"
: "MossTank enabled (no live session yet; the Buff button will "
+ "report 'Not in world' until one is up)");
}
public void Disable()
{
if (_host is not null && _tick is not null)
_host.Events.Tick -= _tick;
_tick = null;
_host?.Log.Info("MossTank disabled");
}
}