Snapshot for release 2026.10.15.2 (internal 2d4b0af)
This commit is contained in:
parent
a89ae04005
commit
d5e0b50de7
224 changed files with 17914 additions and 1182 deletions
|
|
@ -16,6 +16,8 @@
|
|||
<PackageReference Include="Avalonia.Desktop" Version="11.2.3" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.3" />
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.2.3" />
|
||||
<!-- Avalonia pulls Tmds.DBus.Protocol 0.20.0 (GHSA-xrw6-gwf8-vvr9; D-Bus is Linux-only, but pin the fixed version). -->
|
||||
<PackageReference Include="Tmds.DBus.Protocol" Version="0.21.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ internal static class Program
|
|||
MeleeStallTests.Register(runner);
|
||||
ServerMenuTests.Register(runner);
|
||||
MiniRemoteMoveTests.Register(runner);
|
||||
SectionsTests.Register(runner);
|
||||
ItemsCleanTests.Register(runner);
|
||||
DeathRecallTests.Register(runner);
|
||||
InventoryAttributeFilterTests.Register(runner);
|
||||
|
|
@ -128,6 +129,11 @@ internal static class Program
|
|||
SaveFailureTests.Register(runner);
|
||||
DoorTests.Register(runner);
|
||||
BlankLoadTests.Register(runner);
|
||||
GiveProfileTests.Register(runner);
|
||||
TinkerTests.Register(runner);
|
||||
LauncherSwapTests.Register(runner);
|
||||
SelfRatingsTests.Register(runner);
|
||||
IltClientLookupTests.Register(runner);
|
||||
return runner.Run("RynthAi host tests", args.Length > 0 ? args[0] : null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,14 @@
|
|||
<Compile Include="..\..\..\RynthCore\src\RynthCore.Engine\UI\Data\MetaLocation.cs" Link="Engine\MetaLocation.cs" />
|
||||
<!-- The Inventory panel's attribute filter rules and matching (pure; engine 2026-10-11). -->
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.Engine\Compatibility\InventoryAttributeFilter.cs" Link="Engine\InventoryAttributeFilter.cs" />
|
||||
<!-- The Mini Remote sections' manifest parser and catalog (pure; engine 2026.10.5.46), so
|
||||
SectionsTests checks RynthAi's RynthPluginGetSectionsJson against the engine's reader.
|
||||
IltDetect (with AelrynthWire, which it shares a parser with) does the catalog's matching. -->
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.Engine\UI\Sections\ServerForce.cs" Link="Engine\ServerForce.cs" />
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.Engine\UI\Sections\SectionManifest.cs" Link="Engine\SectionManifest.cs" />
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.Engine\UI\Sections\SectionCatalog.cs" Link="Engine\SectionCatalog.cs" />
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.Engine\Compatibility\IltDetect.cs" Link="Engine\IltDetect.cs" />
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.Engine\Compatibility\AelrynthWire.cs" Link="Engine\AelrynthWire.cs" />
|
||||
<!-- The engine's v84 GetObjectProperties record writer (pure), so the propertydump tests feed
|
||||
RynthAi exactly what the engine sends (engine 2026-10-13). -->
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.Engine\Compatibility\PropertyWire.cs" Link="Engine\PropertyWire.cs" />
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ internal static class AmmoTests
|
|||
InHand = unchecked((int)Bow);
|
||||
C.InHandOverride = () => InHand;
|
||||
C.OpenPackOverride = () => unchecked((int)Pack);
|
||||
C.AmmoOffSettleMs = 0; // the ticks here don't wait on the wall clock
|
||||
Target = new WorldObject(unchecked((int)Monster), "Test Dummy", AcObjectClass.Monster);
|
||||
List(Bow, Crossbow);
|
||||
}
|
||||
|
|
@ -172,7 +173,11 @@ internal static class AmmoTests
|
|||
Check.Eq(FakeHost.Uses.Count, 0, "nor the crossbow before the arrows are off");
|
||||
|
||||
Rig.Unwield(Arrows); // the arrows are in the pack
|
||||
Check.False(rig.Tick(), "tick 3: the crossbow wield is sent");
|
||||
rig.C.AmmoOffSettleMs = 60_000;
|
||||
Check.False(rig.Tick(), "arrows just read off: the settle");
|
||||
Check.Eq(FakeHost.Uses.Count, 0, "no crossbow inside the settle");
|
||||
rig.C.AmmoOffSettleMs = 0;
|
||||
Check.False(rig.Tick(), "settled: the crossbow wield is sent");
|
||||
Check.Eq(FakeHost.Uses.Count, 1, "one UseObject");
|
||||
Check.Eq(FakeHost.Uses.LastOrDefault(), Crossbow, "for the crossbow");
|
||||
|
||||
|
|
|
|||
127
Tools/RynthCore.RynthAiHostTests/Tests/GiveProfileTests.cs
Normal file
127
Tools/RynthCore.RynthAiHostTests/Tests/GiveProfileTests.cs
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using RynthCore.Loot;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.Meta;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// actiontrygiveprofile (security review M3, 2026-10-13): a meta someone shared must not read a
|
||||
// profile from outside ItemGiver\ or hand the inventory to a player, only to an NPC or vendor.
|
||||
internal static class GiveProfileTests
|
||||
{
|
||||
private const uint Player = 0x50000F01, Imitator = 0x50000F02;
|
||||
private const uint Npc = 0x80281000;
|
||||
private const uint Mote1 = 0x80281101, Mote2 = 0x80281102;
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("give profile: the profile path stays inside ItemGiver (no rooted path, drive, stream or ..)", PathRules);
|
||||
r.Add("give profile: gives to the NPC with AC's give action, never to a player of the same name", NpcOnly);
|
||||
r.Add("give profile: a refused path returns 0 and is logged once, not every pulse", RefusedPathLoggedOnce);
|
||||
}
|
||||
|
||||
private static void PathRules()
|
||||
{
|
||||
string root = Path.Combine(Program.TempRoot, "ItemGiverPaths");
|
||||
string inside = Path.GetFullPath(root) + Path.DirectorySeparatorChar;
|
||||
string? R(string a) => ExpressionEngine.ResolveGiveProfilePath(a, root);
|
||||
|
||||
Check.Eq(R("salvage"), inside + "salvage.utl", "a bare name is a .utl inside");
|
||||
Check.Eq(R("salvage.utl"), inside + "salvage.utl", ".utl kept");
|
||||
Check.Eq(R("mine.json"), inside + "mine.json", ".json kept");
|
||||
Check.Eq(R(@"sub\deep.json"), inside + @"sub\deep.json", "a subfolder is fine");
|
||||
Check.Eq(R(@"sub\..\back.utl"), inside + "back.utl", ".. that stays inside is fine");
|
||||
Check.Eq(R(@"..\evil.utl"), null, "..\\ climbs out");
|
||||
Check.Eq(R(@"sub\..\..\evil"), null, "climbing out through a subfolder");
|
||||
Check.Eq(R(@"C:\Windows\win.ini"), null, "a full path");
|
||||
Check.Eq(R(@"\\server\share\x.utl"), null, "a UNC path");
|
||||
Check.Eq(R(@"\x.utl"), null, "a root-relative path");
|
||||
Check.Eq(R("C:x.utl"), null, "a drive-relative path");
|
||||
Check.Eq(R("x.utl:hidden"), null, "an alternate data stream");
|
||||
Check.Eq(R(".."), null, "the parent folder itself");
|
||||
Check.Eq(R("."), null, "the folder itself");
|
||||
Check.Eq(R(" "), null, "blank");
|
||||
}
|
||||
|
||||
/// <summary>The player, two carried motes, an NPC and (optionally) a player named like it.</summary>
|
||||
private static (ExpressionEngine E, WorldObjectCache Cache) World(bool withImitator, bool withNpc = true)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.GiveCalls = true;
|
||||
FakeHost.SalvageCalls = true; // MoveItemExternal recorded: it must not be used
|
||||
FakeHost.Names[Player] = "Giver";
|
||||
FakeHost.PlayerIdValue = Player;
|
||||
FakeHost.Positions[Player] = (0x1048002Au, 100f, 100f, 0f);
|
||||
FakeHost.PlayerPose = (0x1048002Au, 100f, 100f, 0f);
|
||||
if (withImitator)
|
||||
{
|
||||
FakeHost.Names[Imitator] = "Town Crier";
|
||||
FakeHost.Positions[Imitator] = (0x1048002Au, 100.5f, 100f, 0f);
|
||||
FakeHost.ItemTypes[Imitator] = 0x10; // a creature
|
||||
FakeHost.Bitfields[Imitator] = 0x18; // BF_PLAYER | BF_ATTACKABLE
|
||||
}
|
||||
if (withNpc)
|
||||
{
|
||||
FakeHost.Names[Npc] = "Town Crier";
|
||||
FakeHost.Positions[Npc] = (0x1048002Au, 101f, 100f, 0f);
|
||||
FakeHost.ItemTypes[Npc] = 0x10;
|
||||
FakeHost.NotAttackable.Add(Npc);
|
||||
FakeHost.Bitfields[Npc] = 0x4; // not a player, not attackable
|
||||
}
|
||||
foreach (uint id in new[] { Mote1, Mote2 })
|
||||
{
|
||||
FakeHost.Names[id] = "Mana Mote";
|
||||
FakeHost.Containers[id] = Player;
|
||||
FakeHost.ItemTypes[id] = 0x80;
|
||||
}
|
||||
var host = FakeHost.Create(playerId: Player);
|
||||
var cache = new WorldObjectCache(host);
|
||||
cache.SetPlayerId(Player);
|
||||
foreach (uint id in new[] { Imitator, Npc, Mote1, Mote2 })
|
||||
if (FakeHost.Names.ContainsKey(id)) cache.OnCreateObject(id);
|
||||
cache.Tick();
|
||||
|
||||
// One rule with no conditions keeps everything.
|
||||
Directory.CreateDirectory(ExpressionEngine.ItemGiverDir);
|
||||
var p = new LootProfile { Name = "give all" };
|
||||
p.Rules.Add(new LootRule { Name = "All", Action = LootAction.Keep });
|
||||
p.Save(Path.Combine(ExpressionEngine.ItemGiverDir, "giveall.json"));
|
||||
|
||||
var e = ExpressionTests.Engine(host, playerId: Player);
|
||||
e.SetObjectCache(cache);
|
||||
return (e, cache);
|
||||
}
|
||||
|
||||
// Backticks: an unquoted name with a space doesn't reach the action as one argument.
|
||||
private const string GiveExpr = "actiontrygiveprofile[`giveall.json`,`Town Crier`]";
|
||||
|
||||
private static void NpcOnly()
|
||||
{
|
||||
var (e, _) = World(withImitator: true);
|
||||
Check.Eq(e.Evaluate(GiveExpr), "1", "an item was given");
|
||||
Check.True(FakeHost.Gives.Count == 1 && FakeHost.Gives[0].Target == Npc, "to the NPC, past the player of that name");
|
||||
Check.True(FakeHost.Gives.Count == 1 && FakeHost.Gives[0].Amount == 0, "the whole object");
|
||||
Check.Eq(FakeHost.ExternalMoves.Count, 0, "never MoveItemExternal (an NPC ignores it)");
|
||||
|
||||
var (e2, _) = World(withImitator: true, withNpc: false);
|
||||
Check.Eq(e2.Evaluate(GiveExpr), "0", "only a player has the name: nothing");
|
||||
Check.Eq(FakeHost.Gives.Count, 0, "nothing given to the player");
|
||||
Check.Eq(FakeHost.ExternalMoves.Count, 0, "nor moved to them");
|
||||
}
|
||||
|
||||
private static void RefusedPathLoggedOnce()
|
||||
{
|
||||
var (e, _) = World(withImitator: false);
|
||||
// The profile exists one folder up: only the path rule refuses it.
|
||||
File.Copy(Path.Combine(ExpressionEngine.ItemGiverDir, "giveall.json"),
|
||||
Path.Combine(ExpressionEngine.ItemGiverDir, "..", "giveall.json"), overwrite: true);
|
||||
for (int i = 0; i < 3; i++)
|
||||
Check.Eq(e.Evaluate("actiontrygiveprofile[`../giveall.json`,`Town Crier`]"), "0", $"pulse {i + 1}: refused");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("refused profile '../giveall.json'")), 1, "logged once, with the argument");
|
||||
Check.Eq(FakeHost.Gives.Count, 0, "nothing given");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
using RynthCore.Plugin.RynthAi.MiniRemote;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// RynthAi's lookup of RynthILT's "RynthILT.Hub" table (MiniRemote/IltClient.Tick). Until
|
||||
// 0.5.60 the "never looked" sentinel was long.MinValue, "now - long.MinValue" overflowed to a
|
||||
// negative number, the recheck gate always said "not due", and RynthAi never found RynthILT:
|
||||
// no ILT tabs, sections or feature bits in the Mini Remote on Infinite Leaftide.
|
||||
internal static class IltClientLookupTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("ILT client: the first Tick (and the first after Reset) looks RynthILT up", FirstLook);
|
||||
r.Add("ILT client: a live table is kept until the recheck interval", LiveTableKept);
|
||||
r.Add("ILT client: no table retries every interval; a shut-down table at once", RetryRules);
|
||||
}
|
||||
|
||||
private static void FirstLook()
|
||||
{
|
||||
// Any clock value, including the large tick counts of a long-running PC.
|
||||
foreach (long now in new[] { 0L, 1_000L, 5_000_000L, long.MaxValue / 2 })
|
||||
Check.True(IltClient.LookupDue(checkedOnce: false, checkedAt: 0, now, haveTable: false, tableLive: false),
|
||||
$"never looked: due at now={now}");
|
||||
}
|
||||
|
||||
private static void LiveTableKept()
|
||||
{
|
||||
Check.False(IltClient.LookupDue(true, checkedAt: 10_000, now: 11_000, haveTable: true, tableLive: true), "live table within the interval");
|
||||
Check.True(IltClient.LookupDue(true, checkedAt: 10_000, now: 13_000, haveTable: true, tableLive: true), "live table after the interval");
|
||||
}
|
||||
|
||||
private static void RetryRules()
|
||||
{
|
||||
Check.False(IltClient.LookupDue(true, checkedAt: 10_000, now: 12_999, haveTable: false, tableLive: false), "no table: waits the interval");
|
||||
Check.True(IltClient.LookupDue(true, checkedAt: 10_000, now: 13_000, haveTable: false, tableLive: false), "no table: looks again after it");
|
||||
Check.True(IltClient.LookupDue(true, checkedAt: 10_000, now: 10_001, haveTable: true, tableLive: false), "Version 0 (RynthILT shut down): looks again at once");
|
||||
}
|
||||
}
|
||||
277
Tools/RynthCore.RynthAiHostTests/Tests/LauncherSwapTests.cs
Normal file
277
Tools/RynthCore.RynthAiHostTests/Tests/LauncherSwapTests.cs
Normal file
|
|
@ -0,0 +1,277 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using RynthCore.Loot;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.CreatureData;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// Mixed launchers (2026-10-12): a crossbow with quarrels to a bow with arrows. The log of
|
||||
// 2026-10-11 14:45:11-17 took 6.4 s and flickered the stance Missile/peace/Melee: combat asked
|
||||
// for Missile mode while the bow (or its arrows) wasn't on, and each step waited the swap gate's
|
||||
// full 3 s. Now no stance request goes out until the launcher and its ammo are on, and the
|
||||
// launcher goes 400 ms after the quarrels read off.
|
||||
internal static class LauncherSwapTests
|
||||
{
|
||||
private const uint Player = 0x50000C01;
|
||||
private const uint Monster = 0x80001001;
|
||||
private const uint Wcid = 434344;
|
||||
private const uint Crossbow = 0x80000601, Bow = 0x80000602, Quarrels = 0x80000603, Arrows = 0x80000604;
|
||||
private const uint Pack = 0x80000501;
|
||||
private const int MissileSlot = 0x00400000, AmmoSlot = 0x00800000;
|
||||
private const int PropAmmoType = 50, PropStack = 12, PropMaxStack = 11;
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("launcher swap: no stance request until the launcher and its ammo are on", NoStanceMidSwap);
|
||||
r.Add("launcher swap: the launcher goes once the old ammo reads off (not 3 s + 2 s)", ShortWaitAfterAmmoOff);
|
||||
r.Add("launcher swap: from peace mode the dequip still holds the stance", PeaceStartHoldsStance);
|
||||
r.Add("swap gate: MoveDone lets the next swap go on the server's answers", GateMoveDone);
|
||||
r.Add("swap holds: a nearly dead target keeps the crossbow (nothing of the swap started)", LowHealthKeepsLauncher);
|
||||
r.Add("swap holds: a swap under way finishes even when the target gets low (quarrels already off)", LowHealthMidSwapFinishes);
|
||||
r.Add("swap holds: a lock after a kill swaps at once; a switch from a live target waits", SettleOnlyAfterSwitch);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WeaponSwapSettleMs (2026-10-15): Kelpie's logs had 22 of 25 settle holds swap anyway within
|
||||
/// 3 s, nearly all on a fresh lock after a kill. Only a switch from another live target waits.
|
||||
/// </summary>
|
||||
private static void SettleOnlyAfterSwitch()
|
||||
{
|
||||
var rig = new Rig(CombatMode.Missile);
|
||||
rig.Lock(Monster, wasSwitch: false);
|
||||
Check.False(rig.Tick(0), "fresh lock 0 ms ago: the swap starts");
|
||||
Check.True(FakeHost.Moves.Count == 1 && FakeHost.Moves[0].Id == Quarrels, "the quarrels go into the pack at once");
|
||||
Check.False(FakeHost.Logs.Any(l => l.Contains("not swapping")), "no settle hold logged");
|
||||
|
||||
rig = new Rig(CombatMode.Missile);
|
||||
rig.Lock(Monster, wasSwitch: true);
|
||||
Check.False(rig.Tick(0), "switched 0 ms ago: the attack waits for the target to settle");
|
||||
Check.Eq(FakeHost.Moves.Count, 0, "nothing of the swap started");
|
||||
Check.Eq(FakeHost.Uses.Count, 0, "no bow wield");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("not swapping") && l.Contains("target switched")), "the hold says why");
|
||||
|
||||
rig.S.WeaponSwapSettleMs = 0;
|
||||
rig.Tick(100);
|
||||
Check.True(FakeHost.Moves.Count == 1 && FakeHost.Moves[0].Id == Quarrels, "setting 0: the swap starts");
|
||||
}
|
||||
|
||||
/// <summary>WeaponSwapMinHealthPct: no swap starts onto a target at 25% or less.</summary>
|
||||
private static void LowHealthKeepsLauncher()
|
||||
{
|
||||
var rig = new Rig(CombatMode.Missile);
|
||||
rig.Cache.OnUpdateHealth(Monster, 0.2f);
|
||||
Check.True(rig.Tick(0), "target at 20%: fight on with the crossbow");
|
||||
Check.Eq(FakeHost.Moves.Count, 0, "the quarrels stay on");
|
||||
Check.Eq(FakeHost.Uses.Count, 0, "no bow wield");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("not swapping") && l.Contains("20% health")), "the hold is logged");
|
||||
|
||||
rig.S.WeaponSwapMinHealthPct = 0;
|
||||
rig.Tick(100);
|
||||
Check.True(FakeHost.Moves.Count == 1 && FakeHost.Moves[0].Id == Quarrels, "setting off: the swap starts");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The ammo fix (2026-10-12) must hold: once the quarrels went into the pack, a hold rule may
|
||||
/// not keep the crossbow (it would stand there with no ammo on); the bow goes on as planned.
|
||||
/// </summary>
|
||||
private static void LowHealthMidSwapFinishes()
|
||||
{
|
||||
var rig = new Rig(CombatMode.Missile);
|
||||
rig.C.AmmoOffSettleMs = 0;
|
||||
Check.False(rig.Tick(0), "full health: the swap starts");
|
||||
Check.True(FakeHost.Moves.Count == 1 && FakeHost.Moves[0].Id == Quarrels, "the quarrels go into the pack");
|
||||
|
||||
rig.Cache.OnUpdateHealth(Monster, 0.1f);
|
||||
Rig.Unwield(Quarrels);
|
||||
FakeHost.CombatModeValue = CombatMode.NonCombat;
|
||||
Check.False(rig.Tick(500), "quarrels off, target at 10%: still not ready");
|
||||
Check.Eq(FakeHost.Uses.LastOrDefault(), Bow, "the bow goes on anyway");
|
||||
Check.Eq(FakeHost.CombatModeRequests.Count, 0, "no Missile request until the bow and arrows are on");
|
||||
|
||||
rig.Landed(Bow, Crossbow, MissileSlot);
|
||||
rig.Tick(1000);
|
||||
Check.Eq(FakeHost.Uses.LastOrDefault(), Arrows, "then its arrows");
|
||||
}
|
||||
|
||||
// ── The rig ───────────────────────────────────────────────────────────────
|
||||
|
||||
private sealed class Rig
|
||||
{
|
||||
public readonly LegacyUiSettings S = new();
|
||||
public readonly CombatManager C;
|
||||
public readonly MonsterDamageStore Store = new();
|
||||
public readonly WorldObject Target;
|
||||
public readonly WeaponSwapGate Gate;
|
||||
public readonly WorldObjectCache Cache;
|
||||
public long T;
|
||||
public int InHand;
|
||||
private readonly MethodInfo _equip = typeof(CombatManager).GetMethod("EquipWeaponAndSetStance", BindingFlags.Instance | BindingFlags.NonPublic)!;
|
||||
|
||||
public Rig(int startMode)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.WeaponCalls = true;
|
||||
FakeHost.CombatModeCalls = true;
|
||||
FakeHost.CombatModeValue = startMode;
|
||||
Item(Crossbow, "Heavy Crossbow", MissileSlot, ammoType: 2);
|
||||
Item(Bow, "Longbow", MissileSlot, ammoType: 1);
|
||||
Item(Quarrels, "Quarrel", AmmoSlot, ammoType: 2, stack: true);
|
||||
Item(Arrows, "Arrow", AmmoSlot, ammoType: 1, stack: true);
|
||||
Wield(Crossbow, MissileSlot);
|
||||
Wield(Quarrels, AmmoSlot);
|
||||
FakeHost.Wcids[Monster] = Wcid;
|
||||
var host = FakeHost.Create();
|
||||
var cache = FakeHost.MakeCache(host, Player, new[] { Crossbow, Bow, Quarrels, Arrows });
|
||||
Cache = cache;
|
||||
C = new CombatManager(host, S, cache);
|
||||
C.SetPlayerId(Player);
|
||||
C.SetDamageStores(null, Store);
|
||||
var skills = new CharacterSkills(host);
|
||||
skills.SetPlayerId(Player);
|
||||
C.SetCharacterSkills(skills);
|
||||
C.CanCastOverride = _ => false;
|
||||
InHand = unchecked((int)Crossbow);
|
||||
C.InHandOverride = () => InHand;
|
||||
C.OpenPackOverride = () => unchecked((int)Pack);
|
||||
C.OffhandReadMs = 0;
|
||||
C.SwapTracker.MinDwellMs = 0;
|
||||
// The live gate's settings, on a test clock; the server answers at once.
|
||||
Gate = new WeaponSwapGate { MinIntervalMs = 3000, NowMs = () => T, ServerIdle = () => true, IsWielded = _ => false };
|
||||
C.SetWeaponSwapGate(Gate);
|
||||
Target = new WorldObject(unchecked((int)Monster), "Test Dummy", AcObjectClass.Monster);
|
||||
S.ItemRules = new[] { Crossbow, Bow }.Select(i => new ItemRule
|
||||
{
|
||||
Id = unchecked((int)i), Name = FakeHost.Names[i], Element = "", ElementSource = "", Action = "Weapon",
|
||||
}).ToList();
|
||||
Store.SetManualWeapon(Wcid, Bow); // the Damage tab says the bow
|
||||
}
|
||||
|
||||
private static void Item(uint id, string name, int validSlots, int ammoType, bool stack = false)
|
||||
{
|
||||
FakeHost.Names[id] = name;
|
||||
FakeHost.ItemTypes[id] = 0x100; // MissileWeapon
|
||||
FakeHost.Ints[(id, 9)] = validSlots;
|
||||
FakeHost.Ints[(id, PropAmmoType)] = ammoType;
|
||||
if (stack) { FakeHost.Ints[(id, PropStack)] = 100; FakeHost.Ints[(id, PropMaxStack)] = 250; }
|
||||
}
|
||||
|
||||
public static void Wield(uint id, int slot) => FakeHost.Ints[(id, 10)] = slot;
|
||||
public static void Unwield(uint id) => FakeHost.Ints.Remove((id, 10));
|
||||
|
||||
/// <summary>One combat equip tick at <paramref name="atMs"/> on the gate's clock; true = ready to attack.</summary>
|
||||
public bool Tick(long atMs)
|
||||
{
|
||||
T = atMs;
|
||||
return (bool)_equip.Invoke(C, new object[] { Target, "Auto" })!;
|
||||
}
|
||||
|
||||
/// <summary>Combat locked <paramref name="target"/> just now (a switch from another live target or not).</summary>
|
||||
public void Lock(uint target, bool wasSwitch)
|
||||
{
|
||||
const BindingFlags F = BindingFlags.Instance | BindingFlags.NonPublic;
|
||||
typeof(CombatManager).GetField("_lockedTargetId", F)!.SetValue(C, unchecked((int)target));
|
||||
typeof(CombatManager).GetField("_targetLockedAt", F)!.SetValue(C, DateTime.Now);
|
||||
typeof(CombatManager).GetField("_lockWasSwitch", F)!.SetValue(C, wasSwitch);
|
||||
}
|
||||
|
||||
public void Landed(uint weapon, uint old, int slot)
|
||||
{
|
||||
Unwield(old);
|
||||
Wield(weapon, slot);
|
||||
InHand = unchecked((int)weapon);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Tests ────────────────────────────────────────────────────────────────
|
||||
|
||||
private static void NoStanceMidSwap()
|
||||
{
|
||||
var rig = new Rig(CombatMode.Missile);
|
||||
rig.C.AmmoOffSettleMs = 0;
|
||||
|
||||
Check.False(rig.Tick(0), "tick 1: not ready");
|
||||
Check.True(FakeHost.Moves.Count == 1 && FakeHost.Moves[0].Id == Quarrels, "the quarrels go into the pack first");
|
||||
Check.Eq(FakeHost.Uses.Count, 0, "no bow wield with the quarrels on");
|
||||
|
||||
// The server takes the quarrels and drops the character to peace mode.
|
||||
Rig.Unwield(Quarrels);
|
||||
FakeHost.CombatModeValue = CombatMode.NonCombat;
|
||||
Check.False(rig.Tick(500), "quarrels off: the bow wield goes out");
|
||||
Check.Eq(FakeHost.Uses.LastOrDefault(), Bow, "UseObject(bow)");
|
||||
Check.Eq(FakeHost.CombatModeRequests.Count, 0, "no Missile request with the bow not on (was the flicker)");
|
||||
for (int i = 1; i <= 3; i++) rig.Tick(500 + i * 100);
|
||||
Check.Eq(FakeHost.CombatModeRequests.Count, 0, "none while the bow's wield is in flight");
|
||||
|
||||
rig.Landed(Bow, Crossbow, MissileSlot);
|
||||
Check.False(rig.Tick(1000), "bow in hand: the arrows go on");
|
||||
Check.Eq(FakeHost.Uses.LastOrDefault(), Arrows, "UseObject(arrows)");
|
||||
Check.Eq(FakeHost.CombatModeRequests.Count, 0, "no Missile request before the arrows are on");
|
||||
|
||||
Rig.Wield(Arrows, AmmoSlot);
|
||||
Check.False(rig.Tick(1500), "bow and arrows: the stance goes out");
|
||||
Check.True(FakeHost.CombatModeRequests.SequenceEqual(new[] { CombatMode.Missile }), "exactly one Missile request, after the arrows");
|
||||
FakeHost.CombatModeValue = CombatMode.Missile;
|
||||
Check.True(rig.Tick(2500), "in Missile mode: ready to shoot");
|
||||
}
|
||||
|
||||
private static void ShortWaitAfterAmmoOff()
|
||||
{
|
||||
var rig = new Rig(CombatMode.Missile);
|
||||
rig.Tick(0);
|
||||
Check.True(FakeHost.Moves.Count == 1 && FakeHost.Moves[0].Id == Quarrels, "the quarrels go into the pack");
|
||||
|
||||
Rig.Unwield(Quarrels);
|
||||
FakeHost.CombatModeValue = CombatMode.NonCombat;
|
||||
rig.Tick(150);
|
||||
Check.Eq(FakeHost.Uses.Count, 0, "just read off: the 400 ms settle");
|
||||
|
||||
// The settle passed (the test can't wait on the wall clock): the launcher goes far inside
|
||||
// the gate's 3 s and the old 2 s equip pacing.
|
||||
rig.C.AmmoOffSettleMs = 0;
|
||||
rig.Tick(600);
|
||||
Check.Eq(FakeHost.Uses.LastOrDefault(), Bow, "the bow at 0.6 s (was 3.0 s)");
|
||||
|
||||
rig.Landed(Bow, Crossbow, MissileSlot);
|
||||
rig.Tick(1100);
|
||||
Check.Eq(FakeHost.Uses.LastOrDefault(), Arrows, "the arrows at 1.1 s (was 6.0 s)");
|
||||
Check.Eq(FakeHost.Moves.Count, 1, "one pack move in all");
|
||||
}
|
||||
|
||||
private static void PeaceStartHoldsStance()
|
||||
{
|
||||
// Peace mode with the crossbow and quarrels on: the not-wielded branch dequips; its stance
|
||||
// request (sent with any wield before) is held for the whole swap.
|
||||
var rig = new Rig(CombatMode.NonCombat);
|
||||
rig.C.AmmoOffSettleMs = 0;
|
||||
Check.False(rig.Tick(0), "not ready");
|
||||
Check.True(FakeHost.Moves.Count == 1 && FakeHost.Moves[0].Id == Quarrels, "the quarrels go into the pack");
|
||||
Check.Eq(FakeHost.CombatModeRequests.Count, 0, "no Missile request with the wrong ammo on");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("stance held")), "the hold is logged");
|
||||
|
||||
Rig.Unwield(Quarrels);
|
||||
rig.Tick(500);
|
||||
Check.Eq(FakeHost.Uses.LastOrDefault(), Bow, "then the bow");
|
||||
Check.Eq(FakeHost.CombatModeRequests.Count, 0, "still no Missile request");
|
||||
}
|
||||
|
||||
private static void GateMoveDone()
|
||||
{
|
||||
long t = 0;
|
||||
var g = new WeaponSwapGate { NowMs = () => t, ServerIdle = () => true, IsWielded = _ => false };
|
||||
Check.True(g.TryBeginSwap("ammo off"), "first swap");
|
||||
g.NoteMove(7, wieldedNow: true);
|
||||
t = 500;
|
||||
Check.False(g.TryBeginSwap("launcher"), "a noted move: held");
|
||||
g.MoveDone(8);
|
||||
Check.False(g.TryBeginSwap("launcher"), "another item's MoveDone changes nothing");
|
||||
g.MoveDone(7);
|
||||
Check.True(g.TryBeginSwap("launcher"), "MoveDone: the launcher goes at 0.5 s");
|
||||
t = 700;
|
||||
Check.False(g.TryBeginSwap("ammo"), "under the 400 ms floor");
|
||||
}
|
||||
}
|
||||
|
|
@ -49,12 +49,16 @@ internal static class LootCorpseTests
|
|||
r.Add("loot chain: without GetContainerContents an unseen item stays unseen (no crash)", UnseenItemOldEngine);
|
||||
r.Add("loot starvation: a corpse waiting behind far-off combat gets a turn, a close monster keeps combat", LootStarvation);
|
||||
r.Add("loot logging: a corpse held by combat is logged once, with the reason", HeldByCombatLoggedOnce);
|
||||
r.Add("boost loot: our kill holds the next target until its corpse is looted (one kill, one loot)", BoostLootOneKillOneLoot);
|
||||
r.Add("boost loot: the wait ends after BoostLootKillWaitMs, for a close monster, and with Boost Loot off", BoostLootHoldLimits);
|
||||
r.Add("boost loot: looting the kill's corpse ends the wait; an older corpse does not", BoostLootWaitEndsOnKillCorpse);
|
||||
r.Add("monster ignore: a close Priority 0 monster neither holds combat nor starves the corpse", IgnoredMonsterDoesNotHoldLoot);
|
||||
r.Add("corpse close: a finished corpse is closed once (CloseContainer, API v76)", FinishedCorpseClosedOnce);
|
||||
r.Add("corpse close: an engine without CloseContainer leaves it to the next open (no close)", FinishedCorpseNotClosedOnOldEngine);
|
||||
r.Add("corpse close: an abandoned open corpse is closed once", AbandonedCorpseClosed);
|
||||
r.Add("corpse close: stopping the macro mid-loot closes the open corpse, not marked completed", MacroStopClosesCorpse);
|
||||
r.Add("loot pacing: a pickup waits for the last bend-down, and no retry is timed while it plays", PickupWaitsForAnimation);
|
||||
r.Add("loot: a pack that takes none of an item's tries is left out; the item tries another, else looting stops", RefusingPackIsLeftOut);
|
||||
r.Add("loot pacing: no pickup (first or retry) while the server owes an answer to a cast; it goes on the UseDone", PickupWaitsForCastAnswer);
|
||||
r.Add("corpse close: not while the last item is between the corpse and the pack - it closes once the item is in the inventory", CloseWaitsForInventory);
|
||||
r.Add("loot pacing: an item merged into a stack in the pack is confirmed without the 4 s arrival wait", MergedPickupConfirmedQuickly);
|
||||
|
|
@ -396,6 +400,113 @@ internal static class LootCorpseTests
|
|||
Check.Eq(ActivityArbiter.Decide(in inputs), BotActivity.Looting, "so looting has the tick without needing a starved turn");
|
||||
}
|
||||
|
||||
// ── Boost Loot Priority: one kill, one loot (2026-10-14, Kelpie: the next target was locked
|
||||
// 6 ms after each kill, the corpse came 3 s later, and corpses were looted in batches) ──
|
||||
|
||||
/// <summary>
|
||||
/// A monster <paramref name="monsterMeters"/> away, Boost Loot Priority on, and combat's
|
||||
/// HoldNewTarget wired to the plugin. The corpse is created only with <paramref name="withCorpse"/>.
|
||||
/// </summary>
|
||||
private static Bot BoostWorld(float monsterMeters, bool withCorpse, out CombatManager combat, bool boost = true)
|
||||
{
|
||||
BaseWorld(corpsePositioned: true);
|
||||
FakeHost.Names[Monster] = "Ancient Water Elemental";
|
||||
FakeHost.ItemTypes[Monster] = ItemTypeCreature;
|
||||
FakeHost.Positions[Monster] = (Me0.Cell, Me0.X + monsterMeters, Me0.Y + 0.5f, Me0.Z);
|
||||
var host = FakeHost.Create(Player);
|
||||
var bot = new Bot(host);
|
||||
bot.S.EnableCombat = true;
|
||||
bot.S.MonsterRange = 50;
|
||||
bot.S.BoostLootPriority = boost;
|
||||
if (withCorpse) bot.Cache.OnCreateObject(Corpse);
|
||||
_ = bot.Cache[unchecked((int)Monster)];
|
||||
bot.Cache.OnUpdateHealth(Monster, 1f);
|
||||
bot.Cache.Tick();
|
||||
combat = new CombatManager(host, bot.S, bot.Cache);
|
||||
combat.SetPlayerId(Player);
|
||||
typeof(CombatManager).GetField("_lastScanTime", Any)?.SetValue(combat, DateTime.MinValue);
|
||||
combat.ScanNearbyTargets();
|
||||
bot.Set("_combatManager", combat);
|
||||
combat.HoldNewTarget = () => (bool)bot.Call("BoostLootHoldsNewTarget")!;
|
||||
return bot;
|
||||
}
|
||||
|
||||
private static void BoostLootOneKillOneLoot()
|
||||
{
|
||||
var bot = BoostWorld(15f, withCorpse: false, out var combat);
|
||||
Check.False((bool)bot.Call("BoostLootHoldsNewTarget")!, "no kill, no corpse: nothing to wait for");
|
||||
|
||||
// The kill lands; the corpse doesn't exist yet (ACE creates it after the death animation).
|
||||
bot.Call("NoteBoostLootKill");
|
||||
combat.HandleCombatTrigger();
|
||||
Check.Eq(combat.activeTargetId, 0, "the next monster (15 m) is not locked while the corpse forms");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("[CombatTarget] next target waits: Boost Loot Priority")), "said once");
|
||||
Check.True(bot.HasLootWork(), "the forming corpse is loot work");
|
||||
Check.False(combat.IsUnderCloseAttack, "nothing locked, nothing close: not engaged");
|
||||
var waiting = new ArbiterInputs(true, false, combat.HasEngageableTarget, true, false, true,
|
||||
combatEngaged: combat.IsUnderCloseAttack, boostLoot: true);
|
||||
Check.Eq(ActivityArbiter.Decide(in waiting), BotActivity.Looting, "so the arbiter gives Looting the tick");
|
||||
|
||||
// The corpse arrives: it is claimed and opened before the next fight.
|
||||
bot.Cache.OnCreateObject(Corpse);
|
||||
bot.Cache.Tick();
|
||||
Check.True(bot.HasLootWork(), "the kill's corpse is lootable");
|
||||
combat.HandleCombatTrigger();
|
||||
Check.Eq(combat.activeTargetId, 0, "still no new target with the corpse in range");
|
||||
bot.Tick(BotActivity.Looting);
|
||||
Check.Eq(bot.Get<int>("_targetCorpseId"), unchecked((int)Corpse), "the corpse is claimed");
|
||||
Check.True(FakeHost.Uses.Contains(Corpse), "and opened");
|
||||
}
|
||||
|
||||
private static void BoostLootHoldLimits()
|
||||
{
|
||||
// The corpse never comes: the wait runs out and the next monster is locked.
|
||||
var bot = BoostWorld(15f, withCorpse: false, out var combat);
|
||||
bot.Call("NoteBoostLootKill");
|
||||
bot.Set("_boostLootKillAt", Environment.TickCount64 - RynthAiPlugin.BoostLootKillWaitMs - 1);
|
||||
Check.False((bool)bot.Call("BoostLootHoldsNewTarget")!, "past BoostLootKillWaitMs: no hold");
|
||||
combat.HandleCombatTrigger();
|
||||
Check.Eq(combat.activeTargetId, unchecked((int)Monster), "the next monster is locked");
|
||||
|
||||
// A monster within 5 yd is fought at once.
|
||||
var close = BoostWorld(2f, withCorpse: false, out var combat2);
|
||||
close.Call("NoteBoostLootKill");
|
||||
combat2.HandleCombatTrigger();
|
||||
Check.Eq(combat2.activeTargetId, unchecked((int)Monster), "a monster at 2 m: locked, the corpse waits");
|
||||
|
||||
// Boost Loot off: the old order (combat first) is unchanged.
|
||||
var off = BoostWorld(15f, withCorpse: false, out var combat3, boost: false);
|
||||
off.Call("NoteBoostLootKill");
|
||||
Check.False(off.HasLootWork(), "no forming-corpse loot work without Boost Loot");
|
||||
combat3.HandleCombatTrigger();
|
||||
Check.Eq(combat3.activeTargetId, unchecked((int)Monster), "the next monster is locked at once");
|
||||
|
||||
// Rare-only looting: most kills leave nothing to wait for.
|
||||
var rare = BoostWorld(15f, withCorpse: false, out var combat4);
|
||||
rare.S.LootOnlyRareCorpses = true;
|
||||
rare.Call("NoteBoostLootKill");
|
||||
combat4.HandleCombatTrigger();
|
||||
Check.Eq(combat4.activeTargetId, unchecked((int)Monster), "Loot Only Rare Corpses: no wait");
|
||||
}
|
||||
|
||||
private static void BoostLootWaitEndsOnKillCorpse()
|
||||
{
|
||||
var bot = BoostWorld(15f, withCorpse: false, out _);
|
||||
var waiting = bot.Get<Dictionary<int, long>>("_corpseWaitingSince");
|
||||
const int Older = 0x0BADC0DE, Fresh = 0x0BADF00D;
|
||||
|
||||
bot.Call("NoteBoostLootKill");
|
||||
long kill = bot.Get<long>("_boostLootKillAt");
|
||||
waiting[Older] = kill - 5000;
|
||||
bot.Call("EndBoostLootKillWait", Older);
|
||||
Check.Eq(bot.Get<long>("_boostLootKillAt"), kill, "a corpse from an earlier kill doesn't end the wait");
|
||||
|
||||
waiting[Fresh] = kill + 1500;
|
||||
bot.Call("EndBoostLootKillWait", Fresh);
|
||||
Check.Eq(bot.Get<long>("_boostLootKillAt"), 0L, "the kill's corpse (first seen after it) ends the wait");
|
||||
Check.False((bool)bot.Call("BoostLootHoldsNewTarget")!, "so combat goes on at once");
|
||||
}
|
||||
|
||||
private static void HeldByCombatLoggedOnce()
|
||||
{
|
||||
var bot = StarvationWorld(15f, out _);
|
||||
|
|
@ -541,20 +652,58 @@ internal static class LootCorpseTests
|
|||
}
|
||||
Check.Eq(FakeHost.ExternalMoves.Count(m => m.Id == Gem), 1, "the pickup goes out once the character is still");
|
||||
|
||||
// The bot's Loot Retry Timeout (the LootBaseline default).
|
||||
int retryWindowMs = bot.S.LootRetryTimeoutMs;
|
||||
|
||||
// Its own bend-down plays for longer than 3 retry windows: no retry, no give-up.
|
||||
FakeHost.CastBusy = 1;
|
||||
TickFor(bot, 1800);
|
||||
TickFor(bot, retryWindowMs * 3 + 300);
|
||||
Check.Eq(FakeHost.ExternalMoves.Count(m => m.Id == Gem), 1, "no retry while the pickup animates");
|
||||
Check.False(FakeHost.Logs.Any(l => l.Contains("pickup failed")), "the item is not given up on");
|
||||
|
||||
// Still again and the item still on the corpse: the retry window starts now.
|
||||
FakeHost.CastBusy = 0;
|
||||
TickFor(bot, 250);
|
||||
TickFor(bot, retryWindowMs / 2);
|
||||
Check.Eq(FakeHost.ExternalMoves.Count(m => m.Id == Gem), 1, "the retry window counts from when the character is still");
|
||||
TickFor(bot, 500);
|
||||
TickFor(bot, retryWindowMs);
|
||||
Check.Eq(FakeHost.ExternalMoves.Count(m => m.Id == Gem), 2, "then one retry");
|
||||
}
|
||||
|
||||
// 2026-10-15, Drakkon: every item went to one pack the server wouldn't take loot into (its
|
||||
// contents unknown to the client), 3 tries each, and every item on every corpse was skipped.
|
||||
// A pack that takes none of an item's tries now counts as full for a while: the item gets one
|
||||
// more round into another pack, and with none left looting stops with the pack-full message.
|
||||
private static void RefusingPackIsLeftOut()
|
||||
{
|
||||
var refusals = new RynthCore.Plugin.RynthAi.Loot.PackRefusals();
|
||||
refusals.Refuse(7, 1000);
|
||||
Check.True(refusals.IsRefused(7, 1000 + RynthCore.Plugin.RynthAi.Loot.PackRefusals.HoldMs - 1), "refused for the hold");
|
||||
Check.False(refusals.IsRefused(7, 1000 + RynthCore.Plugin.RynthAi.Loot.PackRefusals.HoldMs), "then tried again");
|
||||
refusals.Refuse(8, 0);
|
||||
refusals.Accepted(8);
|
||||
Check.False(refusals.IsRefused(8, 1), "an item landing there ends the hold");
|
||||
|
||||
BaseWorld(corpsePositioned: true);
|
||||
var host = FakeHost.Create(Player);
|
||||
var bot = new Bot(host);
|
||||
bot.Cache.OnCreateObject(Corpse);
|
||||
bot.Cache.Tick();
|
||||
bot.Tick(BotActivity.Looting);
|
||||
bot.Cache.OnCreateObject(Gem);
|
||||
bot.Cache.Tick();
|
||||
bot.P.OnViewObjectContents(Corpse);
|
||||
|
||||
// The main pack (the only destination here) never takes the gem: it stays on the corpse.
|
||||
int retryWindowMs = bot.S.LootRetryTimeoutMs;
|
||||
TickFor(bot, retryWindowMs * 4 + 600);
|
||||
Check.True(FakeHost.ExternalMoves.Count(m => m.Id == Gem) >= 3, "three tries into the main pack");
|
||||
Check.True(FakeHost.ExternalMoves.Where(m => m.Id == Gem).All(m => m.Target == Player), "all into the main pack");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("took none of 3 tries") && l.Contains("trying another pack")), "the refusing pack is left out, said once");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("no pack has a free slot")), "no other pack: the corpse is left");
|
||||
Check.True(FakeHost.Chat.Any(l => l.Contains("Pack full")), "and the player is told");
|
||||
Check.False(FakeHost.Logs.Any(l => l.Contains("pickup failed")), "not three more wasted tries into the same pack");
|
||||
}
|
||||
|
||||
// A pickup sent while Bloodstone Bolt VII was unanswered came back
|
||||
// "too busy" (ACE refuses a pickup while IsBusy); the assess-timeout path skips the busy gate.
|
||||
private static void PickupWaitsForCastAnswer()
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ internal static class MiniRemoteMoveTests
|
|||
{
|
||||
private const uint Player = 0x50000E01;
|
||||
|
||||
[System.Runtime.CompilerServices.UnsafeAccessor(System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = "_selectBreeding")]
|
||||
private static extern ref bool SelectBreedingPending(PetsTab pets);
|
||||
|
||||
private const string LegacyHubJson = """
|
||||
{
|
||||
"Bank": { "Pyreals": 99 },
|
||||
|
|
@ -35,7 +38,7 @@ internal static class MiniRemoteMoveTests
|
|||
{
|
||||
r.Add("mini remote: Pets / Quests settings come over from ilt-hub.json once, which is never rewritten", LegacyState);
|
||||
r.Add("mini remote: without RynthILT there are no ILT tabs, bits or verbs", NoRynthIlt);
|
||||
r.Add("mini remote: /ra hub|quests|pets stay RynthAi's; ILT verbs say RynthILT is needed", Commands);
|
||||
r.Add("mini remote: /ra hub|quests|pets stay RynthAi's; quest windows point to RynthOracle; ILT verbs say RynthILT is needed", Commands);
|
||||
r.Add("mini remote: the pyreal refill path never spends without RynthILT's confirmation", RefillNeedsIlt);
|
||||
r.Add("profile: the old Server Features fields still round-trip (RynthILT migrates them)", LegacyProfileFields);
|
||||
r.Add("RynthAi.Hub: table, spell names, nothing before login", HubTable);
|
||||
|
|
@ -123,9 +126,30 @@ internal static class MiniRemoteMoveTests
|
|||
Check.True(c.HandleCommand("pets", new[] { "show" }), "pets show");
|
||||
Check.True(FakeHost.Chat.Any(x => x.Contains("tab pets:show")), "same tab");
|
||||
FakeHost.Chat.Clear();
|
||||
// The Pets tab's Breeding sub-tab is RynthILT's (Infinite Leaftide only): without RynthILT there is none.
|
||||
Check.False(c.Pets.BreedingOffered, "no Breeding sub-tab without RynthILT");
|
||||
Check.True(c.HandleCommand("hub", new[] { "open", "breeding" }), "hub open breeding is answered");
|
||||
Check.True(FakeHost.Chat.Any(x => x.Contains(IltClient.NotLoaded)), "it says RynthILT is needed");
|
||||
Check.False(FakeHost.Chat.Any(x => x.Contains("tab pets:")), "and opens nothing");
|
||||
Check.False(SelectBreedingPending(c.Pets), "no Breeding sub-tab request");
|
||||
FakeHost.Chat.Clear();
|
||||
Check.True(c.HandleCommand("hub", new[] { "tab", "Breed" }), "hub tab breed (the dashboard)");
|
||||
Check.False(FakeHost.Chat.Any(), "tab switches quietly");
|
||||
Check.False(SelectBreedingPending(c.Pets), "still no Breeding sub-tab request without RynthILT");
|
||||
FakeHost.Chat.Clear();
|
||||
Check.True(c.HandleCommand("hub", new[] { "bank" }), "hub bank is handled (answered)");
|
||||
Check.True(FakeHost.Chat.Any(x => x.Contains("RynthILT")), "it says the ILT verbs come with RynthILT");
|
||||
Check.True(FakeHost.Chat.Any(x => x.Contains("/ra hub open quests|pets")), "and lists what RynthAi still has");
|
||||
Check.True(FakeHost.Chat.Any(x => x.Contains("/ra hub open pets|crafting [show|hide|toggle] /ra hub open breeding")), "and lists what RynthAi still has");
|
||||
FakeHost.Chat.Clear();
|
||||
// The Quests tab moved to RynthOracle (2026-10-13): its verbs and tab names say so.
|
||||
Check.True(c.HandleCommand("hub", new[] { "open", "quests" }), "hub open quests is answered");
|
||||
Check.True(FakeHost.Chat.Any(x => x.Contains("RynthOracle") && x.Contains("/ro timers")), "it points to RynthOracle");
|
||||
FakeHost.Chat.Clear();
|
||||
Check.True(c.HandleCommand("quests", new[] { "window" }), "quests window is answered");
|
||||
Check.True(FakeHost.Chat.Any(x => x.Contains("RynthOracle")), "with the same note");
|
||||
FakeHost.Chat.Clear();
|
||||
Check.True(c.HandleCommand("quests", Array.Empty<string>()), "quests (refresh) stays RynthAi's");
|
||||
Check.True(FakeHost.Chat.Any(x => x.Contains("Quest tracker not ready")), "the meta tracker's refresh (none in this test)");
|
||||
FakeHost.Chat.Clear();
|
||||
Check.True(c.HandleCommand("guardian", new[] { "handin" }), "guardian is answered");
|
||||
Check.True(FakeHost.Chat.Any(x => x.Contains("RynthILT")), "with the RynthILT note");
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ internal static class PluginFixTests
|
|||
r.Add("selection: creature classes are Monster, Player, Npc and CombatPet only", CreatureClasses);
|
||||
r.Add("fellowship name read: ReadableBytesFrom ends at the page whose neighbour is PAGE_NOACCESS", ReadableBytesAtGuardPage);
|
||||
r.Add("fellowship name read: it stops at 64 characters and at the end of the probed bytes", NameReadBounded);
|
||||
r.Add("fellowship table: an ACECustom 29-member fellowship is read, torn headers are not", FellowshipTableSizes);
|
||||
}
|
||||
|
||||
// -- Selection ------------------------------------------------------------
|
||||
|
|
@ -161,6 +162,20 @@ internal static class PluginFixTests
|
|||
finally { Marshal.FreeHGlobal(buf); }
|
||||
}
|
||||
|
||||
private static void FellowshipTableSizes()
|
||||
{
|
||||
const int Buckets = 0x1000; // any non-zero bucket array address
|
||||
Check.True(FellowshipTracker.IsPlausibleTable(Buckets, 16, 9), "a full retail fellowship (9)");
|
||||
Check.True(FellowshipTracker.IsPlausibleTable(Buckets, 64, 29), "an Infinite Leaftide fellowship (29, ACECustom MaxFellows)");
|
||||
Check.True(FellowshipTracker.IsPlausibleTable(Buckets, 1, 1), "one member, one bucket");
|
||||
Check.False(FellowshipTracker.IsPlausibleTable(0, 16, 3), "no bucket array");
|
||||
Check.False(FellowshipTracker.IsPlausibleTable(Buckets, 0, 3), "no buckets");
|
||||
Check.False(FellowshipTracker.IsPlausibleTable(Buckets, 16, 0), "no members");
|
||||
Check.False(FellowshipTracker.IsPlausibleTable(Buckets, FellowshipTracker.MaxBuckets + 1, 3), "a torn bucket count");
|
||||
Check.False(FellowshipTracker.IsPlausibleTable(Buckets, 16, FellowshipTracker.MaxMembers + 1), "a torn member count");
|
||||
Check.False(FellowshipTracker.IsPlausibleTable(Buckets, -5, 3), "a negative bucket count");
|
||||
}
|
||||
|
||||
private static void Land(uint id, string name)
|
||||
{
|
||||
FakeHost.Names[id] = name;
|
||||
|
|
|
|||
196
Tools/RynthCore.RynthAiHostTests/Tests/SectionsTests.cs
Normal file
196
Tools/RynthCore.RynthAiHostTests/Tests/SectionsTests.cs
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RynthCore.Engine.UI.Sections;
|
||||
using RynthCore.Plugin.RynthAi.Huds;
|
||||
using RynthCore.Plugin.RynthAi.MiniRemote;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// Mini Remote sections (RynthCore 2026.10.5.46+): RynthCore sends its server verdicts (V lines) and
|
||||
// section rail (X lines) in the "servermenu" payload, and reads RynthAi's views from
|
||||
// RynthPluginGetSectionsJson. RynthAi lists its own views (Pets, Crafting, Spells, Fellowship) and
|
||||
// hosts RynthILT's ILT tabs (RynthILT.Hub: Gear, Charms, Banking, Games); Quests are RynthOracle's,
|
||||
// and RynthILT's Character tab moved out (RynthOracle's Character tab, Session Stats). The manifest is checked
|
||||
// against the engine's own parser and catalog (UI/Sections, linked), so the two sides can't drift.
|
||||
internal static class SectionsTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("sections: V and X lines parse; groups unchanged", ParsesVerdicts);
|
||||
r.Add("sections: the engine verdict is looked up case-insensitively, and goes away with an older payload", VerdictLookup);
|
||||
r.Add("sections: RynthAi's manifest passes the engine parser unchanged", ManifestRoundTrip);
|
||||
r.Add("sections: the engine catalog places RynthAi's views by server", CatalogPlacement);
|
||||
r.Add("sections: tab surfaces map back to their tabs; foreign ids are refused", SurfaceRoundTrip);
|
||||
r.Add("sections: Character redirects to RynthOracle; Charms and Banking stay RynthILT's tabs", MovedTabRedirects);
|
||||
}
|
||||
|
||||
private static void MovedTabRedirects()
|
||||
{
|
||||
foreach (string tab in new[] { "character", "Char", " rates " })
|
||||
Check.Eq(MovedTabs.CommandFor(tab), MovedTabs.OracleCharacter, tab + " -> RynthOracle's Character tab");
|
||||
foreach (string tab in new[] { "charms", "banking", "gear", "games", "pets", "crafting", "", null })
|
||||
Check.True(MovedTabs.CommandFor(tab) == null, (tab ?? "null") + " is still a Mini Remote tab (or none)");
|
||||
Check.Eq(MovedTabs.OracleCharacter, "/ro character", "the Oracle command");
|
||||
Check.Eq(MovedTabs.Diagnostics, "/rc diagnostics", "the engine's Diagnostics command");
|
||||
}
|
||||
|
||||
private const string Payload =
|
||||
"V\tilt\tInfinite Leaftide\t1\ton\t0\n" +
|
||||
"V\taelrynth\tAelrynth\t0\tauto\t0\n" +
|
||||
"X\tchar\tChar\n" +
|
||||
"X\tgames\tGames\n" +
|
||||
"S\tilt\tInfinite Leaftide\t1\t/rc server ilt on\n" +
|
||||
"I\tProgression\t/rc progression\tPlanners.\t\n";
|
||||
|
||||
/// <summary>
|
||||
/// RynthILT's tabs as its GetTabs would give them (Gear not reported yet, Games hidden), plus the
|
||||
/// Character tab an older RynthILT still reports: it moved out of the Mini Remote (2026-10-13)
|
||||
/// and must not be placed any more.
|
||||
/// </summary>
|
||||
private static readonly IltTabInfo[] IltTabs =
|
||||
{
|
||||
new("character", "Character", 520, 440, Shown: true, Available: true),
|
||||
new("banking", "Banking", 560, 520, Shown: true, Available: true),
|
||||
new("gear", "Gear", 560, 520, Shown: true, Available: false),
|
||||
new("charms", "Charms", 560, 520, Shown: true, Available: true),
|
||||
new("games", "Games", 520, 440, Shown: false, Available: false),
|
||||
new("bogus id!", "Nope", 100, 100, Shown: true, Available: true),
|
||||
new("unknowntab", "Unknown", 100, 100, Shown: true, Available: true),
|
||||
};
|
||||
|
||||
private static void ParsesVerdicts()
|
||||
{
|
||||
ServerMenuPayload p = ServerMenuModel.ParsePayload(Payload);
|
||||
Check.Eq(p.Servers.Length, 2, "two verdicts");
|
||||
Check.Eq(p.Servers[0].Id, "ilt", "first verdict id");
|
||||
Check.True(p.Servers[0].Active, "ILT active");
|
||||
Check.Eq(p.Servers[0].Force, "on", "ILT forced on");
|
||||
Check.False(p.Servers[0].Detected, "ILT not detected (forced)");
|
||||
Check.False(p.Servers[1].Active, "Aelrynth inactive");
|
||||
Check.Eq(p.Sections.Length, 2, "two sections");
|
||||
Check.Eq(p.Sections[1].Id, "games", "rail order kept");
|
||||
Check.Eq(p.Groups.Length, 1, "one server group");
|
||||
Check.Eq(p.Groups[0].Items.Single().Command, "/rc progression", "the group's item");
|
||||
|
||||
ServerMenuPayload junk = ServerMenuModel.ParsePayload("V\tilt\n" + "X\t\t\n" + "V\tx\ty\tmaybe\tauto\t1\n");
|
||||
Check.Eq(junk.Groups.Length, 0, "no groups from junk");
|
||||
Check.True(junk.Servers.Length <= 1, "short verdict lines skipped");
|
||||
}
|
||||
|
||||
private static void VerdictLookup()
|
||||
{
|
||||
try
|
||||
{
|
||||
ServerMenuModel.Apply(Payload.Replace("V\tilt\tInfinite Leaftide\t1\ton\t0", "V\tilt\tInfinite Leaftide\t0\toff\t1"));
|
||||
Check.Eq(ServerMenuModel.ServerActive("ILT"), false, "verdict lookup is case-insensitive");
|
||||
Check.Eq(ServerMenuModel.Server("ilt")?.Force, "off", "the override comes with it");
|
||||
|
||||
ServerMenuModel.Apply(Payload);
|
||||
Check.Eq(ServerMenuModel.ServerActive("ilt"), true, "forced on");
|
||||
|
||||
// An older RynthCore: groups only, no verdicts (a server is forced in RynthCore's
|
||||
// Options > Diagnostics, not from the Mini Remote, since 2026-10-13).
|
||||
ServerMenuModel.Apply("S\tilt\tInfinite Leaftide\t1\t/rc ilt on\n");
|
||||
Check.True(ServerMenuModel.ServerActive("ilt") == null, "no verdicts: none to follow");
|
||||
}
|
||||
finally { ServerMenuModel.Apply(string.Empty); }
|
||||
}
|
||||
|
||||
private static List<SectionsManifest.View> SomeViews() => SectionsManifest.Views(IltTabs);
|
||||
|
||||
private static void ManifestRoundTrip()
|
||||
{
|
||||
var views = SomeViews();
|
||||
Check.False(views.Any(v => v.Section == "quests"), "no Quests view: RynthOracle has them");
|
||||
Check.False(views.Any(v => v.Surface == "section:games"), "a tab RynthILT doesn't show isn't listed");
|
||||
Check.False(views.Any(v => v.Surface.Contains("unknowntab") || v.Surface.Contains("bogus")), "unplaced or unsafe tab ids aren't listed");
|
||||
|
||||
string json = SectionsManifest.Build(views, SectionsManifest.OwnSections);
|
||||
SectionManifest m = SectionManifestParser.Parse("RynthAi", json, out string error);
|
||||
Check.Eq(error, string.Empty, "no parse error");
|
||||
Check.Eq(m.Contributions.Length, views.Count, "every view survives");
|
||||
Check.Eq(m.Sections.Length, SectionsManifest.OwnSections.Length, "own sections survive");
|
||||
for (int i = 0; i < views.Count; i++)
|
||||
{
|
||||
SectionsManifest.View v = views[i];
|
||||
SectionContribution c = m.Contributions.Single(x => x.Surface == v.Surface && x.Section == v.Section);
|
||||
Check.Eq(c.Label, v.Label, "label " + v.Surface);
|
||||
Check.Eq(c.Server, v.Server, "server " + v.Surface);
|
||||
Check.Eq(c.Primary, v.Primary, "primary " + v.Surface);
|
||||
Check.Eq(c.Enabled, v.Enabled, "enabled " + v.Surface);
|
||||
Check.Eq(c.Order, v.Order, "order " + v.Surface);
|
||||
}
|
||||
SectionContribution gear = m.Contributions.Single(c => c.Surface == SectionsManifest.SurfaceOf("gear"));
|
||||
Check.False(gear.Enabled, "unavailable Gear is disabled");
|
||||
Check.True(gear.Note.Length > 0, "with a note");
|
||||
Check.False(views.Any(v => v.Surface == SectionsManifest.SurfaceOf("character")), "character moved out: not placed even if RynthILT reports it");
|
||||
foreach (string kept in new[] { "charms", "banking" })
|
||||
{
|
||||
SectionsManifest.View v = views.Single(x => x.Surface == SectionsManifest.SurfaceOf(kept));
|
||||
Check.True(v.Section == "inventory" && v.Server == SectionsManifest.IltServer && v.Enabled, kept + ": an ILT view in Inventory");
|
||||
}
|
||||
Check.True(json.Length < SectionManifestParser.MaxJsonLength / 16, "small");
|
||||
|
||||
SectionsManifest.View session = views.Single(v => v.Surface == SectionsManifest.SessionSurface);
|
||||
Check.Eq(session.Section, "char", "session stats in the char (Session Stats) section");
|
||||
Check.Eq(session.Server, string.Empty, "every world");
|
||||
Check.True(session.Primary, "a primary view (RynthCore drops its own overview)");
|
||||
|
||||
string noIlt = SectionsManifest.Build(SectionsManifest.Views(System.Array.Empty<IltTabInfo>()), SectionsManifest.OwnSections);
|
||||
SectionManifest plain = SectionManifestParser.Parse("RynthAi", noIlt, out string error2);
|
||||
Check.Eq(error2, string.Empty, "without RynthILT: no parse error");
|
||||
Check.Eq(plain.Contributions.Length, 5, "without RynthILT: Session stats, Pets, Crafting, Spells, Fellowship");
|
||||
}
|
||||
|
||||
private static void CatalogPlacement()
|
||||
{
|
||||
SectionManifest m = SectionManifestParser.Parse("RynthAi", SectionsManifest.Build(SomeViews(), SectionsManifest.OwnSections), out _);
|
||||
var iltOn = new ServerState("ilt", "Infinite Leaftide", true, true, ServerForce.Auto, true, "");
|
||||
var iltOff = iltOn with { Active = false };
|
||||
|
||||
List<SectionView> off = SectionCatalog.Build(new[] { m }, _ => false, new[] { iltOff });
|
||||
Check.True(off.Single(v => v.Id == "pets").Panes.Any(p => p.Contribution?.Surface == SectionsManifest.PetsSurface),
|
||||
"Pets everywhere");
|
||||
Check.True(off.Single(v => v.Id == "crafting").Panes.Any(p => p.Contribution?.Surface == SectionsManifest.CraftingSurface),
|
||||
"Crafting everywhere");
|
||||
Check.False(off.Any(v => v.Id == "quests"), "no Quests section of RynthAi's");
|
||||
Check.False(off.Any(v => v.Id == "games"), "no Games off ILT");
|
||||
SectionView charOff = off.Single(v => v.Id == "char");
|
||||
Check.Eq(charOff.Label, SectionCatalog.SessionStatsLabel, "the char section is Session Stats");
|
||||
Check.True(charOff.Panes.Length == 1 && charOff.Panes[0].Contribution?.Surface == SectionsManifest.SessionSurface,
|
||||
"Session Stats: RynthAi's session view replaces the engine overview");
|
||||
|
||||
List<SectionView> on = SectionCatalog.Build(new[] { m }, _ => false, new[] { iltOn });
|
||||
SectionView charOn = on.Single(v => v.Id == "char");
|
||||
Check.True(charOn.Panes.Length == 1 && charOn.Panes[0].Contribution?.Surface == SectionsManifest.SessionSurface,
|
||||
"Session Stats on ILT: session stats only (no ILT Character tab)");
|
||||
SectionView inventoryOn = on.Single(v => v.Id == "inventory");
|
||||
Check.True(inventoryOn.Panes.Any(p => p.Title == "Gear") && inventoryOn.Panes.Any(p => p.Title == "Charms")
|
||||
&& inventoryOn.Panes.Any(p => p.Title == "Banking"),
|
||||
"Inventory on ILT: RynthILT's Gear, Charms and Banking");
|
||||
SectionView inventoryOff = off.Single(v => v.Id == "inventory");
|
||||
Check.False(inventoryOff.Panes.Any(p => p.Title is "Gear" or "Charms" or "Banking"), "Inventory off ILT: none of RynthILT's tabs");
|
||||
Check.True(on.Single(v => v.Id == "spells").Panes.Any(p => p.Contribution?.Surface == SectionsManifest.SpellsSurface), "Spells");
|
||||
Check.True(on.Single(v => v.Id == "fellowship").Panes.Any(p => p.Contribution?.Surface == SectionsManifest.FellowshipSurface), "Fellowship");
|
||||
}
|
||||
|
||||
private static void SurfaceRoundTrip()
|
||||
{
|
||||
foreach (string id in new[] { "gear", "games", "charms", "banking" })
|
||||
{
|
||||
string surface = SectionsManifest.SurfaceOf(id);
|
||||
Check.True(SectionsManifest.TryIltTabOf(surface, out string back) && back == id, "round trip " + surface);
|
||||
Check.Eq(SectionManifestParser.Surface(surface), surface, "the engine accepts " + surface);
|
||||
}
|
||||
Check.False(SectionsManifest.TryIltTabOf(SectionsManifest.SurfaceOf("character"), out _), "character isn't a section tab any more");
|
||||
Check.Eq(SectionManifestParser.Surface(SectionsManifest.SessionSurface), SectionsManifest.SessionSurface, "the engine accepts the session surface");
|
||||
Check.True(SectionsManifest.TryOwnTabOf(SectionsManifest.PetsSurface, out string pets) && pets == MiniRemoteTabs.Pets, "pets is RynthAi's");
|
||||
Check.True(SectionsManifest.TryOwnTabOf(SectionsManifest.CraftingSurface, out string craft) && craft == MiniRemoteTabs.Crafting, "crafting is RynthAi's");
|
||||
Check.False(SectionsManifest.TryIltTabOf(SectionsManifest.PetsSurface, out _), "pets isn't an ILT tab");
|
||||
Check.False(SectionsManifest.TryIltTabOf(SectionsManifest.SpellsSurface, out _), "spells isn't a tab");
|
||||
Check.False(SectionsManifest.TryIltTabOf("section:nonsense", out _), "unknown");
|
||||
Check.False(SectionsManifest.TryIltTabOf("banking", out _), "no prefix");
|
||||
Check.False(SectionsManifest.TryIltTabOf("section:quests", out _), "Quests are RynthOracle's");
|
||||
}
|
||||
}
|
||||
57
Tools/RynthCore.RynthAiHostTests/Tests/SelfRatingsTests.cs
Normal file
57
Tools/RynthCore.RynthAiHostTests/Tests/SelfRatingsTests.cs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
using System.Collections.Generic;
|
||||
using RynthCore.Plugin.RynthAi.ItemInfo;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// Item Info on yourself (/ra iteminfo me, select or click yourself): the rating totals the server
|
||||
// puts in a self-identify (AppraiseInfo.AddRatings) and the login-sent luminance augs, as chat lines.
|
||||
internal static class SelfRatingsTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("self ratings: totals, other ratings and lum augs in Item Info's tags", Totals);
|
||||
r.Add("self ratings: zeros are left out; nothing known still prints a header", Empty);
|
||||
r.Add("self ratings: not identified is flagged; one-line layout joins with |", NotIdentifiedOneLine);
|
||||
}
|
||||
|
||||
private static System.Func<uint, int> Reader(Dictionary<uint, int> ints)
|
||||
=> stype => ints.TryGetValue(stype, out int v) ? v : 0;
|
||||
|
||||
private static void Totals()
|
||||
{
|
||||
var ints = new Dictionary<uint, int>
|
||||
{
|
||||
[307] = 45, [308] = 30, [313] = 10, [314] = 20, [315] = 5, [316] = 15,
|
||||
[323] = 8, [331] = 12, [351] = 4,
|
||||
[333] = 5, [334] = 5, [341] = 50,
|
||||
};
|
||||
List<string> lines = SelfRatings.Build("Silentkelpie", Reader(ints), identified: true, oneLine: false);
|
||||
Check.Eq(lines.Count, 3, "header, other ratings, lum augs (no PK line)");
|
||||
Check.Eq(lines[0], "Silentkelpie's ratings: D 45, DR 30, C 10, CD 20, CR 5, CDR 15", "combat totals in Item Info order");
|
||||
Check.Eq(lines[1], "HB 8, NR 12, LR 4", "healing and resists");
|
||||
Check.Eq(lines[2], "Lum augs (in the totals): D +5, DR +5, V +50", "lum augs signed");
|
||||
foreach (string l in lines)
|
||||
foreach (char c in l)
|
||||
Check.True(c >= 0x20 && c <= 0x7E, "plain ASCII: " + l);
|
||||
}
|
||||
|
||||
private static void Empty()
|
||||
{
|
||||
List<string> lines = SelfRatings.Build("", Reader(new Dictionary<uint, int> { [307] = 0 }), identified: true, oneLine: false);
|
||||
Check.Eq(lines.Count, 1, "only the header");
|
||||
Check.Eq(lines[0], "Your ratings: no combat ratings", "no name: 'Your'");
|
||||
|
||||
List<string> pk = SelfRatings.Build("Pk", Reader(new Dictionary<uint, int> { [381] = 3, [382] = -2 }), true, false);
|
||||
Check.Eq(pk[1], "PK: PKD 3, PKDR -2", "PK line, negative kept");
|
||||
}
|
||||
|
||||
private static void NotIdentifiedOneLine()
|
||||
{
|
||||
var ints = new Dictionary<uint, int> { [307] = 7, [337] = 2 };
|
||||
List<string> lines = SelfRatings.Build("Me", Reader(ints), identified: false, oneLine: true);
|
||||
Check.Eq(lines.Count, 1, "one line");
|
||||
Check.Eq(lines[0], "Me's ratings: D 7 (not identified - totals may be incomplete) | Lum augs (in the totals): SE +2",
|
||||
"flag on the header, parts joined");
|
||||
}
|
||||
}
|
||||
|
|
@ -13,15 +13,16 @@ internal static class ServerMenuTests
|
|||
r.Add("server menu: sections and items parse in order", ParsesSections);
|
||||
r.Add("server menu: malformed lines are skipped, never thrown", SkipsMalformed);
|
||||
r.Add("server menu: tab features name the Mini Remote tab", TabFeature);
|
||||
r.Add("mini remote tabs: Quests and Pets are RynthAi's and first; the ILT tabs come from RynthILT", UniversalTabs);
|
||||
r.Add("mini remote tabs: Pets and Crafting are RynthAi's and first (Quests moved to RynthOracle); the ILT tabs come from RynthILT", UniversalTabs);
|
||||
}
|
||||
|
||||
private static void UniversalTabs()
|
||||
{
|
||||
var tabs = RynthCore.Plugin.RynthAi.MiniRemote.MiniRemoteTabs.Universal;
|
||||
Check.Eq(tabs.Length, 2, "RynthAi's own tabs: Quests and Pets (the ILT tabs are RynthILT's)");
|
||||
Check.Eq(tabs[0], "quests", "Quests leads the tab bar");
|
||||
Check.Eq(tabs[1], "pets", "Pets second");
|
||||
Check.Eq(tabs.Length, 2, "RynthAi's own tabs: Pets and Crafting (the ILT tabs are RynthILT's)");
|
||||
Check.Eq(tabs[0], "pets", "Pets leads the tab bar");
|
||||
Check.Eq(tabs[1], "crafting", "Crafting second (tinker benches and Rings work on any server)");
|
||||
Check.Null(RynthCore.Plugin.RynthAi.MiniRemote.MiniRemoteTabs.Parse("quests"), "no Quests tab: RynthOracle has it (2026-10-13)");
|
||||
Check.Eq(RynthCore.Plugin.RynthAi.MiniRemote.MiniRemoteTabs.Parse("Pet"), "pets", "aliases parse");
|
||||
Check.Null(RynthCore.Plugin.RynthAi.MiniRemote.MiniRemoteTabs.Parse("banking"), "an ILT tab isn't RynthAi's");
|
||||
Check.Null(RynthCore.Plugin.RynthAi.MiniRemote.MiniRemoteTabs.Parse("guardian"), "nor the Guardian panel");
|
||||
|
|
|
|||
352
Tools/RynthCore.RynthAiHostTests/Tests/TinkerTests.cs
Normal file
352
Tools/RynthCore.RynthAiHostTests/Tests/TinkerTests.cs
Normal file
|
|
@ -0,0 +1,352 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RynthCore.Loot;
|
||||
using RynthCore.Plugin.RynthAi.MiniRemote;
|
||||
using RynthCore.Plugin.RynthAi.MiniRemote.Crafting;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// The Crafting tab's tinkering (SilentKelpie's, 2026-10-12): ACE's retail chance
|
||||
// (RecipeManager.GetTinkerChance), the planner's caps and order (imbue once, rend last), bag
|
||||
// matching / choice, and the universal Crafting tab id. Server rows come from the server plugin's
|
||||
// profile ("salvage", ServerSalvageView) and carry their own rules, checked here on rows shaped
|
||||
// like Infinite Leaftide's (RynthILT serves those; RynthILT.Tests checks its data): no tink slot,
|
||||
// applied ints, stack groups (Steel + Serpentine 10), after-cap rows (Leather), an own order, and
|
||||
// prepared rows (tier bags, Ammunition).
|
||||
internal static class TinkerTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("tinker: retail difficulty and chance (ACE GetTinkerChance)", Chance);
|
||||
r.Add("tinker: slot cap, one imbue, attempts this run", SlotsAndImbue);
|
||||
r.Add("tinker: damage-type rend and rend last", Rend);
|
||||
r.Add("tinker: server weapon rows (no slot, an after-cap row last only when the slots are full)", AfterCap);
|
||||
r.Add("tinker: server jewelry rows (applied ints skip, a stack group shares one cap)", StackAndApplied);
|
||||
r.Add("tinker: item rows (Moonstone, Leather, Sandstone)", ItemRows);
|
||||
r.Add("tinker: scan filters", Filters);
|
||||
r.Add("tinker: bag matching (full, Abyssal, Foolproof)", Bags);
|
||||
r.Add("tinker: bag choice by chance and minimum", BagChoice);
|
||||
r.Add("tinker: Crafting is a universal Mini Remote tab", Section);
|
||||
r.Add("tinker: prepared server rows (applied ints, order, tier bags, Ammunition)", Trinkets);
|
||||
r.Add("tinker: a server plugin's salvage (per tab, own keys, own order, no rules unless asked)", PluginSalvage);
|
||||
}
|
||||
|
||||
private static TinkerBenchSettings Settings(params (string Key, int Count)[] counts)
|
||||
{
|
||||
var s = new TinkerBenchSettings { MaxTinks = 10 };
|
||||
foreach (var (k, n) in counts) s.Counts[k] = n;
|
||||
return s;
|
||||
}
|
||||
|
||||
private static TinkerItemFacts Item(AcObjectClass oc, int tinks = 0, bool imbued = false, int damageType = 0,
|
||||
double work = 6, Func<int, int>? flags = null)
|
||||
=> new() { Id = 1, Name = "Test Item", Class = oc, Tinks = tinks, Imbued = imbued, DamageType = damageType,
|
||||
Workmanship = work, FlagInt = flags ?? (_ => 0) };
|
||||
|
||||
private static List<int> Mats(List<TinkerStep> plan) => plan.Select(p => p.Material).ToList();
|
||||
|
||||
private static ServerSalvageView Row(string bench, int material, string kind, bool slot = false, string nameMatch = "",
|
||||
int applied = 0, bool prepared = false, int order = 0, bool afterCap = false,
|
||||
string group = "", int cap = 0)
|
||||
=> new(bench, material, kind, "server row", slot, nameMatch, applied, prepared, order, afterCap, group, cap);
|
||||
|
||||
/// <summary>The tab's rows with these server rows (as the Crafting tab builds them).</summary>
|
||||
private static List<TinkerMaterial> WithServer(TinkerBench bench, params ServerSalvageView[] server)
|
||||
=> TinkerPlanner.Rows(bench, TinkerCatalog.FromServerPlugin(bench, server), null);
|
||||
|
||||
// ILT-shaped rows (RynthILT's Hub/IltSalvage.cs has the real ones).
|
||||
private const int JewelSilverInt = 374, TrinketDiamondInt = 384, TrinketGromnieInt = 386;
|
||||
|
||||
private static readonly ServerSalvageView[] Weapon =
|
||||
{
|
||||
Row("melee", TinkerCatalog.YellowGarnet, "once", order: 70),
|
||||
Row("melee", TinkerCatalog.BlackGarnet, "once", slot: true, nameMatch: "Abyssal", order: 100),
|
||||
Row("melee", TinkerCatalog.Leather, "once", order: 995, afterCap: true),
|
||||
};
|
||||
|
||||
private static readonly ServerSalvageView[] Jewelry =
|
||||
{
|
||||
Row("jewelry", TinkerCatalog.Silver, "once", applied: JewelSilverInt, order: 10),
|
||||
Row("jewelry", TinkerCatalog.Copper, "once", applied: 370, order: 20),
|
||||
Row("jewelry", TinkerCatalog.Serpentine, "tink", order: 50, group: "jewelry-stack", cap: 10),
|
||||
Row("jewelry", TinkerCatalog.Steel, "tink", order: 60, group: "jewelry-stack", cap: 10),
|
||||
};
|
||||
|
||||
private static readonly ServerSalvageView[] TrinketRows =
|
||||
{
|
||||
Row("trinkets", TinkerCatalog.Diamond, "once", applied: TrinketDiamondInt, prepared: true, order: 10),
|
||||
Row("trinkets", TinkerCatalog.Ruby, "once", applied: 385, prepared: true, order: 20),
|
||||
Row("trinkets", TinkerCatalog.GromnieHide, "once", applied: TrinketGromnieInt, prepared: true, order: 30),
|
||||
Row("trinkets", TinkerCatalog.Pyreal, "once", applied: 387, prepared: true, order: 40),
|
||||
};
|
||||
|
||||
/// <summary>A plan's materials as "a,b,c" (Check.Eq compares lists by reference).</summary>
|
||||
private static string Seq(List<TinkerStep> plan) => string.Join(",", Mats(plan));
|
||||
|
||||
private static string Seq(params int[] ids) => string.Join(",", ids);
|
||||
|
||||
private static void Chance()
|
||||
{
|
||||
// Steel (mod 12), item 5, bag 6 (>= item: wkMod 2): 60 + 120 - 28.8 = 151.2.
|
||||
Check.Eq(TinkerMath.Difficulty(TinkerCatalog.Steel, 5, 6, 0), 151, "steel difficulty, first tink");
|
||||
Check.Eq(TinkerMath.Difficulty(TinkerCatalog.Steel, 5, 6, 3), 241, "fourth tink: x1.6");
|
||||
// Gold (mod 10), item 10, bag 3 (< item: wkMod 1): 50 + 200 - 6 = 244.
|
||||
Check.Eq(TinkerMath.Difficulty(TinkerCatalog.Gold, 10, 3, 0), 244, "gold, weaker bag");
|
||||
Check.Eq(TinkerMath.Difficulty(TinkerCatalog.Iron, 5, 5, 10), int.MaxValue, "no 11th tink");
|
||||
Check.True(Math.Abs(TinkerMath.SkillChance(200, 200) - 0.5) < 1e-9, "skill = difficulty is 50%");
|
||||
Check.Eq(TinkerMath.Percent(TinkerMath.Chance(TinkerCatalog.Steel, 300, 5, 6, 0, false, false)), 99, "300 skill vs 151");
|
||||
double plain = TinkerMath.Chance(TinkerCatalog.BlackOpal, 250, 6, 6, 0, false, false);
|
||||
double imbue = TinkerMath.Chance(TinkerCatalog.BlackOpal, 250, 6, 6, 0, true, false);
|
||||
Check.True(Math.Abs(imbue - plain / 3) < 1e-9, "imbues are a third");
|
||||
Check.Eq(TinkerMath.Chance(TinkerCatalog.BlackOpal, 1, 10, 1, 9, true, true), 1.0, "foolproof always lands");
|
||||
Check.Eq(TinkerMath.SalvageMod(TinkerCatalog.RoseQuartz), 25.0, "gem cantrips are mod 25");
|
||||
Check.Eq(TinkerMath.SalvageMod(TinkerCatalog.WhiteQuartz), 20.0, "default mod 20");
|
||||
Check.Eq(TinkerMath.BagWorkmanship(600, 100), 6.0, "bag workmanship is the average");
|
||||
}
|
||||
|
||||
private static void SlotsAndImbue()
|
||||
{
|
||||
var rows = TinkerPlanner.Rows(TinkerBench.Melee, null, null);
|
||||
var s = Settings(("r" + TinkerCatalog.Iron, 10), ("r" + TinkerCatalog.BlackOpal, 1), ("r" + TinkerCatalog.FireOpal, 1));
|
||||
var plan = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 6), s, rows);
|
||||
Check.Eq(Mats(plan).Count(m => m == TinkerCatalog.BlackOpal), 1, "first imbue in order");
|
||||
Check.Eq(Mats(plan).Count(m => m == TinkerCatalog.FireOpal), 0, "second imbue refused");
|
||||
Check.Eq(Mats(plan).Count(m => m == TinkerCatalog.Iron), 3, "imbue takes a slot: 4 free - 1");
|
||||
Check.Eq(plan[0].Material, TinkerCatalog.BlackOpal, "imbue before stat tinks");
|
||||
|
||||
var imbued = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 6, imbued: true), s, rows);
|
||||
Check.Eq(Mats(imbued).Count(m => m == TinkerCatalog.BlackOpal), 0, "already imbued");
|
||||
Check.Eq(imbued.Count, 4, "four Irons fill the free slots");
|
||||
|
||||
var tried = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 0, imbued: true),
|
||||
Settings(("r" + TinkerCatalog.Iron, 3)), rows, k => k == "r" + TinkerCatalog.Iron ? 2 : 0);
|
||||
Check.Eq(tried.Count, 1, "two of three Irons already tried this run");
|
||||
Check.Eq(TinkerPlanner.Summary(imbued), "Iron x4", "summary groups repeats");
|
||||
}
|
||||
|
||||
private static void Rend()
|
||||
{
|
||||
Check.Eq(TinkerCatalog.RendFor(3, false), TinkerCatalog.ImperialTopaz, "slash/pierce: slash");
|
||||
Check.Eq(TinkerCatalog.RendFor(3, true), TinkerCatalog.BlackGarnet, "slash/pierce: pierce");
|
||||
Check.Eq(TinkerCatalog.RendFor(4, false), TinkerCatalog.WhiteSapphire, "bludgeon");
|
||||
Check.Eq(TinkerCatalog.RendFor(16, false), TinkerCatalog.RedGarnet, "fire");
|
||||
Check.Eq(TinkerCatalog.RendFor(0x400, false), TinkerCatalog.Onyx, "nether");
|
||||
Check.Eq(TinkerCatalog.RendFor(0, false), 0, "no damage type, no rend");
|
||||
|
||||
var rows = TinkerPlanner.Rows(TinkerBench.Melee, null, null);
|
||||
var s = Settings(("r" + TinkerCatalog.RendId, 1), ("r" + TinkerCatalog.Iron, 2));
|
||||
var first = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, damageType: 32), s, rows);
|
||||
Check.Eq(first[0].Material, TinkerCatalog.Emerald, "acid weapon: Emerald first");
|
||||
s.RendLast = true;
|
||||
var last = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, damageType: 32), s, rows);
|
||||
Check.Eq(last[^1].Material, TinkerCatalog.Emerald, "rend last");
|
||||
Check.Eq(last.Count, 3, "rend + 2 Iron");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rows from a server plugin's profile (ServerPackInfo.Salvage): only the tab's own, in kind order
|
||||
/// unless a row gives its own, keyed "p" (never sharing a count with retail "r"), and with no rule
|
||||
/// the row doesn't ask for (a Leather without "afterCap" doesn't wait for the 10 ordinary tinks).
|
||||
/// </summary>
|
||||
private static void PluginSalvage()
|
||||
{
|
||||
var salvage = new List<RynthCore.Plugin.Shared.ServerSalvageView>
|
||||
{
|
||||
new("melee", TinkerCatalog.Leather, "once", "server Leather", false, ""),
|
||||
new("melee", TinkerCatalog.Iron, "tink", "server Iron", true, ""),
|
||||
new("melee", TinkerCatalog.Emerald, "imbue", "server imbue", true, ""),
|
||||
new("melee", TinkerCatalog.Steel, "bogus", "unknown kind", true, ""),
|
||||
new("armor", TinkerCatalog.Steel, "tink", "other tab", true, ""),
|
||||
};
|
||||
var server = TinkerCatalog.FromServerPlugin(TinkerBench.Melee, salvage);
|
||||
Check.Eq(server.Count, 3, "this tab's rows; the unknown kind is left out");
|
||||
Check.True(server.All(r => r.Origin == TinkerOrigin.Plugin), "plugin origin");
|
||||
Check.Eq(TinkerCatalog.Key(server[0]), "p" + TinkerCatalog.Leather, "own key");
|
||||
Check.Eq(server[0].Name, TinkerCatalog.MaterialName(TinkerCatalog.Leather), "material name");
|
||||
Check.Eq(TinkerCatalog.FromServerPlugin(TinkerBench.Melee, null).Count, 0, "nothing defined, no rows");
|
||||
|
||||
var rows = TinkerPlanner.Rows(TinkerBench.Melee, server, null);
|
||||
var s = Settings(("p" + TinkerCatalog.Leather, 1), ("p" + TinkerCatalog.Iron, 2), ("p" + TinkerCatalog.Emerald, 1));
|
||||
var plan = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 5), s, rows);
|
||||
Check.Eq(Seq(plan), Seq(TinkerCatalog.Emerald, TinkerCatalog.Iron, TinkerCatalog.Iron, TinkerCatalog.Leather),
|
||||
"imbue, tinks, then once; Leather doesn't wait for the cap");
|
||||
Check.True(server.All(r => !r.AfterCap && r.StackGroup.Length == 0 && r.AppliedInt == 0 && !r.Prepared), "no rules unless asked");
|
||||
|
||||
// A row's own order: this once-row runs before the retail imbues (101) and the plugin's tinks.
|
||||
var ordered = TinkerCatalog.FromServerPlugin(TinkerBench.Melee, new[]
|
||||
{
|
||||
Row("melee", TinkerCatalog.Iron, "tink", slot: true),
|
||||
Row("melee", TinkerCatalog.Turquoise, "once", order: 80),
|
||||
});
|
||||
Check.Eq(ordered[1].Order, 80, "the row's order");
|
||||
Check.Eq(ordered[0].Order, 400, "no order: the kind's default");
|
||||
var first = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon),
|
||||
Settings(("r" + TinkerCatalog.BlackOpal, 1), ("p" + TinkerCatalog.Iron, 1), ("p" + TinkerCatalog.Turquoise, 1)),
|
||||
TinkerPlanner.Rows(TinkerBench.Melee, ordered, null));
|
||||
Check.Eq(Seq(first), Seq(TinkerCatalog.Turquoise, TinkerCatalog.BlackOpal, TinkerCatalog.Iron), "order 80 goes first");
|
||||
|
||||
// The optional fields map onto the planner's row.
|
||||
var mapped = TinkerCatalog.FromServerPlugin(TinkerBench.Jewelry, Jewelry.Concat(new[]
|
||||
{
|
||||
Row("jewelry", TinkerCatalog.Moonstone, "tink", group: "no-cap"),
|
||||
}));
|
||||
Check.Eq(mapped[0].AppliedInt, JewelSilverInt, "applied int");
|
||||
Check.Eq(mapped[2].StackGroup + "/" + mapped[2].StackCap, "jewelry-stack/10", "stack group and cap");
|
||||
Check.Eq(mapped[4].StackGroup, "", "a group without a cap is no group");
|
||||
Check.True(TinkerCatalog.FromServerPlugin(TinkerBench.Melee, Weapon)[2].AfterCap, "after cap");
|
||||
Check.True(TinkerCatalog.FromServerPlugin(TinkerBench.Trinkets, TrinketRows).All(r => r.Prepared), "prepared");
|
||||
}
|
||||
|
||||
private static void AfterCap()
|
||||
{
|
||||
var rows = WithServer(TinkerBench.Melee, Weapon);
|
||||
var s = Settings(("p" + TinkerCatalog.YellowGarnet, 1), ("r" + TinkerCatalog.Iron, 10), ("p" + TinkerCatalog.Leather, 1));
|
||||
var full = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 10), s, rows);
|
||||
Check.Eq(Seq(full), Seq(TinkerCatalog.YellowGarnet, TinkerCatalog.Leather), "capped item: no-slot rows, then Leather");
|
||||
|
||||
var some = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 5), s, rows);
|
||||
Check.Eq(some[^1].Material, TinkerCatalog.Leather, "Irons fill the last 5 slots, then Leather");
|
||||
Check.Eq(Mats(some).Count(m => m == TinkerCatalog.Iron), 5, "five Irons");
|
||||
Check.Eq(Mats(some).Count(m => m == TinkerCatalog.Leather), 1, "Leather once");
|
||||
|
||||
var open = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 5),
|
||||
Settings(("p" + TinkerCatalog.Leather, 1), ("r" + TinkerCatalog.Iron, 2)), rows);
|
||||
Check.True(!Mats(open).Contains(TinkerCatalog.Leather), "Leather waits for the 10 ordinary tinks");
|
||||
|
||||
var retailOnly = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 10), s,
|
||||
TinkerPlanner.Rows(TinkerBench.Melee, null, null));
|
||||
Check.Eq(retailOnly.Count, 0, "no server rows: nothing offered past the cap");
|
||||
}
|
||||
|
||||
private static void StackAndApplied()
|
||||
{
|
||||
var rows = WithServer(TinkerBench.Jewelry, Jewelry);
|
||||
var s = Settings(("p" + TinkerCatalog.Serpentine, 8), ("p" + TinkerCatalog.Steel, 8),
|
||||
("p" + TinkerCatalog.Silver, 1), ("p" + TinkerCatalog.Copper, 1));
|
||||
var plan = TinkerPlanner.Plan(TinkerBench.Jewelry, Item(AcObjectClass.Jewelry, tinks: 0,
|
||||
flags: k => k == JewelSilverInt ? 2 : 0), s, rows);
|
||||
var m = Mats(plan);
|
||||
Check.Eq(m.Count(x => x == TinkerCatalog.Serpentine), 8, "8 Serpentine");
|
||||
Check.Eq(m.Count(x => x == TinkerCatalog.Steel), 2, "Steel stops at 10 combined");
|
||||
Check.True(!m.Contains(TinkerCatalog.Silver), "Silver's applied int already reads 2");
|
||||
Check.Eq(m[0], TinkerCatalog.Copper, "flag rows first (their order)");
|
||||
|
||||
// Two groups don't share; a row outside any group isn't capped.
|
||||
var split = WithServer(TinkerBench.Jewelry,
|
||||
Row("jewelry", TinkerCatalog.Serpentine, "tink", order: 50, group: "a", cap: 3),
|
||||
Row("jewelry", TinkerCatalog.Steel, "tink", order: 60, group: "b", cap: 4),
|
||||
Row("jewelry", TinkerCatalog.Iron, "tink", order: 70));
|
||||
var p2 = Mats(TinkerPlanner.Plan(TinkerBench.Jewelry, Item(AcObjectClass.Jewelry),
|
||||
Settings(("p" + TinkerCatalog.Serpentine, 9), ("p" + TinkerCatalog.Steel, 9), ("p" + TinkerCatalog.Iron, 9)), split));
|
||||
Check.Eq(p2.Count(x => x == TinkerCatalog.Serpentine), 3, "group a: its cap");
|
||||
Check.Eq(p2.Count(x => x == TinkerCatalog.Steel), 4, "group b: its own cap");
|
||||
Check.Eq(p2.Count(x => x == TinkerCatalog.Iron), 9, "no group, no slot: all 9");
|
||||
Check.True(TinkerCatalog.IsTrinket("Ornate Compass") && !TinkerCatalog.IsTrinket("Yellow Topaz Ring"), "trinkets left to their tab");
|
||||
}
|
||||
|
||||
private static void ItemRows()
|
||||
{
|
||||
var rows = TinkerPlanner.Rows(TinkerBench.Items, null, null);
|
||||
var s = Settings(("r" + TinkerCatalog.Moonstone, 2), ("r" + TinkerCatalog.Leather, 1), ("r" + TinkerCatalog.Sandstone, 1));
|
||||
var noMana = TinkerPlanner.Plan(TinkerBench.Items, Item(AcObjectClass.Armor), s, rows);
|
||||
Check.Eq(Seq(noMana), Seq(TinkerCatalog.Leather), "no mana: no Moonstone; not retained: Leather, not Sandstone");
|
||||
|
||||
var mana = new TinkerItemFacts { Class = AcObjectClass.Armor, Workmanship = 5, MaxMana = 800, Retained = true, Tinks = 10 };
|
||||
var retained = TinkerPlanner.Plan(TinkerBench.Items, mana, s, rows);
|
||||
Check.Eq(Seq(retained), Seq(TinkerCatalog.Sandstone), "capped + retained: only Sandstone (no slot)");
|
||||
}
|
||||
|
||||
private static void Filters()
|
||||
{
|
||||
var s = Settings();
|
||||
s.MaxTinks = 8;
|
||||
s.MinFreeTinks = 3;
|
||||
s.SkipImbued = true;
|
||||
Check.Eq(TinkerPlanner.Excluded(Item(AcObjectClass.Armor, tinks: 9), s), "9 tinks (max 8)", "max tinks");
|
||||
Check.Eq(TinkerPlanner.Excluded(Item(AcObjectClass.Armor, tinks: 8), s), "fewer than 3 free tinks", "min free");
|
||||
Check.Eq(TinkerPlanner.Excluded(Item(AcObjectClass.Armor, imbued: true), s), "imbued", "skip imbued");
|
||||
Check.Eq(TinkerPlanner.Excluded(Item(AcObjectClass.Armor, work: 0), s), "no workmanship", "untinkerable");
|
||||
var worn = Item(AcObjectClass.Armor);
|
||||
worn.Equipped = true;
|
||||
Check.Eq(TinkerPlanner.Excluded(worn, s), "equipped", "worn items left alone");
|
||||
Check.Eq(TinkerPlanner.Excluded(Item(AcObjectClass.Armor, tinks: 2), s), "", "eligible");
|
||||
Check.True(TinkerCatalog.Targets(TinkerBench.Caster, AcObjectClass.WandStaffOrb)
|
||||
&& !TinkerCatalog.Targets(TinkerBench.Items, AcObjectClass.Salvage), "bench targets");
|
||||
}
|
||||
|
||||
private static void Bags()
|
||||
{
|
||||
var melee = WithServer(TinkerBench.Melee, Weapon);
|
||||
var rend = new TinkerStep(melee.First(r => r.Id == TinkerCatalog.RendId), TinkerCatalog.BlackGarnet);
|
||||
var abyssal = new TinkerStep(melee.First(r => r.NameMatch == "Abyssal"), TinkerCatalog.BlackGarnet);
|
||||
var iron = new TinkerStep(melee.First(r => r.Id == TinkerCatalog.Iron), TinkerCatalog.Iron);
|
||||
|
||||
Check.True(TinkerPlanner.BagMatches(iron, "Salvage (100)", TinkerCatalog.Iron, 100), "full Iron bag");
|
||||
Check.True(!TinkerPlanner.BagMatches(iron, "Salvage (60)", TinkerCatalog.Iron, 60), "partial bag refused");
|
||||
Check.True(TinkerPlanner.BagMatches(rend, "Salvage (100)", TinkerCatalog.BlackGarnet, 100), "Black Garnet rend bag");
|
||||
Check.True(!TinkerPlanner.BagMatches(rend, "Bag of Abyssal-Touched Gems", TinkerCatalog.BlackGarnet, 100), "Abyssal isn't a rend");
|
||||
Check.True(TinkerPlanner.BagMatches(abyssal, "Bag of Abyssal-Touched Gems", TinkerCatalog.BlackGarnet, 100), "Abyssal row by name");
|
||||
Check.True(TinkerPlanner.BagMatches(rend, "Foolproof Black Garnet", 0, 100), "Foolproof rend by name");
|
||||
Check.True(!TinkerPlanner.BagMatches(rend, "Foolproof Black Opal", 0, 100), "Black Opal isn't Black Garnet");
|
||||
Check.True(TinkerPlanner.IsFoolproof("Foolproof Imperial Topaz"), "foolproof name");
|
||||
}
|
||||
|
||||
private static void BagChoice()
|
||||
{
|
||||
var bags = new List<TinkerBagChoice> { new(1, 4, 0.60), new(2, 7, 0.85), new(3, 9, 0.95) };
|
||||
Check.Eq(TinkerPlanner.SelectBag(bags, 0), 2, "no minimum: best chance");
|
||||
Check.Eq(TinkerPlanner.SelectBag(bags, 80), 1, "minimum 80: the cheapest bag that reaches it");
|
||||
Check.Eq(TinkerPlanner.SelectBag(bags, 99), -1, "nothing reaches 99");
|
||||
var server = new List<TinkerBagChoice> { new(1, 5, null), new(2, 8, null) };
|
||||
Check.Eq(TinkerPlanner.SelectBag(server, 50), 1, "unknown chance: best workmanship");
|
||||
var tie = new List<TinkerBagChoice> { new(1, 9, 1.0), new(2, 3, 1.0) };
|
||||
Check.Eq(TinkerPlanner.SelectBag(tie, 0), 1, "tie: keep the better bag");
|
||||
}
|
||||
|
||||
private static void Section()
|
||||
{
|
||||
// Crafting is one of the Mini Remote's universal tabs (every server), after Quests and Pets.
|
||||
Check.Eq(MiniRemoteTabs.Parse("tinker"), MiniRemoteTabs.Crafting, "/ra hub open tinker");
|
||||
Check.Eq(MiniRemoteTabs.Parse("crafting"), MiniRemoteTabs.Crafting, "crafting id");
|
||||
Check.Eq(MiniRemoteTabs.Crafting, "crafting", "tab id the engine menu sends");
|
||||
Check.True(MiniRemoteTabs.Universal.Contains(MiniRemoteTabs.Crafting), "on the tab bar, every server");
|
||||
Check.Eq(MiniRemoteTabs.Label(MiniRemoteTabs.Crafting), "Crafting", "tab label");
|
||||
}
|
||||
|
||||
private static void Trinkets()
|
||||
{
|
||||
Check.Eq(TinkerPlanner.Rows(TinkerBench.Trinkets, null, null).Count, 0, "retail has no trinket rows");
|
||||
var rows = WithServer(TinkerBench.Trinkets, TrinketRows);
|
||||
var s = Settings(("p" + TinkerCatalog.Pyreal, 1), ("p" + TinkerCatalog.Diamond, 1), ("p" + TinkerCatalog.Ruby, 1),
|
||||
("p" + TinkerCatalog.GromnieHide, 1));
|
||||
var all = TinkerPlanner.Plan(TinkerBench.Trinkets, Item(AcObjectClass.Jewelry), s, rows);
|
||||
Check.Eq(Seq(all), Seq(TinkerCatalog.Diamond, TinkerCatalog.Ruby, TinkerCatalog.GromnieHide, TinkerCatalog.Pyreal),
|
||||
"the rows' order: Diamond, Ruby, Gromnie Hide, Pyreal");
|
||||
var some = TinkerPlanner.Plan(TinkerBench.Trinkets, Item(AcObjectClass.Jewelry,
|
||||
flags: k => k is TrinketDiamondInt or TrinketGromnieInt ? 2 : 0), s, rows);
|
||||
Check.Eq(Seq(some), Seq(TinkerCatalog.Ruby, TinkerCatalog.Pyreal), "applied ints 384 / 386 already 2");
|
||||
var capped = TinkerPlanner.Plan(TinkerBench.Trinkets, Item(AcObjectClass.Jewelry, tinks: 10), s, rows);
|
||||
Check.Eq(capped.Count, 4, "no-slot rows ignore the tink cap");
|
||||
|
||||
var diamond = new TinkerStep(rows.First(r => r.Id == TinkerCatalog.Diamond), TinkerCatalog.Diamond);
|
||||
Check.True(TinkerPlanner.BagMatches(diamond, "Major Diamond Salvage", TinkerCatalog.Diamond, 100, 2), "Major bag at Major");
|
||||
Check.True(!TinkerPlanner.BagMatches(diamond, "Minor Diamond Salvage", TinkerCatalog.Diamond, 100, 2), "Minor bag at Major");
|
||||
Check.True(!TinkerPlanner.BagMatches(diamond, "Salvage (100)", TinkerCatalog.Diamond, 100, 0), "raw bag isn't prepared");
|
||||
Check.True(!TinkerPlanner.BagMatches(diamond, "Major Ruby Salvage", TinkerCatalog.Ruby, 100, 2), "other material");
|
||||
Check.True(TinkerPlanner.IsRawTrinketBag(TinkerCatalog.Diamond, "Salvage (100)", TinkerCatalog.Diamond, 100), "raw bag");
|
||||
Check.True(!TinkerPlanner.IsRawTrinketBag(TinkerCatalog.Diamond, "Moderate Diamond Salvage", TinkerCatalog.Diamond, 100), "prepared isn't raw");
|
||||
Check.True(!TinkerPlanner.IsRawTrinketBag(TinkerCatalog.Diamond, "Salvage (55)", TinkerCatalog.Diamond, 55), "partial raw bag");
|
||||
Check.True(TinkerPlanner.IsTierAmmunition("Moderate Ammunition", 1), "Moderate Ammunition");
|
||||
Check.True(!TinkerPlanner.IsTierAmmunition("Major Ammunition", 1), "wrong tier");
|
||||
Check.True(!TinkerPlanner.IsTierAmmunition("Moderate Diamond Salvage", 1), "not Ammunition");
|
||||
Check.Eq(TinkerPlanner.TierOf("Minor Pyreal Salvage"), 0, "Minor");
|
||||
Check.Eq(TinkerPlanner.TierOf("Salvage (100)"), -1, "no tier");
|
||||
|
||||
Check.True(TinkerCatalog.IsTrinket("Spinning Top") && TinkerCatalog.IsTrinket("Copper Pocket Watch")
|
||||
&& !TinkerCatalog.IsTrinket("Imperial Topaz Necklace"), "trinket names (topaz isn't a top)");
|
||||
Check.True(TinkerCatalog.Targets(TinkerBench.Trinkets, AcObjectClass.Jewelry), "trinkets are jewelry");
|
||||
}
|
||||
}
|
||||
|
|
@ -56,6 +56,10 @@ internal static class WeaponTests
|
|||
r.Add("weapon swap: no flip-flop between two weapons", SwapNoFlipFlop);
|
||||
r.Add("weapon swap: a new target that wants the weapon just swapped away from gets it at once (Drakkon 2026-10-12)", SwapBackForNewTarget);
|
||||
r.Add("weapon swap: a server refusal counts as a failed try", SwapRefused);
|
||||
r.Add("weapon swap: 'too busy' is no try, and a portal or recall ends the rest (Kelpie 2026-10-15)", SwapBusyNotCounted);
|
||||
r.Add("weapon swap: combat reads ACE's busy answer (0x1D then SaveFailed 0) as busy, a real refusal as a try", CombatReadsBusyWield);
|
||||
r.Add("weapon swap: a wield that lands after the choice moved still counts (no swap straight back)", SwapLandsWhenChoiceMoved);
|
||||
r.Add("element choice: a weakness swap must beat the weapon in hand by the min gain", ChoiceMinSwapGain);
|
||||
r.Add("tester's case: Dragon's Isle, an unlisted fire wand and Blades", TesterDragonsIsle);
|
||||
}
|
||||
|
||||
|
|
@ -905,6 +909,57 @@ internal static class WeaponTests
|
|||
Check.Eq(tr2.Next(next, hand, u.AddSeconds(5), forKey: 0x8010), WeaponSwapTracker.Step.Hold, "a fifth swap inside a minute: held");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kelpie 2026-10-14 11:41:06-08: Fire -> Piercing sent, the target changed and the plan
|
||||
/// wanted Fire again while Piercing reached the hand. The landing must count, so the swap
|
||||
/// straight back is held (before: "not seen in hand", no landing, swapped back 2.5 s later).
|
||||
/// </summary>
|
||||
private static void SwapLandsWhenChoiceMoved()
|
||||
{
|
||||
var tr = new WeaponSwapTracker();
|
||||
DateTime t = new(2026, 10, 14, 11, 41, 6);
|
||||
const int fire = 1, piercing = 2;
|
||||
Check.Eq(tr.Next(piercing, fire, t), WeaponSwapTracker.Step.Swap, "Piercing chosen: swap");
|
||||
tr.Sent(piercing, fire, t);
|
||||
Check.Eq(tr.Next(fire, piercing, t.AddMilliseconds(2500)), WeaponSwapTracker.Step.Hold,
|
||||
"Piercing landed while Fire is wanted again: the swap back is held");
|
||||
Check.Eq(tr.PendingId, 0, "nothing in flight once it landed");
|
||||
Check.Eq(tr.TriesFor(piercing), 0, "the landed weapon's tries are cleared");
|
||||
Check.Eq(tr.Notice, null, "no give-up notice: it didn't fail");
|
||||
|
||||
// A third weapon is not the one just swapped away from: allowed.
|
||||
Check.Eq(tr.Next(3, piercing, t.AddMilliseconds(3000)), WeaponSwapTracker.Step.Swap, "another weapon may still swap");
|
||||
}
|
||||
|
||||
/// <summary>WeaponPlanner.KeepInHand: a weakness swap must beat the hand by the min gain.</summary>
|
||||
private static void ChoiceMinSwapGain()
|
||||
{
|
||||
var bows = new List<WeaponCandidate>
|
||||
{
|
||||
new(1, "Fire Bow", CombatMode.Missile, "Fire", "", InHand: true),
|
||||
new(2, "Cold Bow", CombatMode.Missile, "Cold", "", InHand: false),
|
||||
};
|
||||
var close = Rank(("Cold", 1.1), ("Fire", 1.0));
|
||||
var off = WeaponPlanner.Choose(bows, "", close, All);
|
||||
Check.Eq(off.WeaponId, 2, "threshold off: the weakest element wins as before");
|
||||
var keep = WeaponPlanner.Choose(bows, "", close, All, minSwapGain: 0.2);
|
||||
Check.Eq(keep.WeaponId, 1, "Cold only 10% better than Fire in hand: keep the Fire bow");
|
||||
Check.Eq(keep.Element, "Fire", "and its element");
|
||||
Check.True(keep.Source.Contains("within 20%"), "source says why: " + keep.Source);
|
||||
|
||||
var far = Rank(("Cold", 1.5), ("Fire", 1.0));
|
||||
Check.Eq(WeaponPlanner.Choose(bows, "", far, All, minSwapGain: 0.2).WeaponId, 2, "Cold 50% better: swap");
|
||||
|
||||
var learned = new CreatureWeakness.Ranking { Source = "learned", Order = { ("Cold", double.NaN), ("Fire", double.NaN) } };
|
||||
Check.Eq(WeaponPlanner.Choose(bows, "", learned, All, minSwapGain: 0.2).WeaponId, 2, "order only (learned): no threshold, swap");
|
||||
|
||||
var immune = Rank(("Cold", 1.0), ("Fire", 0.0));
|
||||
Check.Eq(WeaponPlanner.Choose(bows, "", immune, All, minSwapGain: 0.5).WeaponId, 2, "the hand does nothing to it: swap");
|
||||
|
||||
// An explicit Monsters rule element is never held back.
|
||||
Check.Eq(WeaponPlanner.Choose(bows, "Cold", close, All, minSwapGain: 0.5).WeaponId, 2, "the rule's Cold: swap");
|
||||
}
|
||||
|
||||
private static void SwapRefused()
|
||||
{
|
||||
var tr = new WeaponSwapTracker { MaxTries = 2 };
|
||||
|
|
@ -918,6 +973,92 @@ internal static class WeaponTests
|
|||
Check.Eq(tr.Next(2, 1, t.AddMilliseconds(500)), WeaponSwapTracker.Step.Hold, "second refusal with MaxTries 2: rest");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kelpie 2026-10-15 00:44:22-32: a house recall right after the wield; the server answered
|
||||
/// all 3 tries 'too busy' and the Frost crossbow was benched for 2 min. A busy answer is no
|
||||
/// try (bounded by MaxBusyRefunds), and a portal or recall ends every rest.
|
||||
/// </summary>
|
||||
private static void SwapBusyNotCounted()
|
||||
{
|
||||
var tr = new WeaponSwapTracker();
|
||||
DateTime t = new(2026, 10, 15, 0, 44, 22);
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
Check.Eq(tr.Next(2, 1, t), WeaponSwapTracker.Step.Swap, $"busy round {i}: swap");
|
||||
tr.Sent(2, 1, t);
|
||||
tr.Busy(t.AddMilliseconds(100));
|
||||
Check.Eq(tr.PendingId, 0, "a busy answer ends the swap in flight");
|
||||
Check.Eq(tr.TriesFor(2), 0, "and gives the try back");
|
||||
Check.Eq(tr.Next(2, 1, t.AddMilliseconds(500)), WeaponSwapTracker.Step.Wait, "the wield waits out the busy pause");
|
||||
t = t.AddMilliseconds(100 + tr.BusyRetryMs);
|
||||
}
|
||||
Check.Eq(tr.Notice, null, "no give-up while the server is only busy");
|
||||
Check.Eq(tr.Next(2, 2, t), WeaponSwapTracker.Step.InHand, "once the server is free the weapon lands");
|
||||
|
||||
// A weapon the server always calls busy still gets rested, after MaxBusyRefunds.
|
||||
var tr2 = new WeaponSwapTracker { MaxTries = 1, MaxBusyRefunds = 2 };
|
||||
DateTime u = t;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
tr2.Next(3, 1, u); tr2.Sent(3, 1, u);
|
||||
tr2.Busy(u);
|
||||
u = u.AddMilliseconds(tr2.BusyRetryMs);
|
||||
}
|
||||
tr2.Next(3, 1, u); tr2.Sent(3, 1, u);
|
||||
tr2.Busy(u);
|
||||
Check.True(tr2.Notice != null && tr2.Notice.Contains("server too busy"), "past the refunds it counts: rested");
|
||||
Check.Eq(tr2.Next(3, 1, u.AddSeconds(5)), WeaponSwapTracker.Step.Hold, "resting");
|
||||
|
||||
// A portal or recall ends the rest.
|
||||
tr2.NewPlace();
|
||||
Check.Eq(tr2.Next(3, 1, u.AddSeconds(10)), WeaponSwapTracker.Step.Swap, "after a portal: try again at once");
|
||||
Check.Eq(tr2.TriesFor(3), 0, "with a fresh count");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Combat reads ACE's busy answer to a wield: WeenieError 0x1D, then InventoryServerSaveFailed
|
||||
/// with no error. The engine keeps only the last record, so the SaveFailed alone must read as
|
||||
/// busy (before: "error 0", no answer, the try ran into the timeout and counted).
|
||||
/// </summary>
|
||||
private static void CombatReadsBusyWield()
|
||||
{
|
||||
const uint Old = 0x7000B001, New = 0x7000B002;
|
||||
FakeHost.Reset();
|
||||
FakeHost.WeenieErrorCalls = true;
|
||||
FakeHost.Names[Old] = "Fire Crossbow"; FakeHost.Names[New] = "Frost Compound Crossbow";
|
||||
var host = FakeHost.Create();
|
||||
var cache = FakeHost.MakeCache(host, Player, new[] { Old, New });
|
||||
var c = new CombatManager(host, new LegacyUiSettings(), cache);
|
||||
c.SetPlayerId(Player);
|
||||
const BindingFlags F = BindingFlags.Instance | BindingFlags.NonPublic;
|
||||
var send = typeof(CombatManager).GetMethod("MarkWieldSent", F)!;
|
||||
var step = typeof(CombatManager).GetMethod("SwapStep", F)!;
|
||||
int oldId = unchecked((int)Old), newId = unchecked((int)New);
|
||||
|
||||
send.Invoke(c, new object[] { newId, oldId });
|
||||
FakeHost.WeenieError(0x1D);
|
||||
FakeHost.WeenieError(0, 0x00A0, Old);
|
||||
var s = (WeaponSwapTracker.Step)step.Invoke(c, new object[] { newId, oldId })!;
|
||||
Check.Eq(s, WeaponSwapTracker.Step.Wait, "busy: wait out the pause, then wield again");
|
||||
Check.Eq(c.SwapTracker.PendingId, 0, "the wield in flight is over");
|
||||
Check.Eq(c.SwapTracker.TriesFor(newId), 0, "and not counted");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("answered 'too busy': not counted")), "logged");
|
||||
|
||||
// A real refusal (a specific error) still counts.
|
||||
c.SwapTracker.NewPlace();
|
||||
send.Invoke(c, new object[] { newId, oldId });
|
||||
FakeHost.WeenieError(0x0036);
|
||||
step.Invoke(c, new object[] { newId, oldId });
|
||||
Check.Eq(c.SwapTracker.TriesFor(newId), 1, "a refusal is a try");
|
||||
|
||||
// Leaving portal space ends tries and rests.
|
||||
FakeHost.Portaling = true;
|
||||
c.OnHeartbeat();
|
||||
FakeHost.Portaling = false;
|
||||
c.OnHeartbeat();
|
||||
Check.Eq(c.SwapTracker.TriesFor(newId), 0, "after the portal: a fresh count");
|
||||
}
|
||||
|
||||
// ── The tester's case ─────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ internal static class Program
|
|||
CombatStallWatchdogTests.Register(runner);
|
||||
CreatureWeaknessTests.Register(runner);
|
||||
MonsterDamageTierTests.Register(runner);
|
||||
LootBaselineTests.Register(runner);
|
||||
return runner.Run("RynthAi tests", args.Length > 0 ? args[0] : null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,12 +21,15 @@
|
|||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\LegacyUi\NavRouteParser.cs" Link="Linked\NavRouteParser.cs" />
|
||||
<!-- Combat: the melee/missile stall ladder (pure timing state, time passed in). -->
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\Combat\CombatStallWatchdog.cs" Link="Linked\CombatStallWatchdog.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\Combat\PointBlankFacing.cs" Link="Linked\PointBlankFacing.cs" />
|
||||
<!-- Weapon weakness selection: element ranking per monster. Its only outside reference is
|
||||
CreatureProfileStore.Folder (the user override folder), faked in Fakes\. -->
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\CreatureData\CreatureWeakness.cs" Link="Linked\CreatureWeakness.cs" />
|
||||
<!-- Learned per-monster damage (System only), for the Aelrynth difficulty-tier tests. -->
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\CreatureData\MonsterDamageStore.cs" Link="Linked\MonsterDamageStore.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\CreatureData\PlayerWeenies.cs" Link="Linked\PlayerWeenies.cs" />
|
||||
<!-- Loot: the measured loot-timer baseline and its [LootSettings] log line. -->
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\LootBaseline.cs" Link="Linked\LootBaseline.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,53 @@ internal static class CombatStallWatchdogTests
|
|||
r.Add("stall: a tick gap starts the count over", TickGapResets);
|
||||
r.Add("stall: ineligible never acts", Ineligible);
|
||||
r.Add("stall: Unfire takes a step back - the same step is due again next tick, not 3 s later", UnfireRetries);
|
||||
r.Add("stall: a missile target at point blank starts the ladder at 3.5 s", PointBlank);
|
||||
r.Add("point blank facing: one snap only for a close target behind, after a full shot cycle", PointBlankFacingRules);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PointBlankFacing (Kelpie 2026-10-14/15: crossbow at 1.7 m, target 177 degrees behind, no
|
||||
/// shots until the target was dropped): snap only within 3 m, more than 90 degrees off, after
|
||||
/// 2.5 s with no shot, once per 3 s per target, then hold 300 ms.
|
||||
/// </summary>
|
||||
private static void PointBlankFacingRules()
|
||||
{
|
||||
var f = new PointBlankFacing();
|
||||
DateTime shot = T0;
|
||||
DateTime now = T0.AddMilliseconds(2600);
|
||||
Check.True(f.ShouldSnap(now, 7, 1.7, 177, shot), "1.7 m, 177 degrees off, 2.6 s since a shot: snap");
|
||||
Check.False(f.ShouldSnap(T0.AddMilliseconds(2000), 7, 1.7, 177, shot), "a shot 2 s ago may still be in flight: wait");
|
||||
Check.False(f.ShouldSnap(now, 7, 3.5, 177, shot), "beyond 3 m the server turns the character itself");
|
||||
Check.False(f.ShouldSnap(now, 7, 1.7, 80, shot), "80 degrees off: left to the server");
|
||||
Check.False(f.ShouldSnap(now, 0, 1.7, 177, shot), "no target");
|
||||
Check.True(f.ShouldSnap(now, 7, 1.7, 177, NoEvidence), "no shot ever: snap");
|
||||
|
||||
f.Snapped(now, 7);
|
||||
Check.True(f.Settling(now.AddMilliseconds(200), 7), "the attack waits 300 ms after the snap");
|
||||
Check.False(f.Settling(now.AddMilliseconds(350), 7), "then goes");
|
||||
Check.False(f.Settling(now.AddMilliseconds(200), 8), "another target isn't held");
|
||||
Check.False(f.ShouldSnap(now.AddMilliseconds(2000), 7, 1.7, 177, shot), "no second snap for the same target within 3 s");
|
||||
Check.True(f.ShouldSnap(now.AddMilliseconds(3100), 7, 1.7, 177, shot), "after 3 s it may snap again");
|
||||
Check.True(f.ShouldSnap(now.AddMilliseconds(500), 8, 1.7, 177, shot), "a new target may snap at once");
|
||||
Check.Eq(f.Snaps, 1, "one snap counted");
|
||||
}
|
||||
|
||||
/// <summary>The caller passes PointBlankStallMs for a missile target within 3 m (Kelpie 2026-10-14).</summary>
|
||||
private static void PointBlank()
|
||||
{
|
||||
var w = new CombatStallWatchdog();
|
||||
Act first = Act.None;
|
||||
int at = -1;
|
||||
for (int t = 0; t <= 10_000 && first == Act.None; t += TickMs)
|
||||
{
|
||||
first = w.Tick(T0.AddMilliseconds(t), eligible: true, NoEvidence, out _,
|
||||
stallAfterMs: CombatStallWatchdog.PointBlankStallMs);
|
||||
if (first != Act.None) at = t;
|
||||
}
|
||||
Check.Eq((first, at), (Act.Reissue, 3500), "step 1 after 3.5 s at point blank");
|
||||
|
||||
var normal = new CombatStallWatchdog();
|
||||
Check.Eq(RunUntilAction(normal, 0, 10_000, NoEvidence), (Act.Reissue, 6000), "the default is still 6 s");
|
||||
}
|
||||
|
||||
/// <summary>Ticks every 500 ms from <paramref name="fromMs"/> to <paramref name="toMs"/>
|
||||
|
|
|
|||
71
Tools/RynthCore.RynthAiTests/Tests/LootBaselineTests.cs
Normal file
71
Tools/RynthCore.RynthAiTests/Tests/LootBaselineTests.cs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiTests.Tests;
|
||||
|
||||
// The loot-timer baseline (LootBaseline.cs) and the [LootSettings] line the corpse looting logs:
|
||||
// each timer marked baseline or custom, floors noted, and the approach range's Min-above-Max note.
|
||||
// Kelpie's and Storm's saved timers on 2026-10-14 are the real-world cases.
|
||||
internal static class LootBaselineTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("loot baseline: the measured values", Values);
|
||||
r.Add("loot baseline: all baseline is said once", AllBaseline);
|
||||
r.Add("loot baseline: Kelpie's custom timers and his Min-above-Max range", Kelpie);
|
||||
r.Add("loot baseline: a timer below the code's floor says what it acts as", Storm);
|
||||
r.Add("loot baseline: legacy fractional ranges are read as 240 yd fractions", FractionalRange);
|
||||
}
|
||||
|
||||
private static void Values()
|
||||
{
|
||||
LootBaseline.Timers b = LootBaseline.Values;
|
||||
Check.Eq(b, new LootBaseline.Timers(100, 300, 300, 1000, 1500, 12000), "baseline timers");
|
||||
// Above the measured 95th percentile of appraisal replies (256 ms).
|
||||
Check.True(LootBaseline.AssessWindowMs > 256, "assess window covers the 95th percentile");
|
||||
foreach (LootBaseline.Entry e in LootBaseline.Compare(b))
|
||||
Check.False(e.BelowFloor, $"{e.Label} baseline is not below its floor");
|
||||
}
|
||||
|
||||
private static void AllBaseline()
|
||||
{
|
||||
string line = LootBaseline.Describe(LootBaseline.Values, 10, 2);
|
||||
Check.True(line.StartsWith("[LootSettings] Content Settle 100 ms baseline"), line);
|
||||
Check.True(line.Contains("-- all baseline"), "summary says all baseline: " + line);
|
||||
Check.False(line.Contains("custom"), "no timer is custom: " + line);
|
||||
Check.False(line.Contains("Approach Range"), "a sane range adds no note: " + line);
|
||||
}
|
||||
|
||||
private static void Kelpie()
|
||||
{
|
||||
var kelpie = new LootBaseline.Timers(125, 550, 450, 1000, 1200, 12000);
|
||||
string line = LootBaseline.Describe(kelpie, 40, 240);
|
||||
Check.True(line.Contains("Content Settle 125 ms custom (baseline 100)"), line);
|
||||
Check.True(line.Contains("Empty Corpse Wait 550 ms custom (baseline 300)"), line);
|
||||
Check.True(line.Contains("Assess Window 450 ms custom (baseline 300)"), line);
|
||||
Check.True(line.Contains("Loot Retry Timeout 1000 ms baseline"), line);
|
||||
Check.True(line.Contains("Corpse Open Retry 1200 ms custom (baseline 1500)"), line);
|
||||
Check.True(line.Contains("Corpse Timeout 12000 ms baseline"), line);
|
||||
Check.True(line.Contains("-- 4 of 6 custom"), line);
|
||||
Check.True(line.Contains("Approach Range Min 240 yd is above Max 40 yd, so Min acts as 40 yd"), line);
|
||||
}
|
||||
|
||||
/// <summary>Storm's saved timers, with Empty Corpse Wait lowered from 200 to 150 to go under its floor.</summary>
|
||||
private static void Storm()
|
||||
{
|
||||
var storm = new LootBaseline.Timers(100, 150, 150, 300, 1500, 8500);
|
||||
string line = LootBaseline.Describe(storm, 6.5, 2);
|
||||
Check.True(line.Contains("Empty Corpse Wait 150 ms custom (baseline 300) [acts as 200]"), line);
|
||||
Check.False(line.Contains("Assess Window 150 ms custom (baseline 300) [acts"), "150 is above the 100 floor: " + line);
|
||||
Check.True(line.Contains("-- 4 of 6 custom"), line);
|
||||
}
|
||||
|
||||
private static void FractionalRange()
|
||||
{
|
||||
// 0.05 of 240 yd = 12 yd Max; Min 20 yd is above it.
|
||||
string line = LootBaseline.Describe(LootBaseline.Values, 0.05, 20);
|
||||
Check.True(line.Contains("Min 20 yd is above Max 12 yd"), line);
|
||||
// Unset values fall back to 10 / 2 yd, which is fine.
|
||||
Check.False(LootBaseline.Describe(LootBaseline.Values, 0, 0).Contains("Approach Range"), "unset range adds no note");
|
||||
}
|
||||
}
|
||||
|
|
@ -47,6 +47,7 @@ internal static partial class Program
|
|||
TestCleanup();
|
||||
TestKillCounter();
|
||||
TestSessionStats();
|
||||
TestRynthAiSnapshot();
|
||||
|
||||
Console.WriteLine($"\n{_asserts} assertions, {_fails} failed.");
|
||||
if (_asserts == 0) { Console.WriteLine("ABORT: zero assertions ran."); return 1; }
|
||||
|
|
@ -56,6 +57,50 @@ internal static partial class Program
|
|||
|
||||
private static readonly DateTime Now = new(2026, 10, 1, 3, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
/// <summary>
|
||||
/// One session (2026-10-13): RynthTracker shows RynthAi's session ("RynthAi.Hub" SessionStats and
|
||||
/// SessionStatsMore) when RynthAi answers; its rates are rounded, not cut off.
|
||||
/// </summary>
|
||||
private static void TestRynthAiSnapshot()
|
||||
{
|
||||
Console.WriteLine("-- RynthAi's session in the Tracker panel");
|
||||
var s = new RynthCore.Plugin.Shared.SessionStatsV1
|
||||
{
|
||||
StartUtcTicks = Now.AddHours(-2).Ticks, SessionSeconds = 7200, Xp = 5_000_000, XpPerHour = 2_499_999.6,
|
||||
Lum = 9000, LumPerHour = 4500.5, LumLast5Min = 120, PassUpTracked = 1, LumPassUp = 300, PassUpPerHour = 149.4,
|
||||
Kills = 40, KillsPerHour = 20,
|
||||
};
|
||||
var more = new RynthCore.Plugin.Shared.SessionStatsMoreV1 { XpPerKill = 125_000, Deaths = 1, MaxLevel = 0, Rad = 77, RadPerHour = 38.5 };
|
||||
var v = RynthCore.Plugin.RynthTracker.TrackerSnapshot.FromRynthAi(s, more, null);
|
||||
Eq(v.SessionStartUtc, Now.AddHours(-2), "RynthAi's session start");
|
||||
Check(v.Xp == 5_000_000 && v.Lum == 9000 && v.Kills == 40 && v.PassUpTracked && v.LumPassUp == 300, "RynthAi's totals");
|
||||
Check(v.XpPerKill == 125_000 && v.Deaths == 1 && v.Rad == 77 && !v.MaxLevel, "and the rest from SessionStatsMore");
|
||||
|
||||
string json = RynthCore.Plugin.RynthTracker.TrackerSnapshot.Build(v, Now);
|
||||
Check(json.Contains("\"ss\":7200.0"), "the clock runs from RynthAi's start: " + json);
|
||||
Check(json.Contains("\"xh\":2500000") && json.Contains("\"lh\":4501") && json.Contains("\"ph\":149") && json.Contains("\"rh\":39"),
|
||||
"rates rounded, not cut off: " + json);
|
||||
Check(json.Contains("\"kt\":40") && json.Contains("\"xk\":125000") && json.Contains("\"dt\":1") && json.Contains("\"pk\":1"), "panel fields: " + json);
|
||||
|
||||
// An older RynthAi (no SessionStatsMore): those fields from the Tracker's own session, else zero.
|
||||
var own = new SessionStatsView(Now.AddHours(-1), 3600, 1, 1, 1, 1, 0, 0, 0, false, 3, 3, 999, 4, 5, 6, true);
|
||||
var old = RynthCore.Plugin.RynthTracker.TrackerSnapshot.FromRynthAi(s, null, own);
|
||||
Check(old.Xp == 5_000_000 && old.XpPerKill == 999 && old.Deaths == 4 && old.Rad == 5 && old.MaxLevel,
|
||||
"older RynthAi: RynthAi's totals, the Tracker's own deaths / Radiance / XP per kill");
|
||||
var bare = RynthCore.Plugin.RynthTracker.TrackerSnapshot.FromRynthAi(s, null, null);
|
||||
Check(bare.XpPerKill == 0 && bare.Deaths == 0 && bare.Rad == 0 && !bare.MaxLevel, "and zero with no own session");
|
||||
|
||||
Eq(RynthCore.Plugin.RynthTracker.TrackerSnapshot.PerHour(double.NaN), 0L, "NaN rate is 0");
|
||||
Eq(RynthCore.Plugin.RynthTracker.TrackerSnapshot.PerHour(-5), 0L, "negative rate is 0");
|
||||
Eq(RynthCore.Plugin.RynthTracker.TrackerSnapshot.PerHour(0.5), 1L, "half rounds up");
|
||||
unsafe
|
||||
{
|
||||
Eq(RynthCore.Plugin.Shared.RynthAiHubApiV1.BaseStructSize, (uint)(8 + 10 * sizeof(nint)), "the hub table's base size (10 functions)");
|
||||
Eq((uint)sizeof(RynthCore.Plugin.Shared.RynthAiHubApiV1), RynthCore.Plugin.Shared.RynthAiHubApiV1.BaseStructSize + (uint)sizeof(nint),
|
||||
"SessionStatsMore appended right after the base");
|
||||
}
|
||||
}
|
||||
|
||||
private static TrackerSessionState Sample() => new()
|
||||
{
|
||||
ProcessId = 4321,
|
||||
|
|
|
|||
|
|
@ -13,9 +13,14 @@
|
|||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>RynthCore.TrackerSessionTests</RootNamespace>
|
||||
<!-- RynthAiHubApi.cs (linked below) declares function-pointer fields. -->
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- One session (2026-10-13): RynthTracker's snapshot of RynthAi's session ("RynthAi.Hub"). -->
|
||||
<Compile Include="..\..\Plugins\Shared\RynthAiHubApi.cs" Link="Linked\RynthAiHubApi.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthTracker\TrackerSnapshot.cs" Link="Linked\TrackerSnapshot.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\TrackerSessionStore.cs" Link="Linked\TrackerSessionStore.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\KillCounter.cs" Link="Linked\KillCounter.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\CombatText.cs" Link="Linked\CombatText.cs" />
|
||||
|
|
|
|||
42
Tools/RynthILT.Tests/AetheriaChunkTests.cs
Normal file
42
Tools/RynthILT.Tests/AetheriaChunkTests.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using RynthCore.Plugin.RynthILT.Hub;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthILT.Tests;
|
||||
|
||||
// The Lugian-hammer aetheria rules (Hub/IltChunkClap.cs): Infinite Leaftide aetheria goes up to
|
||||
// level 10, and aetheria carrying a C, CD or CDR rating is kept unless its keep switch is off.
|
||||
internal static class AetheriaChunkTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("aetheria: the chunk cap runs to one past ILT's level 10", Cap);
|
||||
r.Add("aetheria: C / CD / CDR ratings are kept by default, each with its own switch", Ratings);
|
||||
}
|
||||
|
||||
private static void Cap()
|
||||
{
|
||||
Check.Eq(IltInventory.AetheriaMaxLevel, 10, "ILT max aetheria level");
|
||||
Check.Eq(IltChunkClap.ClampUnderLevel(0), 1, "below 1 clamps to 1");
|
||||
Check.Eq(IltChunkClap.ClampUnderLevel(7), 7, "7 (retail clamp was 6) is allowed");
|
||||
Check.Eq(IltChunkClap.ClampUnderLevel(11), 11, "11 chunks every level");
|
||||
Check.Eq(IltChunkClap.ClampUnderLevel(50), 11, "above 11 clamps to 11");
|
||||
Check.Eq(new IltGearState().ChunkAetheriaUnderLevel, 4, "the default cap is unchanged");
|
||||
}
|
||||
|
||||
private static void Ratings()
|
||||
{
|
||||
var g = new IltGearState();
|
||||
Check.True(g.KeepAetheriaWithCrit && g.KeepAetheriaWithCritDamage && g.KeepAetheriaWithCritDamageResist, "all keep switches on by default");
|
||||
Check.False(IltChunkClap.KeptForRatings(g, 0, 0, 0), "no rating: chunkable");
|
||||
Check.True(IltChunkClap.KeptForRatings(g, 2, 0, 0), "C kept");
|
||||
Check.True(IltChunkClap.KeptForRatings(g, 0, 1, 0), "CD kept");
|
||||
Check.True(IltChunkClap.KeptForRatings(g, 0, 0, 3), "CDR kept");
|
||||
|
||||
g.KeepAetheriaWithCrit = false;
|
||||
Check.False(IltChunkClap.KeptForRatings(g, 2, 0, 0), "C chunkable with its switch off");
|
||||
Check.True(IltChunkClap.KeptForRatings(g, 2, 0, 3), "CDR still keeps a C+CDR sigil");
|
||||
g.KeepAetheriaWithCritDamage = false;
|
||||
g.KeepAetheriaWithCritDamageResist = false;
|
||||
Check.False(IltChunkClap.KeptForRatings(g, 3, 3, 3), "every switch off: ratings don't protect");
|
||||
}
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ internal static class AttributeRaiserTests
|
|||
r.Add("attr raiser: safety (stale costs, another stat's reply, gate off mid-run, held off)", Safety);
|
||||
r.Add("attr raiser: by-hand +1 / +10 priced like UB, refused when unaffordable, costs read on tab open", ByHandPriced);
|
||||
r.Add("aug planner: /aug pulled on tab open, totals, reset targets, copy texts", AugPlanner);
|
||||
r.Add("aug refresh: banner alone does not end /aug; Current updates from level lines", AugRefreshWaitsForLevelLines);
|
||||
r.Add("aug costs: UB's ILT model (tier starts at its S level) in closed form", AugCostModel);
|
||||
r.Add("aug costs: per-server multipliers and rules, saved and reset", AugCostSettings);
|
||||
}
|
||||
|
|
@ -196,6 +197,34 @@ internal static class AttributeRaiserTests
|
|||
Check.Eq(FakeHost.ChatCommands.Count(x => x == "/aug"), 1, "levels loaded: no second automatic /aug");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh current must not finish on the /aug banner alone (chat-hold lag used to leave Current at 0).
|
||||
/// </summary>
|
||||
private static void AugRefreshWaitsForLevelLines()
|
||||
{
|
||||
var settings = new IltSettings();
|
||||
var hub = NewHub("InfiniteLeaftide", settings, "aug-refresh-idle", out _);
|
||||
var prog = hub.Progression;
|
||||
// Seed so EnsureAugs does not queue its own /aug ahead of our Refresh.
|
||||
prog.ApplyAugLines(new List<string> { "Creature: 1" });
|
||||
|
||||
prog.HandleRemote(new[] { "augload" });
|
||||
Check.True(TickUntil(hub, () => FakeHost.ChatCommands.Contains("/aug")), "Refresh current sends /aug");
|
||||
Reply(hub, "---------------------------", "Advanced Augmentation Levels:");
|
||||
// Longer than IdleEndMs (2s): without ArmsIdle this used to ApplyAugLines([]) and clear the status.
|
||||
var until = DateTime.UtcNow.AddMilliseconds(2500);
|
||||
while (DateTime.UtcNow < until) { hub.Tick(); Thread.Sleep(25); }
|
||||
Check.True(FakeHost.ChatCommands.Count(x => x == "/aug") == 1, "still waiting on the same /aug (banner did not end it)");
|
||||
|
||||
Reply(hub, "Creature:4,300", "Item:100", "Specialize: 2");
|
||||
Check.True(TickUntil(hub, () =>
|
||||
{
|
||||
var sb = new System.Text.StringBuilder();
|
||||
prog.AppendSnapshotJson(sb);
|
||||
return sb.ToString().Contains("\"cur\":4300", StringComparison.Ordinal);
|
||||
}), "Current updates once Creature:/Item: lines arrive");
|
||||
}
|
||||
|
||||
private static void Patterns()
|
||||
{
|
||||
Check.True(ServerFeatureGate.Matches("InfiniteLeaftide", "InfiniteLeaftide"), "exact");
|
||||
|
|
|
|||
|
|
@ -13,6 +13,60 @@ internal static class BankCommandTests
|
|||
r.Add("bank: withdraw commands, trade notes by denomination and count", Withdrawals);
|
||||
r.Add("bank: withdraw input is checked before anything is sent", WithdrawRefusals);
|
||||
r.Add("bank: reply lines are recognised, balance and chat lines are not", Replies);
|
||||
r.Add("bank: one item table matches ACECustom's handler (deposit / withdraw / transfer)", ItemTable);
|
||||
r.Add("bank: transfer commands, trade notes by denomination, quoted names", Transfers);
|
||||
r.Add("bank: transfer replies (notes' equivalent, bound prestige coins) are recognised", TransferReplies);
|
||||
}
|
||||
|
||||
private static int TransferIndex(string code) =>
|
||||
System.Array.FindIndex(IltBankCommands.Transfers, t => t.Code == code);
|
||||
|
||||
private static void ItemTable()
|
||||
{
|
||||
string Codes(System.Collections.Generic.IEnumerable<string> codes) => string.Join(",", codes);
|
||||
// ACECustom HandleBank (upstream 976606695): deposit everything; withdraw all but peas and
|
||||
// luminance tokens; transfer all but those and the bound prestige coins.
|
||||
Check.Eq(Codes(System.Linq.Enumerable.Select(IltBankCommands.Deposits, d => d.Args)), ",p,ps,l,lum,k,mk,e,we,pc,n", "deposits");
|
||||
Check.Eq(Codes(System.Linq.Enumerable.Select(IltBankCommands.Withdrawals, w => w.Code)), "p,l,k,mk,e,we,pc,n", "withdrawals");
|
||||
Check.Eq(Codes(System.Linq.Enumerable.Select(IltBankCommands.Transfers, t => t.Code)), "p,l,k,mk,e,we,n", "transfers");
|
||||
Check.Eq(TransferIndex("pc"), -1, "prestige coins are bound: never offered for transfer");
|
||||
Check.Eq(TransferIndex("ps"), -1, "pyreal peas: deposit only");
|
||||
Check.Eq(IltBanking.Currencies.Length, IltBankCommands.Transfers.Length, "the transfer form uses the table");
|
||||
Check.Eq(IltBanking.Currencies[0].Code, "p", "saved transfer index 0 is still pyreals");
|
||||
Check.Eq(IltBanking.Currencies[5].Code, "we", "saved transfer indexes 0-5 keep their currency");
|
||||
}
|
||||
|
||||
private static void Transfers()
|
||||
{
|
||||
int mmd = System.Array.FindIndex(IltBankCommands.NoteDenominations, n => n.Code == "mmd");
|
||||
Check.Eq(IltBankCommands.Transfer(TransferIndex("p"), 250_000, -1, "Bob", out _), "/bank t p 250000 Bob", "pyreals");
|
||||
Check.Eq(IltBankCommands.Transfer(TransferIndex("mk"), 3, -1, " Bob ", out _), "/bank t mk 3 Bob", "name trimmed");
|
||||
Check.Eq(IltBankCommands.Transfer(TransferIndex("l"), 10, -1, "Some Name", out _), "/bank t l 10 \"Some Name\"",
|
||||
"a name with a space is quoted (the server reads one argument)");
|
||||
Check.Eq(IltBankCommands.Transfer(TransferIndex("n"), 4, mmd, "Bob", out _), "/bank t n mmd 4 Bob", "four 250K notes");
|
||||
Check.True(IltBankCommands.IsNoteTransfer(TransferIndex("n")), "notes transfer by denomination");
|
||||
Check.False(IltBankCommands.IsNoteTransfer(TransferIndex("p")), "pyreals don't");
|
||||
Check.Eq(IltBankCommands.NoteValue(mmd, 4), 1_000_000L, "4 x 250K");
|
||||
|
||||
Check.Eq(IltBankCommands.Transfer(-1, 10, -1, "Bob", out string e1), "", "no currency refused");
|
||||
Check.Eq(e1, "Pick a currency.", "why");
|
||||
Check.Eq(IltBankCommands.Transfer(TransferIndex("p"), 0, -1, "Bob", out _), "", "zero refused");
|
||||
Check.Eq(IltBankCommands.Transfer(TransferIndex("p"), 10, -1, " ", out string e2), "", "no recipient refused");
|
||||
Check.Eq(e2, "Enter a recipient.", "why");
|
||||
Check.Eq(IltBankCommands.Transfer(TransferIndex("p"), 10, -1, "Bob\" x", out _), "", "a quote can't break out of the name");
|
||||
Check.Eq(IltBankCommands.Transfer(TransferIndex("n"), 4, 99, "Bob", out _), "", "bad denomination refused");
|
||||
Check.Eq(IltBankCommands.Transfer(TransferIndex("n"), IltBankCommands.MaxNoteCount + 1, mmd, "Bob", out _), "", "too many notes refused");
|
||||
}
|
||||
|
||||
private static void TransferReplies()
|
||||
{
|
||||
Check.True(IltBankCommands.IsTransferReply("Transferred 1,000,000 Pyreals to Bob"), "result");
|
||||
Check.True(IltBankCommands.IsTransferReply("(Equivalent to 4x MMD notes)"), "trade-note equivalent");
|
||||
Check.True(IltBankCommands.IsTransferReply("[BANK] Prestige Coins are bound to you and cannot be transferred."), "bound coins");
|
||||
Check.True(IltBankCommands.IsTransferReply("[Transfer] This command may only be run once every 5 seconds."), "throttled");
|
||||
Check.True(IltBankCommands.IsTransferReply("Invalid denomination. Use: i(100), v(500)"), "bad denomination");
|
||||
Check.False(IltBankCommands.IsTransferReply("[BANK] Pyreals: 1,000"), "a balance line is not");
|
||||
Check.False(IltBankCommands.IsTransferReply("Bob tells you, \"Transferred 5\""), "a tell is not");
|
||||
}
|
||||
|
||||
private static int DepositIndex(string args) =>
|
||||
|
|
|
|||
376
Tools/RynthILT.Tests/BreedingTests.cs
Normal file
376
Tools/RynthILT.Tests/BreedingTests.cs
Normal file
|
|
@ -0,0 +1,376 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using RynthCore.Plugin.RynthILT;
|
||||
using RynthCore.Plugin.RynthILT.Hub;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthILT.Tests;
|
||||
|
||||
// The pet breeding tracker (IltBreedingRules / IltBreedingEssence / IltBreedingSupplies / IltPetBreeding):
|
||||
// the server's rules and where each value came from, the parsers for ACECustom's appraisal block,
|
||||
// chat and "@breed-debug" (formats copied from PetDevice_Breeding.cs / PetDevice_Maturity.cs), each
|
||||
// breeding gate, the pair planner's odds, the supply refusals, and the "RynthILT.Data" v2 reader JSON.
|
||||
internal static class BreedingTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("breeding: tier table has one WCID per tier in every family, no repeats", TierTable);
|
||||
r.Add("breeding: rules come from the server, else the ILT profile, else ACE", RuleSources);
|
||||
r.Add("breeding: stat mutation odds follow ACE's decay, floor and incense cap", MutationOdds);
|
||||
r.Add("breeding: appraisal text gives the stud's charges, refill window and growth", AppraisalParse);
|
||||
r.Add("breeding: chat lines give charges, the guardian, growth stages and events", ChatParse);
|
||||
r.Add("breeding: @breed-debug reply is captured whole or line by line and parsed", DebugParse);
|
||||
r.Add("breeding: each gate (charges, rest, growth, neutered, shiny, bond, tier, ID)", Gates);
|
||||
r.Add("breeding: pair planner blocks wrong sexes and ranges the inherited mutations", Planner);
|
||||
r.Add("breeding: supplies are refused where the server would refuse them", Supplies);
|
||||
r.Add("breeding: reader JSON round-trips through the shared reader view", ReaderJson);
|
||||
r.Add("breeding: saved state survives the hub.json source-generated serializer", StateJson);
|
||||
r.Add("breeding: RynthILT.Data v2 keeps v1 readers working", DataApiVersion);
|
||||
}
|
||||
|
||||
private static IltBreedingRules Rules() => new(new IltBreedingState());
|
||||
|
||||
/// <summary>A healthy adult essence's facts (tier 150, bond 120, appraised).</summary>
|
||||
private static BreedEssenceFacts Facts(int id, bool male, uint wcid = 48946) => new()
|
||||
{
|
||||
Id = id,
|
||||
Name = (male ? "Stud " : "Dam ") + id,
|
||||
Wcid = wcid,
|
||||
HasId = true,
|
||||
Bond = 120,
|
||||
MaleOverride = male,
|
||||
};
|
||||
|
||||
private static void TierTable()
|
||||
{
|
||||
var seen = new HashSet<uint>();
|
||||
foreach (uint[] row in IltBreedingEssence.Families)
|
||||
{
|
||||
Check.Eq(row.Length, IltBreedingEssence.Tiers.Length, "row " + row[0]);
|
||||
foreach (uint w in row) Check.True(seen.Add(w), "WCID " + w + " appears once");
|
||||
}
|
||||
Check.Eq(IltBreedingEssence.Families.Length, 36, "36 combat pet families");
|
||||
Check.Eq(IltBreedingEssence.TierOf(48942), 50, "first fire skeleton is tier 50");
|
||||
Check.Eq(IltBreedingEssence.TierOf(49212), 200, "an out-of-run WCID keeps its slot (tier 200)");
|
||||
Check.Eq(IltBreedingEssence.TierOf(787801072), 300, "the last tier-300 essence");
|
||||
Check.Eq(IltBreedingEssence.TierOf(12345, 125), 125, "unknown WCID: a tier-valued level requirement");
|
||||
Check.Eq(IltBreedingEssence.TierOf(12345, 126), 0, "unknown WCID, odd level: unknown tier");
|
||||
Check.True(IltBreedingEssence.IsCombatEssence(49551), "range end is included");
|
||||
}
|
||||
|
||||
private static void RuleSources()
|
||||
{
|
||||
IltBreedingRules r = Rules();
|
||||
Check.Eq(r.Value(IltBreedingRules.MinTier).Source, BreedRuleSource.AceDefault, "min tier: ACE default");
|
||||
Check.Eq(r.GetInt(IltBreedingRules.MinTier), 100, "min tier 100");
|
||||
Check.Eq(r.Value(IltBreedingRules.MutationDecay).Source, BreedRuleSource.IltProfile, "decay: ILT profile");
|
||||
Check.Near(r.Get(IltBreedingRules.MutationDecay), 0.1, 1e-9, "ILT decay 0.1");
|
||||
Check.Near(r.Get(IltBreedingRules.GuardianEnabled), 1, 1e-9, "ILT runs the mating guardian");
|
||||
|
||||
DateTime t = new(2026, 10, 15, 12, 0, 0, DateTimeKind.Utc);
|
||||
Check.True(r.Learn(IltBreedingRules.MaleCharges, 12, t), "a new value is a change");
|
||||
Check.False(r.Learn(IltBreedingRules.MaleCharges, 12, t), "the same value again isn't");
|
||||
Check.Eq(r.Value(IltBreedingRules.MaleCharges).Source, BreedRuleSource.Server, "learned: seen on server");
|
||||
Check.Eq(r.GetInt(IltBreedingRules.MaleCharges), 12, "learned value wins");
|
||||
Check.False(r.Learn("not_a_rule", 1, t), "unknown keys are ignored");
|
||||
Check.Eq(r.RoomText(), "landblock 0x0106 variant 2", "Seedy Motel room");
|
||||
|
||||
IltBreedingRules frozen = r.Frozen();
|
||||
r.Learn(IltBreedingRules.MaleCharges, 8, t);
|
||||
Check.Eq(frozen.GetInt(IltBreedingRules.MaleCharges), 12, "a frozen copy doesn't follow later learning");
|
||||
|
||||
Check.Eq(r.StageName(2), "Whelp", "default stage names");
|
||||
Check.True(r.LearnStageName(2, "Pup"), "a server's own stage name");
|
||||
Check.Eq(r.StageName(2), "Pup", "seen name wins");
|
||||
for (int i = 0; i < IltBreedingRules.MaxEvents + 5; i++) r.AddEvent("x", "e" + i, t);
|
||||
Check.Eq(r.State.Log.Count, IltBreedingRules.MaxEvents, "event log is capped");
|
||||
Check.Eq(r.State.Log[^1].Text, "e" + (IltBreedingRules.MaxEvents + 4), "newest kept last");
|
||||
}
|
||||
|
||||
private static void MutationOdds()
|
||||
{
|
||||
IltBreedingRules r = Rules();
|
||||
Check.Near(r.StatMutationChance(0, 0), 0.05, 1e-9, "base 5%");
|
||||
Check.Near(r.StatMutationChance(4, 0), 0.05 / 1.4, 1e-9, "decay 0.1 x 4 mutations");
|
||||
Check.Near(r.StatMutationChance(0, 0.10), 0.15, 1e-9, "exquisite incense adds 10%");
|
||||
Check.Near(r.CombinedIncense(0.4, 0.3), 0.5, 1e-9, "both parents' incense capped at 50%");
|
||||
r.Learn(IltBreedingRules.MutationDecay, 10, DateTime.UtcNow);
|
||||
Check.Near(r.StatMutationChance(4, 0), 0.02, 1e-9, "never below the 2% floor");
|
||||
}
|
||||
|
||||
private static void AppraisalParse()
|
||||
{
|
||||
double now = 1_800_000_000;
|
||||
double lastRefill = now - (20 * 3600 + 50 * 60);
|
||||
string desc = "A fire skeleton essence.\nSex: Male (9/12 breeding charges today) - refills in 3h 10m\nBond: Unbound (imprints on first summon)";
|
||||
var seen = IltBreedingRules.FromAppraisal(desc, lastRefill, now);
|
||||
Check.True(seen.Contains((IltBreedingRules.MaleCharges, 12)), "max charges from the stud line");
|
||||
Check.True(seen.Contains((IltBreedingRules.MaleRefillHours, 24)), "refill window from the countdown");
|
||||
|
||||
string growth = "Sex: Female (ready to breed)\nGrowth: Whelp 2/5 - 75 kills to Juvenile, 195 to Adult";
|
||||
Check.True(IltBreedingRules.FromAppraisal(growth, 0, now).Contains((IltBreedingRules.MaturityStages, 5)), "stage count");
|
||||
Check.True(IltBreedingRules.TryParseGrowth(growth, out string name, out int stage, out int stages, out int toNext, out string next, out int toAdult), "growth line");
|
||||
Check.Eq(name, "Whelp", "stage name");
|
||||
Check.Eq(stage, 2, "stage");
|
||||
Check.Eq(stages, 5, "stages");
|
||||
Check.Eq(toNext, 75, "to next");
|
||||
Check.Eq(next, "Juvenile", "next stage");
|
||||
Check.Eq(toAdult, 195, "to adult");
|
||||
|
||||
Check.True(IltBreedingRules.TryParseGrowth("Growth: Young Adult 5/5 - 60 kills to Adult", out name, out stage, out _, out toNext, out next, out toAdult), "last stage");
|
||||
Check.Eq(name, "Young Adult", "two-word stage name");
|
||||
Check.Eq(next, "Adult", "last stage leads to Adult");
|
||||
Check.Eq(toAdult, 60, "last stage: to adult = to next");
|
||||
Check.False(IltBreedingRules.TryParseGrowth("Growth: Adult", out _, out _, out _, out _, out _, out _), "an adult has no countdown");
|
||||
}
|
||||
|
||||
private static void ChatParse()
|
||||
{
|
||||
var a = IltBreedingRules.FromChat("[Breeding] Fire Skeleton Essence spent a breeding charge: 7/12 left today.");
|
||||
Check.True(a.Contains((IltBreedingRules.MaleCharges, 12)), "charge line gives the max");
|
||||
var g = IltBreedingRules.FromChat("The union stirs something... Mating Spirit rises before A and B! Only the two parents can harm it. They have 120s to bring it down together.");
|
||||
Check.True(g.Contains((IltBreedingRules.GuardianEnabled, 1)), "guardian on");
|
||||
Check.True(g.Contains((IltBreedingRules.GuardianSeconds, 120)), "guardian timer");
|
||||
var d = IltBreedingRules.FromChat("[Breeding] Your pet performs the courtship dance, waiting for a partner... (Your partner must have their pet summoned in the same room and *dance* within 5 seconds).");
|
||||
Check.True(d.Contains((IltBreedingRules.DanceWindow, 5)), "dance window");
|
||||
Check.Eq(IltBreedingRules.FromChat("You say, \"hello\"").Count, 0, "ordinary chat says nothing");
|
||||
|
||||
Check.True(IltBreedingRules.TryParseGrownInto("Pup has grown into a Whelp! Its body swells with new strength. (2/5)", out int stage, out string name), "growth line");
|
||||
Check.Eq(stage, 2, "stage number");
|
||||
Check.Eq(name, "Whelp", "stage name");
|
||||
|
||||
Check.Eq(IltPetBreeding.EventKind("The mating ritual has begun between A and B..."), "ritual", "ritual");
|
||||
Check.Eq(IltPetBreeding.EventKind("Congratulations! A baby pet has been born: Pup! Placed in Bob's inventory."), "birth", "birth");
|
||||
Check.Eq(IltPetBreeding.EventKind("A baby pet has been born: Pup! Bob's packs are full, so the baby has been tucked away"), "birth", "deferred birth");
|
||||
Check.Eq(IltPetBreeding.EventKind("Pup has reached adulthood! It stands at its full size"), "adult", "adulthood");
|
||||
Check.Eq(IltPetBreeding.EventKind("Pup has imprinted on you. It is now bound to this character"), "imprint", "imprint");
|
||||
Check.Eq(IltPetBreeding.EventKind("[Breeding] The spectral guardian dissolves back into the ether..."), "guardian", "guardian lost");
|
||||
Check.Eq(IltPetBreeding.EventKind("Bob tells you, \"breed?\""), null, "not a breeding line");
|
||||
}
|
||||
|
||||
private const string DebugReply =
|
||||
"=== PET BREEDING DIAGNOSTICS ===\n" +
|
||||
"Breeding System Enabled: True\n" +
|
||||
"Your Location: Landblock=0x0106, Cell=0x01060186, Variant=2\n" +
|
||||
"Allowed Target: whole landblock 0x106, Variant=2 => Location Match: VALID (Room OK)\n" +
|
||||
"Your Active Pet: Fire Skeleton (WCID 48900) | Device: Fire Skeleton Essence\n" +
|
||||
" Sex: Male (9/10 charges)\n" +
|
||||
"Eligible breeding partners nearby: 1\n" +
|
||||
"================================\n";
|
||||
|
||||
private static void DebugParse()
|
||||
{
|
||||
Check.True(IltBreedingRules.IsDebugLine(DebugReply.TrimEnd('\n')), "whole message is a reply line");
|
||||
Check.True(IltBreedingRules.IsDebugEnd(DebugReply.TrimEnd('\n')), "whole message ends the reply");
|
||||
Check.True(IltBreedingRules.IsDebugEnd("================================"), "rule line alone ends it");
|
||||
Check.False(IltBreedingRules.IsDebugEnd("=== PET BREEDING DIAGNOSTICS ==="), "the header doesn't");
|
||||
Check.False(IltBreedingRules.IsDebugLine("Bob says, \"hi\""), "chat isn't");
|
||||
|
||||
BreedDebugInfo whole = IltBreedingRules.ParseDebug(new[] { DebugReply });
|
||||
BreedDebugInfo split = IltBreedingRules.ParseDebug(DebugReply.Split('\n'));
|
||||
foreach (BreedDebugInfo d in new[] { whole, split })
|
||||
{
|
||||
Check.Eq(d.Enabled, (bool?)true, "enabled");
|
||||
Check.Eq(d.AllowedLandblock, 0x106u, "landblock");
|
||||
Check.Eq(d.AllowedVariant, 2, "variant");
|
||||
Check.Eq(d.AllowedKind, "whole landblock", "kind");
|
||||
Check.Eq(d.LocationOk, (bool?)true, "in the room");
|
||||
Check.Eq(d.Partners, 1, "partners");
|
||||
Check.Eq(d.PetSex, "Male (9/10 charges)", "pet sex line");
|
||||
}
|
||||
var rules = IltBreedingRules.FromChat(DebugReply);
|
||||
Check.True(rules.Contains((IltBreedingRules.Landblock, 0x106)), "room landblock learned");
|
||||
Check.True(rules.Contains((IltBreedingRules.Variant, 2)), "room variant learned");
|
||||
}
|
||||
|
||||
private static void Gates()
|
||||
{
|
||||
IltBreedingRules r = Rules();
|
||||
double now = 1_800_000_000;
|
||||
|
||||
BreedEssence full = IltBreedingEssence.Evaluate(Facts(1, true), r, now);
|
||||
Check.True(full.Ready, "a stud that never bred is full");
|
||||
Check.Eq(full.Charges, 10, "10 charges");
|
||||
Check.Eq(full.Tier, 125, "48946 is tier 125");
|
||||
|
||||
var spent = Facts(2, true);
|
||||
spent.MaleCharges = 0;
|
||||
spent.MaleRefreshUnix = now - 2 * 3600;
|
||||
BreedEssence noCharge = IltBreedingEssence.Evaluate(spent, r, now);
|
||||
Check.Eq(noCharge.Gate, BreedGate.NoCharges, "no charges");
|
||||
Check.Near(noCharge.ReadyAtUnix, now + 22 * 3600, 1, "refills 24h after the last refill");
|
||||
|
||||
spent.MaleRefreshUnix = now - 25 * 3600;
|
||||
Check.True(IltBreedingEssence.Evaluate(spent, r, now).Ready, "refilled once the window passed (the server refills on read)");
|
||||
|
||||
var dam = Facts(3, false);
|
||||
dam.NextBreedUnix = now + 3600 + 300;
|
||||
BreedEssence resting = IltBreedingEssence.Evaluate(dam, r, now);
|
||||
Check.Eq(resting.Gate, BreedGate.Resting, "resting dam");
|
||||
Check.Eq(resting.Status, "Rest 1h 05m", "rest countdown");
|
||||
|
||||
var neut = Facts(4, false);
|
||||
neut.Neutered = true;
|
||||
Check.Eq(IltBreedingEssence.Evaluate(neut, r, now).Gate, BreedGate.Neutered, "neutered");
|
||||
|
||||
var shiny = Facts(5, true);
|
||||
shiny.LongDesc = "Sex: Male (shiny - cannot breed)";
|
||||
Check.Eq(IltBreedingEssence.Evaluate(shiny, r, now).Gate, BreedGate.Shiny, "shiny");
|
||||
|
||||
var baby = Facts(6, false);
|
||||
baby.JuvenileFlag = true;
|
||||
baby.MaturityKills = 130;
|
||||
BreedEssence growing = IltBreedingEssence.Evaluate(baby, r, now);
|
||||
Check.Eq(growing.Gate, BreedGate.Growing, "juvenile");
|
||||
Check.Eq(growing.Stage, 3, "130 kills of 300 over 5 stages: stage 3");
|
||||
Check.Eq(growing.StageName, "Juvenile", "stage 3 name");
|
||||
Check.Eq(growing.KillsToNext, 50, "50 kills to stage 4");
|
||||
|
||||
var weak = Facts(7, true);
|
||||
weak.Bond = 40;
|
||||
Check.Eq(IltBreedingEssence.Evaluate(weak, r, now).Gate, BreedGate.LowBond, "bond under 100");
|
||||
|
||||
BreedEssence low = IltBreedingEssence.Evaluate(Facts(8, true, 48944), r, now);
|
||||
Check.Eq(low.Gate, BreedGate.LowTier, "tier 80 is under the minimum");
|
||||
|
||||
var unread = Facts(9, true);
|
||||
unread.HasId = false;
|
||||
Check.Eq(IltBreedingEssence.Evaluate(unread, r, now).Gate, BreedGate.NeedsId, "not appraised yet");
|
||||
|
||||
var boosted = Facts(10, false);
|
||||
boosted.Incense = 0.05;
|
||||
boosted.Catalyst = true;
|
||||
BreedEssence b = IltBreedingEssence.Evaluate(boosted, r, now);
|
||||
Check.Eq(string.Join("|", b.Boosters), "Refined incense +5%|Chromatic Catalyst", "boosters listed");
|
||||
}
|
||||
|
||||
private static void Planner()
|
||||
{
|
||||
IltBreedingRules r = Rules();
|
||||
double now = 1_800_000_000;
|
||||
var sf = Facts(1, true);
|
||||
sf.MutDamage = 2;
|
||||
sf.MutCrit = 1;
|
||||
sf.Incense = 0.10;
|
||||
var df = Facts(2, false);
|
||||
df.MutDamage = 0;
|
||||
df.MutCrit = 3;
|
||||
BreedEssence stud = IltBreedingEssence.Evaluate(sf, r, now), dam = IltBreedingEssence.Evaluate(df, r, now);
|
||||
|
||||
BreedPairPlan p = IltBreedingPlanner.Plan(stud, dam, r);
|
||||
Check.True(p.CanBreed, "both ready");
|
||||
Check.Eq(p.InheritMin, 1, "lower lines: damage 0 + crit 1");
|
||||
Check.Eq(p.InheritMax, 5, "higher lines: damage 2 + crit 3");
|
||||
Check.Near(p.ChanceBest, 0.15 / 1.1, 1e-9, "best: 1 mutation, incense 10%");
|
||||
Check.Near(p.ChanceWorst, 0.15 / 1.5, 1e-9, "worst: 5 mutations");
|
||||
Check.Near(p.PotencyChance, 0.03, 1e-9, "potency 3%");
|
||||
|
||||
BreedPairPlan wrong = IltBreedingPlanner.Plan(dam, stud, r);
|
||||
Check.False(wrong.CanBreed, "swapped sexes");
|
||||
Check.True(wrong.Blockers.Any(b => b.Contains("must be male")), "says the stud must be male");
|
||||
}
|
||||
|
||||
private static void Supplies()
|
||||
{
|
||||
IltBreedingRules r = Rules();
|
||||
double now = 1_800_000_000;
|
||||
BreedSupplyDef lesser = IltBreedingSupplies.Find(IltBreedingSupplies.LesserIncense)!;
|
||||
BreedSupplyDef exquisite = IltBreedingSupplies.Find(IltBreedingSupplies.ExquisiteIncense)!;
|
||||
BreedSupplyDef draught = IltBreedingSupplies.Find(IltBreedingSupplies.Draught)!;
|
||||
BreedSupplyDef offering = IltBreedingSupplies.Find(IltBreedingSupplies.Offering)!;
|
||||
BreedSupplyDef neuter = IltBreedingSupplies.Find(IltBreedingSupplies.NeuteringKit)!;
|
||||
|
||||
var f = Facts(1, false);
|
||||
f.Incense = 0.05;
|
||||
BreedEssence primed = IltBreedingEssence.Evaluate(f, r, now);
|
||||
Check.NotNull(IltBreedingSupplies.RefuseReason(lesser, primed, r), "weaker incense refused");
|
||||
Check.Null(IltBreedingSupplies.RefuseReason(exquisite, primed, r), "stronger incense taken");
|
||||
Check.True(IltBreedingSupplies.Warning(exquisite, primed).Contains("+5%"), "and warns the +5% is lost");
|
||||
|
||||
var n = Facts(2, false);
|
||||
n.Neutered = true;
|
||||
Check.NotNull(IltBreedingSupplies.RefuseReason(lesser, IltBreedingEssence.Evaluate(n, r, now), r), "no incense on a neutered essence");
|
||||
|
||||
BreedEssence adult = IltBreedingEssence.Evaluate(Facts(3, true), r, now);
|
||||
Check.NotNull(IltBreedingSupplies.RefuseReason(draught, adult, r), "draught: juveniles only");
|
||||
var j = Facts(4, true);
|
||||
j.JuvenileFlag = true;
|
||||
j.MaturityKills = 0;
|
||||
Check.Null(IltBreedingSupplies.RefuseReason(draught, IltBreedingEssence.Evaluate(j, r, now), r), "draught on a juvenile");
|
||||
j.MaturityXpMult = 2.0;
|
||||
Check.NotNull(IltBreedingSupplies.RefuseReason(draught, IltBreedingEssence.Evaluate(j, r, now), r), "not twice");
|
||||
|
||||
Check.Null(IltBreedingSupplies.RefuseReason(offering, adult, r), "offering with the guardian on");
|
||||
r.Learn(IltBreedingRules.GuardianEnabled, 0, DateTime.UtcNow);
|
||||
Check.NotNull(IltBreedingSupplies.RefuseReason(offering, adult, r), "offering refused with the guardian off");
|
||||
Check.NotNull(IltBreedingSupplies.RefuseReason(neuter, adult, r), "the neutering kit is never used from here");
|
||||
Check.Eq(IltBreedingSupplies.PriceText(1_250_000), "1.25M", "price text");
|
||||
}
|
||||
|
||||
private static void ReaderJson()
|
||||
{
|
||||
IltBreedingRules r = Rules();
|
||||
double now = 1_800_000_000;
|
||||
var stud = IltBreedingEssence.Evaluate(Facts(11, true), r, now);
|
||||
var dam = IltBreedingEssence.Evaluate(Facts(12, false), r, now);
|
||||
var events = new[] { new IltBreedingEvent { Utc = new DateTime(2026, 10, 15, 20, 0, 0, DateTimeKind.Utc), Kind = "birth", Text = "A \"baby\" was born" } };
|
||||
var supplies = IltBreedingSupplies.All.Select(s => (s, s.Key == IltBreedingSupplies.RefinedIncense ? 2L : 0L)).ToList();
|
||||
var snap = new BreedingSnapshot(new[] { stud, dam }, supplies, r.All(), events,
|
||||
IltBreedingRules.ParseDebug(new[] { DebugReply }), DateTime.UtcNow, IltTri.On, IltTri.On, IltTri.On,
|
||||
r.RoomText(), 5, "hello", now, true, r.Frozen());
|
||||
|
||||
string json = IltPetBreeding.BuildJson(snap, r, "InfiniteLeaftide");
|
||||
using (JsonDocument.Parse(json)) { } // well-formed
|
||||
IltBreedingView v = IltBreedingView.Parse(json);
|
||||
Check.True(v.Loaded && v.Available, "loaded");
|
||||
Check.Eq(v.Enabled, "on", "enabled");
|
||||
Check.Eq(v.Room, "landblock 0x0106 variant 2", "room");
|
||||
Check.Eq(v.FreeSlots, 5, "free slots");
|
||||
Check.Eq(v.Essences.Count, 2, "two essences");
|
||||
Check.True(v.Essences[0].Male && v.Essences[0].Ready, "stud row");
|
||||
Check.Eq(v.Pairs.Count, 1, "one ready pairing");
|
||||
Check.Near(v.Pairs[0].ChanceBest, 0.05, 1e-6, "pair odds");
|
||||
IltBreedSupplyRow refined = v.Supplies.First(s => s.Key == IltBreedingSupplies.RefinedIncense);
|
||||
Check.Eq(refined.Count, 2L, "supply count");
|
||||
Check.Eq(refined.Targets.Count, 2, "both essences can take it");
|
||||
Check.Eq(v.Supplies.First(s => s.Key == IltBreedingSupplies.LesserIncense).Targets.Count, 0, "none carried: no targets");
|
||||
Check.Eq(v.Rules.Count, IltBreedingRules.Defs.Length, "every rule");
|
||||
Check.Eq(v.Events[0].Text, "A \"baby\" was born", "quotes escaped and read back");
|
||||
Check.Eq(v.Debug?.Match, "valid", "diagnostics");
|
||||
Check.Eq(IltBreedingView.ApplyVerb(" incense2 ", 12), "apply incense2 12", "apply verb");
|
||||
}
|
||||
|
||||
private static void StateJson()
|
||||
{
|
||||
var state = new IltHubState();
|
||||
var rules = new IltBreedingRules(state.Pet.Breeding);
|
||||
rules.Learn(IltBreedingRules.MaleCharges, 12, new DateTime(2026, 10, 15, 0, 0, 0, DateTimeKind.Utc));
|
||||
rules.LearnStageName(1, "Hatchling");
|
||||
rules.AddEvent("birth", "born", DateTime.UtcNow);
|
||||
string json = JsonSerializer.Serialize(state, IltHubJsonContext.Default.IltHubState);
|
||||
IltHubState back = JsonSerializer.Deserialize(json, IltHubJsonContext.Default.IltHubState)!;
|
||||
var again = new IltBreedingRules(back.Pet.Breeding);
|
||||
Check.Eq(again.GetInt(IltBreedingRules.MaleCharges), 12, "learned rule saved");
|
||||
Check.Eq(again.StageName(1), "Hatchling", "stage name saved");
|
||||
Check.Eq(back.Pet.Breeding.Log.Count, 1, "event saved");
|
||||
|
||||
IltHubState old = JsonSerializer.Deserialize("{\"Pet\":{\"PetLog\":[\"a\"]}}", IltHubJsonContext.Default.IltHubState)!;
|
||||
Check.NotNull(old.Pet.Breeding, "a hub.json from before the tracker gets an empty breeding state");
|
||||
}
|
||||
|
||||
private static unsafe void DataApiVersion()
|
||||
{
|
||||
Check.Eq(RynthIltDataApiV1.InterfaceVersion, 2u, "version 2");
|
||||
Check.True(RynthIltDataApiV1.V1Size < (uint)sizeof(RynthIltDataApiV1), "v2 appends to v1");
|
||||
Check.Eq(RynthIltDataApiV1.V1Size, (uint)(8 + 4 * sizeof(IntPtr)), "v1 = two uints and four function pointers");
|
||||
Check.True(DataInterface.Query(RynthIltDataApiV1.InterfaceName, 1) != IntPtr.Zero, "v1 readers still get the table");
|
||||
Check.True(DataInterface.Query(RynthIltDataApiV1.InterfaceName, 2) != IntPtr.Zero, "v2 readers too");
|
||||
Check.True(DataInterface.Query(RynthIltDataApiV1.InterfaceName, 3) == IntPtr.Zero, "a future version isn't claimed");
|
||||
var t = (RynthIltDataApiV1*)DataInterface.Query(RynthIltDataApiV1.InterfaceName, 1);
|
||||
Check.True(t->GetPetBreedingJson != null && t->PetBreedingCommand != null, "breeding functions filled");
|
||||
Check.Eq(RynthIltHub.SectionPetBreeding, "pets-breeding", "section id");
|
||||
}
|
||||
}
|
||||
36
Tools/RynthILT.Tests/ChunkTests.cs
Normal file
36
Tools/RynthILT.Tests/ChunkTests.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using RynthCore.Plugin.RynthILT.Hub;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthILT.Tests;
|
||||
|
||||
// Lugian-hammer chunking (Hub/IltChunkClap.cs): only the Lugian Aetheria Hammer is the tool, and
|
||||
// ILT's result lines name the item and the tool. Ported from SilentKelpie's fix (2026-10-15).
|
||||
internal static class ChunkTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("chunk: only the Lugian Aetheria Hammer is the tool, never a Lugian Hammer weapon", HammerOnly);
|
||||
r.Add("chunk: ILT's result lines (item and tool named) end the wait; combat lines don't", ResultLines);
|
||||
}
|
||||
|
||||
/// <summary>The Flaming Lugian Hammer (a loot weapon) matched " Lugian Hammer", chunked nothing,
|
||||
/// and all 9 Coalesced Aetheria timed out into the skip list.</summary>
|
||||
private static void HammerOnly()
|
||||
{
|
||||
Check.True(IltChunkClap.IsChunkHammer("Lugian Aetheria Hammer"), "the ILT tool");
|
||||
Check.True(IltChunkClap.IsChunkHammer("lugian aetheria hammer"), "any case");
|
||||
Check.False(IltChunkClap.IsChunkHammer("Flaming Lugian Hammer"), "a loot weapon is not the tool");
|
||||
Check.False(IltChunkClap.IsChunkHammer("Lugian Hammer"), "nor the plain one");
|
||||
Check.False(IltChunkClap.IsChunkHammer("Acid Lugian Hammer"), "nor any variant");
|
||||
}
|
||||
|
||||
private static void ResultLines()
|
||||
{
|
||||
Check.Eq(IltChunkClap.ClassifyChat("You smash the Corrupted Sword with the Lugian Aetheria Hammer."), IltChunkClap.ChunkResult.Done, "ILT corrupted line");
|
||||
Check.Eq(IltChunkClap.ClassifyChat("You smash the aetheria with the hammer."), IltChunkClap.ChunkResult.Done, "aetheria line");
|
||||
Check.Eq(IltChunkClap.ClassifyChat("The aetheria is too powerful to chunk."), IltChunkClap.ChunkResult.Refused, "refused");
|
||||
Check.Eq(IltChunkClap.ClassifyChat("You're too busy!"), IltChunkClap.ChunkResult.Busy, "busy");
|
||||
Check.Eq(IltChunkClap.ClassifyChat("You smash Corrupted Shadow for 147 points of bludgeoning damage!"), IltChunkClap.ChunkResult.None,
|
||||
"a combat line naming a corrupted monster is no result");
|
||||
}
|
||||
}
|
||||
113
Tools/RynthILT.Tests/DataApiTests.cs
Normal file
113
Tools/RynthILT.Tests/DataApiTests.cs
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RynthCore.Plugin.RynthILT;
|
||||
using RynthCore.Plugin.RynthILT.Hub;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthILT.Tests;
|
||||
|
||||
// "RynthILT.Data" v1 (Plugins/Shared/RynthIltDataApi.cs, DataInterface.cs): the bank JSON RynthILT
|
||||
// builds (Hub/IltBankExport.cs) read back by the shared reader, the bank verb lines a reader sends
|
||||
// (IltBanking.RunVerb splits them), and the table itself. The charms JSON is MoveTests'
|
||||
// CharmsReaderJson. No plugin in this tree reads the interface yet.
|
||||
internal static class DataApiTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("data: the bank JSON reads back whole: characters (current first), choices, notes, log", BankRoundTrip);
|
||||
r.Add("data: the bank verb lines carry their fields in RunVerb's order", BankVerbs);
|
||||
r.Add("data: bad bank JSON reads as nothing", BankBadJson);
|
||||
// Last: Release() switches the table off for the rest of the process.
|
||||
r.Add("data: the RynthILT.Data table: query, functions, release", DataTable);
|
||||
}
|
||||
|
||||
private static void BankRoundTrip()
|
||||
{
|
||||
var me = new IltBankState { Pyreals = 1_500_000, Luminance = 42, PrestigeCoins = 3,
|
||||
LastUpdated = new DateTime(2026, 10, 13, 21, 25, 37, DateTimeKind.Utc).ToLocalTime() };
|
||||
var alt = new IltBankState { Pyreals = 7, LegendaryKeys = 2, LastUpdated = DateTime.Now };
|
||||
var tx = new List<IltBankTransaction>();
|
||||
for (int i = 0; i < IltBankExport.MaxTransactions + 5; i++)
|
||||
tx.Add(new IltBankTransaction { Timestamp = new DateTime(2026, 10, 1).AddMinutes(i), Type = i % 2 == 0 ? "Sent" : "Received",
|
||||
Currency = "Pyreals", Amount = i, OtherPlayer = "Bob \"the\" Builder" });
|
||||
string json = IltBankExport.Build(true, 1, "InfiniteLeaftide", "Zed",
|
||||
new[] { new IltBankExport.Row("Alt", false, alt), new IltBankExport.Row("Zed", true, me) },
|
||||
"Deposited 5 Pyreals", tx);
|
||||
Check.True(json.All(c => c >= 0x20 && c <= 0x7E), "plain printable ASCII");
|
||||
|
||||
IltBankView v = IltBankView.Parse(json);
|
||||
Check.True(v.Loaded && v.Available, "loaded, ILT");
|
||||
Check.Eq(v.Enabled, 1, "the server has /bank");
|
||||
Check.Eq(v.World, "InfiniteLeaftide", "world");
|
||||
Check.Eq(v.Character, "Zed", "character");
|
||||
Check.Eq(v.Result, "Deposited 5 Pyreals", "last result");
|
||||
Check.Eq(v.Characters.Count, 2, "both characters");
|
||||
Check.True(v.Characters[0].Current && v.Characters[0].Name == "Zed", "the current character first");
|
||||
Check.Eq(v.Characters[0].Pyreals, 1_500_000L, "pyreals");
|
||||
Check.Eq(v.Characters[0].PrestigeCoins, 3L, "prestige coins");
|
||||
Check.Eq(v.Characters[0].UpdatedUtc, new DateTime(2026, 10, 13, 21, 25, 37, DateTimeKind.Utc), "updated, in UTC");
|
||||
Check.Eq(v.Characters[1].LegendaryKeys, 2L, "the other character's keys");
|
||||
|
||||
Check.Eq(v.Deposits.Count, IltBankCommands.Deposits.Length, "every deposit choice");
|
||||
Check.Eq(v.Withdrawals.Count, IltBankCommands.Withdrawals.Length, "every withdraw choice");
|
||||
Check.Eq(v.Transfers.Count, IltBankCommands.Transfers.Length, "every transfer choice");
|
||||
Check.True(v.Transfers.Single(t => t.Notes).Label == "Trade notes", "only trade notes count notes");
|
||||
Check.Eq(v.Notes.Count, IltBankCommands.NoteDenominations.Length, "every note denomination");
|
||||
Check.Eq(v.Notes[^1].Value, 250_000L, "MMD is 250K");
|
||||
|
||||
Check.Eq(v.Transactions.Count, IltBankExport.MaxTransactions, "the log is capped");
|
||||
Check.Eq(v.Transactions[0].Amount, (long)(IltBankExport.MaxTransactions + 4), "newest first");
|
||||
Check.Eq(v.Transactions[0].Player, "Bob \"the\" Builder", "quotes in a name survive");
|
||||
}
|
||||
|
||||
private static void BankVerbs()
|
||||
{
|
||||
Check.Eq(IltBankView.RefreshVerb(), "refresh", "refresh");
|
||||
Check.Eq(IltBankView.DepositVerb(3), "deposit 3", "deposit");
|
||||
Check.Eq(IltBankView.WithdrawVerb(7, 4, 9), "withdraw 7 4 9", "withdraw: index, amount, note");
|
||||
Check.Eq(IltBankView.TransferVerb(6, 2, 9, " Some Name "), "transfer 6 2 9 Some Name", "transfer: the name last, trimmed");
|
||||
foreach (string verb in new[] { IltBankView.RefreshVerb(), IltBankView.DepositVerb(0), IltBankView.WithdrawVerb(0, 1, -1),
|
||||
IltBankView.TransferVerb(0, 1, -1, "Bob") })
|
||||
Check.True(verb.All(c => c >= 0x20 && c <= 0x7E), "ASCII verb (DataInterface refuses anything else): " + verb);
|
||||
}
|
||||
|
||||
private static void BankBadJson()
|
||||
{
|
||||
Check.True(ReferenceEquals(IltBankView.Parse(null), IltBankView.None), "null");
|
||||
Check.True(ReferenceEquals(IltBankView.Parse("{not json"), IltBankView.None), "broken");
|
||||
Check.True(ReferenceEquals(IltBankView.Parse("[1,2]"), IltBankView.None), "not an object");
|
||||
IltBankView empty = IltBankView.Parse("{}");
|
||||
Check.True(empty.Loaded && !empty.Available && empty.Enabled == -1 && empty.Characters.Count == 0, "missing fields read as nothing known");
|
||||
}
|
||||
|
||||
private static unsafe void DataTable()
|
||||
{
|
||||
Check.Eq(DataInterface.Query("RynthILT.Hub", 1), IntPtr.Zero, "another interface's name: not ours");
|
||||
Check.Eq(DataInterface.Query(RynthIltDataApiV1.InterfaceName, 3), IntPtr.Zero, "a newer version than we have: none");
|
||||
var t = (RynthIltDataApiV1*)DataInterface.Query(RynthIltDataApiV1.InterfaceName, 1);
|
||||
Check.True(t != null, "v1 is served");
|
||||
Check.Eq(t->Version, 2u, "Version 2 (v1 readers take it: it starts with the v1 table)");
|
||||
Check.Eq(t->StructSize, (uint)sizeof(RynthIltDataApiV1), "StructSize");
|
||||
Check.Eq(sizeof(RynthIltDataApiV1), 8 + 6 * IntPtr.Size, "header + 6 functions (v1's 4, then the breeding pair)");
|
||||
Check.True(t->GetCharmsJson != null && t->GetBankJson != null && t->ToggleCharm != null && t->BankCommand != null
|
||||
&& t->GetPetBreedingJson != null && t->PetBreedingCommand != null, "every function is filled in");
|
||||
Check.Eq((IntPtr)t, DataInterface.Query(RynthIltDataApiV1.InterfaceName, 1), "the same table each time");
|
||||
|
||||
// No plugin instance here (not logged in): nothing to report, every action refused.
|
||||
byte* buf = stackalloc byte[64];
|
||||
Check.Eq(t->GetCharmsJson(buf, 64), 0, "no charms before login");
|
||||
Check.Eq(t->GetBankJson(buf, 64), 0, "no bank before login");
|
||||
Check.Eq(t->ToggleCharm(1234), 0, "no toggle before login");
|
||||
byte* verb = stackalloc byte[] { (byte)'r', (byte)'e', (byte)'f', (byte)'r', (byte)'e', (byte)'s', (byte)'h', 0 };
|
||||
Check.Eq(t->BankCommand(verb), 0, "no bank command before login");
|
||||
Check.Eq(t->GetPetBreedingJson(buf, 64), 0, "no breeding JSON before login");
|
||||
Check.Eq(t->PetBreedingCommand(verb), 0, "no breeding command before login");
|
||||
|
||||
DataInterface.Release();
|
||||
Check.Eq(t->Version, 0u, "Release zeroes Version (readers re-query)");
|
||||
Check.Eq(DataInterface.Query(RynthIltDataApiV1.InterfaceName, 1), IntPtr.Zero, "and nothing is served after shutdown");
|
||||
Check.Eq(t->GetBankJson(buf, 64), 0, "the old table stays callable and answers nothing");
|
||||
}
|
||||
}
|
||||
141
Tools/RynthILT.Tests/FeatureCatalogTests.cs
Normal file
141
Tools/RynthILT.Tests/FeatureCatalogTests.cs
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using RynthCore.Plugin.RynthILT;
|
||||
using RynthCore.Plugin.RynthILT.Hub;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthILT.Tests;
|
||||
|
||||
// Leaftide feature list (IltFeatureCatalog): every feature the player asked RynthILT to cover is
|
||||
// listed and the states follow the server bits. Also the NUL-terminated copy RynthILT's interfaces
|
||||
// ("RynthServer.Profile", "RynthILT.Data") hand their JSON out with.
|
||||
internal static class FeatureCatalogTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("features: banking, guardian, attributes, augs, paragon x3, split arrows, T11 and fellowship are listed", Listed);
|
||||
r.Add("features: state follows the server bit on ILT, built-ins are on, nothing is known off ILT", States);
|
||||
r.Add("features: the interface copies the JSON only when it fits, NUL-terminated", InterfaceWrite);
|
||||
r.Add("features: the ILT profile is on with the world; a refusal in chat turns a feature off", ProfileOnWithTheWorld);
|
||||
r.Add("features: probed features read checking; options ILT runs off are off until chat shows them", ProbedAndOffInIlt);
|
||||
r.Add("features: charms are on with the ILT world unless refused; rows describe themselves", Charms);
|
||||
}
|
||||
|
||||
/// <summary>ACECustom options Infinite Leaftide runs with off (ServerConfig defaults, PROD_DEPLOY_PLAN.md).</summary>
|
||||
private static readonly string[] OffInIlt = { "pet_strain", "pet_refill", "defense_scaling" };
|
||||
|
||||
/// <summary>Features the login probe (or the /myquests tracker) answers.</summary>
|
||||
private static readonly string[] Probed =
|
||||
{
|
||||
"bank", "attributes", "augmentations", "enlightenment", "clap", "pets", "shinies",
|
||||
"fellowship_blackjack", "quests", "quest_bonus", "powerball", "blackjack",
|
||||
};
|
||||
|
||||
private static void ProfileOnWithTheWorld()
|
||||
{
|
||||
// The features the player asked about, plus the pet switches prod runs on (bond, potency).
|
||||
foreach (string key in new[] { "bank_notes", "t11", "t11_craft_gate", "split_arrows", "charms", "pet_breeding",
|
||||
"pet_maturity", "pet_bond", "pet_potency", "monster_capture", "universal_mastery",
|
||||
"missile_power", "t11_hit_gate", "fship" })
|
||||
{
|
||||
IltFeatureInfo f = IltFeatureCatalog.Find(key)!;
|
||||
Check.Eq(f.Known, IltKnown.Profile, key + " is on in the ILT profile");
|
||||
Check.Eq(IltFeatureCatalog.StateOf(f, true, _ => IltTri.Unknown), IltTri.On, key + " on with the ILT world");
|
||||
Check.Eq(IltFeatureCatalog.StateOf(f, false, _ => IltTri.On), IltTri.Unknown, key + " unknown off ILT");
|
||||
}
|
||||
IltFeatureInfo mastery = IltFeatureCatalog.Find("universal_mastery")!;
|
||||
Check.Eq(IltFeatureCatalog.StateOf(mastery, true, k => k == IltFeature.UniversalMastery ? IltTri.Off : IltTri.Unknown),
|
||||
IltTri.Off, "a refusal in chat turns a profile feature off");
|
||||
Check.Null(IltFeatureCatalog.Find("fellowship_additive"), "upstream ACE's additive fellowship option isn't an ILT feature");
|
||||
}
|
||||
|
||||
private static void ProbedAndOffInIlt()
|
||||
{
|
||||
foreach (string key in Probed)
|
||||
{
|
||||
IltFeatureInfo f = IltFeatureCatalog.Find(key)!;
|
||||
Check.Eq(f.Known, IltKnown.Checked, key + " is answered by the login probe");
|
||||
Check.Eq(IltFeatureCatalog.StateText(IltFeatureCatalog.StateOf(f, true, _ => IltTri.Unknown)), "checking", key + " reads 'checking' until then");
|
||||
}
|
||||
foreach (string key in OffInIlt)
|
||||
{
|
||||
IltFeatureInfo f = IltFeatureCatalog.Find(key)!;
|
||||
Check.Eq(f.Known, IltKnown.ProfileOff, key + " is off in the ILT profile");
|
||||
Check.Eq(IltFeatureCatalog.StateOf(f, true, _ => IltTri.Unknown), IltTri.Off, key + " off with the ILT world");
|
||||
Check.Eq(IltFeatureCatalog.StateOf(f, true, _ => IltTri.On), IltTri.On, key + " on once the server shows it");
|
||||
Check.True(IltFeatureCatalog.Describe(key).Tooltip.Contains("Off in ILT"), key + "'s tooltip says it's off in ILT");
|
||||
}
|
||||
|
||||
// ACECustom's three refill messages (PetDevice.TryApplyPyrealAutoRefillBeforeSummon) prove the refill is on.
|
||||
Check.True(IltServerOptions.IsPyrealRefillLine("You restore one charge on your summoning essence at no cost."), "free refill");
|
||||
Check.True(IltServerOptions.IsPyrealRefillLine("You spend 1,000 pyreals to restore one charge on your summoning essence."), "paid refill");
|
||||
Check.True(IltServerOptions.IsPyrealRefillLine("You need 1,000 pyreals to auto-replenish your summoning essence. You do not have enough pyreals."), "refill too dear");
|
||||
Check.False(IltServerOptions.IsPyrealRefillLine("Your summoning essence is empty."), "an empty essence says nothing about the refill");
|
||||
}
|
||||
|
||||
private static void Charms()
|
||||
{
|
||||
Check.Eq(IltFeatureCatalog.CharmStateOf(true, IltTri.Unknown), IltTri.On, "a charm is on with the ILT world");
|
||||
Check.Eq(IltFeatureCatalog.CharmStateOf(true, IltTri.Off), IltTri.Off, "a refused charm is off");
|
||||
Check.Eq(IltFeatureCatalog.CharmStateOf(false, IltTri.On), IltTri.Unknown, "nothing is claimed off ILT");
|
||||
|
||||
var (label, group, tooltip) = IltFeatureCatalog.Describe(IltFeature.Charm("Mana Barrier"));
|
||||
Check.Eq(label, "Mana Barrier", "a charm row shows the charm's name");
|
||||
Check.Eq(group, IltFeatureCatalog.GroupCharms, "charms have their own section");
|
||||
Check.True(tooltip.Contains("Mana absorbs"), "the tooltip carries the charm's effect");
|
||||
Check.Eq(IltFeatureCatalog.Describe("something_new").Group, IltFeatureCatalog.GroupOther, "an unknown bit goes to Other");
|
||||
}
|
||||
|
||||
private static readonly string[] Requested =
|
||||
{
|
||||
"bank", "guardian", "attributes", "augmentations", "paragon_armor", "paragon_weapons",
|
||||
"paragon_jewelry", "split_arrows", "t11", "fellowship_large", "zone_share", "fellowship_blackjack",
|
||||
};
|
||||
|
||||
private static void Listed()
|
||||
{
|
||||
foreach (string key in Requested)
|
||||
Check.NotNull(IltFeatureCatalog.Find(key), "listed: " + key);
|
||||
Check.Null(IltFeatureCatalog.Find("no_such_feature"), "an unknown key is not found");
|
||||
|
||||
var seen = new System.Collections.Generic.HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (IltFeatureInfo f in IltFeatureCatalog.All)
|
||||
{
|
||||
Check.True(seen.Add(f.Key), "keys are unique: " + f.Key);
|
||||
Check.True(Array.IndexOf(IltFeatureCatalog.Groups, f.Group) >= 0, $"{f.Key} is in a known section ({f.Group})");
|
||||
Check.True(f.Label.Length > 0 && f.Where.Length > 0 && f.Description.Length > 0, f.Key + " has a label, a place and a description");
|
||||
}
|
||||
}
|
||||
|
||||
private static void States()
|
||||
{
|
||||
IltFeatureInfo bank = IltFeatureCatalog.Find("bank")!;
|
||||
IltFeatureInfo guardian = IltFeatureCatalog.Find("guardian")!;
|
||||
Check.Eq(IltFeatureCatalog.StateOf(bank, true, _ => IltTri.On), IltTri.On, "bank on when the server answers /bank");
|
||||
Check.Eq(IltFeatureCatalog.StateOf(bank, true, _ => IltTri.Off), IltTri.Off, "bank off when the server says so");
|
||||
Check.Eq(IltFeatureCatalog.StateOf(bank, true, _ => IltTri.Unknown), IltTri.Unknown, "bank unknown before the check");
|
||||
Check.Eq(IltFeatureCatalog.StateOf(guardian, true, _ => IltTri.Off), IltTri.On, "a built-in feature is on with the ILT world");
|
||||
Check.Eq(IltFeatureCatalog.StateOf(guardian, false, _ => IltTri.On), IltTri.Unknown, "nothing is claimed off ILT");
|
||||
Check.Eq(IltFeatureCatalog.StateText(IltTri.Unknown), "checking", "unknown reads 'checking'");
|
||||
Check.Eq(IltFeatureCatalog.FellowshipMax(true), 29, "ILT fellowships hold 29");
|
||||
Check.Eq(IltFeatureCatalog.FellowshipMax(false), 9, "retail fellowships hold 9");
|
||||
}
|
||||
|
||||
private static unsafe void InterfaceWrite()
|
||||
{
|
||||
const string json = "{\"ilt\":true}";
|
||||
byte* small = stackalloc byte[4];
|
||||
small[0] = 0x55;
|
||||
Check.Eq(ProfileInterface.Write(json, small, 4), json.Length, "too small: the length is returned");
|
||||
Check.Eq(small[0], (byte)0x55, "too small: nothing written");
|
||||
|
||||
byte* exact = stackalloc byte[json.Length];
|
||||
Check.Eq(ProfileInterface.Write(json, exact, json.Length), json.Length, "no room for the NUL: too small");
|
||||
|
||||
byte* big = stackalloc byte[64];
|
||||
int n = ProfileInterface.Write(json, big, 64);
|
||||
Check.Eq(n, json.Length, "fits: the length without the NUL");
|
||||
Check.Eq(big[n], (byte)0, "NUL-terminated");
|
||||
Check.Eq(Encoding.UTF8.GetString(big, n), json, "the JSON copied whole");
|
||||
}
|
||||
}
|
||||
97
Tools/RynthILT.Tests/FellowshipCommandTests.cs
Normal file
97
Tools/RynthILT.Tests/FellowshipCommandTests.cs
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using RynthCore.Plugin.RynthILT.IltFellowship;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthILT.Tests;
|
||||
|
||||
// ILT's fellowship commands (IltFellowship/IltFellowshipCommands.cs, ACECustom /fship) and the
|
||||
// "servercommands" format they are kept in (Plugins/Shared/ServerCommandShare.cs), checked together.
|
||||
internal static class FellowshipCommandTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("ilt fellowship: the /fship list round-trips through the servercommands format", RoundTrip);
|
||||
r.Add("ilt fellowship: chat lines quote multi-word names and need a name for create", Compose);
|
||||
r.Add("ilt fellowship: bad commands and payloads are dropped", Rejects);
|
||||
r.Add("ilt fellowship: RynthCore's verdict decides, else the world name", Active);
|
||||
}
|
||||
|
||||
private static void RoundTrip()
|
||||
{
|
||||
ServerCommandSet? set = ServerCommandShare.Parse(IltFellowshipCommands.Payload(active: true));
|
||||
Check.True(set != null, "parsed");
|
||||
Check.Eq(set!.Section, "fellowship", "section");
|
||||
Check.Eq(set.ServerId, "ilt", "server id");
|
||||
Check.Eq(set.ServerName, "Infinite Leaftide", "server name");
|
||||
Check.Eq(set.Commands.Count, IltFellowshipCommands.Commands.Count, "every command survives");
|
||||
for (int i = 0; i < set.Commands.Count; i++)
|
||||
Check.Eq(set.Commands[i], IltFellowshipCommands.Commands[i], "command " + i);
|
||||
Check.True(set.Commands.All(c => c.Command.StartsWith("/fship", StringComparison.Ordinal)), "all /fship");
|
||||
|
||||
ServerCommandSet? off = ServerCommandShare.Parse(IltFellowshipCommands.Payload(active: false));
|
||||
Check.True(off != null, "the clear parses");
|
||||
Check.Eq(off!.Commands.Count, 0, "the clear has no commands");
|
||||
}
|
||||
|
||||
private static void Compose()
|
||||
{
|
||||
ServerCommand create = Find("Create"), invite = Find("Invite"), dismiss = Find("Dismiss"), list = Find("List nearby");
|
||||
Check.True(ServerCommandShare.Compose(create, "") == null, "create needs a name");
|
||||
Check.True(ServerCommandShare.Compose(create, " ") == null, "blank is no name");
|
||||
Check.Eq(ServerCommandShare.Compose(create, "Leaf"), "/fship create Leaf", "one word");
|
||||
Check.Eq(ServerCommandShare.Compose(create, " Leaf Hunters "), "/fship create \"Leaf Hunters\"", "quoted, spaces collapsed");
|
||||
Check.Eq(ServerCommandShare.Compose(invite, ""), "/fship add", "no name: the selected player");
|
||||
Check.Eq(ServerCommandShare.Compose(invite, "Raw Cigam"), "/fship add \"Raw Cigam\"", "multi-word player");
|
||||
Check.Eq(ServerCommandShare.Compose(dismiss, "Bo\"b\t"), "/fship remove Bob", "quotes and control characters dropped");
|
||||
Check.Eq(ServerCommandShare.Compose(list, "ignored"), "/fship list", "no argument taken");
|
||||
Check.True(dismiss.Confirm && Find("Disband").Confirm && Find("Leave").Confirm && Find("Invite landblock").Confirm, "risky ones ask");
|
||||
Check.False(invite.Confirm || list.Confirm || create.Confirm, "the rest don't");
|
||||
string longName = new string('x', 200);
|
||||
Check.Eq(ServerCommandShare.CleanArgument(longName).Length, ServerCommandShare.MaxArgument, "argument capped");
|
||||
}
|
||||
|
||||
private static void Rejects()
|
||||
{
|
||||
Check.True(ServerCommandShare.Parse(null) == null, "null");
|
||||
Check.True(ServerCommandShare.Parse("") == null, "empty");
|
||||
Check.True(ServerCommandShare.Parse("C\tX\t/fship\t\t\n") == null, "no S line");
|
||||
Check.True(ServerCommandShare.Parse("S\t\tilt\tILT\n") == null, "no section");
|
||||
|
||||
string payload = "S\tfellowship\tilt\tILT\n" +
|
||||
"C\tNo slash\tfship list\t\t\n" +
|
||||
"C\tSpace\t/ fship\t\t\n" +
|
||||
"C\tQuote\t/fship add \"x\"\t\t\n" +
|
||||
"C\t\t/fship list\t\tno label\n" +
|
||||
"C\tLong\t/" + new string('a', ServerCommandShare.MaxCommand + 5) + "\t\t\n" +
|
||||
"C\tShort\t/fship\t\n" +
|
||||
"C\tGood\t/fship list\tzqA\ttip\n";
|
||||
ServerCommandSet? set = ServerCommandShare.Parse(payload);
|
||||
Check.True(set != null, "parsed");
|
||||
Check.Eq(set!.Commands.Count, 1, "only the good command");
|
||||
Check.Eq(set.Commands[0].Flags, "A", "unknown flags dropped");
|
||||
|
||||
var many = Enumerable.Range(0, 40).Select(i => new ServerCommand("B" + i, "/fship list", "", ""));
|
||||
string built = ServerCommandShare.Build(new ServerCommandSet("fellowship", "ilt", "ILT", many.ToList()));
|
||||
Check.Eq(ServerCommandShare.Parse(built)!.Commands.Count, ServerCommandShare.MaxCommands, "capped");
|
||||
|
||||
string tabbed = ServerCommandShare.Build(new ServerCommandSet("fellowship", "ilt", "ILT",
|
||||
new[] { new ServerCommand("A\tB", "/fship list", "", "line one\nline two") }));
|
||||
ServerCommand c = ServerCommandShare.Parse(tabbed)!.Commands[0];
|
||||
Check.Eq(c.Label, "A B", "tab in a field becomes a space");
|
||||
Check.Eq(c.Tooltip, "line one line two", "newline in a field becomes a space");
|
||||
}
|
||||
|
||||
private static void Active()
|
||||
{
|
||||
Check.True(IltFellowshipCommands.IsActive(true, "Coldeve"), "RynthCore says ILT");
|
||||
Check.False(IltFellowshipCommands.IsActive(false, "InfiniteLeaftide"), "RynthCore says not ILT");
|
||||
Check.True(IltFellowshipCommands.IsActive(null, "InfiniteLeaftide"), "no verdict yet: the world name");
|
||||
Check.False(IltFellowshipCommands.IsActive(null, "Coldeve"), "no verdict, another world");
|
||||
Check.False(IltFellowshipCommands.IsActive(null, null), "nothing known");
|
||||
}
|
||||
|
||||
private static ServerCommand Find(string label) =>
|
||||
IltFellowshipCommands.Commands.First(c => c.Label == label);
|
||||
}
|
||||
128
Tools/RynthILT.Tests/IltSettingsTests.cs
Normal file
128
Tools/RynthILT.Tests/IltSettingsTests.cs
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RynthCore.Plugin.RynthILT.IltSettingsView;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthILT.Tests;
|
||||
|
||||
// RynthILT's copy of the ILT settings (IltSettingsView/IltSettingsModel.cs): RynthCore's server
|
||||
// list (plugin API v86, GetServerStateJson: verdict, override, reason), the Hub's feature read, the
|
||||
// engine verdict the Hub follows (IltEngineVerdict), and the RynthCore commands the view sends.
|
||||
internal static class IltSettingsTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("ilt settings: RynthCore's server list gives the ILT verdict, override and reason", ServerList);
|
||||
r.Add("ilt settings: a list without ILT, or no list at all, reads as such", NoIlt);
|
||||
r.Add("ilt settings: the Hub's feature read is published whole", FeatureRead);
|
||||
r.Add("ilt settings: the Hub follows RynthCore's ILT verdict once one arrives", EngineVerdict);
|
||||
r.Add("ilt settings: override and world-name commands are checked before sending", Commands);
|
||||
r.Add("ilt settings: logout clears the copy", ClearOnLogout);
|
||||
}
|
||||
|
||||
// GetServerStateJson as RynthCore writes it (UI/Sections/ServerStateJson.cs, schema 1).
|
||||
private const string State =
|
||||
"{\"schema\":1,\"revision\":3,\"host\":\"infiniteleaftide.online\",\"world\":\"InfiniteLeaftide\",\"pick\":\"auto\"," +
|
||||
"\"active\":\"ilt\",\"activeName\":\"Infinite Leaftide\",\"activePlugin\":\"RynthILT\",\"servers\":[" +
|
||||
"{\"id\":\"ilt\",\"name\":\"Infinite Leaftide\",\"active\":true,\"detected\":false,\"force\":\"on\",\"builtIn\":true," +
|
||||
"\"plugin\":\"RynthILT\",\"reason\":\"forced on for this character\"}," +
|
||||
"{\"id\":\"aelrynth\",\"name\":\"Aelrynth\",\"active\":false,\"detected\":false,\"force\":\"auto\",\"builtIn\":true," +
|
||||
"\"plugin\":\"\",\"reason\":\"not detected\"}]}";
|
||||
|
||||
private const string NoIltState =
|
||||
"{\"schema\":1,\"revision\":1,\"active\":\"\",\"servers\":[" +
|
||||
"{\"id\":\"aelrynth\",\"name\":\"Aelrynth\",\"active\":true,\"detected\":true,\"force\":\"auto\"}]}";
|
||||
|
||||
private static void ServerList()
|
||||
{
|
||||
IltEngineView? v = IltSettingsModel.FromServerState(EngineServerState.Parse(State));
|
||||
Check.True(v?.Server != null, "the ILT server is there");
|
||||
Check.Eq(v!.Server!.Name, "Infinite Leaftide", "name");
|
||||
Check.True(v.Server.Active, "active");
|
||||
Check.False(v.Server.Detected, "not detected (forced)");
|
||||
Check.Eq(v.Server.Force, "on", "override");
|
||||
Check.Eq(v.Server.Reason, "forced on for this character", "reason");
|
||||
|
||||
IltEngineView? odd = IltSettingsModel.FromServerState(EngineServerState.Parse(
|
||||
"{\"schema\":1,\"servers\":[{\"id\":\"ILT\",\"force\":\"WEIRD\"}]}"));
|
||||
Check.True(odd?.Server != null, "the id ignores case");
|
||||
Check.Eq(odd!.Server!.Force, "auto", "an unknown override shows as auto");
|
||||
Check.Eq(odd.Server.Name, "Infinite Leaftide", "a missing name gets the server's");
|
||||
Check.False(odd.Server.Active, "a missing flag is off");
|
||||
}
|
||||
|
||||
private static void NoIlt()
|
||||
{
|
||||
IltEngineView? none = IltSettingsModel.FromServerState(EngineServerState.Parse(NoIltState));
|
||||
Check.True(none != null && none.Server == null, "a list without ILT says so (not 'waiting')");
|
||||
Check.True(IltSettingsModel.FromServerState(null) == null, "no list: nothing");
|
||||
Check.True(EngineServerState.Parse("") == null && EngineServerState.Parse("{\"schema\":2}") == null, "empty or another schema: no list");
|
||||
|
||||
var model = new IltSettingsModel();
|
||||
model.ApplyServerState(EngineServerState.Parse(State));
|
||||
model.ApplyServerState(null);
|
||||
Check.True(model.Engine?.Server?.Active == true, "no answer keeps the last list");
|
||||
}
|
||||
|
||||
private static void FeatureRead()
|
||||
{
|
||||
var model = new IltSettingsModel();
|
||||
var read = new IltFeatureView("Infinite Leaftide", "probe", "12:00:00", Checking: true, IltLike: true,
|
||||
new[] { new KeyValuePair<string, int>("bank", 1) });
|
||||
model.PublishFeatures(read);
|
||||
Check.True(ReferenceEquals(model.Features, read), "published as is");
|
||||
model.PublishFeatures(null);
|
||||
Check.True(model.Features == null, "cleared while there is no Hub");
|
||||
Check.Eq(IltSettingsModel.StateText(1), "on", "1 is on");
|
||||
Check.Eq(IltSettingsModel.StateText(0), "off", "0 is off (not unknown)");
|
||||
Check.Eq(IltSettingsModel.StateText(-1), "unknown", "-1 is unknown");
|
||||
}
|
||||
|
||||
private static void EngineVerdict()
|
||||
{
|
||||
var model = new IltSettingsModel();
|
||||
try
|
||||
{
|
||||
IltEngineVerdict.Attach(model);
|
||||
Check.False(IltEngineVerdict.Pushed, "nothing sent yet");
|
||||
Check.True(IltEngineVerdict.Active == null, "no verdict: RynthILT's own list decides");
|
||||
model.ApplyServerState(EngineServerState.Parse(State));
|
||||
Check.True(IltEngineVerdict.Pushed, "sent");
|
||||
Check.True(IltEngineVerdict.Active == true, "RynthCore says ILT");
|
||||
model.ApplyServerState(EngineServerState.Parse(NoIltState));
|
||||
Check.True(IltEngineVerdict.Pushed && IltEngineVerdict.Active == null, "a list without ILT gives no ILT verdict");
|
||||
model.Clear();
|
||||
Check.False(IltEngineVerdict.Pushed, "logout forgets it");
|
||||
}
|
||||
finally { IltEngineVerdict.Attach(null); }
|
||||
Check.True(IltEngineVerdict.Active == null, "detached");
|
||||
}
|
||||
|
||||
private static void Commands()
|
||||
{
|
||||
Check.Eq(IltSettingsModel.ForceCommand("on"), "/rc server ilt on", "on");
|
||||
Check.Eq(IltSettingsModel.ForceCommand("auto"), "/rc server ilt auto", "auto");
|
||||
Check.Eq(IltSettingsModel.ForceCommand("maybe"), "", "unknown mode sends nothing");
|
||||
Check.Eq(IltSettingsModel.NamesListCommand, "/rc server names ilt", "the names are listed by RynthCore");
|
||||
|
||||
Check.Eq(IltSettingsModel.NamesCommand(true, " *Frost* ", out _), "/rc server names ilt add *Frost*", "add, trimmed");
|
||||
Check.Eq(IltSettingsModel.NamesCommand(false, "Infinite Leaftide", out _), "/rc server names ilt remove Infinite Leaftide", "remove");
|
||||
Check.Eq(IltSettingsModel.NamesCommand(true, "", out string e1), "", "empty refused");
|
||||
Check.True(e1.Length > 0, "with a reason");
|
||||
Check.Eq(IltSettingsModel.NamesCommand(true, new string('a', IltSettingsModel.MaxPattern + 1), out _), "", "too long refused");
|
||||
Check.Eq(IltSettingsModel.NamesCommand(true, "x\n/rc reload", out _), "", "a line break can't start a second command");
|
||||
Check.Eq(IltSettingsModel.NamesCommand(true, "a/b", out _), "", "no '/'");
|
||||
}
|
||||
|
||||
private static void ClearOnLogout()
|
||||
{
|
||||
var model = new IltSettingsModel();
|
||||
model.ApplyServerState(EngineServerState.Parse(State));
|
||||
model.PublishFeatures(new IltFeatureView("w", "", "", false, true, Array.Empty<KeyValuePair<string, int>>()));
|
||||
Check.True(model.Engine != null && model.Features != null, "both copies");
|
||||
model.Clear();
|
||||
Check.True(model.Engine == null && model.Features == null, "cleared");
|
||||
}
|
||||
}
|
||||
|
|
@ -32,6 +32,9 @@ internal static class MoveTests
|
|||
r.Add("move: the interface structs have the agreed layout", InterfaceLayout);
|
||||
r.Add("move: server-list status lines", DescribeLines);
|
||||
r.Add("move: off ILT nothing is sent, no tab or section shows; on ILT the login probe runs", DormantOffIlt);
|
||||
r.Add("move: the charms JSON for RynthILT.Data readers carries the Guardian Hands", CharmsReaderJson);
|
||||
r.Add("move: Character redirects to RynthOracle; Charms and Banking stay RynthILT's tabs", MovedSections);
|
||||
r.Add("sections: RynthILT's manifest (rates, /fship, /qb) is valid schema-1 JSON with its own surfaces", SectionsManifest);
|
||||
// Last: Release() switches the table off for the rest of the process.
|
||||
r.Add("move: the RynthILT.Hub table: query, functions, release", HubTable);
|
||||
}
|
||||
|
|
@ -362,7 +365,11 @@ internal static class MoveTests
|
|||
Check.Eq(sizeof(IltTabV1), 24 + 32 + 4 + 4 + 4, "IltTabV1: id, label, width, height, flags");
|
||||
Check.Eq((int)Marshal.OffsetOf<IltTabV1>(nameof(IltTabV1.Flags)), 64, "IltTabV1.Flags offset");
|
||||
Check.Eq(sizeof(RynthIltHubApiV1), 8 + 9 * IntPtr.Size, "RynthIltHubApiV1: header + 9 functions");
|
||||
Check.Eq(sizeof(RynthAiHubApiV1), 8 + 10 * IntPtr.Size, "RynthAiHubApiV1: header + 10 functions");
|
||||
// SessionStatsMore was appended (2026-10-13); readers accept any table at least
|
||||
// BaseStructSize long, so an older RynthAi still connects.
|
||||
Check.Eq(sizeof(RynthAiHubApiV1), 8 + 11 * IntPtr.Size, "RynthAiHubApiV1: header + 11 functions");
|
||||
Check.Eq((int)RynthAiHubApiV1.BaseStructSize, 8 + 10 * IntPtr.Size, "RynthAiHubApiV1.BaseStructSize: the first release's 10 functions");
|
||||
Check.Eq(RynthAiHubApiV1.SessionStatsMoreOffset, (int)RynthAiHubApiV1.BaseStructSize, "SessionStatsMore right after the base table");
|
||||
Check.Eq(sizeof(QuestFlagV1), 24, "QuestFlagV1");
|
||||
Check.Eq(sizeof(QuestStatusV1), 16, "QuestStatusV1");
|
||||
Check.Eq(RynthIltHubApiV1.InterfaceName, "RynthILT.Hub", "interface name");
|
||||
|
|
@ -394,6 +401,75 @@ internal static class MoveTests
|
|||
while (DateTime.UtcNow < until) { hub.Tick(); System.Threading.Thread.Sleep(50); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The charms JSON behind "RynthILT.Data" is valid JSON; on ILT it has a "hands" array (empty
|
||||
/// with no hand carried) that the shared reader parses, off ILT it has none and still parses.
|
||||
/// </summary>
|
||||
private static void CharmsReaderJson()
|
||||
{
|
||||
var on = NewHub("InfiniteLeaftide", "charms-on");
|
||||
string json = on.CharmsTab.BuildReaderJson();
|
||||
using (var doc = System.Text.Json.JsonDocument.Parse(json))
|
||||
Check.True(doc.RootElement.TryGetProperty("hands", out var hands) && hands.GetArrayLength() == 0,
|
||||
"on ILT: an empty hands array with no Guardian Hand carried");
|
||||
Check.True(json.All(c => c < 128), "ASCII only");
|
||||
var view = IltCharmsView.Parse(json);
|
||||
Check.True(view.Loaded && view.Hands.Count == 0, "the shared reader takes it");
|
||||
|
||||
var withHands = IltCharmsView.Parse("{\"available\":true,\"charms\":[],\"hands\":[" +
|
||||
"{\"id\":1234,\"name\":\"Guardian Hand\",\"active\":\"on\",\"server\":\"off\"},{\"id\":0,\"name\":\"no id\"}]}");
|
||||
Check.Eq(withHands.Hands.Count, 1, "a hand without an id is skipped (nothing to toggle)");
|
||||
Check.True(withHands.Hands[0] == new IltHandRow(1234, "Guardian Hand", "on", "off"), "id, name, active, server");
|
||||
|
||||
var off = NewHub("Aeshnidae", "charms-off");
|
||||
string offJson = off.CharmsTab.BuildReaderJson();
|
||||
using (var doc = System.Text.Json.JsonDocument.Parse(offJson))
|
||||
Check.False(doc.RootElement.TryGetProperty("hands", out _), "off ILT: no hands");
|
||||
Check.True(IltCharmsView.Parse(offJson).Hands.Count == 0, "and the reader shows none");
|
||||
}
|
||||
|
||||
/// <summary>The Character tab moved out (2026-10-13); every other ILT tab is still RynthILT's.</summary>
|
||||
private static void MovedSections()
|
||||
{
|
||||
Check.Eq(IltSections.MovedCommand(IltSection.Character), IltSections.OracleCharacterCommand, "Character -> RynthOracle Character");
|
||||
foreach (var kept in new[] { IltSection.Banking, IltSection.Gear, IltSection.Charms, IltSection.Games })
|
||||
{
|
||||
Check.True(IltSections.MovedCommand(kept) == null, $"{IltSections.Label(kept)} is still RynthILT's");
|
||||
Check.True(IltSections.IsTab(kept), $"{IltSections.Label(kept)} is a Mini Remote tab");
|
||||
}
|
||||
Check.True(IltSections.Tabs.SequenceEqual(new[] { IltSection.Banking, IltSection.Gear, IltSection.Charms, IltSection.Games }),
|
||||
"the tab list is Banking, Gear, Charms, Games");
|
||||
Check.False(IltSections.IsTab(IltSection.Character) || IltSections.IsTab(IltSection.Guardian), "Character and the Guardian aren't tabs");
|
||||
Check.True(IltSections.TryParse("char", out IltSection c) && c == IltSection.Character, "old Character names still parse (for the redirect)");
|
||||
Check.Eq(IltSections.OracleCharacterCommand, "/ro character", "Oracle command");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RynthILT's RynthPluginGetSectionsJson: schema 1 (UI/Sections/SectionManifest.cs in RynthCore),
|
||||
/// every view an ILT one, each surface one RenderEmbed answers.
|
||||
/// </summary>
|
||||
private static void SectionsManifest()
|
||||
{
|
||||
using var doc = System.Text.Json.JsonDocument.Parse(RynthILTPlugin.SectionsJson);
|
||||
var root = doc.RootElement;
|
||||
Check.Eq(root.GetProperty("version").GetInt32(), 1, "schema 1");
|
||||
var sections = root.GetProperty("sections");
|
||||
Check.Eq(sections.GetArrayLength(), 1, "one section of RynthILT's own");
|
||||
Check.Eq(sections[0].GetProperty("id").GetString(), "quests", "a Quests section (the /qb list)");
|
||||
var surfaces = new System.Collections.Generic.List<string>();
|
||||
foreach (var c in root.GetProperty("contributions").EnumerateArray())
|
||||
{
|
||||
Check.Eq(c.GetProperty("server").GetString(), "ilt", "an Infinite Leaftide view");
|
||||
surfaces.Add(c.GetProperty("surface").GetString() ?? "");
|
||||
}
|
||||
Check.True(surfaces.SequenceEqual(new[] { RynthILTPlugin.RatesSurface, RynthILTPlugin.FellowshipSurface, RynthILTPlugin.QuestBonusSurface }),
|
||||
"rates, fellowship, quest bonus: " + string.Join(",", surfaces));
|
||||
Check.True(surfaces.All(s => s.StartsWith("section:ilt-", StringComparison.Ordinal) && s.Length <= 64), "short section:ilt-* surfaces");
|
||||
Check.True(RynthILTPlugin.SectionsJson.All(ch => ch < 128), "ASCII only");
|
||||
Check.True(RynthILTPlugin.IsParsedRemoteAction("servermenu") && RynthILTPlugin.IsParsedRemoteAction("ServerMenu")
|
||||
&& !RynthILTPlugin.IsParsedRemoteAction("prog"), "RynthCore's servermenu push is answered, never queued as a verb");
|
||||
}
|
||||
|
||||
private static void DormantOffIlt()
|
||||
{
|
||||
var off = NewHub("Aeshnidae", "dormant");
|
||||
|
|
@ -414,7 +490,13 @@ internal static class MoveTests
|
|||
TickFor(on, 6800);
|
||||
Check.True(on.Options.IsIltLikeWorld, "InfiniteLeaftide is ILT");
|
||||
Check.True(RynthCore.RynthAiHostTests.Fakes.FakeHost.ChatCommands.Count > 0, "on ILT the login probe asks the server");
|
||||
Check.True(on.TabShown(IltSection.Character), "and the Character tab shows");
|
||||
Check.False(RynthCore.RynthAiHostTests.Fakes.FakeHost.ChatCommands.Any(c => c.Contains("/ilt features", StringComparison.OrdinalIgnoreCase)),
|
||||
"the server is never asked for a feature list (the ILT profile is Rynth-side)");
|
||||
// Character moved out of the Mini Remote (RynthOracle's Character tab, Session Stats);
|
||||
// Charms and Banking are Infinite Leaftide's own screens and stay RynthILT's tabs.
|
||||
Check.False(on.TabShown(IltSection.Character), "Character is no Mini Remote tab any more");
|
||||
Check.Eq(on.TabShown(IltSection.Gear), on.Available, "Gear shows once the server features are known");
|
||||
Check.Eq(on.TabShown(IltSection.Charms), on.Available, "Charms too");
|
||||
on.OnLogout();
|
||||
|
||||
var forced = NewHub("Aeshnidae", "forced");
|
||||
|
|
|
|||
87
Tools/RynthILT.Tests/ProfileTests.cs
Normal file
87
Tools/RynthILT.Tests/ProfileTests.cs
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using RynthCore.Plugin.RynthILT;
|
||||
using RynthCore.Plugin.RynthILT.Hub;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthILT.Tests;
|
||||
|
||||
// RynthILT's "RynthServer.Profile" (ProfileInterface.cs): the same interface and JSON the server
|
||||
// plugins serve, for "ilt", carrying Infinite Leaftide's tinkering salvage (Hub/IltSalvage.cs).
|
||||
// The JSON is read back with the shared reader RynthAi's Crafting tab uses (EngineServerState.cs:
|
||||
// ServerSalvageView.ParseList), so the rows it plans with are the ones checked here. 2026-10-15.
|
||||
internal static unsafe class ProfileTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("profile: RynthILT serves RynthServer.Profile for ilt", Interface);
|
||||
r.Add("profile: ILT's salvage reaches the Crafting tab's reader (Leather after the cap, jewelry stack)", Salvage);
|
||||
}
|
||||
|
||||
private static void Interface()
|
||||
{
|
||||
Check.Eq(ProfileInterface.Query("RynthILT.Hub", 1), IntPtr.Zero, "another interface's name: not this table");
|
||||
Check.Eq(ProfileInterface.Query(RynthServerProfileApiV1.InterfaceName, 2), IntPtr.Zero, "a newer version than we have: none");
|
||||
var t = (RynthServerProfileApiV1*)ProfileInterface.Query(RynthServerProfileApiV1.InterfaceName, 1);
|
||||
Check.True(t != null, "the table");
|
||||
Check.Eq(t->Version, RynthServerProfileApiV1.InterfaceVersion, "version");
|
||||
Check.Eq(t->StructSize, (uint)sizeof(RynthServerProfileApiV1), "struct size");
|
||||
Check.True(t->GetProfileJson != null, "GetProfileJson");
|
||||
|
||||
string json = ProfileInterface.CurrentJson(true, "InfiniteLeaftide");
|
||||
using JsonDocument doc = JsonDocument.Parse(json);
|
||||
JsonElement root = doc.RootElement;
|
||||
Check.Eq(root.GetProperty("schema").GetInt32(), RynthServerProfile.Schema, "schema");
|
||||
Check.Eq(root.GetProperty("id").GetString(), "ilt", "the engine's ILT id");
|
||||
Check.Eq(root.GetProperty("name").GetString(), "Infinite Leaftide", "name");
|
||||
Check.Eq(root.GetProperty("plugin").GetString(), "RynthILT", "plugin");
|
||||
Check.True(root.GetProperty("active").GetBoolean(), "active");
|
||||
Check.Eq(root.GetProperty("world").GetString(), "InfiniteLeaftide", "world");
|
||||
Check.Eq(root.GetProperty("hosts")[0].GetString(), "infiniteleaftide.online", "hosts from the csproj");
|
||||
Check.Eq(ProfileInterface.CurrentJson(true, "InfiniteLeaftide"), json, "unchanged state: the same JSON");
|
||||
Check.False(JsonDocument.Parse(ProfileInterface.CurrentJson(false, null)).RootElement.GetProperty("active").GetBoolean(),
|
||||
"before the Hub is up: not active");
|
||||
}
|
||||
|
||||
private static void Salvage()
|
||||
{
|
||||
var rows = ServerSalvageView.ParseList(ProfileInterface.CurrentJson(true, "InfiniteLeaftide"));
|
||||
Check.Eq(rows.Count, IltSalvage.Rows.Length, "every row arrives");
|
||||
for (int i = 0; i < rows.Count; i++)
|
||||
{
|
||||
var a = IltSalvage.Rows[i];
|
||||
var b = rows[i];
|
||||
bool same = a.Bench == b.Bench && a.Material == b.Material && a.Kind == b.Kind && a.Effect == b.Effect
|
||||
&& a.UsesTinkSlot == b.UsesTinkSlot && a.NameMatch == b.NameMatch && a.AppliedInt == b.AppliedInt
|
||||
&& a.Prepared == b.Prepared && a.Order == b.Order && a.AfterCap == b.AfterCap
|
||||
&& a.StackGroup == b.StackGroup && a.StackCap == b.StackCap;
|
||||
Check.True(same, $"row {i} ({a.Bench} {a.Material}) round-trips");
|
||||
}
|
||||
|
||||
const int Leather = 52, Steel = 64, Serpentine = 71, Silver = 63, Diamond = 20, BlackGarnet = 15;
|
||||
foreach (string bench in new[] { "melee", "missile", "caster" })
|
||||
{
|
||||
var leather = rows.Single(r => r.Bench == bench && r.Material == Leather);
|
||||
Check.True(leather.AfterCap, bench + " Leather: after the cap");
|
||||
Check.False(leather.UsesTinkSlot, bench + " Leather: no tink slot");
|
||||
Check.Eq(leather.Kind, "once", bench + " Leather: once");
|
||||
Check.Eq(leather.Order, 995, bench + " Leather: last");
|
||||
}
|
||||
Check.Eq(rows.Count(r => r.AfterCap), 3, "only the weapon Leathers wait for the cap");
|
||||
|
||||
var stack = rows.Where(r => r.StackGroup.Length > 0).ToList();
|
||||
Check.Eq(string.Join(",", stack.Select(r => r.Bench + ":" + r.Material)), $"jewelry:{Serpentine},jewelry:{Steel}", "Serpentine + Steel stack");
|
||||
Check.True(stack.All(r => r.StackGroup == "jewelry-stack" && r.StackCap == 10 && r.Kind == "tink" && !r.UsesTinkSlot),
|
||||
"one group, cap 10, repeatable, no tink slot");
|
||||
|
||||
Check.Eq(rows.Single(r => r.Bench == "jewelry" && r.Material == Silver).AppliedInt, 374, "jewelry Silver flag int");
|
||||
var diamond = rows.Single(r => r.Bench == "trinkets" && r.Material == Diamond);
|
||||
Check.True(diamond.Prepared && diamond.AppliedInt == 384 && diamond.Order == 10, "trinket Diamond: prepared, flag 384, first");
|
||||
Check.Eq(rows.Count(r => r.Prepared), 4, "the four trinket tiers are prepared");
|
||||
Check.True(rows.Where(r => r.Material == BlackGarnet).All(r => r.NameMatch == "Abyssal" && r.UsesTinkSlot),
|
||||
"Abyssal-Touched Gems by bag name, using a tink slot");
|
||||
Check.False(rows.Any(r => r.Bench is "armor" or "items"), "no armor or item rows");
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,8 @@ namespace RynthILT.Tests;
|
|||
// Offline tests for the RynthILT plugin: the ACECustom bounty tracker (parsing, merging, the
|
||||
// quiet /bounty list read loop on a fake clock, persistence, the bridge JSON) and the ILT Hub
|
||||
// (attribute raiser, aug costs, bank commands, sigil chain, and the move out of RynthAi: data
|
||||
// migration, the RynthILT.Hub table, verb routing, the object view). Each test prints PASS / FAIL.
|
||||
// migration, the RynthILT.Hub table, verb routing, the object view) and its RynthServer.Profile
|
||||
// (ILT's tinkering salvage). Each test prints PASS / FAIL.
|
||||
//
|
||||
// Run: dotnet run -c Release (all tests)
|
||||
// dotnet run -c Release -- window (tests whose name contains "window")
|
||||
|
|
@ -38,6 +39,16 @@ internal static class Program
|
|||
SigilChainTests.Register(runner);
|
||||
BankCommandTests.Register(runner);
|
||||
MoveTests.Register(runner);
|
||||
ChunkTests.Register(runner);
|
||||
ProfileTests.Register(runner);
|
||||
FeatureCatalogTests.Register(runner);
|
||||
IltSettingsTests.Register(runner);
|
||||
FellowshipCommandTests.Register(runner);
|
||||
AetheriaChunkTests.Register(runner);
|
||||
RingChainTests.Register(runner);
|
||||
// Before DataApiTests: its last test releases the RynthILT.Data table, which the breeding version test queries.
|
||||
BreedingTests.Register(runner);
|
||||
DataApiTests.Register(runner);
|
||||
return runner.Run("RynthILT tests", args.Length > 0 ? args[0] : null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
93
Tools/RynthILT.Tests/RingChainTests.cs
Normal file
93
Tools/RynthILT.Tests/RingChainTests.cs
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RynthCore.Plugin.RynthILT.Hub;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthILT.Tests;
|
||||
|
||||
// The Rings inscription chain's pure parts (Hub/IltRingChain.cs, SilentKelpie's RynthAi
|
||||
// Crafting > Rings moved to RynthILT): ingredient names, the craft queue and the scroll pairing.
|
||||
internal static class RingChainTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("rings: ingredients match by name, with alternates and an exclude", Ingredients);
|
||||
r.Add("rings: the queue runs every Step 1, then Step 2, then the glyphs, capped per recipe", Queue);
|
||||
r.Add("rings: scrolls are known by their glyph and paired with targets the UB-IT way", Scrolls);
|
||||
r.Add("rings: the recipe list holds the three steps and eight glyphs", RecipeList);
|
||||
}
|
||||
|
||||
private static IltRingRecipe Recipe(string id) => IltRingChain.Recipes.Single(r => r.Id == id);
|
||||
|
||||
private static void Ingredients()
|
||||
{
|
||||
var step1 = Recipe("ring2_step1_quill_trophy");
|
||||
Check.True(IltRingChain.Matches("Quill of Infliction", step1.Tool), "the quill");
|
||||
Check.True(IltRingChain.Matches("infliction quill", step1.Tool), "an alternate name, any case");
|
||||
Check.False(IltRingChain.Matches("Enlightened Quill of Infliction", step1.Tool), "the enlightened quill is Step 2's, not Step 1's");
|
||||
Check.True(IltRingChain.Matches("Empyrean Trophy", step1.Target), "a trophy");
|
||||
Check.False(IltRingChain.Matches("Trophy Scroll", step1.Target), "plain 'Trophy' isn't enough (scrolls carry the word)");
|
||||
Check.False(IltRingChain.Matches(null, step1.Tool), "no name");
|
||||
Check.False(IltRingChain.Matches("", step1.Tool), "empty name");
|
||||
|
||||
var step2 = Recipe("ring2_step2_ink");
|
||||
Check.True(IltRingChain.Matches("Enlightened Quill of Infliction", step2.Tool), "Step 2 takes Step 1's quill");
|
||||
Check.False(IltRingChain.Matches("Enlightened Infliction Quill of Partition", step2.Tool), "but not the partition quill");
|
||||
|
||||
var flame = Recipe("ring2_glyph_flame");
|
||||
Check.True(IltRingChain.Matches("Enlightened Infliction Quill of Partition", flame.Tool), "Step 3 takes the partition quill");
|
||||
Check.True(IltRingChain.Matches("Glyph of Flame", flame.Target), "the full glyph name");
|
||||
Check.False(IltRingChain.Matches("Glyph of Frost", flame.Target), "another glyph is not");
|
||||
}
|
||||
|
||||
private static void Queue()
|
||||
{
|
||||
var runs = new Dictionary<string, int>
|
||||
{
|
||||
["ring2_glyph_frost"] = 1,
|
||||
["ring2_step2_ink"] = 2,
|
||||
["ring2_step1_quill_trophy"] = 2,
|
||||
["ring2_glyph_bludgeoning"] = 1,
|
||||
};
|
||||
List<IltRingRecipe> q = IltRingChain.Expand(id => runs.TryGetValue(id, out int n) ? n : 0);
|
||||
Check.Eq(string.Join(",", q.Select(r => r.Id)),
|
||||
"ring2_step1_quill_trophy,ring2_step1_quill_trophy,ring2_step2_ink,ring2_step2_ink,ring2_glyph_bludgeoning,ring2_glyph_frost",
|
||||
"tier order, then the definition order within a tier");
|
||||
Check.Eq(IltRingChain.Expand(_ => 0).Count, 0, "nothing queued");
|
||||
Check.Eq(IltRingChain.Expand(id => id == "ring2_step2_ink" ? -5 : 0).Count, 0, "negative runs count as none");
|
||||
Check.Eq(IltRingChain.Expand(id => id == "ring2_step2_ink" ? 500 : 0).Count, IltRingChain.MaxRuns, "capped at MaxRuns");
|
||||
}
|
||||
|
||||
private static void Scrolls()
|
||||
{
|
||||
Check.True(IltRingChain.IsInscriptionScroll("Inscription of Halo of Frost"), "an inscription scroll");
|
||||
Check.False(IltRingChain.IsInscriptionScroll("Scroll of Frost Bolt"), "a spell scroll is not");
|
||||
Check.False(IltRingChain.IsInscriptionScroll(null), "no name");
|
||||
Check.Eq(IltRingChain.GlyphOf("Inscription of Halo of Frost")?.Id, "ring2_glyph_frost", "known by its scroll name");
|
||||
Check.Eq(IltRingChain.GlyphOf("Inscription of Cassius' Ring of Fire")?.Id, "ring2_glyph_flame", "apostrophes too");
|
||||
Check.True(IltRingChain.GlyphOf("Inscription of Something New") == null, "an unknown scroll has no glyph");
|
||||
|
||||
var scrolls = new[]
|
||||
{
|
||||
(Id: 50, Name: "Inscription of Something New"),
|
||||
(Id: 40, Name: "Inscription of Halo of Frost"),
|
||||
(Id: 30, Name: "Inscription of Tectonic Rifts"),
|
||||
(Id: 20, Name: "Inscription of Halo of Frost"),
|
||||
};
|
||||
var pairs = IltRingChain.PairScrolls(scrolls, new[] { 900, 700, 800, 700 });
|
||||
// Scrolls by glyph id (bludgeoning < frost; unknown last), then by id; targets by id, once each.
|
||||
Check.Eq(string.Join(" ", pairs.Select(p => p.Scroll + ">" + p.Target)), "30>700 20>800 40>900", "pairing order");
|
||||
Check.Eq(IltRingChain.PairScrolls(scrolls.Take(1), new[] { 1, 2, 3 }).Count, 1, "one scroll per target, no more pairs than scrolls");
|
||||
Check.Eq(IltRingChain.PairScrolls(scrolls, Array.Empty<int>()).Count, 0, "no targets, no pairs");
|
||||
}
|
||||
|
||||
private static void RecipeList()
|
||||
{
|
||||
Check.Eq(IltRingChain.Recipes.Length, 10, "Step 1, Step 2 and eight glyphs");
|
||||
Check.Eq(IltRingChain.Recipes.Count(r => r.Tier == 3), 8, "eight glyphs");
|
||||
Check.True(IltRingChain.Recipes.Select(r => r.Id).Distinct().Count() == IltRingChain.Recipes.Length, "ids are unique");
|
||||
foreach (var r in IltRingChain.Recipes.Where(r => r.Tier == 3))
|
||||
Check.True(r.ScrollMarkers.Length > 0, r.Id + " knows its scroll's name");
|
||||
}
|
||||
}
|
||||
|
|
@ -39,6 +39,8 @@
|
|||
<Compile Include="..\RynthCore.RynthAiTests\Harness\Check.cs" Link="Harness\Check.cs" />
|
||||
<Compile Include="..\RynthCore.RynthAiTests\Harness\Runner.cs" Link="Harness\Runner.cs" />
|
||||
<Compile Include="..\RynthCore.RynthAiHostTests\Fakes\FakeHost.cs" Link="Fakes\FakeHost.cs" />
|
||||
<!-- The shared reader RynthAi's Crafting tab uses on RynthILT's RynthServer.Profile JSON (ProfileTests),
|
||||
Plugins\Shared\EngineServerState.cs, comes with the plugin now (it reads RynthCore's server list). -->
|
||||
</ItemGroup>
|
||||
|
||||
<!-- The engine's Bounties snapshot reader (self-contained DTOs), so BountyTests checks the plugin's
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthInventory\**\*.cs" Exclude="..\..\Plugins\RynthCore.Plugin.RynthInventory\obj\**;..\..\Plugins\RynthCore.Plugin.RynthInventory\bin\**" Link="RynthInventory\%(RecursiveDir)%(Filename)%(Extension)" />
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.Engine\UI\ScriptWindows\DisplayListParser.cs" Link="Engine\DisplayListParser.cs" />
|
||||
<!-- The plugin links this one from Plugins/Shared (the glob above only covers the plugin's folder). -->
|
||||
<Compile Include="..\..\Plugins\Shared\ChatSource.cs" Link="Shared\ChatSource.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -59,6 +59,25 @@ namespace RynthInventory.Tests
|
|||
Check(!v.ShouldEat(null), "null is fine");
|
||||
}
|
||||
|
||||
// A player imitating the server: their name is in front, or the chat type is theirs.
|
||||
{
|
||||
(VaultFeed v, _) = NewVault();
|
||||
v.Ask(0);
|
||||
Check(!v.ShouldEat("Bob says, \"" + VaultPage(1, 1, 1, A) + "\"", 2), "spoken data line is not ours");
|
||||
Check(!v.ShouldEat("Bob " + VaultPage(1, 1, 1, A), 12), "an emoted data line is not ours");
|
||||
Check(!v.ShouldEat("Bob " + VaultPage(1, 1, 1, A)), "a data line not at the start is not ours, type unknown");
|
||||
Check(!v.ShouldEat(VaultPage(1, 1, 1, A), 3), "a data line in a tell is not ours");
|
||||
Check(!v.ShouldEat("Bob tells you, \"Unknown command: mule-data\"", 3), "a told unknown-command line is not ours");
|
||||
Check(!v.ShouldEat("Unknown command: mule-data", 2), "unknown-command in speech is not ours");
|
||||
Check(!v.ShouldEat("Unknown command: mule-data-ish"), "another command's refusal is not ours");
|
||||
Check(v.ShouldEat("Unknown command: mule-data", 15), "ACE's real reply (Help) is ours");
|
||||
}
|
||||
{
|
||||
(VaultFeed v, _) = NewVault();
|
||||
v.Ask(0);
|
||||
Check(v.ShouldEat(" " + VaultPage(1, 1, 1, A), 0), "the server's line (Broadcast), leading space allowed");
|
||||
}
|
||||
|
||||
// A server without the command.
|
||||
{
|
||||
(VaultFeed v, List<string> sent) = NewVault();
|
||||
|
|
|
|||
18
Tools/RynthLua.CompatTests/Scripts/format.lua
Normal file
18
Tools/RynthLua.CompatTests/Scripts/format.lua
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
-- string.format as standard Lua 5.2+ has it: %s takes any value through tostring, so a
|
||||
-- script that formats a missing field (nil) keeps running (MoonSharp alone throws
|
||||
-- "bad argument #3 to 'format' (string expected, got nil)").
|
||||
local e = { SenderName = "Cap" } -- no Message field, as in the DiscordWebhook report
|
||||
eq(string.format("**%s**: %s", e.SenderName, e.Message), "**Cap**: nil", "nil through %s")
|
||||
eq(string.format("%s %s %s", true, false, nil), "true false nil", "booleans and nil through %s")
|
||||
check(string.format("%s", {}):find("^table") ~= nil, "a table through %s")
|
||||
local obj = setmetatable({}, { __tostring = function() return "custom" end })
|
||||
eq(string.format("[%s]", obj), "[custom]", "__tostring is honoured")
|
||||
eq(("%s=%s"):format("k", nil), "k=nil", "the method form too")
|
||||
|
||||
-- everything else is unchanged
|
||||
eq(string.format("%d%% of %5.1f", 50, 3.14159), "50% of 3.1", "%d, %%, widths")
|
||||
eq(string.format("0x%08X %-4s|", 255, "ab"), "0x000000FF ab |", "hex and left-aligned %s")
|
||||
eq(string.format("%q", "a\"b"), "\"a\\\"b\"", "%q")
|
||||
eq(string.format("no args"), "no args", "no arguments")
|
||||
eq(string.format("%s", 12), "12", "numbers through %s")
|
||||
done()
|
||||
|
|
@ -43,10 +43,13 @@ namespace RynthOracle.Tests
|
|||
QuestLines();
|
||||
Catalog();
|
||||
Servers();
|
||||
EngineServers();
|
||||
QuestNotes();
|
||||
ConquestReplies();
|
||||
AelrynthReplies();
|
||||
Void();
|
||||
Pages();
|
||||
CharacterExtras();
|
||||
Events();
|
||||
Console.WriteLine($"{_pass} passed, {_fail} failed");
|
||||
return _fail == 0 ? 0 : 1;
|
||||
|
|
@ -158,6 +161,71 @@ namespace RynthOracle.Tests
|
|||
Check(QuestCatalog.Validate(string.Join("\n", Enumerable.Repeat("x", 3)), out _) == false, "validation rejects junk");
|
||||
}
|
||||
|
||||
/// <summary>A RynthCore GetServerStateJson answer (schema 1) with the given servers.</summary>
|
||||
private static string EngineJson(string active, string activeName, string activePlugin, string pick, string world, params string[] servers)
|
||||
=> "{\"schema\":1,\"revision\":3,\"host\":\"h\",\"world\":\"" + world + "\",\"pick\":\"" + pick + "\",\"active\":\"" + active
|
||||
+ "\",\"activeName\":\"" + activeName + "\",\"activePlugin\":\"" + activePlugin + "\",\"servers\":[" + string.Join(",", servers) + "]}";
|
||||
|
||||
private static string EngineRow(string id, bool active, string force, string plugin = "", string reason = "")
|
||||
=> "{\"id\":\"" + id + "\",\"name\":\"" + id.ToUpperInvariant() + "\",\"active\":" + (active ? "true" : "false")
|
||||
+ ",\"detected\":" + (active && force == "auto" ? "true" : "false") + ",\"force\":\"" + force
|
||||
+ "\",\"builtIn\":false,\"plugin\":\"" + plugin + "\",\"reason\":\"" + reason + "\"}";
|
||||
|
||||
// RynthCore's server list (API v86) drives the identity: overrides and the Diagnostics pick included.
|
||||
private static void EngineServers()
|
||||
{
|
||||
// The shared parser.
|
||||
Check(RynthCore.Plugin.Shared.EngineServerState.Parse(null) == null && RynthCore.Plugin.Shared.EngineServerState.Parse("junk") == null, "engine state: junk is null");
|
||||
Check(RynthCore.Plugin.Shared.EngineServerState.Parse("{\"schema\":2}") == null, "engine state: another schema is null");
|
||||
var st = RynthCore.Plugin.Shared.EngineServerState.Parse(EngineJson("ilt", "Infinite Leaftide", "RynthILT", "auto", "InfiniteLeaftide",
|
||||
EngineRow("ilt", true, "auto", "RynthILT", "host matches"), EngineRow("aelrynth", false, "auto")));
|
||||
Check(st != null && st.HasActive && st.IsActive("ILT") && st.ActivePlugin == "RynthILT" && !st.Picked, "engine state: active ILT, detected");
|
||||
Check(st!.Servers.Count == 2 && st.Find("aelrynth") != null && st.Find("x") == null && st.Revision == 3, "engine state: rows");
|
||||
|
||||
// Identity from it.
|
||||
ServerIdentity.FromEngine(st, "Launcher Profile", out string tag, out string world, out string source);
|
||||
Check(tag == "" && world == "InfiniteLeaftide" && source.Contains("no RynthOracle pages"), "engine: ILT active has no Oracle tag (its screens are RynthILT's): " + source);
|
||||
Check(source.Contains("host matches"), "engine: the reason is shown: " + source);
|
||||
|
||||
var picked = RynthCore.Plugin.Shared.EngineServerState.Parse(EngineJson("conquest", "ConquestAC", "RynthConquest", "conquest", "",
|
||||
EngineRow("ilt", false, "off"), EngineRow("conquest", true, "on", "RynthConquest")))!;
|
||||
ServerIdentity.FromEngine(picked, "Leaftide Box", out tag, out world, out source);
|
||||
Check(tag == ServerTags.Conquest && world == "Leaftide Box", "engine: a pick beats the world name (and the world falls back): " + source);
|
||||
Check(source.Contains("picked by hand"), "engine: a pick says so: " + source);
|
||||
|
||||
var off = RynthCore.Plugin.Shared.EngineServerState.Parse(EngineJson("", "", "", "mixed", "InfiniteLeaftide", EngineRow("ilt", false, "off")))!;
|
||||
ServerIdentity.FromEngine(off, "", out tag, out _, out source);
|
||||
Check(tag == "", "engine: ILT forced off stays off despite the Leaftide world name: " + source);
|
||||
|
||||
var unknown = RynthCore.Plugin.Shared.EngineServerState.Parse(EngineJson("", "", "", "auto", "Levistras", EngineRow("ilt", false, "auto")))!;
|
||||
ServerIdentity.FromEngine(unknown, "", out tag, out _, out source);
|
||||
Check(tag == ServerTags.Levistras, "engine: a world the engine has no server for still tags by name: " + source);
|
||||
|
||||
var coldeve = RynthCore.Plugin.Shared.EngineServerState.Parse(EngineJson("coldeve", "Coldeve", "RynthColdeve", "auto", "Coldeve", EngineRow("coldeve", true, "auto", "RynthColdeve")))!;
|
||||
ServerIdentity.FromEngine(coldeve, "", out tag, out _, out source);
|
||||
Check(tag == "" && source.Contains("Coldeve"), "engine: a server without Oracle pages has no tag: " + source);
|
||||
|
||||
Check(ServerIdentity.TagForEngineId("AELRYNTH") == ServerTags.Aelrynth && ServerIdentity.TagForEngineId(null) == "", "engine id to tag");
|
||||
Check(ServerIdentity.EngineIdForTag(ServerTags.Aelrynth) == "aelrynth" && ServerIdentity.EngineIdForTag("") == "", "tag to engine id");
|
||||
|
||||
// The owner's profile, read leniently (a server plugin's, and RynthILT's).
|
||||
var prof = RynthCore.Plugin.Shared.ServerProfileView.Parse(
|
||||
"{\"schema\":1,\"id\":\"coldeve\",\"name\":\"Coldeve\",\"plugin\":\"RynthColdeve\",\"ruleset\":\"PvE\",\"emulator\":\"ACE\",\"botting\":\"forbidden\",\"bottingNote\":\"no bots\",\"accountLimit\":\"3 accounts\"}");
|
||||
Check(prof != null && prof.Botting == "forbidden" && prof.Summary() == "PvE, ACE; botting forbidden - no bots; accounts: 3 accounts", "profile: server plugin: " + prof?.Summary());
|
||||
var iltProf = RynthCore.Plugin.Shared.ServerProfileView.Parse("{\"ilt\":true,\"features\":[{\"key\":\"bank\",\"state\":1},{\"key\":\"x\",\"state\":0},{\"key\":\"y\",\"state\":1}]}");
|
||||
Check(iltProf != null && iltProf.Ilt && iltProf.FeaturesOn == 2 && iltProf.Summary() == "ILT world, 2 Leaftide features on", "profile: RynthILT: " + iltProf?.Summary());
|
||||
Check(RynthCore.Plugin.Shared.ServerProfileView.Parse("") == null && RynthCore.Plugin.Shared.ServerProfileView.Parse("[1]") == null, "profile: junk is null");
|
||||
// A user's server-name list (ub-Rythai's ILT Auto list) against the engine's verdict.
|
||||
string[] list = { "InfiniteLeaftide", "Conquest" };
|
||||
Check(RynthCore.Plugin.Shared.EngineServerState.MatchesNameList(null, "Infinite Leaftide", list), "names: no engine, the world name decides (spaces ignored)");
|
||||
Check(!RynthCore.Plugin.Shared.EngineServerState.MatchesNameList(null, "Coldeve", list), "names: no engine, another world");
|
||||
Check(RynthCore.Plugin.Shared.EngineServerState.MatchesNameList(st, "Launcher Profile", list), "names: ILT active matches a Leaftide name whatever the world");
|
||||
Check(RynthCore.Plugin.Shared.EngineServerState.MatchesNameList(picked, "", list), "names: a picked Conquest matches by id");
|
||||
Check(!RynthCore.Plugin.Shared.EngineServerState.MatchesNameList(coldeve, "InfiniteLeaftide", list), "names: Coldeve active beats a Leaftide world name");
|
||||
Check(!RynthCore.Plugin.Shared.EngineServerState.MatchesNameList(off, "InfiniteLeaftide", list), "names: ILT listed and off stays off");
|
||||
Check(RynthCore.Plugin.Shared.EngineServerState.MatchesNameList(unknown, "Conquest", list), "names: a server the engine doesn't list still matches by world");
|
||||
}
|
||||
|
||||
private static void Servers()
|
||||
{
|
||||
Check(ServerIdentity.TagForWorld("Aeshnidae") == ServerTags.Aelrynth, "Aeshnidae (the live world name) is Aelrynth");
|
||||
|
|
@ -165,6 +233,7 @@ namespace RynthOracle.Tests
|
|||
Check(ServerIdentity.TagForWorld("Conquest") == ServerTags.Conquest, "Conquest");
|
||||
Check(ServerIdentity.TagForWorld("Levistras") == ServerTags.Levistras, "Levistras");
|
||||
Check(ServerIdentity.TagForWorld("Coldeve") == "" && ServerIdentity.TagForWorld("") == "", "other servers have no tag");
|
||||
Check(ServerIdentity.TagForWorld("InfiniteLeaftide") == "", "Infinite Leaftide has no Oracle tag (RynthILT draws its screens)");
|
||||
var id = new ServerIdentity();
|
||||
id.Force("", "Coldeve");
|
||||
Check(id.Allows(null) && id.Allows("") && !id.Allows(ServerTags.Conquest) && !id.Allows(ServerTags.Aelrynth), "untagged everywhere, tagged nowhere else");
|
||||
|
|
@ -188,6 +257,78 @@ namespace RynthOracle.Tests
|
|||
Check(view.Tab == OracleView.TabQuests, "a Conquest tab left selected falls back to Quests elsewhere");
|
||||
}
|
||||
|
||||
// Quest notes: tracking and rewards saved per character, UB's reward format and import, kill-task timers.
|
||||
private static void QuestNotes()
|
||||
{
|
||||
string root = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "RynthOracleTests-" + Guid.NewGuid().ToString("N"));
|
||||
try
|
||||
{
|
||||
var r = new QuestReward { XpPercent = 1.5, LumPercent = 2, RecordedLevel = 275, Coins = 3, Trinkets = 1, Medallions = 2,
|
||||
YellowPowder = 1, RedPowder = 1, BluePowder = 1, Mmd = 2 };
|
||||
Check(r.ShortSummary() == "1.5%XP 2%Lum 3C 1T 2M 1Y 1R 1B 2D L275", "UB's short summary: " + r.ShortSummary());
|
||||
Check(QuestReward.Percent(12.345) == "12.3" && QuestReward.Percent(0.1234) == "0.123" && QuestReward.Percent(1.234) == "1.23", "UB's percent format");
|
||||
Check(QuestReward.TryParsePercent("2,5%", out double pc) && pc == 2.5, "a percent with a comma and a % sign");
|
||||
Check(QuestReward.TryParsePercent("5000", out double big) && big == QuestReward.MaxPercent, "percent clamped to 1000");
|
||||
Check(!QuestReward.TryParsePercent("abc", out _) && !QuestReward.TryParseCount("1.5", out _), "junk is refused");
|
||||
Check(QuestReward.TryParseCount("-4", out int neg) && neg == 0 && QuestReward.TryParseCount("", out int blank) && blank == 0, "counts: negatives and blanks are 0");
|
||||
Check(new QuestReward().IsEmpty && !r.IsEmpty, "empty entry");
|
||||
|
||||
// Track and record, then read it back as a new session would.
|
||||
var book = new QuestBook { RootOverride = root, UbRootOverride = "" };
|
||||
book.Load("Infinite Leaftide", "Test \"Char\"");
|
||||
Check(book.Loaded && book.Tracked.Count == 0 && book.RewardCount == 0, "a new character starts empty");
|
||||
book.SetTracked("killtaskdrudges", true);
|
||||
book.SetTracked("30minattributes", true);
|
||||
book.SetTracked("killtaskdrudges", true);
|
||||
book.SetReward("30minattributes", r);
|
||||
Check(book.Tracked.Count == 2 && book.IsTracked("KILLTASKDRUDGES"), "tracked once, case-insensitive");
|
||||
string file = book.PathFor("Infinite Leaftide", "Test \"Char\"");
|
||||
Check(System.IO.File.Exists(file) && System.IO.File.ReadAllText(file).All(ch => ch == '\n' || (ch >= 0x20 && ch <= 0x7E)), "saved at once, plain ASCII");
|
||||
|
||||
var again = new QuestBook { RootOverride = root, UbRootOverride = "" };
|
||||
again.Load("Infinite Leaftide", "Test \"Char\"");
|
||||
Check(again.Tracked.SequenceEqual(new[] { "killtaskdrudges", "30minattributes" }), "tracked list kept in order");
|
||||
Check(again.TryGetReward("30minattributes", out QuestReward back) && back.ShortSummary() == r.ShortSummary(), "rewards read back");
|
||||
again.SetReward("30minattributes", new QuestReward());
|
||||
again.ToggleTracked("killtaskdrudges");
|
||||
Check(again.RewardCount == 0 && again.Tracked.Count == 1, "an empty entry removes the rewards; untrack");
|
||||
|
||||
// UB ILT's quest_rewards.json is imported once for a character without notes.
|
||||
string ub = System.IO.Path.Combine(root, "ub");
|
||||
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(ub, "InfiniteLeaftide", "Kelp"));
|
||||
System.IO.File.WriteAllText(System.IO.Path.Combine(ub, "InfiniteLeaftide", "Kelp", "quest_rewards.json"),
|
||||
"{\"SchemaVersion\":2,\"Character\":\"Kelp\",\"Server\":\"InfiniteLeaftide\",\"Rewards\":{"
|
||||
+ "\"stipendtimer_0812\":{\"XpPercent\":1.25,\"LumPercent\":0,\"RecordedLevel\":300,\"Coins\":5},"
|
||||
+ "\"emptyone\":{\"XpPercent\":0}}}");
|
||||
var imported = new QuestBook { RootOverride = root, UbRootOverride = ub };
|
||||
imported.Load("Infinite Leaftide", "Kelp");
|
||||
Check(imported.RewardCount == 1 && imported.TryGetReward("stipendtimer_0812", out QuestReward ir) && ir.Coins == 5 && ir.RecordedLevel == 300
|
||||
&& imported.LoadNote.Contains("Imported 1"), "UB rewards imported (empty entries skipped): " + imported.LoadNote);
|
||||
var noReimport = new QuestBook { RootOverride = root, UbRootOverride = ub };
|
||||
noReimport.Load("Infinite Leaftide", "Kelp");
|
||||
Check(noReimport.RewardCount == 1 && noReimport.LoadNote.Length == 0, "imported once: the next load reads Oracle's own file");
|
||||
|
||||
// Kill tasks: kills left, then the reset timer, then done (UB's rule).
|
||||
DateTime now = new DateTime(2026, 10, 13, 12, 0, 0, DateTimeKind.Utc);
|
||||
var kt = new QuestFlag { Key = "killtaskdrudges", Solves = 12, MaxSolves = 50, RepeatTime = TimeSpan.FromHours(20), CompletedOnUtc = now.AddHours(-1) };
|
||||
Check(QuestTimer.IsKillTask(kt) && QuestTimer.State(kt, true, now, out string t1) == QuestTimerState.InProgress && t1 == "38 left", "kill task counting");
|
||||
kt.Solves = 50;
|
||||
Check(QuestTimer.State(kt, true, now, out string t2) == QuestTimerState.Waiting && t2.StartsWith("19h"), "kill task waiting: " + t2);
|
||||
kt.CompletedOnUtc = now.AddDays(-2);
|
||||
Check(QuestTimer.State(kt, true, now, out string t3) == QuestTimerState.Done && t3 == "done", "kill task done");
|
||||
var timed = new QuestFlag { Key = "stipendtimer_0812", Solves = 3, RepeatTime = TimeSpan.FromHours(1), CompletedOnUtc = now.AddMinutes(-30) };
|
||||
QuestTimerState s4 = QuestTimer.State(timed, true, now, out string t4);
|
||||
Check(!QuestTimer.IsKillTask(timed) && s4 == QuestTimerState.Waiting && t4 == "30m 0s", "timer: " + t4);
|
||||
timed.CompletedOnUtc = now.AddHours(-2);
|
||||
Check(QuestTimer.State(timed, true, now, out string t5) == QuestTimerState.Ready && t5 == "ready", "timer ran out");
|
||||
Check(QuestTimer.State(timed, false, now, out string t6) == QuestTimerState.Done && t6 == "completed", "one-time quest");
|
||||
}
|
||||
finally
|
||||
{
|
||||
try { System.IO.Directory.Delete(root, true); } catch (System.IO.IOException) { }
|
||||
}
|
||||
}
|
||||
|
||||
private static void ConquestReplies()
|
||||
{
|
||||
var d = new ConquestData();
|
||||
|
|
@ -319,6 +460,13 @@ namespace RynthOracle.Tests
|
|||
ch.Enchantments.Add(new ActiveEnchantment(3531, "Bobo's Quickening", 600, 1800, false));
|
||||
ch.Enchantments.Add(new ActiveEnchantment(SpellIds.SurgeOfDestruction, "Surge of Destruction", 5, 8, false));
|
||||
c.Void.OnChatLine("You cast Corrosion VII on Drudge Slinker", c.NowMs, _ => 0, () => true);
|
||||
// The quest book in a temp folder (never the player's %APPDATA%), with two tracked quests.
|
||||
c.Book.RootOverride = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "RynthOracleTests-" + Guid.NewGuid().ToString("N"));
|
||||
c.Book.UbRootOverride = "";
|
||||
c.Book.Load("Aeshnidae", ch.Name);
|
||||
c.Book.SetTracked("30minattributes", true);
|
||||
c.Book.SetTracked("societyribbonsperdaycounter", true);
|
||||
c.Book.SetReward("30minattributes", new QuestReward { XpPercent = 1.5, RecordedLevel = 126, Coins = 2 });
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
@ -331,6 +479,11 @@ namespace RynthOracle.Tests
|
|||
UiWindow voidW = host.Add(new UiWindow("RynthOracle/Void", "Void") { Visible = true });
|
||||
var vv = new VoidView(c);
|
||||
voidW.Begin(); vv.Draw(voidW); voidW.End();
|
||||
UiWindow timersW = host.Add(new UiWindow("RynthOracle/QuestTimers", "Quest Timers") { Visible = true });
|
||||
var tv = new QuestTimersView(c);
|
||||
timersW.Begin(); tv.Draw(timersW); timersW.End();
|
||||
string timersBody = Encoding.UTF8.GetString(timersW.Body);
|
||||
Check(timersBody.Contains("Attribute and Skill Redistribution") && timersBody.Contains("ready"), "the Quest Timers window lists tracked quests with their timers");
|
||||
|
||||
// Every tab on each server, including the server-specific ones (with data in them).
|
||||
c.Conquest.RequestBank(c.NowMs);
|
||||
|
|
@ -354,6 +507,24 @@ namespace RynthOracle.Tests
|
|||
main.MarkSubmitted(true);
|
||||
}
|
||||
}
|
||||
// The Quests tab with a quest opened (rewards editor) and the Tracked filter on.
|
||||
c.Server.Force("", "Coldeve");
|
||||
c.Settings.TabName = OracleView.TabQuests;
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
Apply(host, Event(2, 89, main.Hash, main.KeyOf("q.tracked"), new byte[] { 1 }));
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
Check(Encoding.UTF8.GetString(main.Body).Contains("2 shown"), "the Tracked filter lists the two tracked quests");
|
||||
Apply(host, Event(1, 90, main.Hash, main.KeyOf("q.r.30minattributes"), new byte[] { 1, 0, 0 }));
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
ParseAll(host, "quests with a quest opened", out int openOps);
|
||||
string openBody = Encoding.UTF8.GetString(main.Body);
|
||||
Check(openOps > 5 && openOps < 1400, $"quests page with a quest opened: {openOps} ops");
|
||||
Check(openBody.Contains("Save rewards") && openBody.Contains("Level: 126"), "the opened quest shows the rewards editor");
|
||||
Check(openBody.Contains("1.5%XP 2C L126"), "the Rewards column shows the recorded rewards");
|
||||
Check(!openBody.Contains("/qb"), "no quest bonus list here (Infinite Leaftide's /qb is RynthILT's)");
|
||||
Console.WriteLine($" Quests (opened): {openOps} ops, {main.Body.Length} bytes");
|
||||
main.MarkSubmitted(true);
|
||||
|
||||
// The Conquest tab's sub-pages and the Aelrynth board views.
|
||||
c.Server.Force(ServerTags.Conquest, "Conquest");
|
||||
c.Settings.TabName = OracleView.TabConquest;
|
||||
|
|
@ -394,6 +565,41 @@ namespace RynthOracle.Tests
|
|||
maxOps = windows.Where(w => w.List != null).Select(w => w.List!.OpCount).DefaultIfEmpty(0).Max();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Character tab's RynthAi session (the generic part of the Mini Remote's old Character
|
||||
/// tab, moved here 2026-10-13). Infinite Leaftide's charms are RynthILT's and never drawn here.
|
||||
/// </summary>
|
||||
private static void CharacterExtras()
|
||||
{
|
||||
OracleContext c = Context();
|
||||
c.Server.Force("", "InfiniteLeaftide");
|
||||
c.Settings.TabName = OracleView.TabCharacter;
|
||||
var view = new OracleView(c);
|
||||
var host = new UiHost();
|
||||
UiWindow main = host.Add(new UiWindow("RynthOracle/Oracle", "Oracle") { Visible = true });
|
||||
|
||||
// Nothing from RynthAi yet: the tab says what to load.
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
string empty = Encoding.UTF8.GetString(main.Body);
|
||||
Check(empty.Contains("Load RynthAi for the session rates"), "without RynthAi: says to load it");
|
||||
Check(!empty.Contains("Charms") && !empty.Contains("RynthILT"), "no charms section on any world (RynthILT's Charms tab)");
|
||||
main.MarkSubmitted(true);
|
||||
|
||||
c.Session = new RynthCore.Plugin.Shared.SessionStatsV1
|
||||
{
|
||||
StartUtcTicks = DateTime.UtcNow.AddHours(-1).Ticks, SessionSeconds = 3600, Xp = 1_234_567, XpPerHour = 1_234_567,
|
||||
Lum = 4000, LumPerHour = 4000, LumLast5Min = 250, Kills = 42, KillsPerHour = 42,
|
||||
};
|
||||
c.SessionKnown = true;
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
ParseAll(host, "Character with the session", out int ops);
|
||||
string body = Encoding.UTF8.GetString(main.Body);
|
||||
Check(ops > 5 && ops < 1400, $"Character with the session: {ops} ops");
|
||||
Check(body.Contains("1,234,567") && body.Contains("4,000") && body.Contains("42 (42/h)"), "the session shows RynthAi's XP, luminance and kills");
|
||||
Check(OracleView.SessionStatsCommand == "/rc miniremote section char", "Session Stats opens the section, not the moved tab");
|
||||
main.MarkSubmitted(true);
|
||||
}
|
||||
|
||||
private static void Events()
|
||||
{
|
||||
OracleContext c = Context();
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthOracle\**\*.cs" Exclude="..\..\Plugins\RynthCore.Plugin.RynthOracle\obj\**;..\..\Plugins\RynthCore.Plugin.RynthOracle\bin\**" Link="RynthOracle\%(RecursiveDir)%(Filename)%(Extension)" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\Combat\FellowshipTracker.cs" Link="RynthOracle\Shared\FellowshipTracker.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\RynthAiHubApi.cs" Link="RynthOracle\Shared\RynthAiHubApi.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\RynthAiSessionClient.cs" Link="RynthOracle\Shared\RynthAiSessionClient.cs" />
|
||||
<!-- RynthCore's server list and the owner plugin's profile (as in the plugin's csproj). -->
|
||||
<Compile Include="..\..\Plugins\Shared\RynthServerProfileApi.cs" Link="RynthOracle\Shared\RynthServerProfileApi.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\EngineServerState.cs" Link="RynthOracle\Shared\EngineServerState.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\ServerStateClient.cs" Link="RynthOracle\Shared\ServerStateClient.cs" />
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.Engine\UI\ScriptWindows\DisplayListParser.cs" Link="Engine\DisplayListParser.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
18
Tools/RynthServerPack.Tests/Program.cs
Normal file
18
Tools/RynthServerPack.Tests/Program.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthServerPack.Tests;
|
||||
|
||||
// Offline tests for the server plugins: the shared model and every server plugin's detection data.
|
||||
//
|
||||
// Run: dotnet run -c Release (all tests)
|
||||
// dotnet run -c Release -- host (tests whose name contains "host")
|
||||
internal static class Program
|
||||
{
|
||||
private static int Main(string[] args)
|
||||
{
|
||||
var runner = new Runner();
|
||||
ServerPackModelTests.Register(runner);
|
||||
ServerProjectsTests.Register(runner);
|
||||
return runner.Run("RynthServerPack tests", args.Length > 0 ? args[0] : null);
|
||||
}
|
||||
}
|
||||
37
Tools/RynthServerPack.Tests/RynthServerPack.Tests.csproj
Normal file
37
Tools/RynthServerPack.Tests/RynthServerPack.Tests.csproj
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!--
|
||||
Tests for the server plugins (Plugins\Shared\ServerPack, built into RynthColdeve, RynthAelrynth, ...):
|
||||
- the shared model (ServerPackModel.cs, ServerPackInfo.cs): RynthCore's "servermenu" verdict,
|
||||
the world-name fallback, the override commands and the sections manifest;
|
||||
- every server plugin's csproj, read as XML: unique ids, plugin names and hosts, and no
|
||||
server's host claimed by another server's list (RynthCore would load the wrong plugin);
|
||||
- the launcher's known-server catalog (RynthCore.App\KnownServerCatalog.cs): every entry names
|
||||
a server plugin whose hosts claim the entry's host, with the same port and emulator.
|
||||
The plugins are NativeAOT x86 libraries, so the pure sources are compiled in here directly.
|
||||
The SDK's manifest file (BCL only) supplies RynthCore's host matching.
|
||||
Run: dotnet run -c Release (exit 0 = pass, 1 = fail; an argument filters by test name)
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<RootNamespace>RynthServerPack.Tests</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerPackInfo.cs" Link="Plugin\ServerPackInfo.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerPackModel.cs" Link="Plugin\ServerPackModel.cs" />
|
||||
<!-- "RynthServer.Profile": the profile JSON, and the shared reader's parser that consumes it. -->
|
||||
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerPackProfile.cs" Link="Plugin\ServerPackProfile.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\EngineServerState.cs" Link="Shared\EngineServerState.cs" />
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.PluginSdk\Manifest\RynthPluginManifest.cs" Link="Sdk\RynthPluginManifest.cs" />
|
||||
<!-- The launcher's known-server picker, checked against the plugins it names. -->
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.App\LaunchServerProfile.cs" Link="Launcher\LaunchServerProfile.cs" />
|
||||
<!-- The RynthAi test tools' check/runner harness (no plugin code in it). -->
|
||||
<Compile Include="..\RynthCore.RynthAiTests\Harness\Check.cs" Link="Harness\Check.cs" />
|
||||
<Compile Include="..\RynthCore.RynthAiTests\Harness\Runner.cs" Link="Harness\Runner.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
243
Tools/RynthServerPack.Tests/ServerPackModelTests.cs
Normal file
243
Tools/RynthServerPack.Tests/ServerPackModelTests.cs
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using RynthCore.Plugin.ServerPack;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthServerPack.Tests;
|
||||
|
||||
// The shared server-plugin model (Plugins\Shared\ServerPack\ServerPackModel.cs): RynthCore's
|
||||
// "servermenu" verdict for the plugin's own server, the world-name fallback before one arrives,
|
||||
// the override commands the card sends, and the sections manifest RynthCore reads.
|
||||
internal static class ServerPackModelTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("server pack: RynthCore's push gives this server's verdict, override and reason", EnginePush);
|
||||
r.Add("server pack: a push without this server, or not a push, changes nothing", ForeignPush);
|
||||
r.Add("server pack: before any push the world name decides", WorldFallback);
|
||||
r.Add("server pack: override commands are checked before sending", ForceCommands);
|
||||
r.Add("server pack: the sections manifest declares the server and a server-only card", SectionsJson);
|
||||
r.Add("server pack: logout clears the verdict", ClearOnLogout);
|
||||
r.Add("server pack: the card's botting line and address", InfoText);
|
||||
r.Add("server pack: the RynthServer.Profile JSON carries the server's settings", ProfileJson);
|
||||
r.Add("server pack: the profile JSON is plain ASCII and escaped", ProfileJsonAscii);
|
||||
}
|
||||
|
||||
private static void ProfileJson()
|
||||
{
|
||||
ServerPackInfo info = new("Coldeve", "Coldeve", new[] { "play.coldeve.ac" }, new[] { "Coldeve" })
|
||||
{
|
||||
Port = 9050, Ruleset = "PvP", Status = "Stable", Botting = BottingPolicy.Restricted, BottingNote = "attended only",
|
||||
AccountLimit = "3 accounts", Facts = new[] { "fact one" }, Commands = new[] { new ServerCommand("/x", "does x") },
|
||||
Discord = "https://discord.gg/x",
|
||||
};
|
||||
string json = ServerPackProfile.BuildJson(info, "RynthColdeve", "0.1.2", true, "Coldeve");
|
||||
using JsonDocument doc = JsonDocument.Parse(json);
|
||||
JsonElement root = doc.RootElement;
|
||||
Check.Eq(root.GetProperty("schema").GetInt32(), ServerPackProfile.Schema, "schema");
|
||||
Check.Eq(root.GetProperty("id").GetString(), "coldeve", "id (lower-cased)");
|
||||
Check.Eq(root.GetProperty("plugin").GetString(), "RynthColdeve", "plugin");
|
||||
Check.Eq(root.GetProperty("version").GetString(), "0.1.2", "version");
|
||||
Check.True(root.GetProperty("active").GetBoolean(), "active");
|
||||
Check.Eq(root.GetProperty("world").GetString(), "Coldeve", "world");
|
||||
Check.Eq(root.GetProperty("hosts")[0].GetString(), "play.coldeve.ac", "hosts");
|
||||
Check.Eq(root.GetProperty("port").GetInt32(), 9050, "port");
|
||||
Check.Eq(root.GetProperty("ruleset").GetString(), "PvP", "ruleset");
|
||||
Check.Eq(root.GetProperty("botting").GetString(), "restricted", "botting");
|
||||
Check.Eq(root.GetProperty("bottingNote").GetString(), "attended only", "botting note");
|
||||
Check.Eq(root.GetProperty("facts")[0].GetString(), "fact one", "facts");
|
||||
Check.Eq(root.GetProperty("commands")[0].GetProperty("what").GetString(), "does x", "commands");
|
||||
Check.Eq(root.GetProperty("discord").GetString(), "https://discord.gg/x", "links");
|
||||
|
||||
// What a reader (RynthOracle, RynthAi's /ra server) makes of it.
|
||||
var view = RynthCore.Plugin.Shared.ServerProfileView.Parse(json);
|
||||
Check.True(view != null, "the shared reader parses it");
|
||||
Check.Eq(view!.Summary(), "PvP, ACE; botting restricted - attended only; accounts: 3 accounts", "the reader's summary");
|
||||
|
||||
// No salvage defined: an empty list, which the Crafting tab reads as "none defined".
|
||||
Check.Eq(root.GetProperty("salvage").GetArrayLength(), 0, "no salvage: empty list");
|
||||
Check.Eq(RynthCore.Plugin.Shared.ServerSalvageView.ParseList(json).Count, 0, "the reader sees none");
|
||||
|
||||
// Salvage defined: each row round-trips through the shared reader.
|
||||
ServerPackInfo withSalvage = new("x", "X", new[] { "x.example" }, new[] { "X" })
|
||||
{
|
||||
Salvage = new[]
|
||||
{
|
||||
new ServerSalvage("melee", 52, "+1 tink past the cap", "once", UsesTinkSlot: false),
|
||||
new ServerSalvage("Armor", 64, "+30 armor level"),
|
||||
new ServerSalvage("", 64, "no bench: skipped"),
|
||||
},
|
||||
};
|
||||
var salvage = RynthCore.Plugin.Shared.ServerSalvageView.ParseList(
|
||||
ServerPackProfile.BuildJson(withSalvage, "RynthX", "1", true, "X"));
|
||||
Check.Eq(salvage.Count, 2, "rows without a bench are skipped");
|
||||
Check.Eq(salvage[0].Bench, "melee", "bench");
|
||||
Check.Eq(salvage[0].Material, 52, "material id");
|
||||
Check.Eq(salvage[0].Kind, "once", "kind");
|
||||
Check.False(salvage[0].UsesTinkSlot, "no tink slot");
|
||||
Check.Eq(salvage[1].Bench, "armor", "bench lower-cased");
|
||||
Check.Eq(salvage[1].Kind, "tink", "default kind");
|
||||
Check.True(salvage[1].UsesTinkSlot, "slot by default");
|
||||
Check.Eq(RynthCore.Plugin.Shared.ServerSalvageView.ParseList("{\"id\":\"x\"}").Count, 0, "a profile without the list (older plugins)");
|
||||
|
||||
// The optional row fields: absent = off / the default, and the writer leaves them out then.
|
||||
Check.True(salvage.All(v => v.AppliedInt == 0 && !v.Prepared && v.Order == 0 && !v.AfterCap
|
||||
&& v.StackGroup.Length == 0 && v.StackCap == 0), "optional fields default when absent");
|
||||
string plain = ServerPackProfile.BuildJson(withSalvage, "RynthX", "1", true, "X");
|
||||
Check.True(!plain.Contains("\"applied\"") && !plain.Contains("\"prepared\"") && !plain.Contains("\"order\"")
|
||||
&& !plain.Contains("\"afterCap\"") && !plain.Contains("\"stackGroup\""), "unset fields are not written");
|
||||
|
||||
ServerPackInfo withRules = new("x", "X", new[] { "x.example" }, new[] { "X" })
|
||||
{
|
||||
Salvage = new[]
|
||||
{
|
||||
new ServerSalvage("melee", 52, "post-cap", "once", UsesTinkSlot: false, Order: 995, AfterCap: true),
|
||||
new ServerSalvage("jewelry", 71, "stack", UsesTinkSlot: false, Order: 50, StackGroup: "jewelry-stack", StackCap: 10),
|
||||
new ServerSalvage("trinkets", 20, "tier", "once", UsesTinkSlot: false, AppliedInt: 384, Prepared: true, Order: 10),
|
||||
},
|
||||
};
|
||||
var rules = RynthCore.Plugin.Shared.ServerSalvageView.ParseList(
|
||||
ServerPackProfile.BuildJson(withRules, "RynthX", "1", true, "X"));
|
||||
Check.Eq(rules.Count, 3, "rows with rules");
|
||||
Check.True(rules[0].AfterCap && rules[0].Order == 995 && !rules[0].Prepared && rules[0].StackGroup.Length == 0, "after cap + order");
|
||||
Check.Eq(rules[1].StackGroup, "jewelry-stack", "stack group");
|
||||
Check.Eq(rules[1].StackCap, 10, "stack cap");
|
||||
Check.True(rules[2].Prepared && rules[2].AppliedInt == 384 && rules[2].Order == 10 && !rules[2].AfterCap, "prepared + applied + order");
|
||||
Check.Eq(RynthCore.Plugin.Shared.ServerSalvageView.ParseList(
|
||||
"{\"salvage\":[{\"bench\":\"jewelry\",\"material\":64,\"stackGroup\":\"g\"},{\"bench\":\"jewelry\",\"material\":71,\"stackGroup\":\"g\",\"stackCap\":0}]}")
|
||||
.Count(v => v.StackGroup.Length > 0), 0, "a stack group without a positive cap is no group");
|
||||
var odd = RynthCore.Plugin.Shared.ServerSalvageView.ParseList(
|
||||
"{\"salvage\":[{\"bench\":\"melee\",\"material\":52,\"applied\":\"x\",\"prepared\":1,\"order\":null,\"afterCap\":\"yes\"}]}");
|
||||
Check.True(odd.Count == 1 && odd[0].AppliedInt == 0 && !odd[0].Prepared && odd[0].Order == 0 && !odd[0].AfterCap,
|
||||
"fields of the wrong type read as absent");
|
||||
|
||||
string idle = ServerPackProfile.BuildJson(info, "RynthColdeve", "0.1.2", false, null);
|
||||
using JsonDocument idleDoc = JsonDocument.Parse(idle);
|
||||
Check.False(idleDoc.RootElement.GetProperty("active").GetBoolean(), "not active");
|
||||
Check.Eq(idleDoc.RootElement.GetProperty("world").GetString(), "", "no world before login");
|
||||
Check.Eq(ServerPackProfile.BottingName(BottingPolicy.Unknown), "unknown", "unknown botting");
|
||||
}
|
||||
|
||||
private static void ProfileJsonAscii()
|
||||
{
|
||||
ServerPackInfo info = new("x", "Caf\u00e9 \"Q\"\n", Array.Empty<string>(), Array.Empty<string>()) { Summary = "a\\b\tc \u2014 d" };
|
||||
string json = ServerPackProfile.BuildJson(info, "RynthX", "1", false, "");
|
||||
bool ascii = true;
|
||||
foreach (char c in json) if (c > 0x7e || c < 0x20) ascii = false;
|
||||
Check.True(ascii, "only printable ASCII: " + json);
|
||||
using JsonDocument doc = JsonDocument.Parse(json);
|
||||
Check.Eq(doc.RootElement.GetProperty("name").GetString(), "Caf\u00e9 \"Q\"", "name round-trips (trimmed)");
|
||||
Check.Eq(doc.RootElement.GetProperty("summary").GetString(), "a\\b\tc \u2014 d", "summary round-trips");
|
||||
}
|
||||
|
||||
private static ServerPackInfo Coldeve() =>
|
||||
new("Coldeve", "Coldeve", new[] { "play.coldeve.ac" }, new[] { "Coldeve" }) { Discord = "https://discord.gg/x" };
|
||||
|
||||
private const string Push =
|
||||
"V\tcoldeve\tColdeve\t1\ton\t0\tforced on for this character\n" +
|
||||
"V\tilt\tInfinite Leaftide\t0\tauto\t0\tnot Infinite Leaftide\n" +
|
||||
"X\tchar\tChar\n" +
|
||||
"S\tcoldeve\tColdeve\t1\t/rc server coldeve on\n" +
|
||||
"I\tColdeve server (RynthColdeve)\t/rc miniremote section char\tWhat is known.\tsection:char\n";
|
||||
|
||||
private static void EnginePush()
|
||||
{
|
||||
var model = new ServerPackModel(Coldeve());
|
||||
Check.True(model.ApplyEngine(Push, 1234), "taken");
|
||||
ServerVerdictView? v = model.Engine;
|
||||
Check.True(v != null, "this server's verdict");
|
||||
Check.True(v!.Active, "active");
|
||||
Check.Eq(v.Force, "on", "override");
|
||||
Check.False(v.Detected, "forced, not detected");
|
||||
Check.Eq(v.Reason, "forced on for this character", "reason");
|
||||
Check.Eq(model.EngineAtMs, 1234L, "when");
|
||||
Check.True(model.IsActive("SomewhereElse"), "RynthCore's verdict beats the world name");
|
||||
}
|
||||
|
||||
private static void ForeignPush()
|
||||
{
|
||||
var model = new ServerPackModel(Coldeve());
|
||||
Check.False(model.ApplyEngine("X\tchar\tChar\n", 1), "no server lines: not a push");
|
||||
Check.False(model.ApplyEngine(null, 1), "null");
|
||||
Check.False(model.ApplyEngine(new string('V', ServerPackModel.MaxPayload + 1), 1), "too long");
|
||||
Check.True(model.Engine == null, "nothing published");
|
||||
|
||||
// A push that lists other servers but not this one yet (RynthCore hasn't read the manifest).
|
||||
Check.True(model.ApplyEngine("V\tilt\tInfinite Leaftide\t1\tauto\t1\thost matches\n", 2), "a push");
|
||||
Check.True(model.Engine == null, "no verdict for this server");
|
||||
ServerPackModel.ParseEngine("V\tCOLDEVE\tColdeve\t0\tweird\t1\n", "coldeve", out bool listed);
|
||||
Check.True(listed, "listed");
|
||||
Check.Eq(ServerPackModel.ParseEngine("V\tCOLDEVE\tColdeve\t0\tweird\t1\n", "coldeve", out _)!.Force, "auto",
|
||||
"id case ignored; an unknown override reads as auto; no reason field is fine");
|
||||
}
|
||||
|
||||
private static void WorldFallback()
|
||||
{
|
||||
var model = new ServerPackModel(Coldeve());
|
||||
Check.True(model.IsActive("Coldeve"), "exact world name");
|
||||
Check.True(model.IsActive(" coldeve "), "case and spaces");
|
||||
Check.False(model.IsActive("ColdeveTwo"), "no partial match without '*'");
|
||||
Check.False(model.IsActive(null), "unknown world");
|
||||
Check.True(ServerPackModel.WorldMatches("Aeshnidae Live", new[] { "Aelrynth*", "Aeshnidae*" }), "wildcard");
|
||||
Check.False(ServerPackModel.WorldMatches("LeafDawn", new[] { "Leafdawning" }), "LeafDawn is not Leafdawning");
|
||||
Check.True(ServerPackModel.WorldMatches("Infinite Leaftide", new[] { "*Leaftide*" }), "both ends");
|
||||
}
|
||||
|
||||
private static void ForceCommands()
|
||||
{
|
||||
Check.Eq(ServerPackModel.ForceCommand("coldeve", "On"), "/rc server coldeve on", "on");
|
||||
Check.Eq(ServerPackModel.ForceCommand("coldeve", "auto"), "/rc server coldeve auto", "auto");
|
||||
Check.Eq(ServerPackModel.ForceCommand("coldeve", "maybe"), "", "unknown mode");
|
||||
Check.Eq(ServerPackModel.ForceCommand("cold eve", "on"), "", "an id with a space");
|
||||
Check.Eq(ServerPackModel.ForceCommand("coldeve; /quit", "on"), "", "no command injection through the id");
|
||||
Check.False(ServerPackModel.IsSafeId(new string('a', 33)), "too long");
|
||||
}
|
||||
|
||||
private static void SectionsJson()
|
||||
{
|
||||
string json = ServerPackModel.BuildSectionsJson(Coldeve(), "RynthColdeve");
|
||||
using JsonDocument doc = JsonDocument.Parse(json);
|
||||
JsonElement root = doc.RootElement;
|
||||
Check.Eq(root.GetProperty("version").GetInt32(), 1, "schema 1");
|
||||
JsonElement server = root.GetProperty("servers")[0];
|
||||
Check.Eq(server.GetProperty("id").GetString(), "coldeve", "server id lower-cased");
|
||||
Check.Eq(server.GetProperty("hosts")[0].GetString(), "play.coldeve.ac", "hosts");
|
||||
Check.Eq(server.GetProperty("worldNames")[0].GetString(), "Coldeve", "world names");
|
||||
JsonElement card = root.GetProperty("contributions")[0];
|
||||
Check.Eq(card.GetProperty("section").GetString(), "server", "in the Server section (not Session Stats)");
|
||||
JsonElement section = root.GetProperty("sections")[0];
|
||||
Check.Eq(section.GetProperty("id").GetString(), "server", "the Server section is declared");
|
||||
Check.Eq(section.GetProperty("label").GetString(), "Server", "its label");
|
||||
Check.Eq(section.GetProperty("order").GetInt32(), 50, "after Session Stats, before Map");
|
||||
Check.Eq(card.GetProperty("server").GetString(), "coldeve", "only while Coldeve is active");
|
||||
Check.Eq(card.GetProperty("surface").GetString(), "section:server-coldeve", "the card's surface");
|
||||
|
||||
var quoted = new ServerPackInfo("odd", "Odd \"Name\"\n", new[] { "a\\b" }, Array.Empty<string>());
|
||||
using JsonDocument odd = JsonDocument.Parse(ServerPackModel.BuildSectionsJson(quoted, "RynthOdd"));
|
||||
Check.Eq(odd.RootElement.GetProperty("servers")[0].GetProperty("hosts")[0].GetString(), "a\\b", "escaped");
|
||||
}
|
||||
|
||||
private static void ClearOnLogout()
|
||||
{
|
||||
var model = new ServerPackModel(Coldeve());
|
||||
model.ApplyEngine(Push, 5);
|
||||
model.Clear();
|
||||
Check.True(model.Engine == null, "verdict cleared");
|
||||
Check.Eq(model.EngineAtMs, 0L, "time cleared");
|
||||
Check.False(model.IsActive("Elsewhere"), "back to the world name");
|
||||
}
|
||||
|
||||
private static void InfoText()
|
||||
{
|
||||
ServerPackInfo c = Coldeve();
|
||||
Check.Eq(c.Address, "play.coldeve.ac:9000", "address");
|
||||
Check.True(c.BottingText.StartsWith("Not published"), "unknown policy says so");
|
||||
Check.True(c.BottingText.Contains("Discord"), "and points at the Discord");
|
||||
var lev = new ServerPackInfo("example", "Example", new[] { "play.example.test" }, new[] { "Example" })
|
||||
{ Botting = BottingPolicy.Forbidden, BottingNote = "no automation" };
|
||||
Check.Eq(lev.BottingText, "Forbidden - no automation", "forbidden");
|
||||
Check.Eq(new ServerPackInfo("x", "", Array.Empty<string>(), Array.Empty<string>()).Address, "", "no host, no address");
|
||||
Check.True(ServerPackModel.LauncherSteps(c)[0].Contains("play.coldeve.ac:9000"), "setup names the address");
|
||||
}
|
||||
}
|
||||
107
Tools/RynthServerPack.Tests/ServerProjectsTests.cs
Normal file
107
Tools/RynthServerPack.Tests/ServerProjectsTests.cs
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using RynthCore.PluginSdk.Manifest;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthServerPack.Tests;
|
||||
|
||||
// Every server plugin's csproj (Plugins\RynthCore.Plugin.Rynth*\ with RynthPluginServerId), read as
|
||||
// XML: the detection data RynthCore's loader and sections use must be unique and must not overlap,
|
||||
// or a client would load (or show) the wrong server's plugin.
|
||||
internal static class ServerProjectsTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("server projects: every listed server has a plugin", AllServersPresent);
|
||||
r.Add("server projects: ids, plugin names and hosts are unique", Unique);
|
||||
r.Add("server projects: no server's host is claimed by another server's list", NoHostOverlap);
|
||||
r.Add("server projects: each new server plugin has ServerData.cs and imports the shared props", Layout);
|
||||
}
|
||||
|
||||
private sealed record Project(string Dir, string PluginName, string Id, string Name, string[] Hosts, string[] Worlds, bool Shared);
|
||||
|
||||
/// <summary>The servers in the request (the server list's busiest, plus Aelrynth) and their plugins.</summary>
|
||||
private static readonly string[] Expected =
|
||||
{
|
||||
"coldeve", "ilt", "frostace", "reefcull", "conquest", "dreamweave", "portalstorm", "sundering",
|
||||
"achard", "leafdawn", "derptide", "frostcull", "thistlecrown", "eversong", "leafdawning", "aelrynth",
|
||||
};
|
||||
|
||||
private static string PluginsDir()
|
||||
{
|
||||
string? dir = AppContext.BaseDirectory;
|
||||
while (dir != null && !Directory.Exists(Path.Combine(dir, "Plugins", "Shared", "ServerPack")))
|
||||
dir = Path.GetDirectoryName(dir);
|
||||
if (dir == null) throw new DirectoryNotFoundException("RynthSuite\\Plugins not found above " + AppContext.BaseDirectory);
|
||||
return Path.Combine(dir, "Plugins");
|
||||
}
|
||||
|
||||
private static List<Project> Load()
|
||||
{
|
||||
var list = new List<Project>();
|
||||
foreach (string dir in Directory.GetDirectories(PluginsDir(), "RynthCore.Plugin.Rynth*"))
|
||||
{
|
||||
string csproj = Path.Combine(dir, Path.GetFileName(dir) + ".csproj");
|
||||
if (!File.Exists(csproj)) continue;
|
||||
XDocument doc = XDocument.Load(csproj);
|
||||
string Prop(string name) => doc.Descendants(name).FirstOrDefault()?.Value.Trim() ?? "";
|
||||
string id = Prop("RynthPluginServerId");
|
||||
if (id.Length == 0) continue;
|
||||
string[] Split(string v) => v.Split('|', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
bool shared = doc.Descendants("Import").Any(i => (i.Attribute("Project")?.Value ?? "").EndsWith("ServerPlugin.props"));
|
||||
string asm = Prop("AssemblyName");
|
||||
list.Add(new Project(dir, asm.Replace("RynthCore.Plugin.", ""), id, Prop("RynthPluginServerName"),
|
||||
Split(Prop("RynthPluginServerHosts")), Split(Prop("RynthPluginServerWorldNames")), shared));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static void AllServersPresent()
|
||||
{
|
||||
List<Project> projects = Load();
|
||||
foreach (string id in Expected)
|
||||
Check.True(projects.Any(p => p.Id == id), "a server plugin for " + id);
|
||||
Check.Eq(projects.Count, Expected.Length, "no unexpected server plugins");
|
||||
}
|
||||
|
||||
private static void Unique()
|
||||
{
|
||||
List<Project> projects = Load();
|
||||
Check.Eq(projects.Select(p => p.Id).Distinct().Count(), projects.Count, "ids unique");
|
||||
Check.Eq(projects.Select(p => p.PluginName.ToLowerInvariant()).Distinct().Count(), projects.Count, "plugin names unique");
|
||||
var hosts = projects.SelectMany(p => p.Hosts).Select(h => h.ToLowerInvariant()).ToList();
|
||||
Check.Eq(hosts.Distinct().Count(), hosts.Count, "hosts unique");
|
||||
foreach (Project p in projects)
|
||||
{
|
||||
Check.True(p.Hosts.Length > 0, p.PluginName + " lists a host (the loader picks plugins by host)");
|
||||
Check.True(p.Worlds.Length > 0, p.PluginName + " lists a world name");
|
||||
Check.True(p.Name.Length > 0, p.PluginName + " has a display name");
|
||||
}
|
||||
}
|
||||
|
||||
private static void NoHostOverlap()
|
||||
{
|
||||
List<Project> projects = Load();
|
||||
foreach (Project owner in projects)
|
||||
foreach (string host in owner.Hosts.Where(h => !h.Contains('*')))
|
||||
foreach (Project other in projects.Where(o => o != owner))
|
||||
{
|
||||
var server = new RynthPluginServer { Id = other.Id, Hosts = other.Hosts.ToList() };
|
||||
Check.False(server.MatchesHost(host, out string hit),
|
||||
$"{owner.PluginName}'s host {host} is not claimed by {other.PluginName} ({hit})");
|
||||
}
|
||||
}
|
||||
|
||||
private static void Layout()
|
||||
{
|
||||
foreach (Project p in Load().Where(p => p.Id != "ilt"))
|
||||
{
|
||||
Check.True(p.Shared, p.PluginName + " imports Shared\\ServerPack\\ServerPlugin.props");
|
||||
Check.True(File.Exists(Path.Combine(p.Dir, "ServerData.cs")), p.PluginName + " has ServerData.cs");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue