The original's DxHud overlay: the player's row, then one per character heard from, each a health bar over split stamina and mana bars with percentages, and for the others an arrow toward them relative to where the player faces plus the distance, fading from white to red as they get further. Ctrl shows a frame and a close box; Ctrl+drag moves it and the spot is saved per character. /mm vitalsharing overlay toggles it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
99 lines
3.4 KiB
C#
99 lines
3.4 KiB
C#
using AcDream.Plugin.Abstractions;
|
|
using OpenAC.MosswartMassacre.Sharing;
|
|
using OpenAC.MosswartMassacre.Tests.Streams;
|
|
|
|
namespace OpenAC.MosswartMassacre.Tests.Sharing;
|
|
|
|
public sealed class VitalSharingOverlayTests
|
|
{
|
|
[Fact]
|
|
public void Paints_the_player_then_each_peer_with_distance()
|
|
{
|
|
using var harness = new PluginHarness("Mossy");
|
|
harness.Host.Automation.Character.CurrentHealth = 50;
|
|
harness.Host.Automation.Character.MaxHealth = 100;
|
|
harness.Host.Automation.Navigation.Snapshot = new PluginNavigationSnapshot(
|
|
true, false, 1u, StreamGoldenTests.Position(), false, false);
|
|
harness.Login();
|
|
var sharing = harness.Feature<VitalSharing>();
|
|
sharing.Start();
|
|
harness.Receive("{\"type\":\"share_position_update\",\"character_name\":\"Horan\",\"player_id\":1342177282,"
|
|
+ "\"ew\":" + ((double)33.65f + (100.0 / 240.0)).ToString(System.Globalization.CultureInfo.InvariantCulture)
|
|
+ ",\"ns\":" + ((double)42.55f).ToString(System.Globalization.CultureInfo.InvariantCulture)
|
|
+ ",\"z\":0,\"heading\":0}");
|
|
harness.Receive("{\"type\":\"share_vital_update\",\"character_name\":\"Horan\",\"player_id\":1342177282,"
|
|
+ "\"current_health\":10,\"max_health\":100}");
|
|
var painter = new RecordingPainter();
|
|
|
|
harness.Feature<VitalSharingOverlay>().Paint(painter);
|
|
|
|
Assert.Equal(["Mossy", "50%", "Horan", "10%", "100"], painter.Texts);
|
|
Assert.Equal(3, painter.Lines);
|
|
}
|
|
|
|
[Fact]
|
|
public void Nothing_is_painted_while_sharing_is_off()
|
|
{
|
|
using var harness = new PluginHarness("Mossy");
|
|
harness.Login();
|
|
var painter = new RecordingPainter();
|
|
|
|
harness.Feature<VitalSharingOverlay>().Paint(painter);
|
|
|
|
Assert.Empty(painter.Texts);
|
|
}
|
|
|
|
[Fact]
|
|
public void Distances_read_as_the_original_wrote_them()
|
|
{
|
|
Assert.Equal((12).ToString("N0"), VitalSharingOverlay.FormatDistance(12.3));
|
|
Assert.Equal((2.5).ToString("N1") + "k", VitalSharingOverlay.FormatDistance(2500));
|
|
Assert.Equal((25).ToString("N0") + "k", VitalSharingOverlay.FormatDistance(25000));
|
|
}
|
|
|
|
private sealed class RecordingPainter : IPluginPainter
|
|
{
|
|
public List<string> Texts { get; } = [];
|
|
|
|
public int Lines { get; private set; }
|
|
|
|
public int Width => 300;
|
|
|
|
public int Height => 300;
|
|
|
|
public void Clear(PluginColor color)
|
|
{
|
|
}
|
|
|
|
public void FillRect(PluginRect rect, PluginColor color)
|
|
{
|
|
}
|
|
|
|
public void StrokeRect(PluginRect rect, PluginColor color, float thickness = 1f)
|
|
{
|
|
}
|
|
|
|
public void DrawLine(PluginPoint from, PluginPoint to, PluginColor color, float thickness = 1f) => Lines++;
|
|
|
|
public void DrawText(string text, PluginPoint position, PluginColor color, bool outline = false) => Texts.Add(text);
|
|
|
|
public PluginSize MeasureText(string text) => new(text.Length * 6, 12);
|
|
|
|
public void DrawImage(PluginImage image, PluginRect destination, PluginColor tint)
|
|
{
|
|
}
|
|
|
|
public void DrawImageTransformed(PluginImage image, PluginRect destination, PluginColor tint,
|
|
double rotationRadians, PluginPoint pivot, double scaleX = 1.0, double scaleY = 1.0)
|
|
{
|
|
}
|
|
|
|
public void PushClip(PluginRect rect)
|
|
{
|
|
}
|
|
|
|
public void PopClip()
|
|
{
|
|
}
|
|
}
|
|
}
|