RynthServers as of 2026-11-08 (internal 865b704): release 2026.11.8.2

This commit is contained in:
Tom Bohar 2026-11-08 21:05:44 -05:00
commit 3dd7e983c3
7 changed files with 214 additions and 57 deletions

View file

@ -72,10 +72,10 @@ internal static class AttributesPage
} }
public static bool CanRaiseOne(SkillsSheet sheet, AttributeLine a) public static bool CanRaiseOne(SkillsSheet sheet, AttributeLine a)
=> !sheet.Busy && a.Raisable && a.CostOne > 0 && sheet.UnassignedXp >= a.CostOne; => a.Raisable && a.CostOne > 0 && sheet.UnassignedXp >= a.CostOne;
public static bool CanRaiseTen(SkillsSheet sheet, AttributeLine a) public static bool CanRaiseTen(SkillsSheet sheet, AttributeLine a)
=> !sheet.Busy && a.Raisable && a.CostTen > 0 && sheet.UnassignedXp >= a.CostTen; => a.Raisable && a.CostTen > 0 && sheet.UnassignedXp >= a.CostTen;
/// <summary>The way through the current rank (0..1) on the attribute or vital chart: the footer's blue bar.</summary> /// <summary>The way through the current rank (0..1) on the attribute or vital chart: the footer's blue bar.</summary>
public static float RankProgress(AttributeLine a) public static float RankProgress(AttributeLine a)

View file

@ -0,0 +1,71 @@
// HeldRaises.cs - presses of the raise arrow and "+10" made while the last raise is still on its way
// (2026-11-08, Tom: "I can't spam +10 unless I click off the skill and back onto it"). The engine sends
// one raise at a time and is Busy until the server's answer lands; a press made meanwhile used to be
// lost (the button was ghosted). Now it's held here and sent, at the new cost, as soon as the answer is
// in - one held press per answer, so five clicks of +10 are five raises of ten, as retail's arrows do.
//
// Pure: SkillsReader presses on the plugin tick and asks Next after each read.
using System;
namespace RynthCore.Plugin.RynthDreamWeave;
/// <summary>What a press raises: Kind 1 attribute, 2 vital, 3 skill (XP), 4 train a skill (credits).</summary>
internal readonly record struct RaiseTarget(int Kind, uint Id, bool Ten)
{
public const int Attribute = 1, Vital = 2, Skill = 3, Train = 4;
}
internal sealed class HeldRaises
{
/// <summary>At most this many presses wait (a stuck mouse doesn't spend everything).</summary>
public const int Max = 10;
/// <summary>Presses not sent this long after the last one are forgotten (the server never answered).</summary>
public const long ForgetMs = 6000;
private readonly object _gate = new();
private RaiseTarget _target;
private int _count;
private long _lastPressMs;
/// <summary>Presses waiting (any thread).</summary>
public int Count { get { lock (_gate) return _count; } }
/// <summary>
/// A press. The same target adds to the ones waiting; another target replaces them (a click on another
/// row or button is a new decision). Training a skill never waits more than once: once trained, the
/// same arrow raises it, which a second click of "train" didn't ask for.
/// </summary>
public void Press(RaiseTarget t, long nowMs)
{
lock (_gate)
{
if (_count > 0 && t == _target) _count = Math.Min(_count + 1, t.Kind == RaiseTarget.Train ? 1 : Max);
else { _target = t; _count = 1; }
_lastPressMs = nowMs;
}
}
/// <summary>The press to send now: none while <paramref name="busy"/> (the last raise hasn't landed).</summary>
public bool Next(long nowMs, bool busy, out RaiseTarget t)
{
lock (_gate)
{
t = _target;
if (_count == 0) return false;
if (nowMs - _lastPressMs > ForgetMs) { _count = 0; return false; }
return !busy;
}
}
/// <summary>The press Next gave went out.</summary>
public void Sent()
{
lock (_gate) if (_count > 0) _count--;
}
/// <summary>Forget them all (refused: not enough XP, at the top; or the character changed).</summary>
public void Drop()
{
lock (_gate) _count = 0;
}
}

View file

@ -210,6 +210,7 @@ internal sealed class SkillsPanel
int first = (int)MathF.Round(_attrScroll); int first = (int)MathF.Round(_attrScroll);
_dl.PushClipRect(P(0, top), P(BannerW, top + listH), true); _dl.PushClipRect(P(0, top), P(BannerW, top + listH), true);
bool onRow = false;
try try
{ {
for (int i = first, y = top; i < rows.Count && y < top + listH; i++, y += RowH) for (int i = first, y = top; i < rows.Count && y < top + listH; i++, y += RowH)
@ -221,11 +222,12 @@ internal sealed class SkillsPanel
Text(RetailData.Pal18, a.Name, 25, y, 150, RowH, White); Text(RetailData.Pal18, a.Name, 25, y, 150, RowH, White);
uint color = a.Buffed > a.Base ? Green : a.Buffed < a.Base ? Red : White; uint color = a.Buffed > a.Base ? Green : a.Buffed < a.Base ? Red : White;
Text(RetailData.Pal18, a.ValueText, 125, y, 149, RowH, color, right: true); Text(RetailData.Pal18, a.ValueText, 125, y, 149, RowH, color, right: true);
if (clicked && Hit(0, y, BannerW, RowH)) _attrSelected = row; if (clicked && Hit(0, y, BannerW, RowH)) { _attrSelected = row; onRow = true; }
if (listHovered && Hit(0, y, BannerW, RowH)) Hover(1000u + (uint)row, AttributesPage.Tip(a)); if (listHovered && Hit(0, y, BannerW, RowH)) Hover(1000u + (uint)row, AttributesPage.Tip(a));
} }
} }
finally { _dl.PopClipRect(); } finally { _dl.PopClipRect(); }
if (clicked && !onRow) _attrSelected = -1; // below the rows: nothing selected, as on the Skills page
if (rows.Count > visible) ScrollBar("attr", ref _attrScroll, top, listH, visible, rows.Count, maxScroll); if (rows.Count > visible) ScrollBar("attr", ref _attrScroll, top, listH, visible, rows.Count, maxScroll);
AttributeLine? sel = null; AttributeLine? sel = null;
@ -235,8 +237,8 @@ internal sealed class SkillsPanel
FooterBox(pageH, title, delta, sel?.BuffDelta ?? 0, one, two, sel != null, FooterBox(pageH, title, delta, sel?.BuffDelta ?? 0, one, two, sel != null,
sel != null ? AttributesPage.RankProgress(sel) : 0, sel != null ? AttributesPage.RankProgress(sel) : 0,
sel != null && AttributesPage.CanRaiseOne(sheet, sel), sel != null && AttributesPage.CanRaiseTen(sheet, sel), showTen: true, sel != null && AttributesPage.CanRaiseOne(sheet, sel), sel != null && AttributesPage.CanRaiseTen(sheet, sel), showTen: true,
sel == null ? null : () => _onTick(() => _reader.Raise(_host, sel, ten: false, _chat)), sel == null ? null : () => Press(new RaiseTarget(sel.Kind, sel.Stype, Ten: false)),
sel == null ? null : () => _onTick(() => _reader.Raise(_host, sel, ten: true, _chat))); sel == null ? null : () => Press(new RaiseTarget(sel.Kind, sel.Stype, Ten: true)));
} }
// ── The Titles page (0x10000539) ──────────────────────────────────── // ── The Titles page (0x10000539) ────────────────────────────────────
@ -492,6 +494,7 @@ internal sealed class SkillsPanel
Vector2 clipMin = P(0, top), clipMax = P(BannerW, top + listH); Vector2 clipMin = P(0, top), clipMax = P(BannerW, top + listH);
_dl.PushClipRect(clipMin, clipMax, true); _dl.PushClipRect(clipMin, clipMax, true);
bool onRow = false;
try try
{ {
for (int i = first, y = top; i < rows.Count && y < top + listH; i++, y += RowH) for (int i = first, y = top; i < rows.Count && y < top + listH; i++, y += RowH)
@ -510,7 +513,7 @@ internal sealed class SkillsPanel
Text(RetailData.Pal18, s.Name, 25, y, 150, RowH, White); Text(RetailData.Pal18, s.Name, 25, y, 150, RowH, White);
uint color = s.Buffed > s.Base ? Green : s.Buffed < s.Base ? Red : White; uint color = s.Buffed > s.Base ? Green : s.Buffed < s.Base ? Red : White;
Text(RetailData.Pal18, SkillsSheet.Number(s.Buffed), 175, y, 99, RowH, color, right: true); Text(RetailData.Pal18, SkillsSheet.Number(s.Buffed), 175, y, 99, RowH, color, right: true);
if (clicked && Hit(0, y, BannerW, RowH)) _selected = s.Id; if (clicked && Hit(0, y, BannerW, RowH)) { _selected = s.Id; onRow = true; }
if (listHovered && Hit(0, y, BannerW, RowH) && RetailData.Skill(s.Id) is RetailSkill info) if (listHovered && Hit(0, y, BannerW, RowH) && RetailData.Skill(s.Id) is RetailSkill info)
Hover(s.Id, info.Formula.Length > 0 ? info.Formula + "\n" + info.Description : info.Description); Hover(s.Id, info.Formula.Length > 0 ? info.Formula + "\n" + info.Description : info.Description);
} }
@ -519,6 +522,9 @@ internal sealed class SkillsPanel
{ {
_dl.PopClipRect(); _dl.PopClipRect();
} }
// A click on a section header or below the rows selects nothing, as retail's: the footer shows the
// skill credits and unassigned XP available (Tom 2026-11-08).
if (clicked && !onRow) _selected = 0;
if (rows.Count > visible) ScrollBar("skills", ref _scroll, top, listH, visible, rows.Count, maxScroll); if (rows.Count > visible) ScrollBar("skills", ref _scroll, top, listH, visible, rows.Count, maxScroll);
} }
@ -626,10 +632,13 @@ internal sealed class SkillsPanel
s != null ? SkillsLayout.RankProgress(s) : 0, s != null ? SkillsLayout.RankProgress(s) : 0,
s != null && SkillsLayout.CanRaiseOne(sheet, s), s != null && SkillsLayout.CanRaiseTen(sheet, s), s != null && SkillsLayout.CanRaiseOne(sheet, s), s != null && SkillsLayout.CanRaiseTen(sheet, s),
showTen: s != null && s.Class >= SkillClass.Trained, showTen: s != null && s.Class >= SkillClass.Trained,
s == null ? null : () => _onTick(() => _reader.Raise(_host, s, ten: false, _chat)), s == null ? null : () => Press(new RaiseTarget(s.Class >= SkillClass.Trained ? RaiseTarget.Skill : RaiseTarget.Train, s.Id, Ten: false)),
s == null ? null : () => _onTick(() => _reader.Raise(_host, s, ten: true, _chat))); s == null ? null : () => Press(new RaiseTarget(RaiseTarget.Skill, s.Id, Ten: true)));
} }
/// <summary>A raise arrow or +10 click: sent on the tick, or held until the last raise lands (HeldRaises).</summary>
private void Press(RaiseTarget t) => _onTick(() => _reader.Press(_host, t, _chat));
/// <summary> /// <summary>
/// The footer: the selected row's title ("Salvaging: 303 (+45)", the buff part green or red), then two /// The footer: the selected row's title ("Salvaging: 303 (+45)", the buff part green or red), then two
/// label/value lines; with a row selected the first sits on the plate whose blue inset fills with the way /// label/value lines; with a row selected the first sits on the plate whose blue inset fills with the way

View file

@ -5,9 +5,11 @@
// them every 2 s while asked, and at once after a raise) and the header's properties, and publishes one // them every 2 s while asked, and at once after a raise) and the header's properties, and publishes one
// SkillsSheet. Nothing is read while the panel is closed. // SkillsSheet. Nothing is read while the panel is closed.
// //
// Spending: the panel's raise arrow and "+10" queue a Raise (or a train, for an untrained skill) with the // Spending: the panel's raise arrow and "+10" queue a press (a raise, or a train for an untrained skill);
// cost the player saw; the engine refuses it when the cost changed meanwhile (RaiseResult.CostChanged), // the tick sends it at the cost the newest numbers say, and the engine refuses it when its own numbers
// so a click never spends more than the footer said. Like retail's arrow there is no confirm. // differ (RaiseResult.CostChanged). Presses made while the last raise is on its way are held (HeldRaises)
// and sent one per answer, and the numbers are read every frame meanwhile, so +10 can be clicked as fast
// as the server answers. Like retail's arrow there is no confirm.
using System; using System;
using System.Threading; using System.Threading;
using RynthCore.PluginSdk; using RynthCore.PluginSdk;
@ -25,6 +27,8 @@ internal sealed class SkillsReader
private long _lastAsk; private long _lastAsk;
private int _readQueued; private int _readQueued;
private string _message = ""; private string _message = "";
private readonly HeldRaises _held = new();
private Action<string>? _chat;
/// <summary>The newest snapshot (any thread).</summary> /// <summary>The newest snapshot (any thread).</summary>
public SkillsSheet Sheet => Volatile.Read(ref _sheet); public SkillsSheet Sheet => Volatile.Read(ref _sheet);
@ -39,7 +43,9 @@ internal sealed class SkillsReader
public bool ReadDue() public bool ReadDue()
{ {
long now = Environment.TickCount64; long now = Environment.TickCount64;
if (now - Volatile.Read(ref _lastAsk) < ReadEveryMs) return false; // A raise on its way or a press waiting: every frame, to send the next one as soon as it may go.
long every = _held.Count > 0 || Volatile.Read(ref _sheet).Busy ? 0 : ReadEveryMs;
if (now - Volatile.Read(ref _lastAsk) < every) return false;
if (Interlocked.Exchange(ref _readQueued, 1) == 1) return false; if (Interlocked.Exchange(ref _readQueued, 1) == 1) return false;
Volatile.Write(ref _lastAsk, now); Volatile.Write(ref _lastAsk, now);
return true; return true;
@ -50,6 +56,7 @@ internal sealed class SkillsReader
{ {
Volatile.Write(ref _sheet, SkillsSheet.Empty); Volatile.Write(ref _sheet, SkillsSheet.Empty);
Volatile.Write(ref _message, ""); Volatile.Write(ref _message, "");
_held.Drop();
} }
/// <summary>Plugin tick: reads the numbers and publishes a new sheet when they are in.</summary> /// <summary>Plugin tick: reads the numbers and publishes a new sheet when they are in.</summary>
@ -105,6 +112,7 @@ internal sealed class SkillsReader
lumMax is > 0 ? lumAvail ?? 0 : null, lumMax is > 0 ? lumMax : null, lumMax is > 0 ? lumAvail ?? 0 : null, lumMax is > 0 ? lumMax : null,
skills, info.Busy, info.SnapshotVersion, attrList, titles); skills, info.Busy, info.SnapshotVersion, attrList, titles);
Volatile.Write(ref _sheet, sheet); Volatile.Write(ref _sheet, sheet);
SendHeld(host);
} }
finally finally
{ {
@ -113,31 +121,67 @@ internal sealed class SkillsReader
} }
/// <summary> /// <summary>
/// Plugin tick: the raise arrow (<paramref name="ten"/> false: one rank, or train an untrained skill /// Plugin tick: the raise arrow or "+10" was pressed (<see cref="RaiseTarget"/>). Sent at once when
/// with credits) or "+10", at the cost the footer showed. The answer comes back in the numbers; /// nothing is on its way, else held until the last raise's answer lands. A refusal is said in the
/// a refusal is said in the footer and chat. /// footer and chat; the answer comes back in the numbers.
/// </summary> /// </summary>
public void Raise(RynthCoreHost host, SkillLine skill, bool ten, Action<string> chat) public void Press(RynthCoreHost host, RaiseTarget target, Action<string> chat)
{ {
_chat = chat;
_held.Press(target, Environment.TickCount64);
Volatile.Write(ref _message, "");
SendHeld(host);
}
/// <summary>Plugin tick: sends the next held press when the last raise has landed.</summary>
private void SendHeld(RynthCoreHost host)
{
SkillsSheet sheet = Volatile.Read(ref _sheet);
if (!_held.Next(Environment.TickCount64, sheet.Busy, out RaiseTarget t)) return;
string name;
RaiseResult r; RaiseResult r;
if (skill.Class < SkillClass.Trained) if (t.Kind is RaiseTarget.Skill or RaiseTarget.Train)
r = host.TrainSkill(skill.Id, skill.TrainCredits); {
SkillLine? skill = null;
foreach (SkillLine s in sheet.Skills) if (s.Id == t.Id) { skill = s; break; }
// Trained meanwhile (a train press) or not trained (a raise press): not what was clicked.
if (skill == null || (t.Kind == RaiseTarget.Train) != (skill.Class < SkillClass.Trained)) { _held.Drop(); return; }
name = skill.Name;
r = t.Kind == RaiseTarget.Train
? host.TrainSkill(skill.Id, skill.TrainCredits)
: host.Raise(TrainingKind.Skill, skill.Id, t.Ten ? 10u : 1u, t.Ten ? skill.CostTen : skill.CostOne, out _);
}
else else
r = host.Raise(TrainingKind.Skill, skill.Id, ten ? 10u : 1u, ten ? skill.CostTen : skill.CostOne, out _); {
AttributeLine? a = null;
foreach (AttributeLine x in sheet.AttributeRows) if (x.Kind == t.Kind && x.Stype == t.Id) { a = x; break; }
if (a == null) { _held.Drop(); return; }
name = a.Name;
r = host.Raise(a.IsVital ? TrainingKind.Vital : TrainingKind.Attribute, a.Stype, t.Ten ? 10u : 1u,
t.Ten ? a.CostTen : a.CostOne, out _);
}
Volatile.Write(ref _lastAsk, 0); // read again at once
switch (r)
{
case RaiseResult.Sent:
_held.Sent();
return;
// The numbers moved under it, or the last raise hasn't landed: it waits for the next read.
case RaiseResult.CostChanged or RaiseResult.Stale or RaiseResult.NotReady or RaiseResult.Busy:
return;
}
_held.Drop();
string what = t.Kind is RaiseTarget.Skill or RaiseTarget.Train ? "skills" : "attributes";
string why = r switch string why = r switch
{ {
RaiseResult.Sent => "", RaiseResult.NotEnough => t.Kind == RaiseTarget.Train ? "Not enough skill credits." : "Not enough unassigned experience.",
RaiseResult.CostChanged or RaiseResult.Stale or RaiseResult.NotReady or RaiseResult.Busy RaiseResult.NotRaisable => $"{name} can't be raised any further.",
=> "The numbers changed; look again and press once more.", RaiseResult.Unavailable => $"This client can't raise {what} from a plugin.",
RaiseResult.NotEnough => skill.Class < SkillClass.Trained ? "Not enough skill credits." : "Not enough unassigned experience.", RaiseResult.EngineTooOld => $"This RynthCore is too old to raise {what} (needs plugin API v79).",
RaiseResult.NotRaisable => $"{skill.Name} can't be raised any further.", _ => $"{name} wasn't raised ({r}).",
RaiseResult.Unavailable => "This client can't raise skills from a plugin.",
RaiseResult.EngineTooOld => "This RynthCore is too old to raise skills (needs plugin API v79).",
_ => $"{skill.Name} wasn't raised ({r}).",
}; };
Volatile.Write(ref _message, why); Volatile.Write(ref _message, why);
Volatile.Write(ref _lastAsk, 0); // read again at once _chat?.Invoke(why);
if (why.Length > 0) chat(why);
} }
// ── Titles (the server's list, kept per character: AttributesTitles.cs) ── // ── Titles (the server's list, kept per character: AttributesTitles.cs) ──
@ -191,30 +235,6 @@ internal sealed class SkillsReader
Volatile.Write(ref _lastAsk, 0); Volatile.Write(ref _lastAsk, 0);
} }
/// <summary>
/// Plugin tick: raises an attribute (Kind 1) or vital maximum (Kind 2) one or ten ranks at the cost the
/// footer showed, as the skills' arrows do.
/// </summary>
public void Raise(RynthCoreHost host, AttributeLine a, bool ten, Action<string> chat)
{
RaiseResult r = host.Raise(a.IsVital ? TrainingKind.Vital : TrainingKind.Attribute, a.Stype, ten ? 10u : 1u,
ten ? a.CostTen : a.CostOne, out _);
string why = r switch
{
RaiseResult.Sent => "",
RaiseResult.CostChanged or RaiseResult.Stale or RaiseResult.NotReady or RaiseResult.Busy
=> "The numbers changed; look again and press once more.",
RaiseResult.NotEnough => "Not enough unassigned experience.",
RaiseResult.NotRaisable => $"{a.Name} can't be raised any further.",
RaiseResult.Unavailable => "This client can't raise attributes from a plugin.",
RaiseResult.EngineTooOld => "This RynthCore is too old to raise attributes (needs plugin API v79).",
_ => $"{a.Name} wasn't raised ({r}).",
};
Volatile.Write(ref _message, why);
Volatile.Write(ref _lastAsk, 0);
if (why.Length > 0) chat(why);
}
private static int Int(RynthCoreHost host, uint id, uint stype) private static int Int(RynthCoreHost host, uint id, uint stype)
=> id != 0 && host.HasGetObjectIntProperty && host.TryGetObjectIntProperty(id, stype, out int v) ? v : 0; => id != 0 && host.HasGetObjectIntProperty && host.TryGetObjectIntProperty(id, stype, out int v) ? v : 0;

