RynthSuite as of 2026-11-08 (internal 6ec9b64): release 2026.11.8.1
This commit is contained in:
parent
7166d256ce
commit
f8fa62b64c
196 changed files with 24980 additions and 633 deletions
216
Tools/RynthDefective.Tests/BusyClearTests.cs
Normal file
216
Tools/RynthDefective.Tests/BusyClearTests.cs
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using RynthCore.Plugin.RynthDefective;
|
||||
using RynthCore.Plugin.RynthDefective.Items;
|
||||
using RynthCore.Plugin.RynthDefective.Model;
|
||||
using RynthCore.Plugin.RynthDefective.Ui;
|
||||
using RynthCore.Plugin.RynthDefective.Use;
|
||||
using RynthCore.Plugin.RynthDefective.Views;
|
||||
|
||||
namespace RynthDefective.Tests
|
||||
{
|
||||
// "Shortcuts clear a stuck busy state" (2026-11-04, DefSettings.ClearStuckBusy): when a press clears
|
||||
// the busy count first (BusyClearRule: only the count holds it, nothing real in flight), the use
|
||||
// controller's clear-then-use (once per press, logged), off by default, the setting, the command.
|
||||
internal static partial class Program
|
||||
{
|
||||
private static void BusyClearDecisions()
|
||||
{
|
||||
Check(!new DefSettings().ClearStuckBusy, "off by default");
|
||||
|
||||
// A count of 2 that moved a second ago, nothing of ours for a long time, no gesture, no RynthAi.
|
||||
var f = new BusyFacts(Count: 2, CountSteadyMs: 1000, Leftover: 0, SinceOwnSendMs: 60_000,
|
||||
Animating: false, AnimatingMs: 0, BotWaiting: null, BotSteadyMs: 0);
|
||||
bool Clear(in BusyFacts x, BusyHold hold = BusyHold.Busy, bool on = true, bool inFlight = false, bool answered = true, long sinceBusy = 60_000) =>
|
||||
BusyClearRule.ShouldClear(on, hold, x, inFlight, answered, sinceBusy);
|
||||
|
||||
Check(Clear(f), "only the count holds it: clear");
|
||||
Check(!Clear(f, on: false), "the option off: never");
|
||||
Check(!Clear(f, BusyHold.Animation) && !Clear(f, BusyHold.Bot) && !Clear(f, BusyHold.None), "held by something else, or not held: no");
|
||||
Check(!Clear(f with { Count = 0 }), "no count: nothing to clear");
|
||||
Check(!Clear(f, inFlight: true), "our own use in flight: no");
|
||||
Check(!Clear(f with { SinceOwnSendMs = 1000 }, answered: false), "our own last use, unanswered, just now: no (it may be the count)");
|
||||
Check(Clear(f with { SinceOwnSendMs = 1000 }, answered: true), "our own last use was answered: the count isn't it");
|
||||
Check(Clear(f with { SinceOwnSendMs = BusyRule.OwnTrustMs }, answered: false), "unanswered but long ago: not ours any more");
|
||||
Check(!Clear(f with { Animating = true, AnimatingMs = 100 }), "a gesture animating: no");
|
||||
Check(!Clear(f with { Animating = true, AnimatingMs = 60_000 }), "even one that has 'animated' for a minute: no");
|
||||
Check(!Clear(f with { BotPaced = true, BotPacedMs = 100 }), "RynthAi's own action unanswered: no");
|
||||
Check(!Clear(f with { BotPaced = true, BotPacedMs = 60_000 }), "even a stale one: no");
|
||||
Check(Clear(f with { BotPaced = false, BotWaiting = true, BotSteadyMs = 100 }),
|
||||
"RynthAi says it has nothing in flight: its 'waiting' bit is its copy of the count");
|
||||
Check(!Clear(f with { BotWaiting = true, BotSteadyMs = 1000 }), "a RynthAi that can't say, waiting on the server just now: no");
|
||||
Check(Clear(f with { BotWaiting = true, BotSteadyMs = BusyRule.BotTrustMs }), "its bit stuck for longer than any of its actions: yes");
|
||||
Check(!Clear(f, sinceBusy: 2000), "the server said 'too busy' 2 s ago: it really is busy, no");
|
||||
Check(Clear(f, sinceBusy: BusyClearRule.ServerBusyRecentMs), "5 s later: yes");
|
||||
}
|
||||
|
||||
private static void UseClearStuckBusy()
|
||||
{
|
||||
ItemRef kit = ItemRef.From(Kit(0x10));
|
||||
|
||||
// Off (the default): a login's count holds the press as before, and nothing is reset.
|
||||
Harness h = With(Kit(0x10));
|
||||
h.World.BusyCount = 2;
|
||||
h.Tick();
|
||||
h.Slot(kit);
|
||||
h.Ticks(3, 1000);
|
||||
Check(h.World.Sent.Count == 0 && h.World.Clears == 0, "off: held, nothing cleared");
|
||||
h.Tick(1000);
|
||||
Eq(string.Join("|", h.World.Sent), "useon 10 me", "off: it goes once the count is a leftover, as before");
|
||||
Eq(h.World.Clears, 0, "off: the count is never reset");
|
||||
|
||||
// On: the clear, then the use as soon as the reset reads.
|
||||
h = With(Kit(0x10));
|
||||
h.Use.Settings.ClearStuckBusy = true;
|
||||
h.World.BusyCount = 2;
|
||||
h.Tick();
|
||||
h.Slot(kit);
|
||||
h.Tick(50);
|
||||
Check(h.World.Clears == 1 && h.World.Sent.Count == 0, "on: cleared first, nothing sent yet");
|
||||
Check(h.Logged.Any(l => l.Contains("held only by the client's busy count (2") && l.Contains("as /ra clearbusy does")), "the clear is logged: " + string.Join(";", h.Logged));
|
||||
Check(h.Said.Any(s => s.Contains("clearing a stuck busy state")), "and on the status line");
|
||||
h.Tick(50);
|
||||
Eq(string.Join("|", h.World.Sent), "useon 10 me", "the reset read: the kit goes at once");
|
||||
Eq(h.World.Clears, 1, "once for the press");
|
||||
Eq(h.Warned.Count, 0, "no warning");
|
||||
|
||||
// The next press gets its own (once per press, not once ever).
|
||||
h.World.Answer();
|
||||
h.Tick(100);
|
||||
h.World.BusyCount = 1; // something raises it again
|
||||
h.Tick(300);
|
||||
h.Slot(kit);
|
||||
h.Tick(50);
|
||||
Eq(h.World.Clears, 2, "a new press held by the count: one more clear");
|
||||
h.Tick(50);
|
||||
Eq(h.World.Sent.Count, 2, "and it goes");
|
||||
|
||||
// The reset doesn't take: the press waits the settle time, then the count is a leftover and it goes.
|
||||
h = With(Kit(0x10));
|
||||
h.Use.Settings.ClearStuckBusy = true;
|
||||
h.World.ClearLands = false;
|
||||
h.World.BusyCount = 2;
|
||||
h.Tick();
|
||||
h.Slot(kit);
|
||||
h.Tick(50);
|
||||
h.Tick(100);
|
||||
Check(h.World.Clears == 1 && h.World.Sent.Count == 0, "the count still reads 2: waiting for the reset");
|
||||
h.Tick(UseController.ClearSettleMs);
|
||||
Eq(string.Join("|", h.World.Sent), "useon 10 me", "after the settle time it goes: what is left is a leftover");
|
||||
Eq(h.World.Clears, 1, "not cleared twice");
|
||||
Eq(h.Use.Busy.Leftover, 2, "2 is the leftover");
|
||||
|
||||
// An engine that can't reset: logged, and the usual rules.
|
||||
h = With(Kit(0x10));
|
||||
h.Use.Settings.ClearStuckBusy = true;
|
||||
h.World.CanClear = false;
|
||||
h.World.BusyCount = 2;
|
||||
h.Tick();
|
||||
h.Slot(kit);
|
||||
h.Ticks(3, 1000);
|
||||
Check(h.World.Sent.Count == 0 && h.Logged.Count(l => l.Contains("can't reset it")) == 1, "can't clear: said once in the log, held as usual");
|
||||
h.Tick(1000);
|
||||
Eq(h.World.Sent.Count, 1, "and goes when the usual rules let it");
|
||||
|
||||
// Never with something real in flight: a gesture, RynthAi's own action, the server's 'too busy'.
|
||||
h = With(Kit(0x10));
|
||||
h.Use.Settings.ClearStuckBusy = true;
|
||||
h.World.BusyCount = 2;
|
||||
h.World.Animating = true;
|
||||
h.Tick();
|
||||
h.Slot(kit);
|
||||
h.Ticks(3, 1000);
|
||||
Eq(h.World.Clears, 0, "a gesture animating: nothing cleared");
|
||||
|
||||
h = With(Kit(0x10));
|
||||
h.Use.Settings.ClearStuckBusy = true;
|
||||
h.World.YieldOn = true;
|
||||
h.World.BotOwnAction = true;
|
||||
h.World.BusyCount = 2;
|
||||
h.Tick();
|
||||
h.Slot(kit);
|
||||
h.Ticks(4, 1000);
|
||||
Eq(h.World.Clears, 0, "RynthAi's own action in flight: nothing cleared");
|
||||
|
||||
h = With(Kit(0x10));
|
||||
h.Use.Settings.ClearStuckBusy = true;
|
||||
h.Slot(kit);
|
||||
h.Tick();
|
||||
Eq(h.World.Sent.Count, 1, "sent");
|
||||
h.World.Answer(UseController.TooBusyError);
|
||||
h.World.BusyCount = 1;
|
||||
h.Tick(100);
|
||||
Check(h.Use.HasPending, "the server said 'too busy': one more try queued");
|
||||
h.Ticks(3, 1000);
|
||||
Eq(h.World.Clears, 0, "the server really is busy: nothing cleared for the retry");
|
||||
|
||||
// Our own last use answered, the count still up a moment (the engine's count catches up later):
|
||||
// the next press may clear it.
|
||||
h = With(Kit(0x10), Potion(0x11));
|
||||
h.Use.Settings.ClearStuckBusy = true;
|
||||
h.Slot(kit);
|
||||
h.Tick();
|
||||
h.World.BusyCount = 1;
|
||||
h.Tick(100);
|
||||
h.World.Answer();
|
||||
h.Tick(100);
|
||||
Check(!h.Use.InFlight, "the kit was answered");
|
||||
h.Slot(ItemRef.From(Potion(0x11)));
|
||||
h.Tick(300);
|
||||
Eq(h.World.Clears, 1, "the potion: the count is no action of ours in flight, cleared");
|
||||
h.Tick(50);
|
||||
Eq(h.World.Sent.Count, 2, "and the potion goes");
|
||||
}
|
||||
|
||||
private static void ClearBusySettingAndCommand()
|
||||
{
|
||||
// The character's file.
|
||||
var d = new DefData();
|
||||
d.Settings.ClearStuckBusy = true;
|
||||
Check(DefStore.Parse(JsonDocument.Parse(DefStore.ToJson(d)).RootElement).Settings.ClearStuckBusy, "saved and read: on");
|
||||
Check(!DefStore.Parse(JsonDocument.Parse("{\"settings\":{\"quantityBox\":true}}").RootElement).Settings.ClearStuckBusy, "a file from before: off");
|
||||
|
||||
// The command.
|
||||
DefCommand c = DefCommandParser.Parse("shortcuts clearbusy on");
|
||||
Check(c.Verb == DefVerb.Shortcuts && c.Text == "on", "/rdef shortcuts clearbusy on");
|
||||
Check(DefCommandParser.Parse("shortcuts clearbusy off").Text == "off", "off");
|
||||
Check(DefCommandParser.Parse("shortcuts ClearBusy OFF").Text == "off", "any case");
|
||||
c = DefCommandParser.Parse("shortcuts clearbusy");
|
||||
Check(c.Verb == DefVerb.Shortcuts && c.Text == "", "alone: says what it is");
|
||||
foreach (string wrong in new[] { "shortcuts", "shortcuts clearbusy maybe", "shortcuts frob on", "shortcuts clearbusy on now" })
|
||||
{
|
||||
c = DefCommandParser.Parse(wrong);
|
||||
Check(c.Verb == DefVerb.Error && c.Error.Contains("Usage", StringComparison.Ordinal), $"'/rdef {wrong}' answers how it's typed: {c.Error}");
|
||||
}
|
||||
Check(DefReplies.ClearBusy(true).Contains(": on") && DefReplies.ClearBusy(true).Contains("/ra clearbusy"), "the on reply says what it does");
|
||||
Check(DefReplies.ClearBusy(false).Contains(": off (the default)"), "the off reply");
|
||||
|
||||
// The settings window's box, and the script-window bar's.
|
||||
var b = new BarRig("clearbusy-settings");
|
||||
var host = new UiHost();
|
||||
UiWindow win = host.Add(new UiWindow("RynthDefective/Settings", "Defective Settings") { Visible = true, ShowInBar = false });
|
||||
var view = new BarSettingsView(b.S) { WindowShown = t => t == BarSettingsView.BarTitle ? true : null };
|
||||
win.Begin(); view.Draw(win); win.End();
|
||||
ParseAll(host, "settings window with the clear-busy box", out _);
|
||||
Check(Encoding.UTF8.GetString(win.Body).Contains("Shortcuts clear a stuck busy state"), "the box is in the settings");
|
||||
var w = new Windows("clearbusy-settings-events");
|
||||
w.Host.Add(win);
|
||||
int saves = b.R.Saves;
|
||||
w.SetBool(win, "set.clearbusy", true);
|
||||
Check(b.S.Settings.ClearStuckBusy && b.R.Saves > saves, "ticking it turns it on, saved");
|
||||
w.SetBool(win, "set.clearbusy", false);
|
||||
Check(!b.S.Settings.ClearStuckBusy, "and off");
|
||||
|
||||
var t = new Windows("clearbusy-old-bar");
|
||||
var panel = new SettingsPanel(t.S, () => { });
|
||||
UiWindow pw = t.Host.Add(new UiWindow("RynthDefective/Old", "Old") { Visible = true });
|
||||
pw.Begin(); panel.Draw(pw); pw.End();
|
||||
Check(Encoding.UTF8.GetString(pw.Body).Contains("Shortcuts clear a stuck busy state"), "the script-window bar's settings have it too");
|
||||
t.SetBool(pw, "set.clearbusy", true);
|
||||
Check(t.S.Settings.ClearStuckBusy, "and it works there");
|
||||
}
|
||||
}
|
||||
}
|
||||
152
Tools/RynthDefective.Tests/ClockTests.cs
Normal file
152
Tools/RynthDefective.Tests/ClockTests.cs
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
using System;
|
||||
using RynthCore.Plugin.RynthDefective.Clock;
|
||||
using RynthCore.Plugin.RynthDefective.Model;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthDefective.Tests
|
||||
{
|
||||
// The Day/Night timer (2026-11-04): Plugins/Shared/DerethClock.cs from a raw clock reading (no game).
|
||||
// With RynthAi's calendar offset the time of day is (raw + 3600) mod 7620 ticks, a tick a real second.
|
||||
internal static partial class Program
|
||||
{
|
||||
/// <summary>A raw clock reading <paramref name="into"/> ticks after Darktide began (a later day, so the raw is positive).</summary>
|
||||
private static double RawAt(double into, int day = 1) => DerethClock.TicksInDay * day + into - 3600;
|
||||
|
||||
private static void ClockDayNight()
|
||||
{
|
||||
Eq(DerethClock.TicksInDay, 7620.0, "a Dereth day is 7620 ticks");
|
||||
Eq(DerethClock.TicksInDay * DerethClock.SecondsPerTick / 60.0, 127.0, "= 2 h 7 min of real time");
|
||||
|
||||
// Darktide's start: night, dawn in 4 hours = 1905 s.
|
||||
DerethNow n = DerethClock.At(RawAt(0));
|
||||
Check(!n.IsDay, "Darktide: night");
|
||||
Eq(n.Hour, 0, "Darktide: hour 0");
|
||||
Eq(n.HourName, "Darktide", "Darktide: its name");
|
||||
Eq(n.SecondsToChange, 1905.0, "Darktide: dawn in 4 hours of 476.25 s");
|
||||
Eq(n.Next, "Day", "at night the day comes next");
|
||||
Eq(n.NextHourName, "Dawnsong", "at Dawnsong");
|
||||
|
||||
// Dawn itself: day for 8 hours, 3810 s.
|
||||
n = DerethClock.At(RawAt(1905));
|
||||
Check(n.IsDay, "Dawnsong: day");
|
||||
Eq(n.HourName, "Dawnsong", "Dawnsong: its name");
|
||||
Eq(n.SecondsToChange, 3810.0, "Dawnsong: dusk in 63.5 real minutes");
|
||||
Eq(n.NextHourName, "Evensong", "by day the night comes at Evensong");
|
||||
|
||||
// The examples: "Night in 23m", "Day in 4m 10s", "Day in 45s".
|
||||
n = DerethClock.At(RawAt(5715 - 1380));
|
||||
Check(n.IsDay, "23 min before dusk: day");
|
||||
Eq(n.HourName, "Midsong-and-Half", "23 min before dusk: hour 9");
|
||||
Eq(DerethClock.Label(n, n.SecondsToChange), "Night in 23m", "23 min before dusk");
|
||||
n = DerethClock.At(RawAt(5715 - 250));
|
||||
Eq(n.HourName, "Warmtide-and-Half", "the last day hour");
|
||||
Eq(DerethClock.Label(n, n.SecondsToChange), "Night in 4m 10s", "250 s before dusk");
|
||||
n = DerethClock.At(RawAt(1905 - 45));
|
||||
Check(!n.IsDay, "45 s before dawn: night");
|
||||
Eq(n.HourName, "Foredawn-and-Half", "the last night hour");
|
||||
Eq(DerethClock.Label(n, n.SecondsToChange), "Day in 45s", "45 s before dawn");
|
||||
|
||||
// Dusk itself: night through midnight to the next dawn, 3810 s.
|
||||
n = DerethClock.At(RawAt(5715));
|
||||
Check(!n.IsDay, "Evensong: night");
|
||||
Eq(n.HourName, "Evensong", "Evensong: its name");
|
||||
Eq(n.SecondsToChange, 3810.0, "Evensong: dawn in 63.5 real minutes (across midnight)");
|
||||
Eq(DerethClock.At(RawAt(7000)).SecondsToChange, 7620.0 - 7000 + 1905, "Gloaming: dawn across midnight");
|
||||
|
||||
// Whole days and the 10-year offset change nothing; a big clock keeps its precision.
|
||||
Eq(DerethClock.At(RawAt(735, day: 200_000)).SecondsToChange, DerethClock.At(RawAt(735)).SecondsToChange, "a later day: the same");
|
||||
|
||||
// Not readable yet.
|
||||
Check(!DerethClock.IsUsable(0), "0: the clock isn't set");
|
||||
Check(!DerethClock.IsUsable(double.NaN) && !DerethClock.IsUsable(-5) && !DerethClock.IsUsable(double.PositiveInfinity), "NaN, negative, infinite: not used");
|
||||
Check(DerethClock.IsUsable(123456.5), "a real reading is used");
|
||||
}
|
||||
|
||||
/// <summary>Against RynthAi's own meta expressions (getisday, getgamehour, getminutesuntilday/night), and the countdown's continuity.</summary>
|
||||
private static void ClockMatchesRynthAi()
|
||||
{
|
||||
const double hourTicks = 476.25;
|
||||
const int dayTicks = 7620;
|
||||
int mismatches = 0, jumps = 0, flips = 0;
|
||||
DerethNow prev = default;
|
||||
double prevRaw = 0;
|
||||
for (double raw = 10_000; raw < 10_000 + 2 * dayTicks; raw += 3.7)
|
||||
{
|
||||
// RynthAi (Meta/ExpressionEngine.cs), as it is written there.
|
||||
double ticks = raw - 210 + hourTicks * 8 + hourTicks * 16 * 30 * 12 * 10;
|
||||
int hour = (int)(ticks % dayTicks / hourTicks);
|
||||
bool isDay = hour >= 4 && hour < 12;
|
||||
double into = ticks % dayTicks;
|
||||
double untilDay = isDay ? 0 : into < 4 * hourTicks ? 4 * hourTicks - into : dayTicks - into + 4 * hourTicks;
|
||||
double untilNight = isDay ? 12 * hourTicks - into : 0;
|
||||
int minutes = (int)((isDay ? untilNight : untilDay) / 60);
|
||||
|
||||
DerethNow n = DerethClock.At(raw);
|
||||
if (n.Hour != hour || n.IsDay != isDay || (int)(n.SecondsToChange / 60) != minutes) mismatches++;
|
||||
|
||||
if (raw > 10_000)
|
||||
{
|
||||
if (n.IsDay != prev.IsDay)
|
||||
{
|
||||
flips++;
|
||||
// The change came when the countdown ran out.
|
||||
if (prev.SecondsToChange > raw - prevRaw + 1e-6) jumps++;
|
||||
}
|
||||
else if (Math.Abs(prev.SecondsToChange - (raw - prevRaw) - n.SecondsToChange) > 1e-6) jumps++; // a second a second
|
||||
}
|
||||
prev = n;
|
||||
prevRaw = raw;
|
||||
}
|
||||
Eq(mismatches, 0, "the hour, day or night and the minutes are RynthAi's");
|
||||
Eq(jumps, 0, "the countdown falls a second a real second, and the change comes when it runs out");
|
||||
Eq(flips, 4, "two days: two dawns and two dusks");
|
||||
}
|
||||
|
||||
private static void ClockCountdownText()
|
||||
{
|
||||
Eq(DerethClock.Countdown(0), "0s", "0");
|
||||
Eq(DerethClock.Countdown(0.2), "1s", "a part second rounds up: never 0s before the change");
|
||||
Eq(DerethClock.Countdown(45), "45s", "under a minute: seconds");
|
||||
Eq(DerethClock.Countdown(59.5), "1m 0s", "59.5 s rounds up to a minute");
|
||||
Eq(DerethClock.Countdown(250), "4m 10s", "under 10 minutes: minutes and seconds");
|
||||
Eq(DerethClock.Countdown(599), "9m 59s", "just under 10 minutes");
|
||||
Eq(DerethClock.Countdown(600), "10m", "10 minutes: minutes only");
|
||||
Eq(DerethClock.Countdown(601), "11m", "over 10 minutes: whole minutes rounded up");
|
||||
Eq(DerethClock.Countdown(1380), "23m", "23 minutes");
|
||||
Eq(DerethClock.Countdown(3600), "1h 0m", "an hour");
|
||||
Eq(DerethClock.Countdown(3810), "1h 4m", "the longest wait: 63.5 minutes");
|
||||
Eq(DerethClock.Countdown(-3), "0s", "a stale reading past the change: 0s, not negative");
|
||||
}
|
||||
|
||||
private static void ClockWindowAndCommand()
|
||||
{
|
||||
// The window counts down from when the tick read the clock.
|
||||
var v = new DayNightView(true, DerethClock.At(RawAt(5715 - 100)), 1000);
|
||||
Eq(v.SecondsLeft(1000), 100.0, "at the reading");
|
||||
Eq(v.SecondsLeft(3500), 97.5, "2.5 s later");
|
||||
Eq(v.SecondsLeft(1_000_000), 0.0, "long after: 0, not negative");
|
||||
Check(!DayNightView.NotReady.Ready, "before the world: not ready");
|
||||
Eq(DayNightWindow.NotInWorld, "—", "out of world it shows a dash");
|
||||
Check(DayNightWindow.Tip(DayNightView.NotReady, 0).Contains("in the world", StringComparison.Ordinal), "tooltip out of world");
|
||||
string tip = DayNightWindow.Tip(v, 100);
|
||||
Check(tip.Contains("Day now (Warmtide-and-Half)", StringComparison.Ordinal) && tip.Contains("Night comes at Evensong, in 1 min 40 s", StringComparison.Ordinal), "tooltip: " + tip);
|
||||
|
||||
// /rdef daynight [show|hide]: parsed, and every answer says what happened.
|
||||
Eq(DefCommandParser.Parse("daynight").Text, "", "alone: toggle");
|
||||
Eq(DefCommandParser.Parse("daynight show").Text, "show", "show");
|
||||
Eq(DefCommandParser.Parse("DayNight ON").Text, "show", "on = show, any case");
|
||||
Eq(DefCommandParser.Parse("daynight hide").Text, "hide", "hide");
|
||||
Eq(DefCommandParser.Parse("daynight off").Text, "hide", "off = hide");
|
||||
DefCommand bad = DefCommandParser.Parse("daynight soon");
|
||||
Check(bad.Verb == DefVerb.Error && bad.Error.Contains("Usage", StringComparison.Ordinal), "a wrong word: the usage");
|
||||
Check(DefCommandParser.Usage.Contains("daynight", StringComparison.Ordinal), "in the usage");
|
||||
|
||||
DerethNow dusk = DerethClock.At(RawAt(5715));
|
||||
Eq(DefReplies.DayNight(1, dusk), (true, "Day/Night timer shown. Night now (Evensong); day in 1h 4m of real time."), "shown, with the time");
|
||||
Eq(DefReplies.DayNight(0, null), (true, "Day/Night timer hidden."), "hidden, out of world: no time");
|
||||
var old = DefReplies.DayNight(-1, dusk);
|
||||
Check(!old.Ok && old.Text.Contains("v90", StringComparison.Ordinal) && old.Text.Contains("day in 1h 4m", StringComparison.Ordinal),
|
||||
"an engine without the window: why, and the time still");
|
||||
}
|
||||
}
|
||||
}
|
||||
269
Tools/RynthDefective.Tests/ExtraBarTests.cs
Normal file
269
Tools/RynthDefective.Tests/ExtraBarTests.cs
Normal file
|
|
@ -0,0 +1,269 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using RynthCore.Plugin.RynthDefective;
|
||||
using RynthCore.Plugin.RynthDefective.Items;
|
||||
using RynthCore.Plugin.RynthDefective.Model;
|
||||
using RynthCore.Plugin.RynthDefective.ShortcutBar;
|
||||
using RynthCore.Plugin.RynthDefective.Ui;
|
||||
using RynthCore.Plugin.RynthDefective.Use;
|
||||
using RynthCore.Plugin.RynthDefective.Views;
|
||||
|
||||
namespace RynthDefective.Tests
|
||||
{
|
||||
// The extra Shortcuts bars (2026-11-04, ExtraBar): adding and removing them (at most 3, the lowest
|
||||
// free number), their own slots filled and used like the main bar's own, the character's file, the
|
||||
// /rdef bars command, what an extra bar's window draws, and the settings window's rows for them.
|
||||
internal static partial class Program
|
||||
{
|
||||
private static void ExtraBarsAddRemoveCap()
|
||||
{
|
||||
var d = new DefData();
|
||||
Eq(d.ExtraBars.Count, 0, "none by default");
|
||||
var numbers = new List<int>();
|
||||
for (int i = 0; i < ExtraBar.Max; i++) numbers.Add(d.AddExtraBar()?.Number ?? 0);
|
||||
Eq(string.Join(",", numbers), "2,3,4", "three bars, numbered 2-4 (the main bar is 1)");
|
||||
Check(d.AddExtraBar() == null && d.ExtraBars.Count == ExtraBar.Max, "a fourth is refused: the cap");
|
||||
Check(ExtraBar.Max + 5 <= 8, "the cap fits the engine's 8 windows for a plugin (RynthDefective draws 5 others, Day/Night included)");
|
||||
Check(d.RemoveExtraBar(3) && d.Extra(3) == null && d.ExtraBars.Count == 2, "remove bar 3");
|
||||
Check(!d.RemoveExtraBar(3), "removing it again: nothing to remove");
|
||||
Eq(d.AddExtraBar()?.Number, 3, "the next added takes the free number (its window comes back where it was)");
|
||||
Eq(string.Join(",", d.ExtraBars.Select(b => b.Number)), "2,3,4", "kept in number order");
|
||||
ExtraBar b2 = d.Extra(2)!;
|
||||
Eq(b2.SlotCount, ExtraBar.DefaultSlots, "10 slots to start");
|
||||
Eq(b2.Slots.Count, ExtraBar.SlotsMax, "always 24 slots kept (fewer shown hides them)");
|
||||
Eq(b2.Title, "Shortcuts 2", "its window's title");
|
||||
Eq(ExtraBar.SurfaceOf(4), "window:bar4", "its surface");
|
||||
|
||||
// The session's words for it, and the saves.
|
||||
var rig = new Rig("xbars");
|
||||
string m = rig.S.AddBar(out int n);
|
||||
Check(n == 2 && rig.S.Data.Extra(2) != null && rig.Saves == 1, "session: bar 2 added and saved");
|
||||
Check(m.Contains("Shortcuts bar 2 added") && m.Contains("drag items"), "it says how to fill it: " + m);
|
||||
for (int i = 0; i < 2; i++) rig.S.AddBar(out _);
|
||||
int saves = rig.Saves;
|
||||
m = rig.S.AddBar(out n);
|
||||
Check(n == 0 && rig.Saves == saves && rig.S.Data.ExtraBars.Count == 3, "at the cap: not added, not saved");
|
||||
Check(m.Contains("Remove one first") && m.Contains("8 windows"), "and it says why: " + m);
|
||||
|
||||
m = rig.S.RemoveBar(1);
|
||||
Check(m.Contains("can't be removed") && rig.S.Data.ExtraBars.Count == 3, "bar 1 is the Shortcuts bar itself: " + m);
|
||||
m = rig.S.RemoveBar(9);
|
||||
Check(m.StartsWith("There is no Shortcuts bar 9", StringComparison.Ordinal) && m.Contains("Extra Shortcuts bars: 2"), "no such bar: it lists them: " + m);
|
||||
rig.Inv = new List<CarriedItem> { Kit(0x7400_0001u) };
|
||||
rig.S.SetFromId(1, 0x7400_0001u, bar: 4);
|
||||
m = rig.S.RemoveBar(4);
|
||||
Check(rig.S.Data.Extra(4) == null && m.Contains("1 of its slots") && m.Contains("forgotten"), "a bar that held something: says it's forgotten: " + m);
|
||||
m = rig.S.RemoveBar(3);
|
||||
Check(m == "Shortcuts bar 3 removed.", "an empty one: " + m);
|
||||
Check(rig.S.DescribeBars().Contains("2 (10 slots, 0 set)") && !rig.S.DescribeBars().Contains("3 (10 slots") && rig.S.DescribeBars().Contains("2 more can be added"), "the list: " + rig.S.DescribeBars());
|
||||
|
||||
m = rig.S.SetBarSlots(2, 12);
|
||||
Check(rig.S.Data.Extra(2)!.SlotCount == 12 && m == "Shortcuts bar 2 shows 12 slots.", "bar 2 shows 12: " + m);
|
||||
m = rig.S.SetBarSlots(2, 99);
|
||||
Check(rig.S.Data.Extra(2)!.SlotCount == ExtraBar.SlotsMax && m.Contains("1 to 24"), "too many: the most: " + m);
|
||||
Check(rig.S.SetBarSlots(7, 3).StartsWith("There is no Shortcuts bar 7", StringComparison.Ordinal), "slots of a bar that isn't there");
|
||||
|
||||
var none = new Rig("xbars-none");
|
||||
Check(none.S.DescribeBars().Contains("/rdef bars add"), "no bars: how to add one");
|
||||
}
|
||||
|
||||
private static void ExtraBarsSlots()
|
||||
{
|
||||
var rig = new Rig("xbar-slots");
|
||||
var kit = Kit(0x7410_0001u);
|
||||
var potion = Potion(0x7410_0002u);
|
||||
rig.Inv = new List<CarriedItem> { kit, potion };
|
||||
rig.S.AddBar(out _);
|
||||
|
||||
rig.Selected = kit.Id;
|
||||
string m = rig.S.SetFromSelected(1, bar: 2);
|
||||
Check(rig.S.Data.Extra(2)!.Slots[0].Item?.Id == kit.Id && rig.S.Data.Slots[0].Empty, "the selected kit goes in bar 2's slot 1, not the main bar's");
|
||||
Check(m.StartsWith("Bar 2 slot 1: Peerless Healing Kit", StringComparison.Ordinal), "named by its bar: " + m);
|
||||
m = rig.S.SetFromId(3, potion.Id, bar: 2);
|
||||
Check(rig.S.Data.Extra(2)!.Slots[2].Item?.Id == potion.Id && m.StartsWith("Bar 2 slot 3:", StringComparison.Ordinal), "an item dropped on bar 2's slot 3");
|
||||
m = rig.S.SetSpell(2, 1, bar: 2); // the spellbook can't be read here: any spell id goes in
|
||||
Check(rig.S.Data.Extra(2)!.Slots[1].IsSpell && m.StartsWith("Bar 2 slot 2:", StringComparison.Ordinal), "a spell in bar 2's slot 2: " + m);
|
||||
Check(rig.S.SetFromId(1, potion.Id, bar: 3).StartsWith("There is no Shortcuts bar 3", StringComparison.Ordinal), "a bar that isn't there");
|
||||
Check(rig.S.SetFromId(25, potion.Id, bar: 2) == "Bar 2 has no slot 25.", "a slot past 24");
|
||||
Check(rig.S.Data.Slots.All(s => s.Empty), "the main bar's own slots are untouched");
|
||||
|
||||
// Pressing: through the use controller, as the main bar's own slots.
|
||||
Check(rig.S.UseSlot(1, bar: 2) == null && rig.S.Use.Pending?.Item?.Id == kit.Id && rig.S.Use.Pending?.Source == "bar 2 slot 1", "a click uses bar 2's kit: " + rig.S.Use.Pending?.Source);
|
||||
rig.S.Use.Reset();
|
||||
Check(rig.S.UseSlot(2, bar: 2) == null && rig.S.Use.Pending?.Spell == 1, "a spell slot casts");
|
||||
rig.S.Use.Reset();
|
||||
m = rig.S.UseSlot(4, bar: 2)!;
|
||||
Check(m.StartsWith("Bar 2 slot 4 is empty", StringComparison.Ordinal) && m.Contains("right-click"), "an empty one says how to fill it: " + m);
|
||||
Check(rig.S.UseSlot(1, bar: 5)!.StartsWith("There is no Shortcuts bar 5", StringComparison.Ordinal), "a bar that isn't there");
|
||||
|
||||
m = rig.S.ClearSlot(3, bar: 2);
|
||||
Check(rig.S.Data.Extra(2)!.Slots[2].Empty && m == "Bar 2 slot 3 cleared.", "cleared: " + m);
|
||||
|
||||
// The slots follow their items: the kit used up, the next of its name is the one.
|
||||
var kit2 = Kit(0x7410_0009u);
|
||||
rig.Inv = new List<CarriedItem> { kit2, potion };
|
||||
Check(rig.S.Maintain(rig.Inv) && rig.S.Data.Extra(2)!.Slots[0].Item?.Id == kit2.Id, "an extra bar's slot follows its item like the main bar's");
|
||||
|
||||
// The main bar's own slots still read as before.
|
||||
Check(rig.S.SetFromId(1, potion.Id) == "Slot 1: Health Potion (used when pressed).", "the main bar's words unchanged: " + rig.S.SetFromId(1, potion.Id));
|
||||
Check(rig.S.UseSlot(43) == "There is no slot 43.", "and its limits");
|
||||
}
|
||||
|
||||
private static void ExtraBarsStore()
|
||||
{
|
||||
var st = new DefStore(Path.Combine(_temp, "xbar-store"));
|
||||
var d = new DefData();
|
||||
ExtraBar a = d.AddExtraBar()!;
|
||||
a.SlotCount = 12;
|
||||
a.Slots[0].Item = ItemRef.From(Kit(0x7420_0001u));
|
||||
a.Slots[0].Mode = UseMode.OnSelf;
|
||||
a.Slots[11] = new DefSlot { SpellId = 1, SpellName = "Strength Other I" };
|
||||
a.Slots[23].Item = ItemRef.From(Potion(0x7420_0002u)); // past the shown count: kept
|
||||
d.AddExtraBar();
|
||||
ExtraBar c = d.AddExtraBar()!;
|
||||
c.SlotCount = 3;
|
||||
d.RemoveExtraBar(3); // bars 2 and 4 are left
|
||||
d.Slots[0].Item = ItemRef.From(Potion(0x7420_0003u));
|
||||
|
||||
Check(st.Save("TestServer", "Test", d) == null, "saved");
|
||||
DefData r = st.Load("TestServer", "Test", out string? problem);
|
||||
Check(problem == null, "read back");
|
||||
Eq(string.Join(",", r.ExtraBars.Select(b => b.Number)), "2,4", "bars 2 and 4");
|
||||
ExtraBar ra = r.Extra(2)!, rc = r.Extra(4)!;
|
||||
Check(ra.SlotCount == 12 && rc.SlotCount == 3, "their slot counts");
|
||||
Check(ra.Slots[0].Item?.Id == 0x7420_0001u && ra.Slots[0].Mode == UseMode.OnSelf, "an item and its mode");
|
||||
Check(ra.Slots[11].SpellId == 1 && ra.Slots[11].SpellName.Length > 0, "a spell slot");
|
||||
Check(ra.Slots[23].Item?.Id == 0x7420_0002u, "a slot past the shown count is kept");
|
||||
Check(ra.Slots.Count == ExtraBar.SlotsMax && rc.Filled == 0, "24 slots each; bar 4 empty");
|
||||
Check(r.Slots[0].Item?.Id == 0x7420_0003u, "the main bar's own slots alongside");
|
||||
Eq(DefStore.ToJson(r), DefStore.ToJson(d), "the round trip writes the same file");
|
||||
|
||||
// A file from before the extra bars: none. Odd entries: skipped, clamped, capped.
|
||||
var old = DefStore.Parse(JsonDocument.Parse("{\"slots\":[]}").RootElement);
|
||||
Eq(old.ExtraBars.Count, 0, "a file from before has none");
|
||||
string odd = "{\"extraBars\":[\"x\", {\"number\":1}, {\"number\":9}, {\"number\":3,\"slotCount\":99,\"slots\":[{\"item\":{\"id\":5,\"name\":\"Arrow\"}}]},"
|
||||
+ "{\"number\":3}, {\"number\":2,\"slotCount\":0}, {\"number\":4,\"slots\":\"none\"}, {\"number\":5}, {\"number\":4}]}";
|
||||
DefData o = DefStore.Parse(JsonDocument.Parse(odd).RootElement);
|
||||
Eq(string.Join(",", o.ExtraBars.Select(b => b.Number)), "2,3,4", "bad numbers (1, 9 and 5) and repeats skipped, sorted, at most 3");
|
||||
Check(o.Extra(3)!.SlotCount == ExtraBar.SlotsMax && o.Extra(3)!.Slots[0].Item?.Name == "Arrow", "too many slots: the most; its item read");
|
||||
Check(o.Extra(2)!.SlotCount == ExtraBar.SlotsMin, "too few: one");
|
||||
Check(o.Extra(4)!.Slots.All(s => s.Empty) && o.Extra(4)!.SlotCount == ExtraBar.DefaultSlots, "slots that aren't a list: empty, the default count");
|
||||
}
|
||||
|
||||
private static void ExtraBarsCommands()
|
||||
{
|
||||
DefCommand c = DefCommandParser.Parse("bars");
|
||||
Check(c.Verb == DefVerb.Bars && c.Text == "list", "/rdef bars lists");
|
||||
Check(DefCommandParser.Parse("bars list").Text == "list", "/rdef bars list");
|
||||
Check(DefCommandParser.Parse("bars add").Text == "add", "/rdef bars add");
|
||||
c = DefCommandParser.Parse("bars remove 3");
|
||||
Check(c.Verb == DefVerb.Bars && c.Text == "remove" && c.Slot == 3, "/rdef bars remove 3");
|
||||
c = DefCommandParser.Parse("bars slots 2 12");
|
||||
Check(c.Verb == DefVerb.Bars && c.Text == "slots" && c.Slot == 2 && c.Count == 12, "/rdef bars slots 2 12");
|
||||
c = DefCommandParser.Parse("bars show 4");
|
||||
Check(c.Verb == DefVerb.Bars && c.Text == "show" && c.Slot == 4, "/rdef bars show 4");
|
||||
Check(DefCommandParser.Parse("bars hide 4").Text == "show", "hide is the same toggle");
|
||||
foreach (string wrong in new[] { "bars remove", "bars remove two", "bars slots 2", "bars slots 2 99", "bars slots 2 0", "bars show", "bars frob", "bars add 2" })
|
||||
{
|
||||
c = DefCommandParser.Parse(wrong);
|
||||
Check(c.Verb == DefVerb.Error && (c.Error.Contains("e.g.", StringComparison.Ordinal) || c.Error.Contains("Usage", StringComparison.Ordinal)),
|
||||
$"'/rdef {wrong}' answers how it's typed: {c.Error}");
|
||||
}
|
||||
Check(DefCommandParser.Usage.Contains("bars"), "the usage line has it");
|
||||
|
||||
// The surfaces the engine draws them by.
|
||||
Check(RynthDefectivePlugin.TryExtraSurface("window:bar2", out int s2) && s2 == 2, "window:bar2 is bar 2");
|
||||
Check(RynthDefectivePlugin.TryExtraSurface(ExtraBar.SurfaceOf(4), out int s5) && s5 == 4, "window:bar4 is bar 4");
|
||||
foreach (string not in new[] { "window:bar", "window:bar1", "window:bar6", "window:bar22", "window:panels", "window:barx" })
|
||||
Check(!RynthDefectivePlugin.TryExtraSurface(not, out _), $"{not} is no extra bar");
|
||||
}
|
||||
|
||||
private static void ExtraBarSnapshot()
|
||||
{
|
||||
var rig = new Rig("xbar-snap");
|
||||
var kit = Kit(0x7430_0001u);
|
||||
rig.Inv = new List<CarriedItem> { kit };
|
||||
rig.S.AddBar(out _);
|
||||
rig.S.AddBar(out _);
|
||||
rig.S.SetFromId(2, kit.Id, bar: 3);
|
||||
rig.S.SetSpell(5, 1, bar: 3);
|
||||
|
||||
BarSnapshot v = BarSnapshotBuilder.BuildExtra(rig.S, 3, rig.Inv, canCast: true);
|
||||
Check(v.Ready && v.Bar == 3 && v.Slots.Length == ExtraBar.DefaultSlots, "bar 3: ready, 10 slots");
|
||||
Check(v.MinSlots == ExtraBar.SlotsMin && v.MaxSlots == ExtraBar.SlotsMax, "its edit buttons go 1-24");
|
||||
Check(v.Slots.All(s => !s.Retail && s.Key.Length == 0 && s.AllKeys.Length == 0), "no game slots, no keys");
|
||||
Check(v.Slots[1].ObjectId == kit.Id && v.Slots[1].Count == "28", "slot 2: the kit and its uses left");
|
||||
Check(v.Slots[1].Tooltip.Contains("Click: use it on you") && !v.Slots[1].Tooltip.Contains("press the key") && !v.Slots[1].Tooltip.Contains("No key yet"),
|
||||
"its tooltip: clicks, no keys: " + v.Slots[1].Tooltip);
|
||||
Check(v.Slots[4].SpellId == 1 && !v.Slots[4].Tooltip.Contains("press the key"), "slot 5: the spell");
|
||||
Check(v.Slots[0].Empty && v.Slots[0].Tooltip.Contains("Drag an item"), "an empty slot says how to fill it");
|
||||
Eq(string.Join(",", v.Extras.Select(e => e.Number + ":" + e.Filled)), "2:0,3:2", "the bars there are, for the menus");
|
||||
Check(v.CanAddBar, "two more can be added");
|
||||
rig.S.SetBarSlots(3, 2);
|
||||
Eq(BarSnapshotBuilder.BuildExtra(rig.S, 3, rig.Inv, true).Slots.Length, 2, "fewer slots shown");
|
||||
Check(!BarSnapshotBuilder.BuildExtra(rig.S, 4, rig.Inv, true).Ready, "a bar that isn't there: not ready");
|
||||
rig.S.AddBar(out _);
|
||||
rig.S.AddBar(out _);
|
||||
Check(!BarSnapshotBuilder.BuildExtra(rig.S, 2, rig.Inv, true).CanAddBar, "at three: no more");
|
||||
Check(BarSnapshot.NotReady.Bar == 0 && BarSnapshot.NotReady.MaxSlots == DefSettings.BarSlotsMax, "the main bar's limits by default");
|
||||
}
|
||||
|
||||
private static void ExtraBarSettings()
|
||||
{
|
||||
var b = new BarRig("xbar-settings");
|
||||
var host = new UiHost();
|
||||
UiWindow win = host.Add(new UiWindow("RynthDefective/Settings", "Defective Settings") { Visible = true, ShowInBar = false });
|
||||
var view = new BarSettingsView(b.S);
|
||||
var shown = new Dictionary<string, bool> { [BarSettingsView.BarTitle] = true };
|
||||
view.WindowShown = t => shown.TryGetValue(t, out bool v) ? v : null;
|
||||
view.ShowWindow = (t, v) => shown[t] = v;
|
||||
int adds = 0;
|
||||
var removed = new List<int>();
|
||||
view.AddBar = () => { adds++; b.S.AddBar(out _); };
|
||||
view.RemoveBar = n => { removed.Add(n); b.S.RemoveBar(n); };
|
||||
void Draw() { win.Begin(); view.Draw(win); win.End(); }
|
||||
string Text() => Encoding.UTF8.GetString(win.Body);
|
||||
var w = new Windows("xbar-settings-events");
|
||||
w.Host.Add(win);
|
||||
|
||||
Draw();
|
||||
ParseAll(host, "settings window with no extra bars", out _);
|
||||
Check(Text().Contains("More shortcut bars") && Text().Contains("Add a shortcut bar"), "the section and its Add button");
|
||||
w.Click(win, "set.xbar.add");
|
||||
Eq(adds, 1, "Add a shortcut bar adds one");
|
||||
Draw();
|
||||
Check(Text().Contains("Shortcuts bar 2: opening..."), "not hosted yet: opening");
|
||||
shown[ExtraBar.TitleOf(2)] = false;
|
||||
Draw();
|
||||
ParseAll(host, "settings window with bar 2", out int ops);
|
||||
Check(ops < 1500, "inside the engine's limits");
|
||||
w.SetBool(win, "set.xbar.2.shown", true);
|
||||
Check(shown[ExtraBar.TitleOf(2)], "its box shows it");
|
||||
w.SetInt(win, "set.xbar.2.slots", 15);
|
||||
Check(b.S.Data.Extra(2)!.SlotCount == 15, "its slider sets its slots");
|
||||
w.Click(win, "set.xbar.2.remove");
|
||||
Draw();
|
||||
Check(Text().Contains("Remove Shortcuts bar 2?") && removed.Count == 0, "Remove asks first");
|
||||
w.Click(win, "set.xbar.2.no");
|
||||
Draw();
|
||||
Check(!Text().Contains("Remove Shortcuts bar 2?") && b.S.Data.Extra(2) != null, "Keep it keeps it");
|
||||
w.Click(win, "set.xbar.2.remove");
|
||||
Draw();
|
||||
w.Click(win, "set.xbar.2.yes");
|
||||
Check(removed.SequenceEqual(new[] { 2 }) && b.S.Data.Extra(2) == null, "Remove it removes it");
|
||||
|
||||
for (int i = 0; i < ExtraBar.Max; i++) b.S.AddBar(out _);
|
||||
Draw();
|
||||
Check(!Text().Contains("Add a shortcut bar") && Text().Contains("as many as there can be"), "at three: no Add button, and why");
|
||||
|
||||
// An engine without the Shortcuts bar: no section.
|
||||
shown.Remove(BarSettingsView.BarTitle);
|
||||
Draw();
|
||||
Check(!Text().Contains("More shortcut bars"), "no Shortcuts bar on this engine: no extra bars either");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -73,6 +73,9 @@ namespace RynthDefective.Tests
|
|||
Run("busy rule with RynthAi holding: its own action and our last use hold, the rest of the count doesn't", BusyRulePaced);
|
||||
Run("use: the player's turn - after a death the press goes next, RynthAi holds and is let go", UsePlayersTurn);
|
||||
Run("use: just after a portal the client takes nothing for a few seconds - the press waits and goes when it can", UseAfterPortal);
|
||||
Run("busy clear rule: only a count with nothing real in flight is cleared", BusyClearDecisions);
|
||||
Run("use: shortcuts clear a stuck busy state - off by default, then clear once per press and use", UseClearStuckBusy);
|
||||
Run("store, command and settings: shortcuts clear a stuck busy state", ClearBusySettingAndCommand);
|
||||
Run("spells: the table's names and flags, the name search", SpellTableAndSearch);
|
||||
Run("spells: whom a cast goes to", SpellCastTarget);
|
||||
Run("spells: a slot casts, Magic mode first, refusals", SpellUse);
|
||||
|
|
@ -98,6 +101,12 @@ namespace RynthDefective.Tests
|
|||
Run("bar: making it independent offers to copy the game's 18 slots", BarIndependentCopy);
|
||||
Run("store: the independent bar setting; files from before read it off", BarStoreIndependent);
|
||||
Run("window: the settings window parses and its switches reach their code", BarSettingsWindow);
|
||||
Run("extra bars: add and remove, the lowest free number, at most 4", ExtraBarsAddRemoveCap);
|
||||
Run("extra bars: their own slots filled, used and kept like the main bar's own", ExtraBarsSlots);
|
||||
Run("store: the extra bars saved and read; files from before and odd ones", ExtraBarsStore);
|
||||
Run("extra bars: /rdef bars parsing", ExtraBarsCommands);
|
||||
Run("extra bars: what an extra bar's window draws (no game slots, no keys)", ExtraBarSnapshot);
|
||||
Run("window: the settings window's rows for the extra bars", ExtraBarSettings);
|
||||
Run("corpses: the server's lines", CorpseLinesParse);
|
||||
Run("corpses: a death, the server's line before or after it, nothing dropped", CorpseDeaths);
|
||||
Run("corpses: a corpse in view is the death beside it, else one found", CorpseSeen);
|
||||
|
|
@ -117,6 +126,10 @@ namespace RynthDefective.Tests
|
|||
Run("quantity: a server's bank - its values, pack + bank, one that can't be read, max", QtyBankRules);
|
||||
Run("quantity: buy and max with no bank, a bank that covers it, one that doesn't, one that can't be read", QtyBankBuy);
|
||||
Run("store: the quantity box setting; files from before read it on", QtyStore);
|
||||
Run("day/night: day or night, the hour and the real seconds to dawn or dusk", ClockDayNight);
|
||||
Run("day/night: the same as RynthAi's meta expressions, a countdown with no jumps", ClockMatchesRynthAi);
|
||||
Run("day/night: the countdown text (23m, 4m 10s, 45s)", ClockCountdownText);
|
||||
Run("day/night: the window's view and tooltip, /rdef daynight and its answers", ClockWindowAndCommand);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -257,6 +270,20 @@ namespace RynthDefective.Tests
|
|||
Releases++;
|
||||
BotHeldNow = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// The busy-count resets asked for ("Shortcuts clear a stuck busy state"). CanClear false: an engine
|
||||
/// without ForceResetBusyCount. ClearLands false: the reset doesn't take. It lands on the next tick.
|
||||
/// </summary>
|
||||
public int Clears;
|
||||
public bool CanClear = true, ClearLands = true;
|
||||
private bool _clearPending;
|
||||
public bool ClearBusyCount()
|
||||
{
|
||||
if (!CanClear) return false;
|
||||
Clears++;
|
||||
_clearPending = ClearLands;
|
||||
return true;
|
||||
}
|
||||
public int UseDoneSeq { get; set; } = 1;
|
||||
public int CombatMode { get; set; } = Stance.NonCombat;
|
||||
public int RefusalSeq { get; set; }
|
||||
|
|
@ -307,7 +334,11 @@ namespace RynthDefective.Tests
|
|||
return true;
|
||||
}
|
||||
|
||||
public void Advance(long ms) => NowMs += ms;
|
||||
public void Advance(long ms)
|
||||
{
|
||||
NowMs += ms;
|
||||
if (_clearPending) { BusyCount = 0; _clearPending = false; } // the engine resets on the game's next tick
|
||||
}
|
||||
public void Answer(uint error = 0)
|
||||
{
|
||||
UseDoneSeq++;
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ namespace RynthDefective.Tests
|
|||
{
|
||||
// Wrong words: the parser's error is the reply, with an example or the usage.
|
||||
string[] wrong = { "use", "set", "set x", "set 0", "spell 3", "spell", "clear", "clear x", "bind 3", "bind", "unbind", "unbind x", "slots", "slots 99",
|
||||
"qty 0", "qty lots", "split 0", "give someone", "give -1", "buy 0 Mana Scarab" };
|
||||
"qty 0", "qty lots", "split 0", "give someone", "give -1", "buy 0 Mana Scarab", "bars remove", "bars slots 2", "bars frob", "shortcuts", "shortcuts clearbusy maybe", "daynight later" };
|
||||
foreach (string w in wrong)
|
||||
{
|
||||
DefCommand c = DefCommandParser.Parse(w);
|
||||
|
|
@ -105,6 +105,9 @@ namespace RynthDefective.Tests
|
|||
("Stamina Kit", DefVerb.Use), ("corpses", DefVerb.Corpses), ("corpses clear", DefVerb.Corpses),
|
||||
("qty", DefVerb.Quantity), ("qty 25", DefVerb.Quantity), ("split", DefVerb.Split), ("split 25 into Sack", DefVerb.Split),
|
||||
("give 10", DefVerb.Give), ("buy 25 Mana Scarab", DefVerb.Buy), ("buy max", DefVerb.Buy),
|
||||
("daynight", DefVerb.DayNight), ("daynight show", DefVerb.DayNight), ("daynight hide", DefVerb.DayNight),
|
||||
("bars", DefVerb.Bars), ("bars add", DefVerb.Bars), ("bars remove 2", DefVerb.Bars), ("bars slots 2 12", DefVerb.Bars),
|
||||
("bars show 3", DefVerb.Bars), ("shortcuts clearbusy on", DefVerb.Shortcuts), ("shortcuts clearbusy", DefVerb.Shortcuts),
|
||||
};
|
||||
var seen = new HashSet<DefVerb>();
|
||||
foreach (var (typed, verb) in right)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@
|
|||
(RynthCore src/RynthCore.Engine/UI/ScriptWindows/DisplayListParser.cs, compiled in from the
|
||||
sibling RynthCore checkout) and that clicks reach the code that drew the button; the quantity box
|
||||
(counts, max and half, a vendor's price and the most you can buy, every refusal, split / give / buy
|
||||
against a scripted world).
|
||||
against a scripted world); the Day/Night timer's clock (day or night, the real seconds to the next dawn or
|
||||
dusk, the countdown text, /rdef daynight).
|
||||
Nothing native is loaded: no AC, no ImGui context. Files go to a temp folder, never C:\Games.
|
||||
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
|
||||
-->
|
||||
|
|
@ -41,6 +42,8 @@
|
|||
<Compile Include="..\..\Plugins\Shared\RynthAiStatusApi.cs" Link="Shared\RynthAiStatusApi.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\RynthInstallPaths.cs" Link="Shared\RynthInstallPaths.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\CommandReply.cs" Link="Shared\CommandReply.cs" />
|
||||
<!-- The Day/Night timer's clock math (2026-11-04). -->
|
||||
<Compile Include="..\..\Plugins\Shared\DerethClock.cs" Link="Shared\DerethClock.cs" />
|
||||
<!-- The server plugin's bank values for the quantity box's buys (2026-10-31). -->
|
||||
<Compile Include="..\..\Plugins\Shared\EngineServerState.cs" Link="Shared\EngineServerState.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\ServerStateClient.cs" Link="Shared\ServerStateClient.cs" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue