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
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue