vitals.vitae is the penalty percent computed exactly as the original's client library did from the vitae multiplier; character_stats carries the titles (by name, server order), the current title id and the allegiance (monarch, patron, rank, followers); telemetry.vt_state reads the bot's published meta state; dungeon_map reads the landblock's indoor cells; the main window's Tools buttons reopen the Mossy Tracker and Metas windows even after the player closed them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
73 lines
2.7 KiB
C#
73 lines
2.7 KiB
C#
using AcDream.Plugin.Abstractions;
|
|
|
|
namespace OpenAC.MosswartMassacre.Tests;
|
|
|
|
public sealed class HostReadingsTests
|
|
{
|
|
[Theory]
|
|
// The original's (long)((1.00 - (v + 0.0000001f)) * 100 + 0.5f).
|
|
[InlineData(1f, 0)]
|
|
[InlineData(0.95f, 5)]
|
|
[InlineData(0.9f, 10)]
|
|
[InlineData(0.6f, 40)]
|
|
// 0.995 plus the nudge is just over 0.995 as a float: the rounding lands on 0.
|
|
[InlineData(0.995f, 0)]
|
|
public void Vitae_is_the_penalty_in_percent_as_the_original_rounded_it(float multiplier, int expected) =>
|
|
Assert.Equal(expected, HostReadings.VitaePercent(multiplier));
|
|
|
|
[Fact]
|
|
public void The_vitals_frame_carries_the_vitae_penalty()
|
|
{
|
|
using var harness = new PluginHarness("Mossy");
|
|
harness.Host.Automation.Character.VitaeMultiplier = 0.95f;
|
|
harness.Host.Automation.Character.MaxHealth = 10;
|
|
harness.Login();
|
|
harness.Frames.Clear();
|
|
|
|
harness.Feature<OpenAC.MosswartMassacre.Streams.VitalsStream>().SendNow();
|
|
|
|
Assert.EndsWith(",\"vitae\":5}", Assert.Single(harness.Frames), StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void Titles_are_null_until_listed_then_names_in_order_and_the_current_id()
|
|
{
|
|
var character = new Fakes.FakeCharacter();
|
|
Assert.Null(HostReadings.Titles(character));
|
|
Assert.Null(HostReadings.CurrentTitle(character));
|
|
|
|
character.Titles = [new PluginCharacterTitle(7, "Adventurer"), new PluginCharacterTitle(3, "Sawato Resident")];
|
|
character.CurrentTitleId = 3;
|
|
|
|
Assert.Equal(["Adventurer", "Sawato Resident"], HostReadings.Titles(character));
|
|
Assert.Equal(3, HostReadings.CurrentTitle(character));
|
|
}
|
|
|
|
[Fact]
|
|
public void Allegiance_maps_monarch_patron_rank_and_followers()
|
|
{
|
|
var automation = new Fakes.FakeAutomation();
|
|
Assert.Null(HostReadings.Allegiance(automation));
|
|
|
|
automation.Allegiance.Snapshot = new PluginAllegianceSnapshot(1, true, "Mossy Club", 3u, 40u, 17u, 5u)
|
|
{
|
|
Monarch = new PluginAllegianceMember(5u, "King", 8u, 200u, 1, 2, true),
|
|
};
|
|
|
|
var summary = HostReadings.Allegiance(automation)!.Value;
|
|
Assert.Equal("Mossy Club", summary.Name);
|
|
Assert.Equal(new OpenAC.MosswartMassacre.Streams.AllegianceMember("King", 1, 8, 2), summary.Monarch);
|
|
Assert.Null(summary.Patron);
|
|
Assert.Equal(3, summary.Rank);
|
|
Assert.Equal(17, summary.Followers);
|
|
}
|
|
|
|
[Fact]
|
|
public void Meta_state_comes_from_the_bots_status_line()
|
|
{
|
|
var host = new Fakes.FakeHost();
|
|
Assert.Equal(string.Empty, HostReadings.MetaState(host));
|
|
host.StatusBoard.Lines[("acdream.mosstank", "metaState")] = "Combat";
|
|
Assert.Equal("Combat", HostReadings.MetaState(host));
|
|
}
|
|
}
|