View file

@ -131,17 +131,19 @@ internal static class SkillsLayout
("Unassigned Experience:", unassigned)); ("Unassigned Experience:", unassigned));
} }
/// <summary>Whether the raise arrow (+1, or train for an untrained skill) can be pressed now.</summary> /// <summary>
/// Whether the raise arrow (+1, or train for an untrained skill) can be pressed now. Not ghosted while an
/// earlier raise is on its way: that press is held and sent when it lands (HeldRaises).
/// </summary>
public static bool CanRaiseOne(SkillsSheet sheet, SkillLine s) public static bool CanRaiseOne(SkillsSheet sheet, SkillLine s)
{ {
if (sheet.Busy) return false;
if (s.Class >= SkillClass.Trained) return s.Raisable && s.CostOne > 0 && sheet.UnassignedXp >= s.CostOne; if (s.Class >= SkillClass.Trained) return s.Raisable && s.CostOne > 0 && sheet.UnassignedXp >= s.CostOne;
return s.Trainable && s.TrainCredits > 0 && sheet.SkillCredits >= s.TrainCredits; return s.Trainable && s.TrainCredits > 0 && sheet.SkillCredits >= s.TrainCredits;
} }
/// <summary>Whether "+10" can be pressed now (trained or specialized, ten ranks left and affordable).</summary> /// <summary>Whether "+10" can be pressed now (trained or specialized, ten ranks left and affordable).</summary>
public static bool CanRaiseTen(SkillsSheet sheet, SkillLine s) public static bool CanRaiseTen(SkillsSheet sheet, SkillLine s)
=> !sheet.Busy && s.Class >= SkillClass.Trained && s.Raisable && s.CostTen > 0 && sheet.UnassignedXp >= s.CostTen; => s.Class >= SkillClass.Trained && s.Raisable && s.CostTen > 0 && sheet.UnassignedXp >= s.CostTen;
/// <summary> /// <summary>
/// Retail's header line one: the allegiance rank's title for the heritage and sex, then the name /// Retail's header line one: the allegiance rank's title for the heritage and sex, then the name

View file

@ -30,6 +30,7 @@ internal static class DreamWeaveSkillsTests
r.Add("dreamweave skills: the Attributes page (rows, values, footer, bar)", Attributes); r.Add("dreamweave skills: the Attributes page (rows, values, footer, bar)", Attributes);
r.Add("dreamweave skills: the Titles page (the server's list, updates, saving)", Titles); r.Add("dreamweave skills: the Titles page (the server's list, updates, saving)", Titles);
r.Add("dreamweave skills: one main panel at a time, as retail", OnePanel); r.Add("dreamweave skills: one main panel at a time, as retail", OnePanel);
r.Add("dreamweave skills: +10 presses made while a raise is on its way wait for its answer", HeldPresses);
} }
private static void Attributes() private static void Attributes()
@ -175,7 +176,8 @@ internal static class DreamWeaveSkillsTests
Check.True(SkillsLayout.CanRaiseTen(rich, Skill(14, SkillClass.Trained, ten: 12000)), "ten affordable"); Check.True(SkillsLayout.CanRaiseTen(rich, Skill(14, SkillClass.Trained, ten: 12000)), "ten affordable");
Check.False(SkillsLayout.CanRaiseTen(rich, Skill(14, SkillClass.Trained, ten: 90_000)), "ten too dear"); Check.False(SkillsLayout.CanRaiseTen(rich, Skill(14, SkillClass.Trained, ten: 90_000)), "ten too dear");
Check.False(SkillsLayout.CanRaiseOne(rich, Skill(14, SkillClass.Trained, one: -1, raisable: false)), "at the top"); Check.False(SkillsLayout.CanRaiseOne(rich, Skill(14, SkillClass.Trained, one: -1, raisable: false)), "at the top");
Check.False(SkillsLayout.CanRaiseOne(rich with { Busy = true }, Skill(14, SkillClass.Trained)), "an earlier raise still pending"); Check.True(SkillsLayout.CanRaiseOne(rich with { Busy = true }, Skill(14, SkillClass.Trained)), "lit while an earlier raise is on its way (the press is held)");
Check.True(SkillsLayout.CanRaiseTen(rich with { Busy = true }, Skill(14, SkillClass.Trained, ten: 12000)), "+10 too");
Check.True(SkillsLayout.CanRaiseOne(rich, Skill(23, SkillClass.Untrained, credits: 6, trainable: true)), "train with credits"); Check.True(SkillsLayout.CanRaiseOne(rich, Skill(23, SkillClass.Untrained, credits: 6, trainable: true)), "train with credits");
Check.False(SkillsLayout.CanRaiseOne(rich with { SkillCredits = 5 }, Skill(23, SkillClass.Untrained, credits: 6, trainable: true)), "not enough credits"); Check.False(SkillsLayout.CanRaiseOne(rich with { SkillCredits = 5 }, Skill(23, SkillClass.Untrained, credits: 6, trainable: true)), "not enough credits");
Check.False(SkillsLayout.CanRaiseTen(rich, Skill(23, SkillClass.Untrained, credits: 6, trainable: true)), "no +10 for untrained"); Check.False(SkillsLayout.CanRaiseTen(rich, Skill(23, SkillClass.Untrained, credits: 6, trainable: true)), "no +10 for untrained");
@ -312,4 +314,56 @@ internal static class DreamWeaveSkillsTests
rule.Reset(); rule.Reset();
Check.Eq(rule.Next(true, Map), default(OnePanelRule.Step), "after a reset the first frame only learns again"); Check.Eq(rule.Next(true, Map), default(OnePanelRule.Step), "after a reset the first frame only learns again");
} }
private static void HeldPresses()
{
var held = new HeldRaises();
var ten = new RaiseTarget(RaiseTarget.Skill, 14, Ten: true);
Check.False(held.Next(0, busy: false, out _), "nothing pressed");
held.Press(ten, 0);
Check.True(held.Next(0, busy: false, out RaiseTarget t) && t == ten, "a press goes at once when nothing is on its way");
held.Sent();
// Spamming while the first is on its way: each waits, none is lost.
held.Press(ten, 100); held.Press(ten, 150); held.Press(ten, 200);
Check.Eq(held.Count, 3, "three held");
Check.False(held.Next(250, busy: true, out _), "not while the last raise hasn't landed");
Check.True(held.Next(300, busy: false, out _), "its answer is in: the next goes");
held.Sent();
Check.Eq(held.Count, 2, "one per answer");
// Another button or row is a new decision.
var one = new RaiseTarget(RaiseTarget.Skill, 14, Ten: false);
held.Press(one, 400);
Check.Eq(held.Count, 1, "another target replaces what waited");
held.Drop();
Check.Eq(held.Count, 0, "refused: all forgotten");
// Train never waits twice: once trained the same arrow raises, which wasn't asked for.
var train = new RaiseTarget(RaiseTarget.Train, 23, Ten: false);
held.Press(train, 500); held.Press(train, 520);
Check.Eq(held.Count, 1, "one train");
held.Drop();
for (int i = 0; i < 50; i++) held.Press(ten, 600);
Check.Eq(held.Count, HeldRaises.Max, "capped");
Check.False(held.Next(600 + HeldRaises.ForgetMs + 1, busy: false, out _), "forgotten when no answer came");
Check.Eq(held.Count, 0, "and dropped");
// The Attributes tab (2026-11-08: the fix has to reach it too): +10 on Strength and on a vital are
// held like a skill's, one per answer, not capped at one like train.
var str = new RaiseTarget(RaiseTarget.Attribute, 1, Ten: true);
held.Press(str, 10_000);
Check.True(held.Next(10_000, busy: false, out t) && t == str, "an attribute +10 goes at once");
held.Sent();
for (int i = 0; i < 4; i++) held.Press(str, 10_050 + i);
Check.Eq(held.Count, 4, "attribute +10 spam: four held");
Check.False(held.Next(10_100, busy: true, out _), "attribute: not while the last raise is on its way");
Check.True(held.Next(10_200, busy: false, out t) && t == str, "attribute: the next goes when it lands");
held.Sent();
Check.Eq(held.Count, 3, "attribute: one per answer");
// A vital with the same id is another target (Kind 2), so it replaces what waited.
var vital = new RaiseTarget(RaiseTarget.Vital, 1, Ten: true);
held.Press(vital, 10_300);
Check.Eq(held.Count, 1, "a vital is not the attribute with the same id");
held.Press(vital, 10_310); held.Press(vital, 10_320);
Check.Eq(held.Count, 3, "vital +10 spam is held too");
held.Drop();
}
} }

View file

@ -72,6 +72,7 @@
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\SkillsSheet.cs" Link="DreamWeave\SkillsSheet.cs" /> <Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\SkillsSheet.cs" Link="DreamWeave\SkillsSheet.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\AttributesTitles.cs" Link="DreamWeave\AttributesTitles.cs" /> <Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\AttributesTitles.cs" Link="DreamWeave\AttributesTitles.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\OnePanelRule.cs" Link="DreamWeave\OnePanelRule.cs" /> <Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\OnePanelRule.cs" Link="DreamWeave\OnePanelRule.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\HeldRaises.cs" Link="DreamWeave\HeldRaises.cs" />
<!-- The RynthAi test tools' check/runner harness (no plugin code in it). --> <!-- The RynthAi test tools' check/runner harness (no plugin code in it). -->
<Compile Include="$(RynthSuiteRoot)Tools\RynthCore.RynthAiTests\Harness\Check.cs" Link="Harness\Check.cs" /> <Compile Include="$(RynthSuiteRoot)Tools\RynthCore.RynthAiTests\Harness\Check.cs" Link="Harness\Check.cs" />
<Compile Include="$(RynthSuiteRoot)Tools\RynthCore.RynthAiTests\Harness\Runner.cs" Link="Harness\Runner.cs" /> <Compile Include="$(RynthSuiteRoot)Tools\RynthCore.RynthAiTests\Harness\Runner.cs" Link="Harness\Runner.cs" />