Snapshot for release 2026.10.19.1 (internal f0bdcf8)
This commit is contained in:
parent
5419838250
commit
39de36d3af
131 changed files with 11266 additions and 520 deletions
|
|
@ -5,12 +5,216 @@ 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.
|
||||
// The cap covers levelled Coalesced Aetheria; an unlevelled one chunks, as in ub-IT. Corrupted
|
||||
// weapons follow ub-IT's hard rules and its optional keep rules, and /clap needs a colour with its
|
||||
// own trinket.
|
||||
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);
|
||||
r.Add("aetheria: rating level - at or above keeps, below chunks (Coalesced too)", RatingLevel);
|
||||
r.Add("aetheria: the level cap applies to levelled Coalesced Aetheria; unlevelled Coalesced chunks (ub-IT)", CoalescedCap);
|
||||
r.Add("aetheria: a failed read is not 'unlevelled': unreadable pieces are kept, levelled Coalesced keeps its cap", UnreadableAetheria);
|
||||
r.Add("aetheria: never-chunk, tinker / imbue, item XP, ratings and the cap each keep a piece", AetheriaRules);
|
||||
r.Add("chunk: kind by class and name; chunks and powder are clap material", Kinds);
|
||||
r.Add("corrupted: ub-IT hard rules (workmanship, cleave 1, or 2 on two-handed non-thrust)", CorruptedHardRules);
|
||||
r.Add("corrupted: ub-IT keep rules, all off by default", CorruptedKeepRules);
|
||||
r.Add("corrupted: a failed read is kept; two-handed cleave 2 chunks and other cleave 2 does not", UnreadableCorrupted);
|
||||
r.Add("chunk: busy blocks peace mode, not combat with chunk-in-combat on (ub-IT v2.0.1059)", BusyGate);
|
||||
r.Add("chunk: a target that leaves the pack counts as chunked; still carried after 10 s times out", WaitOutcome);
|
||||
r.Add("clap: the server's WCIDs, each colour paired with its trinket, Coalesced only unrevealed level 1-3", ClapPairs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Coalesced Aetheria has its level from loot (ACECustom 1-10, ratings at 6+); it used to skip
|
||||
/// the cap, so a cap of 9 still chunked a level 10 Coalesced piece.
|
||||
/// </summary>
|
||||
private static void CoalescedCap()
|
||||
{
|
||||
Check.True(IltChunkClap.UnderChunkCap(8, 9), "level 8 under a cap of 9");
|
||||
Check.False(IltChunkClap.UnderChunkCap(9, 9), "level 9 is not below 9");
|
||||
Check.False(IltChunkClap.UnderChunkCap(10, 9), "a level 10 Coalesced piece is kept");
|
||||
Check.True(IltChunkClap.UnderChunkCap(10, 11), "11 chunks every level");
|
||||
Check.False(IltChunkClap.UnderChunkCap(0, 11), "revealed aetheria with no level read: never chunked");
|
||||
Check.False(IltChunkClap.UnderChunkCap(9, 9, coalesced: true), "a levelled Coalesced piece keeps the cap");
|
||||
Check.True(IltChunkClap.UnderChunkCap(0, 4, coalesced: true), "an unlevelled Coalesced piece chunks (it used to be kept forever)");
|
||||
Check.True(IltChunkClap.UnderChunkCap(0, 1, coalesced: true), "even with the lowest cap");
|
||||
}
|
||||
|
||||
private static readonly IltChunkClap.AetheriaFacts PlainCoalesced = new(
|
||||
Coalesced: true, MaxLevel: 0, NeverChunk: false, ItemXp: 0, Tinkers: 0, Imbue: 0, Crit: 0, CritDamage: 0, CritDamageResist: 0);
|
||||
|
||||
private static void AetheriaRules()
|
||||
{
|
||||
var g = new IltGearState();
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced), null, "a plain unlevelled Coalesced piece chunks");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { MaxLevel = 3 }), null, "level 3 under the default cap of 4");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { MaxLevel = 4 }), "level at or above the cap", "level 4 at the default cap");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { NeverChunk = true }), "never-chunk flag", "bool 9030");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { Tinkers = 1 }), "tinkered or imbued", "tinkered");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { Imbue = 4 }), "tinkered or imbued", "imbued");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { ItemXp = 100 }), "has item XP", "levelled by use");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { Crit = 2 }), "kept for its C / CD / CDR rating", "a C 2 piece is kept by default");
|
||||
g.KeepAetheriaWithCrit = false;
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { Crit = 2 }), null, "C switch off: a C 2 piece chunks");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { Coalesced = false }), "no level read", "revealed aetheria needs a level");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The rules read 0 for "the item has none" and for "the host could not read it". An unlevelled
|
||||
/// Coalesced piece is chunked (ub-IT), but only when its level was truly read as none; a piece whose
|
||||
/// properties could not be read is kept, whatever the numbers say.
|
||||
/// </summary>
|
||||
private static void UnreadableAetheria()
|
||||
{
|
||||
var g = new IltGearState();
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced), null, "read as unlevelled: chunks");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { Unreadable = "no appraisal" }),
|
||||
"item data unreadable (no appraisal)", "the same piece with failed reads: kept");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { MaxLevel = 2, Unreadable = "no item XP" }),
|
||||
"item data unreadable (no item XP)", "a levelled piece with failed reads: kept");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(new IltGearState { ChunkAetheriaUnderLevel = 1 }, PlainCoalesced), null, "unlevelled chunks at the lowest cap too");
|
||||
|
||||
// Levelled Coalesced pieces keep the cap.
|
||||
var cap9 = new IltGearState { ChunkAetheriaUnderLevel = 9 };
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(cap9, PlainCoalesced with { MaxLevel = 8 }), null, "levelled 8 under a cap of 9");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(cap9, PlainCoalesced with { MaxLevel = 9 }), "level at or above the cap", "levelled 9 at a cap of 9");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(cap9, PlainCoalesced with { MaxLevel = 10 }), "level at or above the cap", "levelled 10 over a cap of 9");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(new IltGearState { ChunkAetheriaUnderLevel = 11 }, PlainCoalesced with { MaxLevel = 10 }), null, "cap 11 chunks every level");
|
||||
}
|
||||
|
||||
private static void UnreadableCorrupted()
|
||||
{
|
||||
var g = new IltGearState();
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword with { Unreadable = "no appraisal" }),
|
||||
"item data unreadable (no appraisal)", "failed reads: kept (they would read as a plain weapon)");
|
||||
var keepCb = new IltGearState { KeepCorruptedCrushingBlow = true };
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(keepCb, PlainSword with { Unreadable = "float properties" }),
|
||||
"item data unreadable (float properties)", "a keep rule whose float cannot be read keeps the weapon");
|
||||
var twoHanded = PlainSword with { WieldSkill = 41, Cleaving = 2 };
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, twoHanded), null, "two-handed cleave 2 chunks");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword with { Cleaving = 2 }), "cleave over the limit", "other cleave 2 is kept");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, twoHanded with { WieldSkill = 0, WeaponType = 11 }), null, "WeaponType two-handed counts");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, twoHanded with { AttackType = 2 }), "cleave over the limit", "two-handed thrust keeps the 1 limit");
|
||||
}
|
||||
|
||||
private static void Kinds()
|
||||
{
|
||||
var gem = RynthCore.Loot.AcObjectClass.Gem;
|
||||
Check.Eq(IltChunkClap.KindOf(gem, "Coalesced Aetheria"), IltChunkClap.ChunkKind.Aetheria, "Coalesced");
|
||||
Check.Eq(IltChunkClap.KindOf(gem, "Blue Aetheria"), IltChunkClap.ChunkKind.Aetheria, "revealed sigil");
|
||||
Check.Eq(IltChunkClap.KindOf(gem, "Red Aetheria Chunk"), IltChunkClap.ChunkKind.None, "chunk");
|
||||
Check.Eq(IltChunkClap.KindOf(gem, "Aetheria Powder"), IltChunkClap.ChunkKind.None, "powder");
|
||||
Check.Eq(IltChunkClap.KindOf(RynthCore.Loot.AcObjectClass.MeleeWeapon, "Corrupted Greatsword"), IltChunkClap.ChunkKind.Corrupted, "melee");
|
||||
Check.Eq(IltChunkClap.KindOf(RynthCore.Loot.AcObjectClass.MissileWeapon, "Corrupted Bow"), IltChunkClap.ChunkKind.Corrupted, "missile");
|
||||
Check.Eq(IltChunkClap.KindOf(RynthCore.Loot.AcObjectClass.WandStaffOrb, "Corrupted Orb"), IltChunkClap.ChunkKind.None, "casters are not chunked (ub-IT)");
|
||||
Check.Eq(IltChunkClap.KindOf(RynthCore.Loot.AcObjectClass.MeleeWeapon, "Greatsword"), IltChunkClap.ChunkKind.None, "not corrupted");
|
||||
}
|
||||
|
||||
private static readonly IltChunkClap.CorruptedFacts PlainSword = new() { Workmanship = 6, AttackType = 4, WieldSkill = 45 };
|
||||
|
||||
private static void CorruptedHardRules()
|
||||
{
|
||||
var g = new IltGearState();
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword), null, "a plain corrupted sword chunks");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword with { Workmanship = 0 }), "no workmanship", "workmanship 0");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword with { Tinkers = 1 }), "tinkered or imbued", "tinkered");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword with { Imbue = 1 }), "tinkered or imbued", "imbued");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword with { NeverChunk = true }), "never-chunk flag", "bool 9030");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword with { Cleaving = 1 }), null, "one-handed cleave 1");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword with { Cleaving = 2 }), "cleave over the limit", "one-handed cleave 2");
|
||||
|
||||
var twoHanded = PlainSword with { WieldSkill = 41, Cleaving = 2 };
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, twoHanded), null, "two-handed cleave 2 chunks (it never did before)");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, twoHanded with { Cleaving = 3 }), "cleave over the limit", "two-handed cleave 3");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, twoHanded with { AttackType = 2 }), "cleave over the limit", "a two-handed thrust weapon keeps the 1 limit");
|
||||
Check.Eq(IltChunkClap.MaxChunkCleave(0, 11, 4), 2, "WeaponType TwoHanded counts too");
|
||||
Check.Eq(IltChunkClap.MaxChunkCleave(45, 0, 4), 1, "one-handed");
|
||||
}
|
||||
|
||||
private static void CorruptedKeepRules()
|
||||
{
|
||||
var g = new IltGearState();
|
||||
var loaded = PlainSword with
|
||||
{
|
||||
CritFrequency = 0.1, CritMultiplier = 1.5, IgnoreArmor = 0.2, Slayer = 5, AttackType = 160,
|
||||
ElementalBonus = 10, MaxDamage = 400, Spells = new[] { 2072 },
|
||||
};
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, loaded), null, "every keep rule is off by default");
|
||||
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedCrushingBlow = true }, loaded), "kept: Crushing Blow", "Crushing Blow");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedBitingStrike = true }, loaded), "kept: Biting Strike", "Biting Strike");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedArmorCleaving = true }, loaded), "kept: Armor Cleaving", "Armor Cleaving");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedAnySlayer = true }, loaded), "kept: slayer", "slayer");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedMultiStrike = true }, loaded), "kept: multi-strike", "multi-strike 160");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedMultiStrike = true }, PlainSword), null, "a single slash is not multi-strike");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedElementalBonus = true }, loaded), "kept: elemental bonus", "elemental");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedMaxDamageAtLeast = 400 }, loaded), "kept: max damage", "max damage at the limit");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedMaxDamageAtLeast = 401 }, loaded), null, "max damage under the limit");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedAnySpell = true }, loaded), "kept: has a spell", "any spell");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedSpellIds = "100, 2072" }, loaded), "kept: listed spell", "listed spell id");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedSpellIds = "100 200" }, loaded), null, "other spell ids");
|
||||
|
||||
Check.Eq(IltChunkClap.ParseSpellIds("1, 2;3 x -4 0").Count, 3, "positive ids only, any separator");
|
||||
Check.Eq(IltChunkClap.ParseSpellIds(null).Count, 0, "no list");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Silentkelpie 2026-10-18: a Coalesced piece was chunked (Red Aetheria Chunk arrived) with no
|
||||
/// result line, and it was filed as skipped after 10 s instead of counted.
|
||||
/// </summary>
|
||||
private static void WaitOutcome()
|
||||
{
|
||||
Check.Eq(IltChunkClap.WaitOutcome(500, targetStillCarried: true), IltChunkClap.ChunkWait.Waiting, "still carried, within the wait");
|
||||
Check.Eq(IltChunkClap.WaitOutcome(1_100, targetStillCarried: false), IltChunkClap.ChunkWait.Gone, "gone from the pack: chunked");
|
||||
Check.Eq(IltChunkClap.WaitOutcome(12_000, targetStillCarried: false), IltChunkClap.ChunkWait.Gone, "gone beats the timeout");
|
||||
Check.Eq(IltChunkClap.WaitOutcome(10_000, targetStillCarried: true), IltChunkClap.ChunkWait.TimedOut, "still carried at 10 s: timed out");
|
||||
}
|
||||
|
||||
private static void BusyGate()
|
||||
{
|
||||
Check.True(IltChunkClap.AllowsChunkWhileBusy(isBusy: false, isPeace: true, chunkInCombat: false), "idle in peace");
|
||||
Check.False(IltChunkClap.AllowsChunkWhileBusy(isBusy: true, isPeace: true, chunkInCombat: true), "busy in peace waits");
|
||||
Check.True(IltChunkClap.AllowsChunkWhileBusy(isBusy: true, isPeace: false, chunkInCombat: true), "busy swinging with chunk-in-combat");
|
||||
Check.False(IltChunkClap.AllowsChunkWhileBusy(isBusy: true, isPeace: false, chunkInCombat: false), "busy in combat without it");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ACECustom /clap: red (Coalesced 42636 at 1-3, chunk 310147, powder 42644) with Empyrean
|
||||
/// Trinkets (34276); blue (42635, 310149, 300019) with Falatacot (34277). 42635/42636 were taken
|
||||
/// for chunks, and one side alone counted, so auto-clap sent /clap with nothing to pair.
|
||||
/// </summary>
|
||||
private static void ClapPairs()
|
||||
{
|
||||
const string Co = "Coalesced Aetheria";
|
||||
Check.Eq(IltChunkClap.ClapPartOf(42636, Co, 2), IltChunkClap.ClapPart.Red, "red Coalesced level 2");
|
||||
Check.Eq(IltChunkClap.ClapPartOf(42635, Co, 3), IltChunkClap.ClapPart.Blue, "blue Coalesced level 3");
|
||||
Check.Eq(IltChunkClap.ClapPartOf(42636, Co, 0), IltChunkClap.ClapPart.Red, "level not read yet: the server decides");
|
||||
Check.Eq(IltChunkClap.ClapPartOf(42636, Co, 4), IltChunkClap.ClapPart.None, "level 4 Coalesced is not clapped");
|
||||
Check.Eq(IltChunkClap.ClapPartOf(42636, "Aetheria", 1), IltChunkClap.ClapPart.None, "revealed aetheria is not clapped");
|
||||
Check.Eq(IltChunkClap.ClapPartOf(42637, Co, 1), IltChunkClap.ClapPart.None, "yellow has no clap use");
|
||||
Check.Eq(IltChunkClap.ClapPartOf(310147, "Red Aetheria Chunk", 0), IltChunkClap.ClapPart.Red, "red chunk");
|
||||
Check.Eq(IltChunkClap.ClapPartOf(310149, "Blue Aetheria Chunk", 0), IltChunkClap.ClapPart.Blue, "blue chunk");
|
||||
Check.Eq(IltChunkClap.ClapPartOf(310150, "Yellow Aetheria Chunk", 0), IltChunkClap.ClapPart.None, "yellow chunk");
|
||||
Check.Eq(IltChunkClap.ClapPartOf(42644, "Aetheria Powder", 0), IltChunkClap.ClapPart.Red, "red powder");
|
||||
Check.Eq(IltChunkClap.ClapPartOf(300019, "Aetheria Powder", 0), IltChunkClap.ClapPart.Blue, "blue powder");
|
||||
Check.Eq(IltChunkClap.ClapPartOf(34276, "Ancient Empyrean Trinket", 0), IltChunkClap.ClapPart.Empyrean, "Empyrean trinket");
|
||||
Check.Eq(IltChunkClap.ClapPartOf(34277, "Ancient Falatacot Trinket", 0), IltChunkClap.ClapPart.Falatacot, "Falatacot trinket");
|
||||
Check.Eq(IltChunkClap.ClapPartOf(0, "Red Aetheria Chunk", 0), IltChunkClap.ClapPart.Red, "no WCID yet: the chunk name");
|
||||
Check.Eq(IltChunkClap.ClapPartOf(0, Co, 1), IltChunkClap.ClapPart.None, "no WCID yet: a Coalesced piece's colour is unknown");
|
||||
Check.Eq(IltChunkClap.ClapPartOf(273, "Pyreal", 0), IltChunkClap.ClapPart.None, "anything else");
|
||||
|
||||
var R = IltChunkClap.ClapPart.Red; var B = IltChunkClap.ClapPart.Blue;
|
||||
var E = IltChunkClap.ClapPart.Empyrean; var F = IltChunkClap.ClapPart.Falatacot;
|
||||
Check.True(IltChunkClap.CanClap(new[] { R, E }), "red + Empyrean");
|
||||
Check.True(IltChunkClap.CanClap(new[] { B, F }), "blue + Falatacot");
|
||||
Check.False(IltChunkClap.CanClap(new[] { R, F }), "red needs Empyrean, not Falatacot");
|
||||
Check.False(IltChunkClap.CanClap(new[] { B, E }), "blue needs Falatacot, not Empyrean");
|
||||
Check.False(IltChunkClap.CanClap(new[] { E, F }), "trinkets alone");
|
||||
Check.False(IltChunkClap.CanClap(new[] { R, B }), "aetheria alone");
|
||||
Check.False(IltChunkClap.CanClap(System.Array.Empty<IltChunkClap.ClapPart>()), "nothing carried");
|
||||
}
|
||||
|
||||
private static void Cap()
|
||||
|
|
@ -39,4 +243,35 @@ internal static class AetheriaChunkTests
|
|||
g.KeepAetheriaWithCritDamageResist = false;
|
||||
Check.False(IltChunkClap.KeptForRatings(g, 3, 3, 3), "every switch off: ratings don't protect");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The rating level: a C / CD / CDR rating at or above it keeps the piece, a lower one chunks
|
||||
/// (if the level cap allows). The default of 1 keeps any rating, as before.
|
||||
/// </summary>
|
||||
private static void RatingLevel()
|
||||
{
|
||||
var g = new IltGearState();
|
||||
Check.Eq(g.KeepAetheriaRatingAtLeast, 1, "default: any rating keeps");
|
||||
Check.True(IltChunkClap.KeptForRatings(g, 1, 0, 0), "C 1 kept at the default");
|
||||
|
||||
g.KeepAetheriaRatingAtLeast = 2;
|
||||
Check.False(IltChunkClap.KeptForRatings(g, 1, 0, 0), "C 1 below level 2: chunks");
|
||||
Check.True(IltChunkClap.KeptForRatings(g, 2, 0, 0), "C 2 at level 2: kept");
|
||||
Check.True(IltChunkClap.KeptForRatings(g, 3, 0, 0), "C 3 above level 2: kept");
|
||||
Check.True(IltChunkClap.KeptForRatings(g, 1, 0, 2), "CDR 2 keeps a C 1 + CDR 2 piece");
|
||||
Check.False(IltChunkClap.KeptForRatings(g, 1, 1, 1), "every rating below the level: chunks");
|
||||
|
||||
g.KeepAetheriaWithCrit = false;
|
||||
Check.False(IltChunkClap.KeptForRatings(g, 5, 0, 0), "a switch that is off ignores the level");
|
||||
|
||||
Check.Eq(IltChunkClap.ClampRatingLevel(0), 1, "below 1 clamps to 1");
|
||||
Check.Eq(IltChunkClap.ClampRatingLevel(99), IltChunkClap.MaxRatingLevel, "clamped to the maximum");
|
||||
|
||||
var coalescedC1 = PlainCoalesced with { Crit = 1 };
|
||||
var level2 = new IltGearState { KeepAetheriaRatingAtLeast = 2 };
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(level2, coalescedC1), null, "an unlevelled C 1 Coalesced piece chunks at rating level 2");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(level2, PlainCoalesced with { Crit = 2 }), "kept for its C / CD / CDR rating", "a C 2 one is kept");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(level2, coalescedC1 with { MaxLevel = 6 }), "level at or above the cap",
|
||||
"a low rating does not override the level cap");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ internal static class AttributeRaiserTests
|
|||
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 refresh: a probe that left Current empty retries /aug once; a click during the probe runs after it", AugProbeRetry);
|
||||
r.Add("aug lines: separators in the level (4,300 / 4.300 / 4 300 / 4'300) and trailing notes read", AugLineValues);
|
||||
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);
|
||||
}
|
||||
|
|
@ -225,6 +227,63 @@ internal static class AttributeRaiserTests
|
|||
}), "Current updates once Creature:/Item: lines arrive");
|
||||
}
|
||||
|
||||
// Silentkelpie (PR #12): the login probe could end on the banner alone (chat-hold backlog) and leave
|
||||
// Current empty with nothing to retry it; a Refresh current click during the probe was dropped.
|
||||
private static void AugProbeRetry()
|
||||
{
|
||||
var hub = NewHub("InfiniteLeaftide", new IltSettings(), "aug-probe-retry", out _);
|
||||
var prog = hub.Progression;
|
||||
|
||||
// Probe reply: the banner and no level lines. The tap runs ApplyAugLines then AfterExternalAugCapture.
|
||||
prog.ApplyAugLines(new List<string> { "---------------------------", "Advanced Augmentation Levels:" });
|
||||
prog.AfterExternalAugCapture();
|
||||
Check.True(TickUntil(hub, () => FakeHost.ChatCommands.Contains("/aug")), "Current still empty: /aug is sent again");
|
||||
prog.AfterExternalAugCapture(); // the retry is in flight, and was the one retry
|
||||
prog.ApplyAugLines(new List<string> { "Advanced Augmentation Levels:" });
|
||||
prog.AfterExternalAugCapture();
|
||||
for (int i = 0; i < 20; i++) { hub.Tick(); Thread.Sleep(25); }
|
||||
Check.Eq(FakeHost.ChatCommands.Count(x => x == "/aug"), 1, "only one retry");
|
||||
|
||||
Reply(hub, "Creature:4,300", "Item:100");
|
||||
Check.True(TickUntil(hub, () =>
|
||||
{
|
||||
var sb = new System.Text.StringBuilder();
|
||||
prog.AppendSnapshotJson(sb);
|
||||
return sb.ToString().Contains("\"cur\":4300", StringComparison.Ordinal);
|
||||
}), "the retry's level lines fill Current");
|
||||
|
||||
// A probe with levels needs no retry.
|
||||
var hub2 = NewHub("InfiniteLeaftide", new IltSettings(), "aug-probe-ok", out _);
|
||||
hub2.Progression.ApplyAugLines(new List<string> { "Creature: 12" });
|
||||
hub2.Progression.AfterExternalAugCapture();
|
||||
for (int i = 0; i < 20; i++) { hub2.Tick(); Thread.Sleep(25); }
|
||||
Check.Eq(FakeHost.ChatCommands.Count(x => x == "/aug"), 0, "levels present: no retry");
|
||||
}
|
||||
|
||||
private static void AugLineValues()
|
||||
{
|
||||
Check.True(IltParse.AugLine.IsMatch("Creature:4,300") && IltParse.AugLine.IsMatch("Creature: 4.300")
|
||||
&& IltParse.AugLine.IsMatch("Creature: 4 300") && IltParse.AugLine.IsMatch("Creature: 4'300"), "the regex matches each grouping");
|
||||
Check.False(IltParse.AugLine.IsMatch("Creature: none") || IltParse.AugLine.IsMatch("Advanced Augmentation Levels:"), "and not a line with no number");
|
||||
Check.Eq(IltParse.ParseAugValue(IltParse.AugLine.Match("Creature:4,300").Groups[2].Value), 4300L, "comma");
|
||||
Check.Eq(IltParse.ParseAugValue(IltParse.AugLine.Match("Creature: 4.300").Groups[2].Value), 4300L, "period");
|
||||
Check.Eq(IltParse.ParseAugValue(IltParse.AugLine.Match("Creature: 4 300").Groups[2].Value), 4300L, "space");
|
||||
Check.Eq(IltParse.ParseAugValue(IltParse.AugLine.Match("Creature: 4'300").Groups[2].Value), 4300L, "apostrophe");
|
||||
Check.Eq(IltParse.ParseAugValue(IltParse.AugLine.Match("Creature: 1,234,567").Groups[2].Value), 1234567L, "two groups");
|
||||
Check.Eq(IltParse.ParseAugValue(IltParse.AugLine.Match("Duration: 5 (adds 3)").Groups[2].Value), 5L, "a trailing note");
|
||||
Check.Eq(IltParse.ParseAugValue(IltParse.AugLine.Match("Specialize: 2").Groups[2].Value), 2L, "plain");
|
||||
Check.Eq(IltParse.ParseAugValue(IltParse.AugLine.Match("Item: 2750").Groups[2].Value), 2750L, "no separator");
|
||||
Check.Eq(IltParse.ParseAugValue(""), 0L, "empty");
|
||||
|
||||
var hub = NewHub("InfiniteLeaftide", new IltSettings(), "aug-values", out _);
|
||||
hub.Progression.ApplyAugLines(new List<string> { "Creature: 2 750", "Item: 1.200", "Life: 300" });
|
||||
var sb = new System.Text.StringBuilder();
|
||||
hub.Progression.AppendSnapshotJson(sb);
|
||||
string snap = sb.ToString();
|
||||
Check.True(snap.Contains("\"cur\":2750", StringComparison.Ordinal) && snap.Contains("\"cur\":1200", StringComparison.Ordinal)
|
||||
&& snap.Contains("\"cur\":300", StringComparison.Ordinal), "the planner takes the grouped levels whole");
|
||||
}
|
||||
|
||||
private static void Patterns()
|
||||
{
|
||||
Check.True(ServerFeatureGate.Matches("InfiniteLeaftide", "InfiniteLeaftide"), "exact");
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ internal static class BankCommandTests
|
|||
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);
|
||||
r.Add("bank: only the balance dump is backstop-eaten, and only just after a quiet refresh", LeakedDump);
|
||||
}
|
||||
|
||||
private static int TransferIndex(string code) =>
|
||||
|
|
@ -117,4 +118,29 @@ internal static class BankCommandTests
|
|||
Check.False(IltBankCommands.IsActionReply("Bob tells you, \"Deposited 5 pyreals\""), "a tell is not");
|
||||
Check.False(IltBankCommands.IsActionReply(""), "empty");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SilentKelpie's backstop for a quiet refresh whose reply leaked into chat, narrowed: the dump's
|
||||
/// header and "Label: N" lines only, never errors, bound-coin notes or Transferred / Received lines,
|
||||
/// and never a balance read outside the window after a quiet refresh (a macro's or plugin's /bank).
|
||||
/// </summary>
|
||||
private static void LeakedDump()
|
||||
{
|
||||
Check.True(IltBanking.IsBalanceDumpLine("[BANK] Your balances are:"), "header");
|
||||
Check.True(IltBanking.IsBalanceDumpLine("[BANK] Pyreals: 1,000"), "pyreals");
|
||||
Check.True(IltBanking.IsBalanceDumpLine("[BANK] Luminance: 2,500,000"), "luminance");
|
||||
Check.True(IltBanking.IsBalanceDumpLine("[BANK] Weakly Enlightened Coins: 3"), "weakly enlightened coins");
|
||||
Check.True(IltBanking.IsBalanceDumpLine("[BANK] Prestige Coins: 2 (bound to you and cannot be traded)"), "prestige coins");
|
||||
Check.False(IltBanking.IsBalanceDumpLine("[BANK] Too many parameters"), "an error");
|
||||
Check.False(IltBanking.IsBalanceDumpLine("[BANK] Prestige Coins are bound to you and cannot be transferred."), "the bound-coin note");
|
||||
Check.False(IltBanking.IsBalanceDumpLine("Transferred 1,000,000 Pyreals to Bob"), "a transfer reply");
|
||||
Check.False(IltBanking.IsBalanceDumpLine("Received 5 Pyreals from Bob"), "a received line");
|
||||
Check.False(IltBanking.IsBalanceDumpLine("Bob tells you, \"[BANK] Pyreals: 5\""), "a tell quoting a dump");
|
||||
|
||||
const long Win = IltBanking.QuietBalanceWindowMs;
|
||||
Check.True(IltBanking.EatLeakedDump(true, 1_000, 1_000 + Win), "a dump line inside the window is eaten");
|
||||
Check.False(IltBanking.EatLeakedDump(true, 1_000 + Win + 1, 1_000 + Win), "after the window it shows (a macro's /bank)");
|
||||
Check.False(IltBanking.EatLeakedDump(true, 1_000, 0), "no quiet refresh out: it shows (typed /bank, loud refresh, other plugins)");
|
||||
Check.False(IltBanking.EatLeakedDump(false, 1_000, 1_000 + Win), "a non-dump [BANK] line inside the window still shows");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
173
Tools/RynthILT.Tests/ChunkTargetTests.cs
Normal file
173
Tools/RynthILT.Tests/ChunkTargetTests.cs
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using RynthCore.Plugin.RynthILT.Hub;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthILT.Tests;
|
||||
|
||||
// The chunk rules end to end: a fake inventory with the Lugian Aetheria Hammer and one candidate,
|
||||
// IltChunkClap.Tick, and whether the hammer was used on the candidate. These cover what the pure
|
||||
// rule tests (AetheriaChunkTests) cannot: the properties as RynthILT reads them from the host, an
|
||||
// item that is not appraised, and a host that cannot tell whether an appraisal arrived. The hammer
|
||||
// destroys what it is used on, so "used on it" is the thing to get right.
|
||||
internal static class ChunkTargetTests
|
||||
{
|
||||
private const uint Player = 0x50000F01;
|
||||
private const uint Hammer = 0x5000A001;
|
||||
private const uint Item = 0x5000A002;
|
||||
private const uint ItemTypeGem = 0x00000800;
|
||||
private const uint ItemTypeMelee = 0x00000001;
|
||||
private const uint ItemTypeMisc = 0x00000080;
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("chunk (live path): unlevelled Coalesced chunks only when its level was truly read as none", UnlevelledVsUnreadable);
|
||||
r.Add("chunk (live path): levelled Coalesced Aetheria obeys the cap; other aetheria needs a level", LevelledCap);
|
||||
r.Add("chunk (live path): corrupted two-handed cleave 2 chunks, other corrupted cleave 2 does not", CorruptedCleave);
|
||||
r.Add("chunk (live path): corrupted keep rules and the rating level are off by default and protect when on", KeepRulesLive);
|
||||
r.Add("chunk (live path): a busy client in combat chunks with chunk-in-combat on, not off; peace waits for idle", CombatBusy);
|
||||
}
|
||||
|
||||
/// <summary>One chunk pass on a fake pack. Returns the targets the hammer was used on.</summary>
|
||||
private static List<uint> Pass(string folder, Action<IltGearState> settings, Action<uint> candidate,
|
||||
uint itemType = ItemTypeGem, string name = "Coalesced Aetheria", bool appraised = true,
|
||||
bool hostCanSayAppraised = true, bool busy = false, int combatMode = 1)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.WorldName = "InfiniteLeaftide";
|
||||
FakeHost.ContentsCalls = true;
|
||||
FakeHost.UseOnCalls = true;
|
||||
FakeHost.WeaponCalls = hostCanSayAppraised; // installs HasAppraisalData / RequestId / combat mode
|
||||
FakeHost.BusyCalls = true;
|
||||
FakeHost.BusyStateValue = busy ? 1 : 0;
|
||||
FakeHost.CombatModeValue = combatMode;
|
||||
FakeHost.Names[Hammer] = "Lugian Aetheria Hammer"; FakeHost.ItemTypes[Hammer] = ItemTypeMisc; FakeHost.Containers[Hammer] = Player;
|
||||
FakeHost.Names[Item] = name; FakeHost.ItemTypes[Item] = itemType; FakeHost.Containers[Item] = Player;
|
||||
if (appraised) FakeHost.Appraised.Add(Item);
|
||||
candidate(Item);
|
||||
var host = FakeHost.Create(Player);
|
||||
string dir = Path.Combine(Program.TempRoot, "chunk-" + folder);
|
||||
Directory.CreateDirectory(dir);
|
||||
var hub = new IltHubController(host, dir, new IltSettings(), new RynthAiClient(host));
|
||||
var g = hub.State.Gear;
|
||||
g.AutoChunkAetheria = true;
|
||||
g.AutoChunkCorrupted = true;
|
||||
settings(g);
|
||||
hub.Gear.ChunkClap.Tick(10_000);
|
||||
return FakeHost.UsesOn.Where(u => u.Source == Hammer).Select(u => u.Target).ToList();
|
||||
}
|
||||
|
||||
private static void Ints(uint id, params (uint Key, int Value)[] values)
|
||||
{
|
||||
foreach (var (k, v) in values) FakeHost.Ints[(id, k)] = v;
|
||||
}
|
||||
|
||||
private static void UnlevelledVsUnreadable()
|
||||
{
|
||||
// Truly unlevelled: the appraisal arrived and the item has no level (int 319), no XP, no tinks.
|
||||
Check.Eq(Pass("coal-unlevelled", _ => { }, _ => { }).Count, 1, "appraised, no level: chunked (ub-IT)");
|
||||
// Even with the cap at its lowest.
|
||||
Check.Eq(Pass("coal-unlevelled-cap1", g => g.ChunkAetheriaUnderLevel = 1, _ => { }).Count, 1, "cap 1 does not stop an unlevelled one");
|
||||
// Not appraised yet: nothing is known, so it is asked for, not hammered.
|
||||
var asked = Pass("coal-unappraised", _ => { }, _ => { }, appraised: false);
|
||||
Check.Eq(asked.Count, 0, "not appraised: not chunked");
|
||||
Check.True(FakeHost.IdRequests.Contains(Item), "its appraisal is requested");
|
||||
// The host cannot say whether an appraisal arrived: a level of 0 might be a failed read.
|
||||
Check.Eq(Pass("coal-unreadable", _ => { }, _ => { }, hostCanSayAppraised: false).Count, 0,
|
||||
"host cannot confirm the appraisal: kept, not chunked");
|
||||
// The same unconfirmable host with a read level still keeps (no half-trusted piece is hammered).
|
||||
Check.Eq(Pass("coal-unreadable-lvl", _ => { }, id => Ints(id, (IltInventory.IntItemMaxLevel, 2)), hostCanSayAppraised: false).Count, 0,
|
||||
"host cannot confirm the appraisal: even a read level 2 is kept");
|
||||
// A revealed (non-Coalesced) aetheria with no level is never chunked.
|
||||
Check.Eq(Pass("rev-unlevelled", _ => { }, _ => { }, name: "Blue Aetheria").Count, 0, "revealed aetheria with no level: kept");
|
||||
// Item XP, tinks or the never-chunk flag keep it.
|
||||
Check.Eq(Pass("coal-xp", _ => { }, id => FakeHost.Quads[(id, IltInventory.QuadItemTotalXp)] = 500).Count, 0, "has item XP: kept");
|
||||
Check.Eq(Pass("coal-tinked", _ => { }, id => Ints(id, (IltInventory.IntNumTimesTinkered, 1))).Count, 0, "tinkered: kept");
|
||||
Check.Eq(Pass("coal-never", _ => { }, id => FakeHost.Bools[(id, IltInventory.BoolNeverChunk)] = true).Count, 0, "never-chunk flag: kept");
|
||||
}
|
||||
|
||||
private static void LevelledCap()
|
||||
{
|
||||
Check.Eq(Pass("cap-l3", _ => { }, id => Ints(id, (IltInventory.IntItemMaxLevel, 3))).Count, 1, "level 3 under the default cap of 4");
|
||||
Check.Eq(Pass("cap-l4", _ => { }, id => Ints(id, (IltInventory.IntItemMaxLevel, 4))).Count, 0, "level 4 at the default cap of 4: kept");
|
||||
Check.Eq(Pass("cap9-l8", g => g.ChunkAetheriaUnderLevel = 9, id => Ints(id, (IltInventory.IntItemMaxLevel, 8))).Count, 1, "level 8 under a cap of 9");
|
||||
Check.Eq(Pass("cap9-l9", g => g.ChunkAetheriaUnderLevel = 9, id => Ints(id, (IltInventory.IntItemMaxLevel, 9))).Count, 0, "level 9 at a cap of 9: kept");
|
||||
Check.Eq(Pass("cap9-l10", g => g.ChunkAetheriaUnderLevel = 9, id => Ints(id, (IltInventory.IntItemMaxLevel, 10))).Count, 0, "level 10 over a cap of 9: kept");
|
||||
Check.Eq(Pass("cap11-l10", g => g.ChunkAetheriaUnderLevel = 11, id => Ints(id, (IltInventory.IntItemMaxLevel, 10))).Count, 1, "cap 11 chunks every level");
|
||||
Check.Eq(Pass("rev-l2", _ => { }, id => Ints(id, (IltInventory.IntItemMaxLevel, 2)), name: "Blue Aetheria").Count, 1, "a levelled revealed piece under the cap");
|
||||
}
|
||||
|
||||
private static void CorruptedCleave()
|
||||
{
|
||||
void Weapon(uint id, int cleave, int wieldSkill = 45, int weaponType = 0, int attackType = 4) =>
|
||||
Ints(id, (IltInventory.IntItemWorkmanship, 6), (IltInventory.IntCleaving, cleave), (IltInventory.IntWieldSkillType, wieldSkill),
|
||||
(IltInventory.IntWeaponType, weaponType), (IltInventory.IntAttackType, attackType));
|
||||
Check.Eq(Pass("cor-1h-c1", _ => { }, id => Weapon(id, 1), ItemTypeMelee, "Corrupted Sword").Count, 1, "one-handed cleave 1 chunks");
|
||||
Check.Eq(Pass("cor-1h-c2", _ => { }, id => Weapon(id, 2), ItemTypeMelee, "Corrupted Sword").Count, 0, "one-handed cleave 2 is kept");
|
||||
Check.Eq(Pass("cor-2h-c2", _ => { }, id => Weapon(id, 2, wieldSkill: 41), ItemTypeMelee, "Corrupted Greatsword").Count, 1, "two-handed cleave 2 chunks");
|
||||
Check.Eq(Pass("cor-2h-c3", _ => { }, id => Weapon(id, 3, wieldSkill: 41), ItemTypeMelee, "Corrupted Greatsword").Count, 0, "two-handed cleave 3 is kept");
|
||||
Check.Eq(Pass("cor-2h-thrust", _ => { }, id => Weapon(id, 2, wieldSkill: 41, attackType: 2), ItemTypeMelee, "Corrupted Spear").Count, 0, "two-handed thrust cleave 2 is kept");
|
||||
Check.Eq(Pass("cor-nowork", _ => { }, id => Ints(id, (IltInventory.IntCleaving, 1)), ItemTypeMelee, "Corrupted Sword").Count, 0, "no workmanship read: kept");
|
||||
Check.Eq(Pass("cor-unreadable", _ => { }, id => Weapon(id, 1), ItemTypeMelee, "Corrupted Sword", hostCanSayAppraised: false).Count, 0,
|
||||
"host cannot confirm the appraisal: kept");
|
||||
Check.Eq(Pass("cor-off", g => g.AutoChunkCorrupted = false, id => Weapon(id, 1), ItemTypeMelee, "Corrupted Sword").Count, 0, "auto-chunk corrupted off: not touched");
|
||||
}
|
||||
|
||||
private static void KeepRulesLive()
|
||||
{
|
||||
var def = new IltGearState();
|
||||
Check.True(!def.KeepCorruptedCrushingBlow && !def.KeepCorruptedBitingStrike && !def.KeepCorruptedArmorCleaving
|
||||
&& !def.KeepCorruptedAnySlayer && !def.KeepCorruptedMultiStrike && !def.KeepCorruptedElementalBonus
|
||||
&& !def.KeepCorruptedAnySpell && def.KeepCorruptedMaxDamageAtLeast == 0 && def.KeepCorruptedSpellIds == "",
|
||||
"every corrupted keep rule is off by default");
|
||||
Check.Eq(def.KeepAetheriaRatingAtLeast, 1, "the rating level defaults to 1 (any rating keeps, as before)");
|
||||
|
||||
void Loaded(uint id)
|
||||
{
|
||||
Ints(id, (IltInventory.IntItemWorkmanship, 6), (IltInventory.IntCleaving, 1), (IltInventory.IntAttackType, 160),
|
||||
(IltInventory.IntSlayerCreatureType, 5), (IltInventory.IntElementalDamageBonus, 10), (IltInventory.IntDamage, 400));
|
||||
FakeHost.Doubles[(id, IltInventory.FloatCriticalFrequency)] = 0.1;
|
||||
FakeHost.Doubles[(id, IltInventory.FloatCriticalMultiplier)] = 1.5;
|
||||
FakeHost.Doubles[(id, IltInventory.FloatIgnoreArmor)] = 0.2;
|
||||
FakeHost.SpellIds[id] = new uint[] { 2072 };
|
||||
}
|
||||
int Run(string tag, Action<IltGearState> s) => Pass("keep-" + tag, s, Loaded, ItemTypeMelee, "Corrupted Sword").Count;
|
||||
Check.Eq(Run("none", _ => { }), 1, "a loaded corrupted weapon chunks while every keep rule is off");
|
||||
Check.Eq(Run("crush", g => g.KeepCorruptedCrushingBlow = true), 0, "Crushing Blow on: kept");
|
||||
Check.Eq(Run("bite", g => g.KeepCorruptedBitingStrike = true), 0, "Biting Strike on: kept");
|
||||
Check.Eq(Run("armor", g => g.KeepCorruptedArmorCleaving = true), 0, "Armor Cleaving on: kept");
|
||||
Check.Eq(Run("slayer", g => g.KeepCorruptedAnySlayer = true), 0, "slayer on: kept");
|
||||
Check.Eq(Run("multi", g => g.KeepCorruptedMultiStrike = true), 0, "multi-strike on: kept");
|
||||
Check.Eq(Run("elem", g => g.KeepCorruptedElementalBonus = true), 0, "elemental bonus on: kept");
|
||||
Check.Eq(Run("maxdmg", g => g.KeepCorruptedMaxDamageAtLeast = 400), 0, "max damage 400 on: kept");
|
||||
Check.Eq(Run("maxdmg-hi", g => g.KeepCorruptedMaxDamageAtLeast = 401), 1, "max damage above the weapon's: chunks");
|
||||
Check.Eq(Run("spell", g => g.KeepCorruptedAnySpell = true), 0, "any spell on: kept");
|
||||
Check.Eq(Run("spellid", g => g.KeepCorruptedSpellIds = "2072"), 0, "a listed spell id: kept");
|
||||
Check.Eq(Run("spellid-other", g => g.KeepCorruptedSpellIds = "100"), 1, "another spell id: chunks");
|
||||
|
||||
// The rating level on a live Coalesced piece with a C 1 rating.
|
||||
void C1(uint id) => Ints(id, (IltInventory.IntGearCrit, 1));
|
||||
Check.Eq(Pass("rate-default", _ => { }, C1).Count, 0, "C 1 is kept at the default rating level");
|
||||
Check.Eq(Pass("rate-2", g => g.KeepAetheriaRatingAtLeast = 2, C1).Count, 1, "C 1 chunks once the rating level is 2");
|
||||
Check.Eq(Pass("rate-2-c2", g => g.KeepAetheriaRatingAtLeast = 2, id => Ints(id, (IltInventory.IntGearCrit, 2))).Count, 0, "C 2 is kept at level 2");
|
||||
Check.Eq(Pass("rate-2-off", g => { g.KeepAetheriaRatingAtLeast = 2; g.KeepAetheriaWithCrit = false; }, id => Ints(id, (IltInventory.IntGearCrit, 5))).Count, 1,
|
||||
"the C switch off ignores the rating level");
|
||||
}
|
||||
|
||||
private static void CombatBusy()
|
||||
{
|
||||
Check.Eq(Pass("busy-combat-on", g => g.ChunkInCombat = true, _ => { }, busy: true, combatMode: 2).Count, 1,
|
||||
"busy in combat mode with chunk-in-combat on: chunks");
|
||||
Check.Eq(Pass("busy-combat-off", g => g.ChunkInCombat = false, _ => { }, busy: true, combatMode: 2).Count, 0,
|
||||
"busy in combat mode with chunk-in-combat off: waits");
|
||||
Check.Eq(Pass("idle-combat-on", g => g.ChunkInCombat = true, _ => { }, busy: false, combatMode: 2).Count, 1,
|
||||
"idle in combat mode with chunk-in-combat on: chunks");
|
||||
Check.Eq(Pass("busy-peace", g => g.ChunkInCombat = true, _ => { }, busy: true, combatMode: 1).Count, 0,
|
||||
"busy in peace mode waits for idle even with chunk-in-combat on");
|
||||
Check.Eq(Pass("idle-peace", g => g.ChunkInCombat = false, _ => { }, busy: false, combatMode: 1).Count, 1,
|
||||
"idle in peace mode chunks");
|
||||
}
|
||||
}
|
||||
|
|
@ -367,9 +367,13 @@ internal static class MoveTests
|
|||
Check.Eq(sizeof(RynthIltHubApiV1), 8 + 9 * IntPtr.Size, "RynthIltHubApiV1: header + 9 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");
|
||||
// VaultedDungeonsEnabled was appended (2026-10-18): the Vaulted Dungeons master switch.
|
||||
Check.Eq(sizeof(RynthAiHubApiV1), 8 + 12 * IntPtr.Size, "RynthAiHubApiV1: header + 12 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(RynthAiHubApiV1.VaultedDungeonsEnabledOffset, 8 + 11 * IntPtr.Size, "VaultedDungeonsEnabled right after SessionStatsMore");
|
||||
Check.Eq((int)Marshal.OffsetOf<RynthAiHubApiV1>(nameof(RynthAiHubApiV1.VaultedDungeonsEnabled)), RynthAiHubApiV1.VaultedDungeonsEnabledOffset,
|
||||
"VaultedDungeonsEnabledOffset is where the field really is");
|
||||
Check.Eq(sizeof(QuestFlagV1), 24, "QuestFlagV1");
|
||||
Check.Eq(sizeof(QuestStatusV1), 16, "QuestStatusV1");
|
||||
Check.Eq(RynthIltHubApiV1.InterfaceName, "RynthILT.Hub", "interface name");
|
||||
|
|
@ -437,8 +441,10 @@ internal static class MoveTests
|
|||
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.True(IltSections.MovedCommand(IltSection.VaultedDungeons) == null && IltSections.IsTab(IltSection.VaultedDungeons),
|
||||
"Vaulted Dungeons is a RynthILT tab (shown only with the master switch, VaultedDungeonsTests)");
|
||||
Check.True(IltSections.Tabs.SequenceEqual(new[] { IltSection.Banking, IltSection.Gear, IltSection.Charms, IltSection.Games, IltSection.VaultedDungeons }),
|
||||
"the tab list is Banking, Gear, Charms, Games, Vaulted Dungeons");
|
||||
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");
|
||||
|
|
|
|||
|
|
@ -45,7 +45,9 @@ internal static class Program
|
|||
IltSettingsTests.Register(runner);
|
||||
FellowshipCommandTests.Register(runner);
|
||||
AetheriaChunkTests.Register(runner);
|
||||
ChunkTargetTests.Register(runner);
|
||||
RingChainTests.Register(runner);
|
||||
VaultedDungeonsTests.Register(runner);
|
||||
// Before DataApiTests: its last test releases the RynthILT.Data table, which the breeding version test queries.
|
||||
BreedingTests.Register(runner);
|
||||
DataApiTests.Register(runner);
|
||||
|
|
|
|||
527
Tools/RynthILT.Tests/VaultedDungeonsTests.cs
Normal file
527
Tools/RynthILT.Tests/VaultedDungeonsTests.cs
Normal file
|
|
@ -0,0 +1,527 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using RynthCore.Plugin.RynthILT.Hub;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.PluginSdk;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthILT.Tests;
|
||||
|
||||
// The Vaulted Dungeons keeper (Hub/IltVaultedDungeons.cs, Silentkelpie's, taken in with the owner's
|
||||
// safety rules): ILT only, a master switch (RynthAi's setting, off by default) that gates everything,
|
||||
// no resume of Active from the saved file, a recall that waits out combat / buffing, /rc quit once per
|
||||
// activation and never while gated, and a no-kill timer that restarts on kills and captures.
|
||||
// The clock, the master switch, RynthAi's activity and the gem use are the module's test seams.
|
||||
internal static class VaultedDungeonsTests
|
||||
{
|
||||
private const uint Player = 0x50000C01;
|
||||
private const uint Quarry = 0x01F7; // dungeon 1: Tyrant's Quarry
|
||||
private const uint Elsewhere = 0x0001;
|
||||
private const string Luminance = "You've banked 1,234 Luminance.";
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("vaulted: not an ILT world -> inert (no tick work, no recall, no quit, a 'not available' reply)", NotIlt);
|
||||
r.Add("vaulted: master off -> inert even with a saved Active, Auto Start and Kill Client", MasterOff);
|
||||
r.Add("vaulted: master on + explicit start -> recalls at 1 s then every 5 s outside, stops inside; a saved Active is not resumed", ExplicitStartRecalls);
|
||||
r.Add("vaulted: Auto Start On Arrival is honoured only with the master on", AutoStart);
|
||||
r.Add("vaulted: Kill Client fires once per activation and restarts on luminance, a killing blow and a capture", QuitOnceAndResets);
|
||||
r.Add("vaulted: Kill Client is never sent once the master goes off, even between the timer and the send", QuitNeverWhenGated);
|
||||
r.Add("vaulted: a busy bot (combat, buffing, server wait, client busy) defers the recall; the warning keeps its cadence", BusyDefers);
|
||||
r.Add("vaulted: turning the master off mid-run stops it at once and says so once; turning it on starts Off", MasterOffMidRun);
|
||||
r.Add("vaulted: the tab and /ra hub open vaulted follow ILT + the master; settings file format kept", TabAndFile);
|
||||
r.Add("vaulted: capture lines are the Pets tab's own success replies", CaptureLines);
|
||||
r.Add("vaulted: settings go through the source-generated JSON context (NativeAOT has no reflection serializer)", SourceGeneratedContext);
|
||||
}
|
||||
|
||||
// ── Rig ──────────────────────────────────────────────────────────────────
|
||||
|
||||
private sealed class Rig
|
||||
{
|
||||
public IltHubController Hub = null!;
|
||||
public IltVaultedDungeons V = null!;
|
||||
public string Dir = "";
|
||||
public long T = 1_000_000;
|
||||
public bool Master;
|
||||
public RynthAiActivity? Act = RynthAiActivity.None;
|
||||
public int MasterCalls, AllowCalls = int.MaxValue;
|
||||
public readonly List<string> GemsUsed = new();
|
||||
public bool HasGem = true;
|
||||
|
||||
public int Quits => FakeHost.ChatCommands.Count(c => c == "/rc quit");
|
||||
public int ChatCount(string part) => FakeHost.Chat.Count(c => c.Contains(part, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
public void Step(long ms) { T += ms; V.Tick(T); }
|
||||
public void Inside() => FakeHost.PlayerPose = ((Quarry << 16) | 0x0100u, 0, 0, 0);
|
||||
public void Outside() => FakeHost.PlayerPose = ((Elsewhere << 16) | 0x0100u, 0, 0, 0);
|
||||
public string SettingsFile => Path.Combine(Dir, "VaultedDungeons", "settings.json");
|
||||
public void WriteSettings(string json)
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(SettingsFile)!);
|
||||
File.WriteAllText(SettingsFile, json);
|
||||
}
|
||||
}
|
||||
|
||||
private static Rig NewRig(string world, string folder, bool master, bool busyCalls = false)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.WorldName = world;
|
||||
FakeHost.BusyCalls = busyCalls;
|
||||
var host = FakeHost.Create(Player);
|
||||
var rig = new Rig { Master = master, Dir = Path.Combine(Program.TempRoot, folder) };
|
||||
Directory.CreateDirectory(rig.Dir);
|
||||
rig.Hub = new IltHubController(host, rig.Dir, new IltSettings(), new RynthAiClient(host));
|
||||
rig.V = rig.Hub.VaultedDungeons;
|
||||
rig.V.Clock = () => rig.T;
|
||||
rig.V.MasterEnabled = () => { rig.MasterCalls++; return rig.Master && rig.MasterCalls <= rig.AllowCalls; };
|
||||
rig.V.Activity = () => rig.Act;
|
||||
rig.V.UseGem = name => { if (!rig.HasGem) return false; rig.GemsUsed.Add(name); return true; };
|
||||
rig.Outside();
|
||||
return rig;
|
||||
}
|
||||
|
||||
/// <summary>Dungeon 1 (Tyrant's Quarry), the primary gem, the given extras. "active": true is on disk to prove it is ignored.</summary>
|
||||
private static string Settings(string extras = "")
|
||||
=> "{ \"active\": true, \"dungeon\": 1, \"gem\": 1" + (extras.Length > 0 ? ", " + extras : "") + " }";
|
||||
|
||||
// ── ILT only ─────────────────────────────────────────────────────────────
|
||||
|
||||
private static void NotIlt()
|
||||
{
|
||||
var rig = NewRig("Aelrynth", "vd-notilt", master: true);
|
||||
rig.WriteSettings(Settings("\"autoStart\": true, \"quit\": true, \"quitMinutes\": 1"));
|
||||
string before = File.ReadAllText(rig.SettingsFile);
|
||||
|
||||
rig.Outside();
|
||||
for (int i = 0; i < 20; i++) rig.Step(1000);
|
||||
rig.Inside();
|
||||
for (int i = 0; i < 10; i++) rig.Step(30_000);
|
||||
Check.False(rig.V.IsActive, "not running on another world, though the master is on and Auto Start was saved");
|
||||
Check.Eq(rig.GemsUsed.Count, 0, "no recall gem");
|
||||
Check.Eq(rig.Quits, 0, "no /rc quit");
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 0, "no command of any kind (no /vt, /ub or /rc)");
|
||||
Check.Eq(rig.ChatCount("[Vaulted Dungeons]"), 0, "and not a word in chat");
|
||||
Check.Eq(File.ReadAllText(rig.SettingsFile), before, "the settings file wasn't even read or rewritten");
|
||||
|
||||
rig.V.HandleCommand(new[] { "on" });
|
||||
Check.False(rig.V.IsActive, "/ilt vaulted on is refused");
|
||||
Check.Eq(rig.ChatCount("Not available on this server"), 1, "with the 'not available on this server' reply");
|
||||
FakeHost.Chat.Clear();
|
||||
rig.V.HandleCommand(new[] { "status" });
|
||||
Check.Eq(rig.ChatCount("Not available on this server"), 1, "status says the same");
|
||||
Check.False(rig.Hub.TabShown(IltSection.VaultedDungeons), "no tab");
|
||||
Check.False(rig.Hub.SectionAvailable(IltSection.VaultedDungeons), "not available");
|
||||
|
||||
// The controller doesn't tick it either (and the module would refuse anyway).
|
||||
rig.Hub.Tick();
|
||||
Check.Eq(rig.GemsUsed.Count, 0, "the controller's tick does nothing here");
|
||||
}
|
||||
|
||||
// ── Master switch ────────────────────────────────────────────────────────
|
||||
|
||||
private static void MasterOff()
|
||||
{
|
||||
var rig = NewRig("InfiniteLeaftide", "vd-masteroff", master: false);
|
||||
rig.WriteSettings(Settings("\"autoStart\": true, \"quit\": true, \"quitMinutes\": 1, \"disableMeta\": true"));
|
||||
string before = File.ReadAllText(rig.SettingsFile);
|
||||
|
||||
rig.Outside();
|
||||
for (int i = 0; i < 20; i++) rig.Step(1000);
|
||||
rig.Inside();
|
||||
for (int i = 0; i < 10; i++) rig.Step(30_000); // five minutes inside: a one-minute Kill Client would have fired
|
||||
Check.False(rig.V.IsActive, "off: a saved Active and Auto Start start nothing");
|
||||
Check.Eq(rig.GemsUsed.Count, 0, "no recall gem");
|
||||
Check.Eq(rig.Quits, 0, "no /rc quit");
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 0, "no arrival commands (/vt opt set ...) either");
|
||||
Check.Eq(rig.ChatCount("[Vaulted Dungeons]"), 0, "silent");
|
||||
Check.Eq(File.ReadAllText(rig.SettingsFile), before, "settings untouched");
|
||||
Check.True(rig.Hub.Options.IsIltLikeWorld, "(it is an ILT world: the master switch is what holds it)");
|
||||
Check.False(rig.Hub.TabShown(IltSection.VaultedDungeons), "the tab is hidden");
|
||||
Check.False(rig.Hub.SectionAvailable(IltSection.VaultedDungeons), "and not available");
|
||||
|
||||
rig.V.HandleCommand(new[] { "on" });
|
||||
Check.False(rig.V.IsActive, "/ilt vaulted on is refused");
|
||||
Check.Eq(rig.ChatCount("Settings > Navigation"), 1, "and says where the switch is");
|
||||
rig.V.HandleCommand(new[] { "toggle" });
|
||||
Check.False(rig.V.IsActive, "toggle too");
|
||||
|
||||
// Through the controller, the real wiring: nothing either.
|
||||
for (int i = 0; i < 5; i++) rig.Hub.Tick();
|
||||
Check.Eq(rig.GemsUsed.Count, 0, "the controller's tick does nothing while off");
|
||||
|
||||
// The lines that restart the timer are ignored too (nothing is running).
|
||||
rig.V.OnChat(Luminance);
|
||||
rig.V.OnKillNotification();
|
||||
Check.Eq(rig.Quits, 0, "still nothing");
|
||||
}
|
||||
|
||||
// ── Recalls ──────────────────────────────────────────────────────────────
|
||||
|
||||
private static void ExplicitStartRecalls()
|
||||
{
|
||||
var rig = NewRig("InfiniteLeaftide", "vd-recall", master: true);
|
||||
rig.WriteSettings(Settings()); // "active": true on disk: ignored
|
||||
rig.Outside();
|
||||
rig.Step(0);
|
||||
Check.False(rig.V.IsActive, "a saved Active is not resumed after login");
|
||||
for (int i = 0; i < 10; i++) rig.Step(1000);
|
||||
Check.Eq(rig.GemsUsed.Count, 0, "so nothing is recalled until the player starts it");
|
||||
|
||||
rig.V.HandleCommand(new[] { "on" });
|
||||
Check.True(rig.V.IsActive, "an explicit start");
|
||||
rig.Step(0); // first tick outside: the clock starts
|
||||
rig.Step(500);
|
||||
Check.Eq(rig.GemsUsed.Count, 0, "0.5 s out: too early");
|
||||
rig.Step(500); // 1 s
|
||||
Check.Eq(rig.GemsUsed.Count, 1, "the first recall comes 1 s after leaving");
|
||||
Check.Eq(rig.GemsUsed[0], "Primary Portal Recall Gem", "the chosen gem");
|
||||
rig.Step(4000);
|
||||
Check.Eq(rig.GemsUsed.Count, 1, "4 s later: not yet");
|
||||
rig.Step(1000); // 5 s since the last use
|
||||
Check.Eq(rig.GemsUsed.Count, 2, "then every 5 s");
|
||||
rig.Step(5000);
|
||||
Check.Eq(rig.GemsUsed.Count, 3, "again");
|
||||
|
||||
rig.Inside();
|
||||
rig.Step(1000);
|
||||
for (int i = 0; i < 12; i++) rig.Step(1000);
|
||||
Check.Eq(rig.GemsUsed.Count, 3, "inside the dungeon: no more gems");
|
||||
|
||||
FakeHost.Portaling = true;
|
||||
rig.Outside();
|
||||
rig.Step(10_000);
|
||||
Check.Eq(rig.GemsUsed.Count, 3, "portal space: nothing used");
|
||||
FakeHost.Portaling = false;
|
||||
rig.Step(0);
|
||||
rig.Step(1000);
|
||||
Check.Eq(rig.GemsUsed.Count, 4, "out again: 1 s, then a recall");
|
||||
|
||||
rig.HasGem = false;
|
||||
rig.Step(5000);
|
||||
Check.Eq(rig.GemsUsed.Count, 4, "no gem in the pack: none used");
|
||||
Check.True(rig.ChatCount("No Primary Portal Recall Gem") >= 1, "and it says so");
|
||||
}
|
||||
|
||||
private static void AutoStart()
|
||||
{
|
||||
// Master on: arriving in the chosen dungeon switches it on, and the arrival commands go out.
|
||||
var on = NewRig("InfiniteLeaftide", "vd-auto-on", master: true);
|
||||
on.WriteSettings(Settings("\"autoStart\": true, \"disableMeta\": true"));
|
||||
on.Inside();
|
||||
on.Step(0);
|
||||
Check.True(on.V.IsActive, "Auto Start On Arrival switches the keeper on (master on)");
|
||||
Check.True(FakeHost.ChatCommands.Contains("/vt opt set EnableMeta False"), "and runs the arrival commands");
|
||||
|
||||
// Auto Start off, master on: a relog inside does not resume a saved Active.
|
||||
var manual = NewRig("InfiniteLeaftide", "vd-auto-off", master: true);
|
||||
manual.WriteSettings(Settings("\"disableMeta\": true"));
|
||||
manual.Inside();
|
||||
manual.Step(0);
|
||||
Check.False(manual.V.IsActive, "no Auto Start: not resumed");
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 0, "and the arrival commands wait for an Active keeper");
|
||||
|
||||
// Master off, Auto Start saved: nothing; then the master comes on while inside.
|
||||
var gated = NewRig("InfiniteLeaftide", "vd-auto-gated", master: false);
|
||||
gated.WriteSettings(Settings("\"autoStart\": true"));
|
||||
gated.Inside();
|
||||
gated.Step(0);
|
||||
Check.False(gated.V.IsActive, "master off: Auto Start does nothing");
|
||||
gated.Master = true;
|
||||
gated.Step(1000);
|
||||
Check.True(gated.V.IsActive, "with the master on, Auto Start (the player's own saved choice) applies");
|
||||
}
|
||||
|
||||
// ── Kill Client ──────────────────────────────────────────────────────────
|
||||
|
||||
private static Rig QuitRig(string folder, int minutes = 2)
|
||||
{
|
||||
var rig = NewRig("InfiniteLeaftide", folder, master: true);
|
||||
rig.WriteSettings(Settings("\"quit\": true, \"quitMinutes\": " + minutes));
|
||||
rig.Inside();
|
||||
rig.Step(0);
|
||||
rig.V.HandleCommand(new[] { "on" });
|
||||
rig.Step(0); // inside: the no-kill clock starts here
|
||||
return rig;
|
||||
}
|
||||
|
||||
private static void QuitOnceAndResets()
|
||||
{
|
||||
// Luminance line.
|
||||
var rig = QuitRig("vd-quit-lum");
|
||||
rig.Step(119_000);
|
||||
Check.Eq(rig.Quits, 0, "just under 2 minutes: no quit");
|
||||
rig.V.OnChat(Luminance);
|
||||
rig.Step(119_000);
|
||||
Check.Eq(rig.Quits, 0, "the luminance line restarted the timer");
|
||||
rig.Step(2_000);
|
||||
Check.Eq(rig.Quits, 1, "2 minutes after the last kill: /rc quit");
|
||||
for (int i = 0; i < 10; i++) rig.Step(60_000);
|
||||
Check.Eq(rig.Quits, 1, "and only once");
|
||||
// A kill after the quit went out doesn't arm a second one (once per activation).
|
||||
rig.V.OnChat(Luminance);
|
||||
for (int i = 0; i < 10; i++) rig.Step(60_000);
|
||||
Check.Eq(rig.Quits, 1, "still once");
|
||||
|
||||
// The player's own killing blow.
|
||||
rig = QuitRig("vd-quit-kill");
|
||||
rig.Step(110_000);
|
||||
rig.V.OnKillNotification();
|
||||
rig.Step(110_000);
|
||||
Check.Eq(rig.Quits, 0, "a killing blow restarted the timer");
|
||||
rig.Step(15_000);
|
||||
Check.Eq(rig.Quits, 1, "and it fires after the next idle stretch");
|
||||
|
||||
// A pet capture.
|
||||
rig = QuitRig("vd-quit-capture");
|
||||
rig.Step(110_000);
|
||||
rig.V.OnChat("You have successfully siphoned the essence of the Olthoi Warrior.");
|
||||
rig.Step(110_000);
|
||||
Check.Eq(rig.Quits, 0, "a capture restarted the timer");
|
||||
rig.V.OnChat("The echo resonates perfectly.");
|
||||
rig.Step(110_000);
|
||||
Check.Eq(rig.Quits, 0, "so does the other success reply");
|
||||
rig.Step(15_000);
|
||||
Check.Eq(rig.Quits, 1, "then it fires");
|
||||
|
||||
// Lines that are not kills don't restart it.
|
||||
rig = QuitRig("vd-quit-noise");
|
||||
rig.Step(110_000);
|
||||
rig.V.OnChat("You hit the Olthoi Warrior for 50 points of damage.");
|
||||
rig.V.OnChat("The essence is not ready yet.");
|
||||
rig.V.OnChat("Bob says, \"You've banked 5 Luminance.\""); // a player's chat, not the system line
|
||||
rig.Step(15_000);
|
||||
Check.Eq(rig.Quits, 1, "damage lines, a refused capture and someone else's chat don't count");
|
||||
|
||||
// The minutes are the player's setting: 1 minute here.
|
||||
rig = QuitRig("vd-quit-1m", minutes: 1);
|
||||
rig.Step(59_000);
|
||||
Check.Eq(rig.Quits, 0, "1 minute setting: not yet");
|
||||
rig.Step(2_000);
|
||||
Check.Eq(rig.Quits, 1, "fires at 1 minute");
|
||||
|
||||
// Off -> on again is a new activation: one more quit may be sent.
|
||||
rig.V.HandleCommand(new[] { "off" });
|
||||
rig.V.HandleCommand(new[] { "on" });
|
||||
rig.Step(0);
|
||||
rig.Step(61_000);
|
||||
Check.Eq(rig.Quits, 2, "a new activation gets its own single quit");
|
||||
}
|
||||
|
||||
private static void QuitNeverWhenGated()
|
||||
{
|
||||
// The master goes off, the timer would have fired: nothing is sent, and it stopped.
|
||||
var rig = QuitRig("vd-quit-gated");
|
||||
rig.Step(100_000);
|
||||
rig.Master = false;
|
||||
rig.Step(30_000);
|
||||
Check.Eq(rig.Quits, 0, "master off before the timer: no /rc quit");
|
||||
Check.False(rig.V.IsActive, "and the keeper is off");
|
||||
rig.Step(600_000);
|
||||
Check.Eq(rig.Quits, 0, "ever");
|
||||
|
||||
// The master goes off between the timer firing and the send (asked again right before sending).
|
||||
rig = QuitRig("vd-quit-race");
|
||||
rig.Step(100_000);
|
||||
rig.AllowCalls = rig.MasterCalls + 1; // true at the top of the next tick, false when it re-checks
|
||||
rig.Step(21_000); // the timer fires in this tick
|
||||
Check.Eq(rig.Quits, 0, "master off between the timer firing and the send: not sent");
|
||||
Check.False(rig.V.IsActive, "the keeper stopped");
|
||||
Check.Eq(rig.ChatCount("Stopped"), 1, "said once");
|
||||
|
||||
// Not an ILT world any more (the world name changes): same.
|
||||
rig = QuitRig("vd-quit-world");
|
||||
rig.Step(100_000);
|
||||
FakeHost.WorldName = "Aelrynth";
|
||||
rig.Step(30_000);
|
||||
Check.Eq(rig.Quits, 0, "world no longer ILT: no /rc quit");
|
||||
Check.False(rig.V.IsActive, "stopped");
|
||||
|
||||
// Not Active: the timer has nothing to do (the player turned it off).
|
||||
rig = QuitRig("vd-quit-off");
|
||||
rig.V.HandleCommand(new[] { "off" });
|
||||
for (int i = 0; i < 10; i++) rig.Step(60_000);
|
||||
Check.Eq(rig.Quits, 0, "Off: no quit");
|
||||
}
|
||||
|
||||
// ── Combat / buff guard ──────────────────────────────────────────────────
|
||||
|
||||
private static void BusyDefers()
|
||||
{
|
||||
var rig = NewRig("InfiniteLeaftide", "vd-busy", master: true, busyCalls: true);
|
||||
rig.WriteSettings(Settings());
|
||||
rig.Outside();
|
||||
rig.Step(0);
|
||||
rig.V.HandleCommand(new[] { "on" });
|
||||
rig.Act = RynthAiActivity.MacroRunning | RynthAiActivity.Combat;
|
||||
rig.Step(0);
|
||||
rig.Step(1000);
|
||||
rig.Step(4000);
|
||||
Check.Eq(rig.GemsUsed.Count, 0, "in combat: the recall is deferred");
|
||||
Check.Eq(rig.ChatCount("Waiting to use the Primary Portal Recall Gem"), 1, "and says why, once");
|
||||
rig.Step(20_000);
|
||||
Check.Eq(rig.ChatCount("Waiting to use"), 1, "no repeat inside the 30 s warning cadence");
|
||||
rig.Step(10_000);
|
||||
Check.Eq(rig.ChatCount("Waiting to use"), 2, "the warning comes again after 30 s");
|
||||
Check.Eq(rig.GemsUsed.Count, 0, "still nothing used");
|
||||
|
||||
rig.Act = RynthAiActivity.MacroRunning; // clear
|
||||
rig.Step(100);
|
||||
Check.Eq(rig.GemsUsed.Count, 1, "the first clear tick recalls (it was due all along)");
|
||||
|
||||
// Buffing, the server wait, looting, salvaging, crafting and RynthAi not answering all defer too.
|
||||
foreach (RynthAiActivity? busy in new RynthAiActivity?[]
|
||||
{ RynthAiActivity.Buffing, RynthAiActivity.ServerAction, RynthAiActivity.Looting, RynthAiActivity.Salvaging, RynthAiActivity.Crafting, null })
|
||||
{
|
||||
int before = rig.GemsUsed.Count;
|
||||
rig.Act = busy;
|
||||
rig.Step(6000);
|
||||
Check.Eq(rig.GemsUsed.Count, before, $"busy ({(busy.HasValue ? busy.Value.ToString() : "RynthAi not ready")}): deferred");
|
||||
rig.Act = RynthAiActivity.None;
|
||||
rig.Step(100);
|
||||
Check.Eq(rig.GemsUsed.Count, before + 1, "and used once it is clear");
|
||||
}
|
||||
|
||||
// The client's own busy hourglass.
|
||||
FakeHost.BusyStateValue = 1;
|
||||
int n = rig.GemsUsed.Count;
|
||||
rig.Step(6000);
|
||||
Check.Eq(rig.GemsUsed.Count, n, "the client is busy: deferred");
|
||||
FakeHost.BusyStateValue = 0;
|
||||
rig.Step(100);
|
||||
Check.Eq(rig.GemsUsed.Count, n + 1, "used when it clears");
|
||||
|
||||
// Busy never blocks the Kill Client (it is not a game action that can be lost).
|
||||
var q = NewRig("InfiniteLeaftide", "vd-busy-quit", master: true);
|
||||
q.WriteSettings(Settings("\"quit\": true, \"quitMinutes\": 1"));
|
||||
q.Inside();
|
||||
q.Step(0);
|
||||
q.V.HandleCommand(new[] { "on" });
|
||||
q.Step(0);
|
||||
q.Act = RynthAiActivity.Combat;
|
||||
q.Step(61_000);
|
||||
Check.Eq(q.Quits, 1, "a busy bot still gets its Kill Client");
|
||||
}
|
||||
|
||||
// ── Master off mid-run ───────────────────────────────────────────────────
|
||||
|
||||
private static void MasterOffMidRun()
|
||||
{
|
||||
var rig = NewRig("InfiniteLeaftide", "vd-midrun", master: true);
|
||||
rig.WriteSettings(Settings("\"quit\": true, \"quitMinutes\": 1"));
|
||||
rig.Outside();
|
||||
rig.Step(0);
|
||||
rig.V.HandleCommand(new[] { "on" });
|
||||
rig.Step(0);
|
||||
rig.Step(1000);
|
||||
Check.Eq(rig.GemsUsed.Count, 1, "running: a recall went out");
|
||||
|
||||
rig.Master = false;
|
||||
rig.Step(10);
|
||||
Check.False(rig.V.IsActive, "the master went off: stopped on that very tick");
|
||||
Check.Eq(rig.ChatCount("Stopped"), 1, "and it said so");
|
||||
for (int i = 0; i < 20; i++) rig.Step(5000);
|
||||
Check.Eq(rig.GemsUsed.Count, 1, "no more recalls");
|
||||
Check.Eq(rig.ChatCount("Stopped"), 1, "and the notice wasn't repeated");
|
||||
Check.Eq(rig.Quits, 0, "no quit");
|
||||
|
||||
rig.Master = true;
|
||||
rig.Step(10);
|
||||
Check.False(rig.V.IsActive, "turned back on: it starts Off, nothing resumes by itself");
|
||||
rig.Step(10_000);
|
||||
Check.Eq(rig.GemsUsed.Count, 1, "nothing recalled");
|
||||
rig.V.HandleCommand(new[] { "on" });
|
||||
rig.Step(0);
|
||||
rig.Step(1000);
|
||||
Check.Eq(rig.GemsUsed.Count, 2, "until the player starts it again");
|
||||
|
||||
// The Mini Remote button path (posted to the pump) re-checks the switch as well.
|
||||
rig.V.HandleCommand(new[] { "off" });
|
||||
rig.Master = false;
|
||||
rig.Hub.Context.Post(() => rig.V.HandleCommand(new[] { "on" }));
|
||||
rig.Hub.Tick();
|
||||
Check.False(rig.V.IsActive, "an On click that lands after the switch went off is refused");
|
||||
}
|
||||
|
||||
// ── Tab, commands, file ──────────────────────────────────────────────────
|
||||
|
||||
private static void TabAndFile()
|
||||
{
|
||||
var rig = NewRig("InfiniteLeaftide", "vd-tab", master: true);
|
||||
Check.True(rig.Hub.TabShown(IltSection.VaultedDungeons), "ILT + master on: the tab is shown");
|
||||
Check.True(IltSections.Tabs.Contains(IltSection.VaultedDungeons), "it is one of the tab-bar tabs");
|
||||
Check.True(IltSections.IsTab(IltSection.VaultedDungeons), "a Mini Remote tab");
|
||||
Check.Eq(IltSections.TabId(IltSection.VaultedDungeons), "vaulted", "tab id");
|
||||
Check.True(IltSections.TryParse("vaulted", out var s) && s == IltSection.VaultedDungeons, "/ra hub open vaulted parses");
|
||||
Check.True(IltSections.TryParse("vaulted-dungeons", out s) && s == IltSection.VaultedDungeons, "and the long names");
|
||||
Check.True(RynthCore.Plugin.RynthILT.RynthILTPlugin.IsIltVerb(new[] { "hub", "open", "vaulted" }), "RynthILT takes '/ra hub open vaulted'");
|
||||
rig.Master = false;
|
||||
Check.False(rig.Hub.TabShown(IltSection.VaultedDungeons), "master off: hidden");
|
||||
|
||||
// The file: the format Silentkelpie's keeper wrote, kept. A start is saved.
|
||||
rig = NewRig("InfiniteLeaftide", "vd-file", master: true);
|
||||
rig.WriteSettings("""{ "dungeon": 3, "gem": 2, "quit": true, "quitMinutes": 7, "autoStart": false, "attackPower": 0.5 }""");
|
||||
rig.V.HandleCommand(new[] { "status" });
|
||||
Check.Eq(rig.ChatCount("dungeon=Wailing Cells, gem=Secondary Portal Recall Gem, kill-client=7m"), 1, "dungeon list and gem names as upstream");
|
||||
rig.V.HandleCommand(new[] { "on" });
|
||||
rig.Step(0);
|
||||
string saved = File.ReadAllText(rig.SettingsFile);
|
||||
Check.True(saved.Contains("\"active\": true") && saved.Contains("\"quitMinutes\": 7") && saved.Contains("\"dungeon\": 3"),
|
||||
"saved in the same camelCase layout");
|
||||
|
||||
// A new session (relog) reads it back with Active Off.
|
||||
var again = NewRig("InfiniteLeaftide", "vd-file", master: true);
|
||||
FakeHost.Chat.Clear();
|
||||
again.V.HandleCommand(new[] { "status" });
|
||||
Check.True(again.ChatCount("Off — dungeon=Wailing Cells") == 1 && !again.V.IsActive, "the next session starts Off, with the same choices");
|
||||
}
|
||||
|
||||
// The NativeAOT build (what ships) turns reflection-based System.Text.Json off, so the keeper's
|
||||
// settings must use IltVaultedDungeonsJsonContext. This project runs on the normal runtime where
|
||||
// reflection would still work, so assert the generated metadata exists and that the file layout
|
||||
// is what the context (not an options object) produces.
|
||||
private static void SourceGeneratedContext()
|
||||
{
|
||||
var ctx = IltVaultedDungeonsJsonContext.Default;
|
||||
Check.True(ctx.Cfg != null, "the context has metadata for the settings type (IltVaultedDungeonsJsonContext.Default.Cfg)");
|
||||
Check.True(ctx.GetTypeInfo(typeof(IltVaultedDungeons.Cfg)) != null, "and resolves it by type");
|
||||
|
||||
var cfg = new IltVaultedDungeons.Cfg
|
||||
{
|
||||
Active = true, Dungeon = 3, Gem = 2, Quit = true, QuitMinutes = 7, ShowInDungeon = true,
|
||||
AutoStart = true, DisableMeta = true, DisableNav = false, RepeatAttack = true, SetPower = true, AttackPower = 0.5f,
|
||||
};
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(cfg, ctx.Cfg);
|
||||
Check.True(json.Contains("\"active\": true") && json.Contains("\"quitMinutes\": 7") && json.Contains("\"attackPower\": 0.5"),
|
||||
"serializes indented with camelCase names");
|
||||
Check.True(json.Contains("\n"), "indented");
|
||||
|
||||
var back = System.Text.Json.JsonSerializer.Deserialize(json, ctx.Cfg);
|
||||
Check.True(back != null, "round-trips");
|
||||
Check.True(back!.Active && back.Dungeon == 3 && back.Gem == 2 && back.Quit && back.QuitMinutes == 7 && back.ShowInDungeon
|
||||
&& back.AutoStart && back.DisableMeta && !back.DisableNav && back.RepeatAttack && back.SetPower && back.AttackPower == 0.5f,
|
||||
"every field survives");
|
||||
|
||||
// The shape of the file Silentkelpie's keeper wrote (camelCase, partial) still reads.
|
||||
var upstream = System.Text.Json.JsonSerializer.Deserialize(
|
||||
"""{ "dungeon": 2, "gem": 1, "quit": true, "quitMinutes": 5 }""", ctx.Cfg);
|
||||
Check.True(upstream != null && upstream.Dungeon == 2 && upstream.Gem == 1 && upstream.Quit && upstream.QuitMinutes == 5 && !upstream.Active,
|
||||
"a partial upstream file reads, missing fields keep their defaults");
|
||||
|
||||
bool threw = false;
|
||||
try { System.Text.Json.JsonSerializer.Deserialize("{ not json", ctx.Cfg); } catch (System.Text.Json.JsonException) { threw = true; }
|
||||
Check.True(threw, "a corrupt file still throws, which the keeper's bad-file copy relies on");
|
||||
}
|
||||
|
||||
private static void CaptureLines()
|
||||
{
|
||||
Check.True(PetCaptureLines.IsSuccess("You have successfully siphoned the essence."), "siphoned");
|
||||
Check.True(PetCaptureLines.IsSuccess("The echo resonates perfectly."), "echo");
|
||||
Check.True(PetCaptureLines.IsSuccess("The essence is captured!"), "captured");
|
||||
Check.False(PetCaptureLines.IsSuccess("The creature is too strong to be siphoned."), "a refusal is not a success");
|
||||
Check.False(PetCaptureLines.IsSuccess("siphon failed"), "nor a failure");
|
||||
Check.False(PetCaptureLines.IsSuccess(""), "empty");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue