RynthServers as of 2026-11-08 (internal 471970b): release 2026.11.8.1
This commit is contained in:
parent
f9db7bad87
commit
e52923ba5c
40 changed files with 4831 additions and 31 deletions
336
Tools/RetailDataGen/gen_retail_data.py
Normal file
336
Tools/RetailDataGen/gen_retail_data.py
Normal file
|
|
@ -0,0 +1,336 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Writes RynthDreamWeave's DreamWeave/RetailData.g.cs from a retail client_portal.dat.
|
||||
|
||||
The DreamWeave Skills panel draws the retail Character panel's Skills page 1:1, so it carries the
|
||||
numbers and glyph tables the retail client reads from portal.dat:
|
||||
|
||||
0x0E000018 XpTable the level chart (total XP for levels 0..275) and the skill-credit levels
|
||||
0x0E000004 SkillTable each skill's name, icon, whether it is usable untrained (MinLevel 1), its
|
||||
formula and description (the hover tooltip)
|
||||
0x2300000E (local dat) the character titles, keyed by AC's string hash of "ID_CharacterTitle_<name>"
|
||||
0x400000xx Font the glyph tables of the five faces the page uses (Palatino_Linotype_14/16/18,
|
||||
Chat_PalatinoLinotype_Large = 20, Stonehenge_36), ASCII and Latin-1 only;
|
||||
the engine draws their glyph sheets (GetIconTexture kind FontSheet)
|
||||
|
||||
Run it again only if the dat changes (it hasn't since end of retail):
|
||||
|
||||
python gen_retail_data.py [client_portal.dat] [client_local_English.dat] [ACE CharacterTitle.cs] >..\\..\\Plugins\\RynthCore.Plugin.RynthDreamWeave\\DreamWeave\\RetailData.g.cs
|
||||
|
||||
No dependencies; the dat reader is the minimal B-tree walk the AC dat format needs.
|
||||
"""
|
||||
import struct
|
||||
import sys
|
||||
|
||||
PORTAL = sys.argv[1] if len(sys.argv) > 1 else r"C:\Games\ACE\Dats\client_portal.dat"
|
||||
LOCAL = sys.argv[2] if len(sys.argv) > 2 else r"C:\Games\ACE\Dats\client_local_English.dat"
|
||||
# The CharacterTitle names (ACE.Entity/Enum/CharacterTitle.cs of any ACE checkout): only the names are read.
|
||||
ENUM = sys.argv[3] if len(sys.argv) > 3 else r"C:\Projects\_dwsrc\ACE-DreamWeave\Source\ACE.Entity\Enum\CharacterTitle.cs"
|
||||
|
||||
|
||||
def cs(s):
|
||||
"""A C# string literal."""
|
||||
return '"' + s.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n').replace('\r', '') + '"'
|
||||
|
||||
HDR = 0x140
|
||||
BRANCHES = 0x3E
|
||||
MAX_ENTRIES = 0x3D
|
||||
ENTRY_SIZE = 24
|
||||
|
||||
|
||||
class Dat:
|
||||
def __init__(self, path):
|
||||
self.f = open(path, 'rb')
|
||||
self.f.seek(HDR)
|
||||
(_ft, self.block_size, _fs, _ds, _dss, _fh, _ftl, _fc, self.root) = struct.unpack('<9I', self.f.read(36))
|
||||
self.entries = {}
|
||||
self._walk(self.root)
|
||||
|
||||
def _chain(self, offset, size):
|
||||
out = bytearray()
|
||||
nxt = offset
|
||||
while len(out) < size and nxt:
|
||||
self.f.seek(nxt)
|
||||
n = struct.unpack('<I', self.f.read(4))[0] & 0x7FFFFFFF
|
||||
out += self.f.read(min(self.block_size - 4, size - len(out)))
|
||||
nxt = n
|
||||
return bytes(out[:size])
|
||||
|
||||
def _walk(self, offset):
|
||||
node = self._chain(offset, 4 * BRANCHES + 4 + ENTRY_SIZE * MAX_ENTRIES)
|
||||
branches = struct.unpack_from('<%dI' % BRANCHES, node, 0)
|
||||
count = struct.unpack_from('<I', node, 4 * BRANCHES)[0]
|
||||
for i in range(count):
|
||||
_flags, did, off, size, _date, _it = struct.unpack_from('<6I', node, 4 * BRANCHES + 4 + i * ENTRY_SIZE)
|
||||
self.entries[did] = (off, size)
|
||||
if branches[0] != 0:
|
||||
for i in range(count + 1):
|
||||
self._walk(branches[i])
|
||||
|
||||
def read(self, did):
|
||||
off, size = self.entries[did]
|
||||
return self._chain(off, size)
|
||||
|
||||
|
||||
def xp_table(dat):
|
||||
b = dat.read(0x0E000018)
|
||||
o = 4
|
||||
a, v, t, s, levels = struct.unpack_from('<iiiiI', b, o)
|
||||
o += 20 + 4 * (a + 1 + v + 1 + t + 1 + s + 1)
|
||||
attrs = list(struct.unpack_from('<%dI' % (a + 1), b, 4 + 20))
|
||||
vitals = list(struct.unpack_from('<%dI' % (v + 1), b, 4 + 20 + 4 * (a + 1)))
|
||||
o0 = 4 + 20 + 4 * (a + 1 + v + 1)
|
||||
trained = list(struct.unpack_from('<%dI' % (t + 1), b, o0))
|
||||
special = list(struct.unpack_from('<%dI' % (s + 1), b, o0 + 4 * (t + 1)))
|
||||
totals = list(struct.unpack_from('<%dQ' % (levels + 1), b, o))
|
||||
o += 8 * (levels + 1)
|
||||
credits = list(struct.unpack_from('<%dI' % (levels + 1), b, o))
|
||||
return totals, credits, trained, special, attrs, vitals
|
||||
|
||||
|
||||
def skill_table(dat):
|
||||
b = dat.read(0x0E000004)
|
||||
o = 4
|
||||
count = struct.unpack_from('<H', b, o)[0]
|
||||
o += 4
|
||||
|
||||
def pstring():
|
||||
nonlocal o
|
||||
n = struct.unpack_from('<H', b, o)[0]
|
||||
o += 2
|
||||
text = b[o:o + n].decode('latin-1')
|
||||
o += n
|
||||
o = (o + 3) & ~3
|
||||
return text
|
||||
|
||||
rows = []
|
||||
for _ in range(count):
|
||||
sid = struct.unpack_from('<I', b, o)[0]
|
||||
o += 4
|
||||
desc = pstring()
|
||||
name = pstring()
|
||||
icon, _tc, _sc, _cat, _cg, min_level = struct.unpack_from('<IiiIII', b, o)
|
||||
o += 24
|
||||
# SkillFormula W X Y Z Attr1 Attr2: X = 0 means no attribute part; Z divides.
|
||||
_w, fx, _y, fz, a1, a2 = struct.unpack_from('<6I', b, o)
|
||||
o += 24 + 24 # the formula, three doubles
|
||||
rows.append((sid, name, icon, min_level == 1, desc, fx, fz, a1, a2))
|
||||
return sorted(rows)
|
||||
|
||||
|
||||
ATTR = {1: 'Strength', 2: 'Endurance', 3: 'Quickness', 4: 'Coordination', 5: 'Focus', 6: 'Self'}
|
||||
|
||||
|
||||
def formula(fx, fz, a1, a2):
|
||||
"""The tooltip's first line as retail writes it: "( Focus + Self ) / 4"."""
|
||||
if fx == 0 or a1 not in ATTR:
|
||||
return ''
|
||||
text = '( ' + ATTR[a1] + (' + ' + ATTR[a2] if a2 in ATTR else '') + ' )'
|
||||
return text + (' / %d' % fz if fz > 1 else '')
|
||||
|
||||
|
||||
def ac_hash(s):
|
||||
"""AC's string-id hash (PStringBase): what string table entries are keyed by."""
|
||||
h = 0
|
||||
for ch in s:
|
||||
h = ((h << 4) + ord(ch)) & 0xFFFFFFFF
|
||||
hi = h & 0xF0000000
|
||||
if hi:
|
||||
h ^= hi >> 24
|
||||
h &= 0x0FFFFFFF
|
||||
return h
|
||||
|
||||
|
||||
def string_table(dat, fid):
|
||||
"""A type-0x23 string table: id -> first string (AcClientReborn Dat/AcStringTable.cs has the format)."""
|
||||
b = dat.read(fid)
|
||||
o = [9]
|
||||
|
||||
def cu32():
|
||||
b0 = b[o[0]]
|
||||
if not b0 & 0x80:
|
||||
o[0] += 1
|
||||
return b0
|
||||
if not b0 & 0x40:
|
||||
v = struct.unpack_from('>H', b, o[0])[0] & 0x3FFF
|
||||
o[0] += 2
|
||||
return v
|
||||
v = struct.unpack_from('>I', b, o[0])[0] & 0x3FFFFFFF
|
||||
o[0] += 4
|
||||
return v
|
||||
|
||||
def ustr():
|
||||
n = cu32()
|
||||
s = b[o[0]:o[0] + 2 * n].decode('utf-16-le', 'replace')
|
||||
o[0] += 2 * n
|
||||
return s
|
||||
|
||||
def u16():
|
||||
v = struct.unpack_from('<H', b, o[0])[0]
|
||||
o[0] += 2
|
||||
return v
|
||||
|
||||
def u32():
|
||||
v = struct.unpack_from('<I', b, o[0])[0]
|
||||
o[0] += 4
|
||||
return v
|
||||
|
||||
out = {}
|
||||
for _ in range(cu32()):
|
||||
sid = u32()
|
||||
for _ in range(u16()):
|
||||
ustr()
|
||||
for _ in range(u16()):
|
||||
ustr()
|
||||
strings = [ustr() for _ in range(u32())]
|
||||
for _ in range(u32()):
|
||||
u32()
|
||||
o[0] += 1
|
||||
out[sid] = strings[0] if strings else ''
|
||||
return out
|
||||
|
||||
|
||||
def enum_names(path):
|
||||
"""CharacterTitle's members in order (a C# enum: "Name," or "Name = n,"), id -> name."""
|
||||
import re
|
||||
names, n, inside = {}, 0, False
|
||||
for line in open(path, encoding='utf-8'):
|
||||
line = line.split('//')[0].strip()
|
||||
if line.startswith('public enum'):
|
||||
inside = True
|
||||
continue
|
||||
if not inside or not line or line in ('{',):
|
||||
continue
|
||||
if line.startswith('}'):
|
||||
break
|
||||
m = re.match(r'^(\w+)\s*(?:=\s*(\w+))?\s*,?$', line)
|
||||
if not m:
|
||||
continue
|
||||
if m.group(2):
|
||||
n = int(m.group(2), 0)
|
||||
names[n] = m.group(1)
|
||||
n += 1
|
||||
return names
|
||||
|
||||
|
||||
def titles(local, enum_path):
|
||||
"""CharacterTitleId -> the title's text, from string table 0x2300000E keyed by
|
||||
hash("ID_CharacterTitle_" + its original name). The names come from ACE's CharacterTitle enum
|
||||
(names only, no code), whose spellings drop the original's underscores: each is tried as written,
|
||||
then with underscores between its words, then matched by its letters alone."""
|
||||
import re
|
||||
table = string_table(local, 0x2300000E)
|
||||
by_letters = {}
|
||||
for text in table.values():
|
||||
by_letters.setdefault(re.sub(r'[^a-z0-9]', '', text.lower()), []).append(text)
|
||||
out, missing = {}, []
|
||||
for tid, name in sorted(enum_names(enum_path).items()):
|
||||
if tid == 0 or name.upper().startswith('UNKNOWN'):
|
||||
continue
|
||||
words = re.sub(r'(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])', '_', name)
|
||||
text = None
|
||||
for cand in (name, words):
|
||||
k = ac_hash('ID_CharacterTitle_' + cand)
|
||||
if k in table:
|
||||
text = table[k]
|
||||
break
|
||||
if text is None:
|
||||
hits = by_letters.get(re.sub(r'[^a-z0-9]', '', name.lower()), [])
|
||||
if len(hits) == 1:
|
||||
text = hits[0]
|
||||
if text is None:
|
||||
missing.append(name)
|
||||
else:
|
||||
out[tid] = text
|
||||
sys.stderr.write('titles: %d named, %d not found (%s)\n' % (len(out), len(missing), ', '.join(missing[:12])))
|
||||
return out
|
||||
|
||||
|
||||
FONTS = [
|
||||
('Pal14', 0x40000002, False),
|
||||
('Pal16', 0x40000000, False),
|
||||
('Pal18', 0x40000001, False),
|
||||
('Pal20', 0x40000004, False),
|
||||
('Stone36', 0x40000010, True),
|
||||
]
|
||||
|
||||
|
||||
def font(dat, did):
|
||||
b = dat.read(did)
|
||||
o = 4
|
||||
max_h, _max_w, n = struct.unpack_from('<III', b, o)
|
||||
o += 12
|
||||
glyphs = {}
|
||||
for _ in range(n):
|
||||
u, ox, oy, w, h, hb, ha, vb = struct.unpack_from('<HHHBBbbb', b, o)
|
||||
o += 11
|
||||
glyphs[u] = (ox, oy, w, h, hb, ha, vb)
|
||||
bx, by, base, fg, bg = struct.unpack_from('<IIIII', b, o)
|
||||
sheets = []
|
||||
for sid in (fg, bg):
|
||||
if sid:
|
||||
t = dat.read(sid)
|
||||
sheets.append(struct.unpack_from('<ii', t, 8))
|
||||
else:
|
||||
sheets.append((0, 0))
|
||||
return max_h, bx, by, base, fg, bg, sheets, glyphs
|
||||
|
||||
|
||||
def main():
|
||||
dat = Dat(PORTAL)
|
||||
totals, credits, trained, special, attrs, vitals = xp_table(dat)
|
||||
skills = skill_table(dat)
|
||||
w = sys.stdout.write
|
||||
w('// <auto-generated> by Tools/RetailDataGen/gen_retail_data.py from a retail client_portal.dat.\n')
|
||||
w('// The numbers the retail client reads to draw its Character panel: do not edit by hand.\n')
|
||||
w('namespace RynthCore.Plugin.RynthDreamWeave;\n\n')
|
||||
w('internal static partial class RetailData\n{\n')
|
||||
w(' /// <summary>XpTable 0x0E000018: total experience to reach each level, 0..%d.</summary>\n' % (len(totals) - 1))
|
||||
w(' public static readonly ulong[] LevelTotals =\n {\n')
|
||||
for i in range(0, len(totals), 6):
|
||||
w(' ' + ', '.join('%dUL' % v for v in totals[i:i + 6]) + ',\n')
|
||||
w(' };\n\n')
|
||||
w(' /// <summary>XpTable 0x0E000018: skill credits granted on reaching each level, 0..%d.</summary>\n' % (len(credits) - 1))
|
||||
w(' public static readonly byte[] LevelCredits =\n {\n')
|
||||
for i in range(0, len(credits), 30):
|
||||
w(' ' + ', '.join(str(v) for v in credits[i:i + 30]) + ',\n')
|
||||
w(' };\n\n')
|
||||
for field, chart, what in (('TrainedSkillXp', trained, 'a trained skill'), ('SpecializedSkillXp', special, 'a specialized skill'),
|
||||
('AttributeXp', attrs, 'an attribute'), ('VitalXp', vitals, 'a vital\'s maximum')):
|
||||
w(' /// <summary>XpTable 0x0E000018: total XP to reach each rank of %s, 0..%d.</summary>\n'
|
||||
% (what, len(chart) - 1))
|
||||
w(' public static readonly uint[] %s =\n {\n' % field)
|
||||
for i in range(0, len(chart), 8):
|
||||
w(' ' + ', '.join('%dU' % v for v in chart[i:i + 8]) + ',\n')
|
||||
w(' };\n\n')
|
||||
w(' /// <summary>SkillTable 0x0E000004: id, name, icon, usable untrained (MinLevel 1), and the hover\n')
|
||||
w(' /// tooltip\'s formula line and description.</summary>\n')
|
||||
w(' public static readonly RetailSkill[] Skills =\n {\n')
|
||||
for sid, name, icon, usable, desc, fx, fz, a1, a2 in skills:
|
||||
w(' new(%d, %s, 0x%08Xu, %s, %s, %s),\n' % (sid, cs(name), icon, 'true' if usable else 'false',
|
||||
cs(formula(fx, fz, a1, a2)), cs(desc)))
|
||||
w(' };\n\n')
|
||||
names = titles(Dat(LOCAL), ENUM)
|
||||
w(' /// <summary>String table 0x2300000E: CharacterTitleId -> the title (the header\'s second line).</summary>\n')
|
||||
w(' public static readonly System.Collections.Generic.Dictionary<int, string> Titles = new()\n {\n')
|
||||
for tid, text in sorted(names.items()):
|
||||
w(' [%d] = %s,\n' % (tid, cs(text)))
|
||||
w(' };\n\n')
|
||||
for field, did, outline in FONTS:
|
||||
max_h, bx, by, base, fg, bg, sheets, glyphs = font(dat, did)
|
||||
chars = [c for c in sorted(glyphs) if 0x20 <= c <= 0x7E or 0xA0 <= c <= 0xFF]
|
||||
w(' /// <summary>Font 0x%08X: glyphs as char, sheet x, y, w, h, before, after, top.</summary>\n' % did)
|
||||
w(' public static readonly RetailFont %s = new(0x%08Xu, %d, %d, %d, %d, 0x%08Xu, %d, %d, 0x%08Xu, %d, %d, new short[]\n {\n'
|
||||
% (field, did, max_h, base, bx, by, fg, sheets[0][0], sheets[0][1], bg if outline else 0,
|
||||
sheets[1][0] if outline else 0, sheets[1][1] if outline else 0))
|
||||
for i in range(0, len(chars), 4):
|
||||
parts = []
|
||||
for c in chars[i:i + 4]:
|
||||
ox, oy, gw, gh, hb, ha, vb = glyphs[c]
|
||||
parts.append('%d,%d,%d,%d,%d,%d,%d,%d' % (c, ox, oy, gw, gh, hb, ha, vb))
|
||||
w(' ' + ', '.join(parts) + ',\n')
|
||||
w(' });\n\n')
|
||||
w('}\n')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
315
Tools/RynthServerPack.Tests/DreamWeaveSkillsTests.cs
Normal file
315
Tools/RynthServerPack.Tests/DreamWeaveSkillsTests.cs
Normal file
|
|
@ -0,0 +1,315 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RynthCore.Engine.UI.Sections;
|
||||
using RynthCore.Plugin.RynthDreamWeave;
|
||||
using RynthCore.Plugin.ServerPack;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthServerPack.Tests;
|
||||
|
||||
// RynthDreamWeave's Skills panel (2026-11-07): DreamWeave's level chart past 275 (the reason for the panel:
|
||||
// AC's own panel reads a negative "XP for next level" there), the retail data it carries, the list's
|
||||
// sections and footer, and the shared ServerWindows hook it is declared through.
|
||||
internal static class DreamWeaveSkillsTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("dreamweave skills: the retail chart is portal.dat's, levels 0..275", RetailChart);
|
||||
r.Add("dreamweave skills: the chart past 275 follows the server's rule", ExtendedChart);
|
||||
r.Add("dreamweave skills: XP for next level past 275 (the reported level-344 character)", NextLevelPast275);
|
||||
r.Add("dreamweave skills: XP for next level at the edges", NextLevelEdges);
|
||||
r.Add("dreamweave skills: sections, order and what shows in each", Sections);
|
||||
r.Add("dreamweave skills: the footer reads as retail's", Footer);
|
||||
r.Add("dreamweave skills: raise arrows only when affordable", RaiseGates);
|
||||
r.Add("dreamweave skills: header words (rank title, character title)", Header);
|
||||
r.Add("dreamweave skills: the XP bar fills with the way through the level", LevelBar);
|
||||
r.Add("dreamweave skills: tooltips (formula, description, wrapped as retail)", Tooltips);
|
||||
r.Add("dreamweave skills: fonts and skill table", RetailTables);
|
||||
r.Add("hooks: server windows are validated and declared frameless only when the engine can", Windows);
|
||||
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: one main panel at a time, as retail", OnePanel);
|
||||
}
|
||||
|
||||
private static void Attributes()
|
||||
{
|
||||
Check.Eq(string.Join(",", AttributesPage.Rows.Select(r => r.Name)), "Strength,Endurance,Coordination,Quickness,Focus,Self,Health,Stamina,Mana", "retail's order");
|
||||
var str = new AttributeLine(1, 1, "Strength", 0, 200, 250, 1000, 12000, true, false, 50, RetailData.AttributeXp[50] + (RetailData.AttributeXp[51] - RetailData.AttributeXp[50]) / 2);
|
||||
Check.Eq(str.ValueText, "250", "an attribute shows its buffed value");
|
||||
Check.Eq(AttributesPage.FooterTitle(str), ("Strength: 250", " (+50)"), "footer title");
|
||||
Check.Eq(AttributesPage.FooterTitle(null).Text, "Select an Attribute to Improve", "retail's prompt");
|
||||
var sheet = SkillsSheet.Empty with { UnassignedXp = 5000, SkillCredits = 2 };
|
||||
Check.Eq(AttributesPage.FooterLines(sheet, str).One, ("Experience To Raise:", "1,000"), "cost");
|
||||
Check.Eq(AttributesPage.FooterLines(sheet, null).One, ("Skill Credits Available:", "2"), "nothing selected");
|
||||
Check.True(AttributesPage.CanRaiseOne(sheet, str) && !AttributesPage.CanRaiseTen(sheet, str), "one affordable, ten not");
|
||||
Check.Near(AttributesPage.RankProgress(str), 0.5, 0.01, "half way through rank 50");
|
||||
var health = new AttributeLine(2, 1, "Health", 0, 300, 350, -1, -1, false, true, 196, 0, Current: 280);
|
||||
Check.Eq(health.ValueText, "280/350", "a vital shows current/maximum, as retail");
|
||||
Check.Eq(AttributesPage.FooterLines(sheet, health).One, ("Experience To Raise:", "Infinity!"), "at the top");
|
||||
Check.Eq(AttributesPage.RankProgress(health), 0f, "the last rank: empty");
|
||||
Check.True(AttributesPage.Tip(health).StartsWith("(Endurance/2)"), "health's hover text");
|
||||
}
|
||||
|
||||
private static void Titles()
|
||||
{
|
||||
// Game event 0x0029: u32 1, u32 displayed (433), u32 count (3), ids 1, 433, 7.
|
||||
byte[] table = new byte[12 + 12];
|
||||
void U32(int at, uint v) => System.Buffers.Binary.BinaryPrimitives.WriteUInt32LittleEndian(table.AsSpan(at), v);
|
||||
U32(0, 1); U32(4, 433); U32(8, 3); U32(12, 1); U32(16, 433); U32(20, 7);
|
||||
Check.True(TitleList.TryParseTable(table, out TitleList list), "parses");
|
||||
Check.Eq(list.Displayed, 433U, "displayed");
|
||||
Check.Eq(list.Earned.Count, 3, "three earned");
|
||||
Check.Eq(list.Sorted()[0].Text, "Adventurer", "sorted by text (retail's list)");
|
||||
Check.False(TitleList.TryParseTable(table.AsSpan(0, 18), out _), "a short list is refused");
|
||||
|
||||
byte[] update = new byte[8];
|
||||
System.Buffers.Binary.BinaryPrimitives.WriteUInt32LittleEndian(update, 2);
|
||||
System.Buffers.Binary.BinaryPrimitives.WriteUInt32LittleEndian(update.AsSpan(4), 1);
|
||||
TitleList after = list.WithUpdate(update);
|
||||
Check.True(after.Earned.Contains(2U) && after.Displayed == 2, "0x002B adds a title and can make it the displayed one");
|
||||
Check.Eq(list.WithDisplayed(1).Displayed, 1U, "CharacterTitleId moves the displayed one");
|
||||
|
||||
string saved = after.Save();
|
||||
TitleList back = TitleList.Load(saved);
|
||||
Check.Eq(back.Save(), saved, "saved and loaded per character");
|
||||
Check.False(TitleList.Load("").Known, "nothing saved: not known yet");
|
||||
Check.False(TitleList.Load("garbage").Known, "a broken save is nothing");
|
||||
}
|
||||
|
||||
private static void RetailChart()
|
||||
{
|
||||
Check.Eq(RetailData.LevelTotals.Length, 276, "levels 0..275");
|
||||
Check.Eq(RetailData.LevelTotals[2], 1000UL, "level 2");
|
||||
Check.Eq(RetailData.LevelTotals[275], 191_226_310_247UL, "level 275 (AC's panel subtracts from this past 275)");
|
||||
Check.Eq(RetailData.LevelCredits[275], (byte)1, "a credit at 275");
|
||||
}
|
||||
|
||||
private static void ExtendedChart()
|
||||
{
|
||||
IReadOnlyList<ulong> t = DreamWeaveXp.Totals;
|
||||
for (int i = 0; i <= 275; i++) Check.Eq(t[i], RetailData.LevelTotals[i], "retail levels kept, " + i);
|
||||
// The step past 275 grows by 3,390,451,400 / 3,342,189,670 (the chart's last two steps).
|
||||
ulong s275 = t[275] - t[274], s274 = t[274] - t[273];
|
||||
Check.Eq(t[276] - t[275], (ulong)((UInt128)s275 * s275 / s274), "the first synthesized step");
|
||||
for (int i = 277; i < t.Count; i++) Check.True(t[i] - t[i - 1] >= t[i - 1] - t[i - 2], "steps never shrink, " + i);
|
||||
Check.True(t[^1] <= DreamWeaveXp.TotalCap, "the top stays under long.MaxValue / 2");
|
||||
Check.True(DreamWeaveXp.MaxLevel > 1000, "a thousand-odd levels: " + DreamWeaveXp.MaxLevel);
|
||||
// A flat or shrinking chart repeats its last step; too short a chart is left alone.
|
||||
Check.Eq(string.Join(",", DreamWeaveXp.Extend(new ulong[] { 0, 10, 20 }, 50)), "0,10,20,30,40,50", "flat tail");
|
||||
Check.Eq(string.Join(",", DreamWeaveXp.Extend(new ulong[] { 0, 10 }, 50)), "0,10", "too short");
|
||||
}
|
||||
|
||||
private static void NextLevelPast275()
|
||||
{
|
||||
// The report's character: level 344, 600,303,541,190 total XP. AC's panel read -409,077,230,943.
|
||||
const long total = 600_303_541_190;
|
||||
IReadOnlyList<ulong> t = DreamWeaveXp.Totals;
|
||||
Check.True(t[344] <= (ulong)total && (ulong)total < t[345], "the total is level 344 on DreamWeave's chart, as the server says");
|
||||
Check.Eq(t[344], 593_567_252_692UL, "level 344");
|
||||
Check.Eq(t[345], 602_816_527_434UL, "level 345");
|
||||
Check.Eq(DreamWeaveXp.ToNextLevel(344, total), 2_512_986_244L, "XP for next level");
|
||||
var sheet = SkillsSheet.Empty with { Level = 344, TotalXp = total };
|
||||
Check.Eq(sheet.NextLevelText, "2,512,986,244", "as the panel prints it");
|
||||
Check.Eq((long)RetailData.LevelTotals[275] - total, -409_077_230_943L, "what AC's own panel showed (for the record)");
|
||||
}
|
||||
|
||||
private static void NextLevelEdges()
|
||||
{
|
||||
Check.Eq(DreamWeaveXp.ToNextLevel(1, 0), 1000L, "level 1");
|
||||
Check.Eq(DreamWeaveXp.ToNextLevel(275, (long)RetailData.LevelTotals[275]), (long)(DreamWeaveXp.Totals[276] - DreamWeaveXp.Totals[275]), "at 275 it goes on");
|
||||
Check.Eq(DreamWeaveXp.ToNextLevel(10, long.MaxValue / 4), 0L, "already past the next level: 0, not negative");
|
||||
Check.Null(DreamWeaveXp.ToNextLevel(DreamWeaveXp.MaxLevel, 0), "the chart's top");
|
||||
Check.Eq((SkillsSheet.Empty with { Level = DreamWeaveXp.MaxLevel, TotalXp = 1 }).NextLevelText, "Infinity!", "retail's word at the top");
|
||||
Check.Null(DreamWeaveXp.ToNextLevel(0, 5), "no level");
|
||||
Check.Eq(SkillsSheet.Empty.NextLevelText, "", "nothing read yet");
|
||||
}
|
||||
|
||||
private static SkillLine Skill(uint id, SkillClass c, bool usable = true, int b = 100, int buffed = 100,
|
||||
long one = 1000, long ten = 12000, int credits = 0, bool raisable = true, bool trainable = false)
|
||||
=> new(id, RetailData.Skill(id)?.Name ?? "?", RetailData.Skill(id)?.Icon ?? 0, c, usable, b, buffed, one, ten, credits, raisable, trainable, false);
|
||||
|
||||
private static void Sections()
|
||||
{
|
||||
var skills = new List<SkillLine>
|
||||
{
|
||||
Skill(46, SkillClass.Specialized), Skill(38, SkillClass.Specialized), // Finesse Weapons, Alchemy
|
||||
Skill(14, SkillClass.Trained), // Arcane Lore
|
||||
Skill(40, SkillClass.Untrained, usable: true), // Salvaging
|
||||
Skill(33, SkillClass.Untrained, usable: false), // Life Magic
|
||||
};
|
||||
List<SkillRow> rows = SkillsLayout.Rows(skills);
|
||||
string text = string.Join(" | ", rows.Select(r => r.IsBanner ? "[" + SkillsLayout.Title(r.Section) + "]" : r.Skill!.Name));
|
||||
Check.Eq(text, "[Specialized Skills] | Alchemy | Finesse Weapons | [Trained Skills] | Arcane Lore | [Untrained Skills] | Salvaging | [Unusable Skills] | Life Magic",
|
||||
"sections in retail's order, names sorted");
|
||||
Check.Eq(SkillsLayout.Rows(new[] { Skill(14, SkillClass.Trained) }).Count, 2, "empty sections are left out");
|
||||
}
|
||||
|
||||
private static void Footer()
|
||||
{
|
||||
var sheet = SkillsSheet.Empty with { UnassignedXp = 275_586_157_349, SkillCredits = 3 };
|
||||
var (none1, none2) = SkillsLayout.FooterLines(sheet, null);
|
||||
Check.Eq(SkillsLayout.FooterTitle(null).Text, "Select a Skill to Improve", "nothing selected");
|
||||
Check.Eq(none1, ("Skill Credits Available:", "3"), "credits");
|
||||
Check.Eq(none2, ("Unassigned Experience:", "275,586,157,349"), "unassigned");
|
||||
|
||||
// The reported footer: "Salvaging: 303 (+45)", "Experience To Raise: Infinity!" at the top rank.
|
||||
SkillLine salvaging = Skill(40, SkillClass.Specialized, b: 258, buffed: 303, one: -1, ten: -1, raisable: false);
|
||||
Check.Eq(SkillsLayout.FooterTitle(salvaging), ("Salvaging: 303", " (+45)"), "title and buff part");
|
||||
var (s1, s2) = SkillsLayout.FooterLines(sheet, salvaging);
|
||||
Check.Eq(s1, ("Experience To Raise:", "Infinity!"), "maxed");
|
||||
Check.Eq(s2, ("Unassigned Experience:", "275,586,157,349"), "unassigned");
|
||||
Check.Eq(SkillsLayout.FooterTitle(Skill(40, SkillClass.Trained, b: 300, buffed: 290)).Delta, " (-10)", "a debuff");
|
||||
|
||||
SkillLine untrained = Skill(23, SkillClass.Untrained, usable: false, credits: 6, trainable: true);
|
||||
Check.Eq(SkillsLayout.FooterTitle(untrained), ("Lockpick", ""), "untrained: the name alone");
|
||||
var (u1, u2) = SkillsLayout.FooterLines(sheet, untrained);
|
||||
Check.Eq(u1, ("Skill Credits To Raise:", "6"), "credits to train");
|
||||
Check.Eq(u2, ("Skill Credits Available:", "3"), "credits on hand");
|
||||
}
|
||||
|
||||
private static void RaiseGates()
|
||||
{
|
||||
var rich = SkillsSheet.Empty with { UnassignedXp = 50_000, SkillCredits = 10 };
|
||||
Check.True(SkillsLayout.CanRaiseOne(rich, Skill(14, SkillClass.Trained, one: 1000)), "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.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, 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.CanRaiseTen(rich, Skill(23, SkillClass.Untrained, credits: 6, trainable: true)), "no +10 for untrained");
|
||||
}
|
||||
|
||||
private static void Header()
|
||||
{
|
||||
Check.Eq(SkillsLayout.Identity(1, 1, "Obviously Bored"), "Male Aluvian Obviously Bored", "the reported line");
|
||||
Check.Eq(SkillsLayout.Identity(2, 2, ""), "Female Gharu'ndim", "no title");
|
||||
Check.Eq(SkillsLayout.Identity(0, 0, null), "", "nothing known");
|
||||
Check.Eq(SkillsLayout.PkStatus(0x02), "Non-Player Killer", "NPK");
|
||||
Check.Eq(SkillsLayout.PkStatus(0x04), "Player Killer", "PK");
|
||||
Check.Eq(SkillsLayout.PkStatus(0x40), "Player Killer Lite", "PK lite");
|
||||
|
||||
// The reported retail header: "Yeoman Drakkon" / "Male Aluvian Obviously Bored".
|
||||
Check.Eq(SkillsLayout.NameLine("Drakkon", 1, 1, 1), "Yeoman Drakkon", "Aluvian rank 1");
|
||||
Check.Eq(SkillsLayout.NameLine("Drakkon", 1, 1, 0), "Drakkon", "no allegiance rank");
|
||||
Check.Eq(SkillsLayout.NameLine("Lucy", 2, 4, 9), "Queen Lucy", "a Viamontian queen");
|
||||
Check.Eq(SkillsLayout.NameLine("Kor", 1, 6, 3), "Optio Kor", "Gearknight titles are the same for both");
|
||||
Check.Eq(SkillsLayout.Title(433), "Obviously Bored", "CharacterTitleId 433");
|
||||
Check.Eq(SkillsLayout.Title(1), "Adventurer", "title 1");
|
||||
Check.Eq(SkillsLayout.Title(0), "", "no title");
|
||||
Check.True(RetailData.Titles.Count > 800, "the title table: " + RetailData.Titles.Count);
|
||||
}
|
||||
|
||||
private static void LevelBar()
|
||||
{
|
||||
IReadOnlyList<ulong> t = DreamWeaveXp.Totals;
|
||||
Check.Eq(SkillsLayout.LevelProgress(345, (long)t[345]), 0f, "just levelled");
|
||||
Check.Near(SkillsLayout.LevelProgress(345, (long)(t[345] + (t[346] - t[345]) / 4)), 0.25, 1e-6, "a quarter of the way");
|
||||
// The reported level-345 character (605,149,503,805 XP) is about a quarter through 345.
|
||||
float p = SkillsLayout.LevelProgress(345, 605_149_503_805);
|
||||
Check.True(p > 0.2f && p < 0.3f, "the reported character: " + p);
|
||||
Check.Eq(SkillsLayout.LevelProgress(DreamWeaveXp.MaxLevel, 1), 1f, "the top");
|
||||
Check.Eq(SkillsLayout.LevelProgress(0, 5), 0f, "unknown");
|
||||
|
||||
// The footer's blue bar: a skill's way through its rank (it fills from use).
|
||||
uint[] tr = RetailData.TrainedSkillXp, sp = RetailData.SpecializedSkillXp;
|
||||
Check.Eq(tr.Length, 209, "trained ranks 0..208");
|
||||
Check.Eq(sp.Length, 227, "specialized ranks 0..226");
|
||||
Check.Eq(sp[^1], 4_100_490_438U, "the specialized cap");
|
||||
SkillLine Spec(uint ranks, uint xp, bool top = false) => new(38, "Alchemy", 0, SkillClass.Specialized, true, 1, 1, 1, 1, 0, !top, false, top, ranks, xp);
|
||||
Check.Near(SkillsLayout.RankProgress(Spec(100, sp[100] + (sp[101] - sp[100]) / 2)), 0.5, 1e-3, "half way through rank 100");
|
||||
Check.Eq(SkillsLayout.RankProgress(Spec(100, sp[100])), 0f, "just ranked up");
|
||||
Check.Eq(SkillsLayout.RankProgress(Spec(226, sp[226], top: true)), 0f, "the last rank: empty, as retail's maxed Salvaging");
|
||||
Check.Eq(SkillsLayout.RankProgress(new SkillLine(23, "Lockpick", 0, SkillClass.Untrained, false, 0, 0, -1, -1, 6, false, true, false, 0, 0)), 0f, "untrained");
|
||||
Check.Near(SkillsLayout.RankProgress(new SkillLine(14, "Arcane Lore", 0, SkillClass.Trained, true, 1, 1, 1, 1, 0, true, false, false, 10, tr[10] + (tr[11] - tr[10]) / 4)), 0.25, 0.01, "trained uses its own chart");
|
||||
}
|
||||
|
||||
private static void Tooltips()
|
||||
{
|
||||
RetailSkill ie = RetailData.Skill(32)!;
|
||||
Check.Eq(ie.Formula, "( Focus + Self ) / 4", "Item Enchantment's formula, as retail's tooltip writes it");
|
||||
Check.Eq(ie.Description, "Allows you to cast spells that affect an item's properties.", "its description");
|
||||
Check.Eq(RetailData.Skill(24)!.Formula, "( Quickness )", "one attribute, no divisor");
|
||||
Check.Eq(RetailData.Skill(19)!.Formula, "", "no attribute part: no formula line");
|
||||
// Retail breaks that description after "item's" (the reported tooltip).
|
||||
Check.Eq(string.Join("|", RetailData.Pal14.Wrap(ie.Description, 230)), "Allows you to cast spells that affect an item's|properties.", "wrapped as retail");
|
||||
Check.Eq(RetailData.Pal14.Wrap("", 230).Count, 0, "nothing to wrap");
|
||||
}
|
||||
|
||||
private static void RetailTables()
|
||||
{
|
||||
Check.Eq(RetailData.Skills.Length, 38, "the 38 skills of end-of-retail's table");
|
||||
Check.Eq(RetailData.Skill(40)?.Name, "Salvaging", "by id");
|
||||
Check.True(RetailData.Skill(40)!.UsableUntrained && !RetailData.Skill(33)!.UsableUntrained, "usable untrained");
|
||||
Check.True(RetailData.Skills.All(s => (s.Icon >> 24) == 0x06), "icons are 0x06 textures");
|
||||
foreach (RetailFont f in new[] { RetailData.Pal14, RetailData.Pal16, RetailData.Pal18, RetailData.Pal20, RetailData.Stone36 })
|
||||
{
|
||||
Check.True(f.TryGlyph('0', out RetailGlyph zero) && zero.Width > 0, $"0x{f.Id:X8} has digits");
|
||||
Check.True(f.Sheet >> 24 == 0x06 && f.SheetWidth <= 2048, $"0x{f.Id:X8} sheet fits the engine's font-sheet kind");
|
||||
}
|
||||
Check.True(RetailData.Pal16.Measure("Alchemy") > RetailData.Pal16.Measure("Jump"), "widths add up");
|
||||
Check.Eq(RetailData.Pal16.Measure(""), 0, "empty");
|
||||
Check.True(RetailData.Stone36.OutlineSheet != 0 && RetailData.Pal16.OutlineSheet == 0, "only the level number is outlined");
|
||||
}
|
||||
|
||||
private static void Windows()
|
||||
{
|
||||
Func<bool, System.Numerics.Vector2> draw = _ => default;
|
||||
var notes = new List<string>();
|
||||
var ok = ServerPackWindows.Validate(new List<ServerWindow>
|
||||
{
|
||||
new("skills", "DreamWeave Skills", "", 310, 610, 120, 120, true, draw, FitHeight: true, UnderUi: true, DrawScale: true),
|
||||
new("skills", "Again", "", 1, 1, 1, 1, false, draw),
|
||||
new("server", "Taken", "", 1, 1, 1, 1, false, draw),
|
||||
new("Bad", "Bad", "", 1, 1, 1, 1, false, draw),
|
||||
new("blank", " ", "", 1, 1, 1, 1, false, draw),
|
||||
}, notes.Add);
|
||||
Check.Eq(ok.Count, 1, "one good window");
|
||||
Check.Eq(notes.Count, 4, "four notes: " + string.Join("; ", notes));
|
||||
Check.Eq(ServerPackWindows.IdOf("window:skills"), "skills", "surface to id");
|
||||
Check.Null(ServerPackWindows.IdOf("window:server"), "the server window is the shared code's");
|
||||
Check.Null(ServerPackWindows.IdOf("section:server-dreamweave"), "not a window");
|
||||
|
||||
var info = new ServerPackInfo("dreamweave", "DreamWeave", new[] { "play.acdreamweave.com" }, new[] { "DreamWeave" });
|
||||
foreach (bool frameless in new[] { true, false })
|
||||
{
|
||||
string json = ServerPackModel.BuildSectionsJson(info, "RynthDreamWeave", null, ok, frameless);
|
||||
SectionManifest? m = SectionManifestParser.Parse("RynthDreamWeave", json, out string error);
|
||||
Check.NotNull(m, "parses: " + error);
|
||||
SectionWindowDecl? skills = m!.Windows.FirstOrDefault(w => w.Id == "skills");
|
||||
if (!frameless) { Check.Null(skills, "an engine without frameless windows doesn't get it"); continue; }
|
||||
Check.NotNull(skills, "declared");
|
||||
Check.Eq(skills!.Surface, "window:skills", "surface");
|
||||
Check.Eq(skills.Server, "dreamweave", "DreamWeave only");
|
||||
Check.True(skills.Frameless && skills.Bar, "frameless, on the bar");
|
||||
Check.True(skills.FitHeight, "sized by the panel (retail's bottom-edge resize)");
|
||||
Check.True(skills.UnderUi, "drawn under AC's own UI (\"layer\": \"underUi\")");
|
||||
Check.True(skills.DrawScale, "its own draw size, 100% = retail's pixels (\"scale\": \"draw\"), not the text size");
|
||||
Check.True(m.Windows.Any(w => w.Id == ServerPackModel.WindowId), "the server window is still there");
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnePanel()
|
||||
{
|
||||
const uint Inventory = 1u << 3, Spellbook = 1u << 7, Map = 1u << 10;
|
||||
var rule = new OnePanelRule();
|
||||
Check.Eq(rule.Next(false, Inventory), default(OnePanelRule.Step), "the first frame only learns");
|
||||
Check.Eq(rule.Next(false, Inventory), default(OnePanelRule.Step), "nothing changed");
|
||||
// The Character panel opens with the inventory up: the inventory goes.
|
||||
Check.Eq(rule.Next(true, Inventory), new OnePanelRule.Step(Inventory, false), "opening it closes AC's open panel");
|
||||
// AC still reads the inventory open for a moment: not an opening.
|
||||
Check.Eq(rule.Next(true, Inventory), default(OnePanelRule.Step), "a panel on its way out isn't an opening");
|
||||
Check.Eq(rule.Next(true, 0), default(OnePanelRule.Step), "the inventory closed");
|
||||
// The spellbook opens while it's up: it goes.
|
||||
Check.Eq(rule.Next(true, Spellbook), new OnePanelRule.Step(0, true), "an AC panel opening closes it");
|
||||
Check.Eq(rule.Next(true, Spellbook), default(OnePanelRule.Step), "asked once, not every frame while it closes");
|
||||
Check.Eq(rule.Next(false, Spellbook), default(OnePanelRule.Step), "closed");
|
||||
// AC switching between its own panels with it closed: none of its business.
|
||||
Check.Eq(rule.Next(false, Map), default(OnePanelRule.Step), "AC's own switch");
|
||||
// Opened again with two up (an engine without retail's own rule): both go.
|
||||
Check.Eq(rule.Next(true, Map | Spellbook), new OnePanelRule.Step(Map | Spellbook, false), "closes every open one");
|
||||
rule.Reset();
|
||||
Check.Eq(rule.Next(true, Map), default(OnePanelRule.Step), "after a reset the first frame only learns again");
|
||||
}
|
||||
}
|
||||
183
Tools/RynthServerPack.Tests/DreamWeaveTests.cs
Normal file
183
Tools/RynthServerPack.Tests/DreamWeaveTests.cs
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using RynthCore.Plugin.RynthDreamWeave;
|
||||
using RynthCore.Plugin.ServerPack;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthServerPack.Tests;
|
||||
|
||||
// RynthDreamWeave's bank check (Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave, 2026-11-02): "/b"
|
||||
// every minute after the first 20 s, "[BANK] Luminance: N" read into the "bankLuminance" profile value
|
||||
// for Lum/hr, deposits taken out, its own replies marked for hiding while a typed /b shows, and the
|
||||
// setting (on by default).
|
||||
internal static class DreamWeaveTests
|
||||
{
|
||||
// The /b reply as DreamWeave's ShowBankBalances sends it.
|
||||
private static readonly string[] Reply =
|
||||
{
|
||||
"[BANK] Your balances:",
|
||||
"[BANK] Pyreals (shared by every character on this account): 12,345,678",
|
||||
"[BANK] Luminance: 8,904,758",
|
||||
"[BANK] Legendary Keys: 3",
|
||||
"[BANK] Promissory Notes: 0",
|
||||
"[BANK] Offline Bonus Time: 1h 20m",
|
||||
"[BANK] Alternate Character Bonus +25% until Enl 2, Level 150",
|
||||
"[BANK] Type /bank for the full list of commands.",
|
||||
};
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("dreamweave: /b every minute while logged in, not in the first 20 s, not when turned off", Timing);
|
||||
r.Add("dreamweave: the /b reply's luminance is read, and every line of it is ours to hide", ReplyRead);
|
||||
r.Add("dreamweave: a /b the player types updates the value and its reply shows", TypedShows);
|
||||
r.Add("dreamweave: deposits are taken out of the published value", Deposits);
|
||||
r.Add("dreamweave: a pasted or quoted bank line is ignored", Pasted);
|
||||
r.Add("dreamweave: the setting is on by default and saved", Setting);
|
||||
r.Add("dreamweave: the profile value key is the shared bankLuminance", Key);
|
||||
}
|
||||
|
||||
private static void Timing()
|
||||
{
|
||||
var b = new DreamWeaveBank();
|
||||
Check.Null(b.CheckDue(0), "nothing before login");
|
||||
long t = 1_000_000;
|
||||
b.Login(t);
|
||||
Check.Null(b.CheckDue(t + 19_000), "not in the first 20 s");
|
||||
Check.Eq(b.CheckDue(t + 20_000), "/b", "the first check 20 s after login");
|
||||
Check.Null(b.CheckDue(t + 50_000), "not again within the minute");
|
||||
Check.Eq(b.CheckDue(t + 80_000), "/b", "a minute later");
|
||||
b.OnChatLine("[BANK] Luminance: 10", t + 100_000);
|
||||
Check.Null(b.CheckDue(t + 140_000), "a reading starts the minute again");
|
||||
Check.Eq(b.CheckDue(t + 160_000), "/b", "a minute after the reading");
|
||||
b.CheckEveryMinute = false;
|
||||
Check.Null(b.CheckDue(t + 400_000), "off: no checks");
|
||||
b.CheckEveryMinute = true;
|
||||
Check.Eq(b.CheckDue(t + 400_000), "/b", "on again");
|
||||
b.Logout();
|
||||
Check.Null(b.CheckDue(t + 900_000), "nothing after logout");
|
||||
Check.True(DreamWeaveBank.IsBalanceCommand(" /B ") && DreamWeaveBank.IsBalanceCommand("/bank"), "/b and /bank are the balance command");
|
||||
Check.False(DreamWeaveBank.IsBalanceCommand("/b d") || DreamWeaveBank.IsBalanceCommand("/bank deposit"), "a deposit isn't");
|
||||
}
|
||||
|
||||
private static void ReplyRead()
|
||||
{
|
||||
var b = new DreamWeaveBank();
|
||||
long t = 1_000_000;
|
||||
b.Login(t);
|
||||
Check.Null(b.Published, "no value before a reading");
|
||||
b.CheckDue(t + 20_000);
|
||||
b.NoteTypedCommand(); // our own /b through the chat bar
|
||||
b.Tick();
|
||||
long now = t + 20_500;
|
||||
foreach (string line in Reply)
|
||||
Check.True(b.OnChatLine(line, now += 100), "ours: " + line);
|
||||
Check.Eq(b.Luminance, (long?)8_904_758, "luminance with commas");
|
||||
Check.Eq(b.Published, (long?)8_904_758, "published as read");
|
||||
Check.False(b.OnChatLine("You say, \"hello\"", now), "other chat isn't ours");
|
||||
Check.False(b.OnChatLine("[BANK] Luminance: 8,904,800", now + 30_000), "a reply long after the request isn't ours");
|
||||
Check.Eq(b.Luminance, (long?)8_904_800, "but it is read");
|
||||
Check.True(b.OnChatLine("[12:01:02] [BANK] Luminance: 8,904,900\r\n", now + 30_100) == false && b.Luminance == 8_904_900,
|
||||
"a chat timestamp in front is fine");
|
||||
b.Logout();
|
||||
Check.Null(b.Published, "logout forgets the reading");
|
||||
}
|
||||
|
||||
private static void TypedShows()
|
||||
{
|
||||
var b = new DreamWeaveBank();
|
||||
long t = 1_000_000;
|
||||
b.Login(t);
|
||||
// The player types /b with no request of ours out: read, and shown.
|
||||
b.NoteTypedCommand();
|
||||
b.Tick();
|
||||
Check.False(b.OnChatLine("[BANK] Your balances:", t + 5_000), "typed: the heading shows");
|
||||
Check.False(b.OnChatLine("[BANK] Luminance: 1,000", t + 5_100), "typed: the luminance shows");
|
||||
Check.Eq(b.Published, (long?)1_000, "typed: the value updates");
|
||||
|
||||
// Our check goes out, then the player types /b too: the reply is theirs and shows.
|
||||
b.CheckDue(t + 80_000);
|
||||
b.NoteTypedCommand(); // ours, through the chat bar
|
||||
b.NoteTypedCommand(); // the player's
|
||||
b.Tick();
|
||||
Check.False(b.OnChatLine("[BANK] Luminance: 1,500", t + 80_300), "both asked: the reply shows");
|
||||
Check.Eq(b.Published, (long?)1_500, "and is read");
|
||||
|
||||
// Our check, and the chat bar never sees our send: still ours.
|
||||
b.CheckDue(t + 200_000);
|
||||
b.Tick();
|
||||
Check.True(b.OnChatLine("[BANK] Luminance: 1,600", t + 200_300), "ours without the chat bar echo");
|
||||
// A failed send leaves nothing waiting.
|
||||
b.Request(t + 300_000);
|
||||
b.NotSent();
|
||||
Check.False(b.OnChatLine("[BANK] Luminance: 1,700", t + 300_100), "a failed send: the reply isn't ours");
|
||||
}
|
||||
|
||||
private static void Deposits()
|
||||
{
|
||||
var b = new DreamWeaveBank();
|
||||
long t = 1_000_000;
|
||||
b.Login(t);
|
||||
b.OnChatLine("[BANK] Luminance: 100,000", t);
|
||||
b.OnChatLine("[BANK] Luminance: 150,000", t + 60_000);
|
||||
Check.Eq(b.Published, (long?)150_000, "earned: the value rises");
|
||||
Check.False(b.OnChatLine("[BANK] Deposited 20,000 luminance. Balance: 170,000", t + 70_000), "a deposit line shows");
|
||||
Check.Eq(b.Luminance, (long?)170_000, "the deposit's balance is a reading");
|
||||
Check.Eq(b.Published, (long?)150_000, "the deposit isn't earned");
|
||||
b.OnChatLine("[BANK] Luminance: 180,000", t + 130_000);
|
||||
Check.Eq(b.Published, (long?)160_000, "earned after it counts");
|
||||
b.OnChatLine("[BANK] Deposited all. Pyreals: 1,000 | Luminance: 230,000 | Keys: 1 | Promissory Notes: 0", t + 140_000);
|
||||
Check.Eq(b.MovedIn, 70_000L, "deposit all: what the bank gained since the reading moved in");
|
||||
Check.Eq(b.Published, (long?)160_000, "deposit all isn't earned");
|
||||
b.OnChatLine("[BANK] Luminance: 30,000", t + 200_000);
|
||||
Check.Eq(b.Published, (long?)0, "spending from the bank is a drop (readers don't count drops), never below 0");
|
||||
b.OnChatLine("[BANK] Luminance: 35,000", t + 260_000);
|
||||
Check.Eq(b.Published, (long?)5_000, "and what comes after it counts");
|
||||
}
|
||||
|
||||
private static void Pasted()
|
||||
{
|
||||
var b = new DreamWeaveBank();
|
||||
b.Login(0);
|
||||
b.Request(1_000);
|
||||
Check.False(b.OnChatLine("Someone tells you, \"[BANK] Luminance: 999,999,999\"", 1_100), "a tell");
|
||||
Check.False(b.OnChatLine("[General] Someone says, \"[BANK] Luminance: 999\"", 1_200), "a channel");
|
||||
b.OnChatLine("[BANK] Luminance: lots", 1_300);
|
||||
Check.Null(b.Luminance, "nothing read");
|
||||
}
|
||||
|
||||
private static void Setting()
|
||||
{
|
||||
string dir = Path.Combine(Path.GetTempPath(), "RynthServerPack.Tests", "dreamweave-" + Guid.NewGuid().ToString("N"));
|
||||
try
|
||||
{
|
||||
var s = new ServerPackSettings(Path.Combine(dir, "rynthdreamweave.json"));
|
||||
s.Load();
|
||||
var b = new DreamWeaveBank();
|
||||
b.LoadSettings(s);
|
||||
Check.True(b.CheckEveryMinute, "on by default");
|
||||
b.CheckEveryMinute = false;
|
||||
b.SaveSettings(s);
|
||||
var s2 = new ServerPackSettings(s.FilePath);
|
||||
s2.Load();
|
||||
var b2 = new DreamWeaveBank();
|
||||
b2.LoadSettings(s2);
|
||||
Check.False(b2.CheckEveryMinute, "off is saved");
|
||||
}
|
||||
finally
|
||||
{
|
||||
try { if (Directory.Exists(dir)) Directory.Delete(dir, recursive: true); } catch { }
|
||||
}
|
||||
}
|
||||
|
||||
private static void Key()
|
||||
{
|
||||
Check.Eq(DreamWeaveBank.LuminanceKey, RynthServerProfile.ValueBankLuminance, "the shared key");
|
||||
Check.True(ServerProfileValues.IsValidKey(DreamWeaveBank.LuminanceKey), "a valid profile value key");
|
||||
var values = new ServerProfileValues();
|
||||
values.Set(DreamWeaveBank.LuminanceKey, 8_904_758);
|
||||
string json = ServerPackProfile.BuildJson(new ServerPackInfo("dreamweave", "DreamWeave", new[] { "play.example.test" }, new[] { "DreamWeave" }), "RynthDreamWeave", "0.1.0", true,
|
||||
"DreamWeave", values.Snapshot(out _));
|
||||
Check.Eq(ServerProfileView.Value(json, RynthServerProfile.ValueBankLuminance, -1), 8_904_758.0, "readers get it from the profile");
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,8 @@ internal static class Program
|
|||
QuestPackTests.Register(runner);
|
||||
LevistrasTests.Register(runner);
|
||||
ServerPackCommandsTests.Register(runner);
|
||||
DreamWeaveSkillsTests.Register(runner);
|
||||
DreamWeaveTests.Register(runner);
|
||||
return runner.Run("RynthServerPack tests", args.Length > 0 ? args[0] : null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@
|
|||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\AelrynthBoards.cs" Link="Aelrynth\AelrynthBoards.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\AelrynthFeature.cs" Link="Aelrynth\AelrynthFeature.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\VaultFeed.cs" Link="Aelrynth\VaultFeed.cs" />
|
||||
<!-- RynthDreamWeave's bank check for Lum/hr (pure part). -->
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\DreamWeaveBank.cs" Link="DreamWeave\DreamWeaveBank.cs" />
|
||||
<!-- The difficulty tier RynthAelrynth publishes for RynthAi (and the value names, RynthServerProfileApi.cs). -->
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\AelrynthDifficulty.cs" Link="Aelrynth\AelrynthDifficulty.cs" />
|
||||
<Compile Include="$(RynthSuiteRoot)Plugins\Shared\RynthServerProfileApi.cs" Link="Shared\RynthServerProfileApi.cs" />
|
||||
|
|
@ -62,6 +64,14 @@
|
|||
<!-- The launcher's known-server picker, checked against the plugins it names. -->
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.App\LaunchServerProfile.cs" Link="Launcher\LaunchServerProfile.cs" />
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.App\KnownServerCatalog.cs" Link="Launcher\KnownServerCatalog.cs" />
|
||||
<!-- Windows of a server plugin's own (2026-11-07) and RynthDreamWeave's Skills panel (pure parts). -->
|
||||
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerPackWindows.cs" Link="Plugin\ServerPackWindows.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\RetailData.cs" Link="DreamWeave\RetailData.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\RetailData.g.cs" Link="DreamWeave\RetailData.g.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\DreamWeaveXp.cs" Link="DreamWeave\DreamWeaveXp.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\OnePanelRule.cs" Link="DreamWeave\OnePanelRule.cs" />
|
||||
<!-- 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\Runner.cs" Link="Harness\Runner.cs" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue