Snapshot for release 2026.10.31.1 (internal 69b244e)
This commit is contained in:
parent
8cb74c7685
commit
2546497f37
122 changed files with 22896 additions and 170 deletions
44
tools/HeadlessHostTests/TeleportTests.cs
Normal file
44
tools/HeadlessHostTests/TeleportTests.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
// ============================================================================
|
||||
// TeleportTests - a teleport drops the surroundings, as the retail client does (the captured session
|
||||
// goes from the dungeon to Holtburg and back: Holtburg's shop and corpse must not follow the character home).
|
||||
// ============================================================================
|
||||
|
||||
using RynthCore.Headless.Session;
|
||||
using RynthCore.Headless.World;
|
||||
|
||||
namespace HeadlessHostTests;
|
||||
|
||||
internal static class TeleportTests
|
||||
{
|
||||
[System.Runtime.CompilerServices.ModuleInitializer]
|
||||
internal static void Register() => Suites.Add("teleport", Run, order: 60);
|
||||
|
||||
private static void Run()
|
||||
{
|
||||
long now = 1000;
|
||||
var link = new FakeLink();
|
||||
var session = new ClientSession(link, new SessionOptions { Account = Fixture.Account, PickFirstCharacter = true }, () => now);
|
||||
session.Start("x");
|
||||
int teleports = 0, deleted = 0;
|
||||
session.World.PlayerTeleported += () => teleports++;
|
||||
session.World.ObjectDeleted += _ => deleted++;
|
||||
foreach (string line in File.ReadLines(Fixture.CapturePath))
|
||||
{
|
||||
if (line.StartsWith('#') || line.Length == 0) continue;
|
||||
string[] f = line.Split(' ');
|
||||
if (f[1] != "S") continue;
|
||||
link.Inbox.Enqueue(Convert.FromHexString(f[2]));
|
||||
now += 5;
|
||||
session.Tick();
|
||||
}
|
||||
WorldState w = session.World;
|
||||
bool Has(string name) => w.Objects.Values.Any(o => o.Name == name);
|
||||
T.Check(teleports >= 2, $"the capture teleports out and back ({teleports})");
|
||||
T.Check(deleted > 0, $"plugins hear the dropped objects as deletes ({deleted})");
|
||||
T.Check(!Has("Shopkeeper Renald the Elder") && !Has("Corpse of Drudge Skulker"), "Holtburg's shopkeeper and corpse are gone after the teleport home");
|
||||
T.Check(Has("Viamontian Laced Boots") && Has("Sack"), "what the character carries stays");
|
||||
T.Check(w.Objects.ContainsKey(w.Player.Id), "the player stays");
|
||||
T.Check(w.Objects.Count < Fixture.Shared.Session.World.Objects.Count,
|
||||
$"fewer objects than the replay that keeps them ({w.Objects.Count} < {Fixture.Shared.Session.World.Objects.Count})");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue