Snapshot for release 2026.10.20.1 (internal 7116fab)

This commit is contained in:
Tom Bohar 2026-10-20 21:28:18 -04:00
commit bfcd48950d
215 changed files with 16200 additions and 2838 deletions

View file

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using RynthCore.Plugin.Shared;
namespace RynthCore.Plugin.RynthInventory.Data;
/// <summary>One character on the Banking tab: its saved balances (null = never read) and account.</summary>
internal sealed record BankRosterEntry(string Name, string Account, bool Current, IltBankRow? Bank);
/// <summary>
/// The Banking tab's character list (2026-10-13; the Mini Remote's Banking tab moved here). Every
/// character RynthILT has bank balances for on this server (its saved per-character state, so every
/// account played on this PC), plus every character Global Inventory has recorded on the same
/// server without a balance yet, so the list covers the same characters as the inventory does.
/// Pure: the tests feed it a parsed bank view and an index.
/// </summary>
internal static class BankRoster
{
/// <summary>
/// The merged list: the logged-in character first, then by name. A name in both lists keeps
/// RynthILT's balances and the inventory's account.
/// </summary>
public static List<BankRosterEntry> Build(IltBankView bank, InventoryIndex? index)
{
var byName = new Dictionary<string, BankRosterEntry>(StringComparer.OrdinalIgnoreCase);
foreach (IltBankRow r in bank.Characters)
byName[r.Name] = new BankRosterEntry(r.Name, string.Empty, r.Current, r);
if (index != null)
{
foreach (CharacterInfo ci in index.Characters)
{
// Same server only: a bank belongs to one world.
if (!SameServer(ci, bank)) continue;
string account = !string.IsNullOrEmpty(ci.Account) && ci.Account != "unknown" ? ci.Account : string.Empty;
if (byName.TryGetValue(ci.Name, out BankRosterEntry? have))
byName[ci.Name] = have with { Account = account, Current = have.Current || ci.IsCurrentCharacter };
else
byName[ci.Name] = new BankRosterEntry(ci.Name, account, ci.IsCurrentCharacter, null);
}
}
var list = new List<BankRosterEntry>(byName.Values);
list.Sort((a, b) => a.Current != b.Current ? (a.Current ? -1 : 1) : string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase));
return list;
}
/// <summary>
/// A recorded character is on the bank's server: the world RynthILT names when it gave one,
/// otherwise the server Global Inventory says you are on now.
/// </summary>
private static bool SameServer(CharacterInfo ci, IltBankView bank) =>
bank.World.Length > 0 ? InventoryIndex.SameName(ci.Server, bank.World) : ci.IsCurrentServer;
/// <summary>The sums over every character with a balance (one row of the same shape).</summary>
public static IltBankRow Totals(IReadOnlyList<BankRosterEntry> roster)
{
long py = 0, lum = 0, lk = 0, mk = 0, ec = 0, wec = 0, pc = 0;
foreach (BankRosterEntry e in roster)
{
if (e.Bank is not { } b) continue;
py += b.Pyreals; lum += b.Luminance; lk += b.LegendaryKeys; mk += b.MythicalKeys;
ec += b.EnlightenedCoins; wec += b.WeaklyEnlightenedCoins; pc += b.PrestigeCoins;
}
return new IltBankRow("Total", false, py, lum, lk, mk, ec, wec, pc, DateTime.MinValue);
}
/// <summary>
/// The withdraw / transfer amount typed in the form: a positive whole number (commas and spaces
/// allowed), or 0 when it isn't one.
/// </summary>
public static long ParseAmount(string? text)
{
if (string.IsNullOrWhiteSpace(text)) return 0;
string digits = text.Replace(",", string.Empty).Replace(" ", string.Empty).Trim();
return long.TryParse(digits, System.Globalization.NumberStyles.None, System.Globalization.CultureInfo.InvariantCulture, out long n) && n > 0 ? n : 0;
}
}

View file

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using RynthCore.Plugin.Shared;
namespace RynthCore.Plugin.RynthInventory.Data;
/// <summary>
/// Storage another plugin read for us (Plugins/Shared/StorageFeed.cs): a server-side store the client
/// is never shown, e.g. Aelrynth's account vault from RynthAelrynth. Filed with the character's storage
/// like a container that was opened; RynthInventory itself knows nothing about any server's store.
/// Pure: RynthInventory.Tests covers it.
/// </summary>
internal static class ExternalStorage
{
/// <summary>The feed's record as a storage record, seen now (<paramref name="seenUtc"/>).</summary>
public static StorageRecord ToRecord(StorageFeedRecord feed, DateTime seenUtc)
{
var items = new List<ItemRecord>(feed.Items.Count);
foreach (StorageFeedItem f in feed.Items)
{
var it = new ItemRecord
{
Id = f.Id,
Wcid = f.Wcid,
Name = f.Name,
Icon = f.Icon,
Underlay = f.Underlay,
Overlay = f.Overlay,
Stack = Math.Max(1, f.Stack),
MaxStack = f.MaxStack,
ItemType = f.ItemType,
Place = ItemPlace.Storage,
};
it.Category = ItemCategory.FromItemType(it.ItemType);
items.Add(it);
}
return new StorageRecord { Id = feed.Id, Name = feed.Name, Label = feed.Label, Cell = 0, SeenUtc = seenUtc, Items = items };
}
/// <summary>A copy of <paramref name="storage"/> with <paramref name="record"/> in it (replacing the one with its id).</summary>
public static List<StorageRecord> FileInto(IReadOnlyList<StorageRecord> storage, StorageRecord record)
{
var list = new List<StorageRecord>(storage);
int i = list.FindIndex(s => s.Id == record.Id);
if (i >= 0) list[i] = record; else list.Add(record);
return list;
}
}