Snapshot for release 2026.10.21.1 (internal 32a418d)
This commit is contained in:
commit
6fe5630e8c
202 changed files with 43765 additions and 0 deletions
428
Plugins/RynthCore.Plugin.RynthConquest/Conquest/ConquestData.cs
Normal file
428
Plugins/RynthCore.Plugin.RynthConquest/Conquest/ConquestData.cs
Normal file
|
|
@ -0,0 +1,428 @@
|
|||
// Ported from Oracle of Dereth by Advis Eveldan (advis61), MIT. See THIRD_PARTY_NOTICES.md.
|
||||
// Moved here from RynthOracle (Data/Conquest.cs) on 2026-10-20: Conquest-only features live in RynthConquest.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using RynthCore.Plugin.ServerPack;
|
||||
|
||||
namespace RynthCore.Plugin.RynthConquest;
|
||||
|
||||
/// <summary>A labelled value from a server reply ("Pyreals" = "1,039,678,533 (4,158 MMDs)").</summary>
|
||||
internal sealed class NamedValue
|
||||
{
|
||||
public string Name = "";
|
||||
public string Value = "";
|
||||
}
|
||||
|
||||
/// <summary>One of ConquestAC's advanced augmentations (counts from "/augs").</summary>
|
||||
internal sealed class ConquestAug
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly int CoinCost;
|
||||
public readonly double LumBase, LumPercent;
|
||||
public int Count;
|
||||
|
||||
public ConquestAug(string name, int coinCost, double lumBase, double lumPercent)
|
||||
{
|
||||
Name = name; CoinCost = coinCost; LumBase = lumBase; LumPercent = lumPercent;
|
||||
}
|
||||
|
||||
/// <summary>The next purchase's luminance (Conquest-ACE's tiered cost, as upstream mirrors it).</summary>
|
||||
public long NextLuminanceCost()
|
||||
{
|
||||
long idx = Count;
|
||||
(double tierBase, long pos) = idx >= 65 ? (LumBase * 30.0, idx - 65)
|
||||
: idx >= 60 ? (LumBase * 12.0, idx - 60)
|
||||
: idx >= 30 ? (LumBase * 4.8, idx - 30)
|
||||
: idx >= 15 ? (LumBase * 2.4, idx - 15)
|
||||
: (LumBase, idx);
|
||||
// The server truncates to long; the epsilon keeps 6,229,499.9999 (binary floating point) at the
|
||||
// confirmed in-game 6,229,500 (Creature at 25).
|
||||
return (long)(tierBase * (1.0 + pos * LumPercent) + 1e-6);
|
||||
}
|
||||
|
||||
public string NextCostText() =>
|
||||
$"{CoinCost} coins, {(NextLuminanceCost() / 1_000_000.0).ToString("0.##", CultureInfo.InvariantCulture)}M lum";
|
||||
|
||||
private double ResistPercent()
|
||||
{
|
||||
const double MaxBonus = 0.32, LinearRate = 0.003, Tuning = 0.0034597;
|
||||
const int LinearCap = 10;
|
||||
if (Count <= 0) return 0.0;
|
||||
double bonus = Count <= LinearCap
|
||||
? Count * LinearRate
|
||||
: LinearCap * LinearRate + (MaxBonus - LinearCap * LinearRate) * (1.0 - Math.Pow(1.0 - Tuning, Count - LinearCap));
|
||||
return Math.Min(bonus, MaxBonus) * 100.0;
|
||||
}
|
||||
|
||||
/// <summary>The effect at the current count (upstream's reading of the Conquest-ACE source).</summary>
|
||||
public string Effect() => Name switch
|
||||
{
|
||||
"Creature" => $"+{Count} to creature buffs, -{Count} to debuffs",
|
||||
"Item" => $"+{Count}% attack/melee, +{Count * 0.5:0.#} blood/spirit, +{Count} AL",
|
||||
"Life" => $"+{ResistPercent():0.##}% prot, +{ResistPercent():0.##}% vuln, +{Count * 0.10:0.##} regen, +{Count / 10} surge rating",
|
||||
"War" => $"+{Count * 2}% war magic potency",
|
||||
"Void" => $"+{Count * 1.5:0.##}% void magic potency",
|
||||
"Melee" => $"+{Count} melee damage, +{Count * 1.5:0.#}% crit damage",
|
||||
"Missile" => $"+{Count} missile damage, +{Count * 1.5:0.#}% crit damage",
|
||||
"Duration" => $"+{Count * 5}% spell duration",
|
||||
"Specialization" => $"+{Count} skill spec cap (now {70 + Count})",
|
||||
_ => "",
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>A fellowship from "/fship list".</summary>
|
||||
internal sealed class ConquestFellowship
|
||||
{
|
||||
public string Name = "", Leader = "", Members = "", Location = "";
|
||||
|
||||
public int MemberCount
|
||||
{
|
||||
get
|
||||
{
|
||||
int slash = Members.IndexOf('/');
|
||||
return int.TryParse(slash >= 0 ? Members[..slash] : Members, out int n) ? n : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A row of a leaderboard.</summary>
|
||||
internal sealed class BoardRow
|
||||
{
|
||||
public int Rank;
|
||||
public string Name = "";
|
||||
public string Value = "";
|
||||
public string Extra = "";
|
||||
public bool IsYou;
|
||||
}
|
||||
|
||||
/// <summary>One of ConquestAC's /top boards.</summary>
|
||||
internal sealed class ConquestBoard
|
||||
{
|
||||
public readonly string Key, Label, Header;
|
||||
public readonly List<BoardRow> Rows = new();
|
||||
public BoardRow? You;
|
||||
public DateTime UpdatedUtc = DateTime.MinValue;
|
||||
|
||||
public ConquestBoard(string key, string label, string header) { Key = key; Label = label; Header = header; }
|
||||
|
||||
public string Command => "/top " + Key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Everything Conquest-only: bank balances and bank commands ("/b", "/bank"),
|
||||
/// advanced augmentations ("/augs"), enlightenment augmentations ("/enl augs"), the XP bonus
|
||||
/// breakdown ("/bonus"), fellowships looking for members ("/fship list"), the /top boards, and
|
||||
/// the void damage-over-time duration scaling. RynthConquest only feeds it chat while the server is
|
||||
/// Conquest (and only loads there); every reply regex is anchored at the start of the line (after
|
||||
/// an optional chat timestamp), as upstream does, so a pasted copy in a chat channel can't
|
||||
/// overwrite your values.
|
||||
/// </summary>
|
||||
internal sealed class ConquestData
|
||||
{
|
||||
private const string Ts = @"^\s*(?:\[[^\]]*\][\s:]*)?";
|
||||
|
||||
// /b balances
|
||||
private static readonly Regex BankLine = new(Ts + @"\[BANK\]\s+(.+?):\s*(.*\S)\s*$");
|
||||
private static readonly Regex BankChrome = new(Ts + @"\[BANK\]\s+[^:]*:\s*$");
|
||||
private static readonly Regex EventToken = new(@"Event Tokens \[(.+?)\]");
|
||||
private static readonly Regex DepositReply = new(Ts + @"(?:No .+? (?:found|available) to deposit|Deposited\b.*)\s*$", RegexOptions.IgnoreCase);
|
||||
// /augs
|
||||
private static readonly Regex AugLine = new(Ts + @"(Creature|Item|Life|War|Void|Duration|Specialization|Melee|Missile):\s*([\d,]+)\b");
|
||||
private static readonly Regex AugChrome = new(Ts + @"(?:-{3,}|Advanced Augmentation Levels:|Use /aug info for per-level effect details\.)\s*$", RegexOptions.IgnoreCase);
|
||||
// /enl augs
|
||||
private static readonly Regex EnlLine = new(Ts + @"([A-Za-z][A-Za-z '\-]*?):\s*(([\d,]+)\s*\(\s*[\d,]+\s+max\s*\))\s*$");
|
||||
private static readonly Regex EnlChrome = new(Ts + @"Enlightenment Augmentations:\s*$");
|
||||
// /bonus
|
||||
private static readonly Regex BonusLine = new(Ts + @"(Quest|Enlightenment|PK Dungeon|Augmentation|Equipment|Total) Bonus(?:\s*\(([^)]+)\))?:\s*(.+\S)\s*$");
|
||||
private static readonly Regex BonusChrome = new(Ts + @"={2,}\s*XP Bonuses\s*={2,}\s*$");
|
||||
// /fship list
|
||||
private static readonly Regex FshipHeader = new(Ts + @"Fellowships looking for members");
|
||||
private static readonly Regex FshipLine = new(Ts + @"-\s+(.+?)\s+\(Leader:\s+(.+?)\)\s+\[(\d+/\d+)\](?:\s+@\s+(.+?))?\s*$");
|
||||
// /top
|
||||
private static readonly Regex TopHeader = new(Ts + @"Top\s+(\d+)\s+Players?\s+by\s+(.+?):\s*$");
|
||||
private static readonly Regex TopEntry = new(Ts + @"(\d+):\s+([\d,]+)\s+-\s+(.+?)\s*$");
|
||||
private static readonly Regex TopSeparator = new(Ts + @"\.\.\.\s*$");
|
||||
|
||||
private static readonly string[] EnlOrder =
|
||||
{
|
||||
"Damage", "Damage Reduction", "Crit Damage", "Crit Damage Reduction", "Imbue", "Salvage", "Skill Credits",
|
||||
"Stamina Benediction", "Mana Benediction", "Cleave", "Arrow Split", "Spell Chain", "Aetheria Surge", "Void Contagion",
|
||||
};
|
||||
private static readonly Dictionary<string, string> EnlCosts = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
["Cleave"] = "1 Pristine Token", ["Arrow Split"] = "1 Pristine Token", ["Spell Chain"] = "1 Pristine Token",
|
||||
["Aetheria Surge"] = "1 Pristine Token", ["Void Contagion"] = "1 Pristine Token",
|
||||
["Damage"] = "2 Tokens", ["Damage Reduction"] = "2 Tokens", ["Crit Damage"] = "2 Tokens",
|
||||
["Crit Damage Reduction"] = "2 Tokens", ["Imbue"] = "2 Tokens", ["Salvage"] = "2 Tokens",
|
||||
["Skill Credits"] = "4 Tokens", ["Stamina Benediction"] = "4 Tokens", ["Mana Benediction"] = "4 Tokens",
|
||||
};
|
||||
|
||||
public const int PyrealsPerMmd = 250_000;
|
||||
|
||||
public readonly List<NamedValue> Bank = new();
|
||||
public readonly List<ConquestAug> Augs = new()
|
||||
{
|
||||
new("Creature", 25, 2_500_000, 0.003825), new("Item", 100, 3_000_000, 0.006825), new("Life", 75, 2_500_000, 0.0095),
|
||||
new("War", 50, 1_750_000, 0.00425), new("Void", 50, 1_800_000, 0.00425), new("Duration", 30, 1_400_000, 0.00625),
|
||||
new("Specialization", 125, 3_000_000, 0.02), new("Melee", 50, 1_750_000, 0.00425), new("Missile", 50, 1_750_000, 0.00425),
|
||||
};
|
||||
public List<NamedValue> EnlAugs { get; private set; } = new();
|
||||
public readonly List<NamedValue> Bonuses = new()
|
||||
{
|
||||
new() { Name = "Quest" }, new() { Name = "Enlightenment" }, new() { Name = "PK Dungeon" }, new() { Name = "Augmentation" },
|
||||
new() { Name = "Equipment" }, new() { Name = "Total (Kills)" }, new() { Name = "Total (Quest/Lum)" },
|
||||
};
|
||||
public readonly List<ConquestFellowship> Fellowships = new();
|
||||
public readonly List<ConquestBoard> Boards = new()
|
||||
{
|
||||
new("augs", "Augs", "Total Augmentations"), new("deaths", "Deaths", "Deaths"), new("enl", "Enlightens", "Enlightenment"),
|
||||
new("level", "Levels", "Level"), new("lum", "Luminance", "Banked Luminance"), new("bank", "Pyreals", "Banked Pyreals"),
|
||||
new("qb", "QB", "Quest Bonus"), new("titles", "Titles", "Titles"),
|
||||
};
|
||||
|
||||
public DateTime BankUtc = DateTime.MinValue, AugsUtc = DateTime.MinValue, EnlUtc = DateTime.MinValue,
|
||||
BonusUtc = DateTime.MinValue, FshipUtc = DateTime.MinValue;
|
||||
public int Revision { get; private set; }
|
||||
|
||||
private readonly ServerChatRequest _bankReq = new(), _augReq = new(), _enlReq = new(), _bonusReq = new(), _fshipReq = new(),
|
||||
_topReq = new(), _depositReq = new();
|
||||
private ConquestBoard? _collecting;
|
||||
private long _collectingMs;
|
||||
private int _collectingExpected = int.MaxValue;
|
||||
private bool _collectingCleared;
|
||||
|
||||
public static string EnlCost(string name) => EnlCosts.TryGetValue(name, out string? c) ? c : "";
|
||||
|
||||
public int AugTotal => Augs.Sum(a => a.Count);
|
||||
public int DurationAugs => Augs.First(a => a.Name == "Duration").Count;
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
Bank.Clear();
|
||||
foreach (ConquestAug a in Augs) a.Count = 0;
|
||||
EnlAugs = new List<NamedValue>();
|
||||
foreach (NamedValue b in Bonuses) b.Value = "";
|
||||
Fellowships.Clear();
|
||||
foreach (ConquestBoard b in Boards) { b.Rows.Clear(); b.You = null; b.UpdatedUtc = DateTime.MinValue; }
|
||||
BankUtc = AugsUtc = EnlUtc = BonusUtc = FshipUtc = DateTime.MinValue;
|
||||
_collecting = null;
|
||||
Revision++;
|
||||
}
|
||||
|
||||
// ── Requests (the plugin sends the command; each returns the command text) ──
|
||||
|
||||
public string RequestBank(long now) { _bankReq.Sent(now); return "/b"; }
|
||||
public string RequestAugs(long now) { _augReq.Sent(now); return "/augs"; }
|
||||
public string RequestEnl(long now) { _enlReq.Sent(now); return "/enl augs"; }
|
||||
public string RequestBonus(long now) { _bonusReq.Sent(now); return "/bonus"; }
|
||||
public string RequestFships(long now) { _fshipReq.Sent(now); Fellowships.Clear(); Revision++; return "/fship list"; }
|
||||
|
||||
public string RequestBoard(ConquestBoard board, long now)
|
||||
{
|
||||
_topReq.Sent(now);
|
||||
Open(board, now);
|
||||
return "/top " + board.Key;
|
||||
}
|
||||
|
||||
/// <summary>An automatic deposit: its reply is ours to hide.</summary>
|
||||
public string AutoDeposit(long now) { _depositReq.Sent(now); return "/bank deposit"; }
|
||||
|
||||
/// <summary>
|
||||
/// A chat line: true when it was a reply this module reads; <paramref name="ours"/> = it
|
||||
/// answers a request RynthConquest sent (eligible to be hidden).
|
||||
/// </summary>
|
||||
public bool OnChatLine(string text, long now, out bool ours)
|
||||
{
|
||||
ours = false;
|
||||
Match m;
|
||||
|
||||
if (_depositReq.Awaiting(now) && DepositReply.IsMatch(text)) { ours = true; _depositReq.Extend(now); return true; }
|
||||
|
||||
if ((m = BankLine.Match(text)).Success)
|
||||
{
|
||||
string name = EventToken.Replace(m.Groups[1].Value.Trim(), "$1");
|
||||
string value = m.Groups[2].Value.Trim();
|
||||
if (name == "Pyreals" && long.TryParse(value.Replace(",", ""), out long py))
|
||||
value += $" ({(py / PyrealsPerMmd).ToString("N0", CultureInfo.InvariantCulture)} MMDs)";
|
||||
NamedValue? e = Bank.FirstOrDefault(b => b.Name == name);
|
||||
if (e != null) e.Value = value; else Bank.Add(new NamedValue { Name = name, Value = value });
|
||||
BankUtc = DateTime.UtcNow;
|
||||
return Done(_bankReq, now, out ours);
|
||||
}
|
||||
if (_bankReq.Awaiting(now) && BankChrome.IsMatch(text)) return Done(_bankReq, now, out ours);
|
||||
|
||||
if ((m = AugLine.Match(text)).Success)
|
||||
{
|
||||
ConquestAug? a = Augs.FirstOrDefault(x => x.Name == m.Groups[1].Value);
|
||||
if (a != null && int.TryParse(m.Groups[2].Value.Replace(",", ""), out int c)) a.Count = c;
|
||||
AugsUtc = DateTime.UtcNow;
|
||||
return Done(_augReq, now, out ours);
|
||||
}
|
||||
if (_augReq.Awaiting(now) && AugChrome.IsMatch(text)) return Done(_augReq, now, out ours);
|
||||
|
||||
if (EnlChrome.IsMatch(text))
|
||||
{
|
||||
EnlAugs = new List<NamedValue>();
|
||||
return Done(_enlReq, now, out ours);
|
||||
}
|
||||
if ((m = EnlLine.Match(text)).Success)
|
||||
{
|
||||
// "Label: N (M max)" is specific to the "/enl augs" reply (its header starts a fresh list).
|
||||
string name = m.Groups[1].Value.Trim();
|
||||
var list = new List<NamedValue>(EnlAugs.Where(x => x.Name != name)) { new() { Name = name, Value = m.Groups[2].Value.Trim() } };
|
||||
list.Sort((x, y) => Rank(x.Name).CompareTo(Rank(y.Name)));
|
||||
EnlAugs = list;
|
||||
EnlUtc = DateTime.UtcNow;
|
||||
return Done(_enlReq, now, out ours);
|
||||
}
|
||||
|
||||
if ((m = BonusLine.Match(text)).Success)
|
||||
{
|
||||
string q = m.Groups[2].Value.Trim();
|
||||
string name = q.Length > 0 ? $"{m.Groups[1].Value} ({q})" : m.Groups[1].Value;
|
||||
NamedValue? b = Bonuses.FirstOrDefault(x => x.Name == name);
|
||||
if (b != null) b.Value = m.Groups[3].Value.Trim();
|
||||
BonusUtc = DateTime.UtcNow;
|
||||
return Done(_bonusReq, now, out ours);
|
||||
}
|
||||
if (_bonusReq.Awaiting(now) && BonusChrome.IsMatch(text)) return Done(_bonusReq, now, out ours);
|
||||
|
||||
if (FshipHeader.IsMatch(text))
|
||||
{
|
||||
if (!_fshipReq.Awaiting(now)) Fellowships.Clear();
|
||||
FshipUtc = DateTime.UtcNow;
|
||||
return Done(_fshipReq, now, out ours);
|
||||
}
|
||||
if ((m = FshipLine.Match(text)).Success)
|
||||
{
|
||||
Fellowships.Add(new ConquestFellowship
|
||||
{
|
||||
Name = m.Groups[1].Value.Trim(), Leader = m.Groups[2].Value.Trim(), Members = m.Groups[3].Value.Trim(),
|
||||
Location = m.Groups[4].Success ? m.Groups[4].Value.Trim() : "",
|
||||
});
|
||||
FshipUtc = DateTime.UtcNow;
|
||||
return Done(_fshipReq, now, out ours);
|
||||
}
|
||||
|
||||
if ((m = TopHeader.Match(text)).Success)
|
||||
{
|
||||
ConquestBoard? board = Active(now) ?? Boards.FirstOrDefault(b => b.Header.Equals(m.Groups[2].Value.Trim(), StringComparison.OrdinalIgnoreCase));
|
||||
if (board == null) return false;
|
||||
Open(board, now);
|
||||
ClearOnce();
|
||||
_collectingExpected = int.TryParse(m.Groups[1].Value, out int n) ? n : int.MaxValue;
|
||||
return Done(_topReq, now, out ours);
|
||||
}
|
||||
if ((m = TopEntry.Match(text)).Success && Active(now) is ConquestBoard cb)
|
||||
{
|
||||
ClearOnce();
|
||||
int.TryParse(m.Groups[1].Value, out int rank);
|
||||
string name = m.Groups[3].Value.Trim();
|
||||
var row = new BoardRow { Rank = rank, Value = m.Groups[2].Value.Trim(), Name = name };
|
||||
if (name.EndsWith("(You)", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
row.IsYou = true;
|
||||
row.Name = name[..^5].Trim();
|
||||
cb.You = row;
|
||||
}
|
||||
if (rank <= _collectingExpected && cb.Rows.All(r => r.Rank != rank)) cb.Rows.Add(row);
|
||||
cb.Rows.Sort((x, y) => x.Rank.CompareTo(y.Rank));
|
||||
cb.UpdatedUtc = DateTime.UtcNow;
|
||||
_collectingMs = now;
|
||||
return Done(_topReq, now, out ours);
|
||||
}
|
||||
if (Active(now) != null && TopSeparator.IsMatch(text)) return Done(_topReq, now, out ours);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool Done(ServerChatRequest req, long now, out bool ours)
|
||||
{
|
||||
ours = req.Awaiting(now);
|
||||
req.Extend(now);
|
||||
Revision++;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int Rank(string name)
|
||||
{
|
||||
int i = Array.FindIndex(EnlOrder, n => n.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
return i < 0 ? EnlOrder.Length : i;
|
||||
}
|
||||
|
||||
private void Open(ConquestBoard board, long now)
|
||||
{
|
||||
if (_collecting == board && now - _collectingMs < 15_000) return;
|
||||
_collecting = board;
|
||||
_collectingMs = now;
|
||||
_collectingExpected = int.MaxValue;
|
||||
_collectingCleared = false;
|
||||
}
|
||||
|
||||
private ConquestBoard? Active(long now) => _collecting != null && now - _collectingMs < 15_000 ? _collecting : null;
|
||||
|
||||
private void ClearOnce()
|
||||
{
|
||||
if (_collectingCleared || _collecting == null) return;
|
||||
_collecting.Rows.Clear();
|
||||
_collecting.You = null;
|
||||
_collectingCleared = true;
|
||||
}
|
||||
|
||||
// ── Bank commands (Conquest-ACE's /bank; tokens are its one-letter currency codes) ──
|
||||
|
||||
public sealed record Currency(string Label, string Token, long Multiplier = 1, long Max = long.MaxValue);
|
||||
|
||||
public static readonly Currency[] Withdrawable =
|
||||
{
|
||||
new("Conquest Coins", "c"), new("Event Tokens", "e"), new("Legendary Keys", "k"), new("Pyreals", "p"),
|
||||
new("Soul Fragments", "s"), new("MMD Notes (250k)", "n"), new("MM Notes (200k)", "n MM"), new("M Notes (100k)", "n M"),
|
||||
new("D Notes (50k)", "n D"), new("C Notes (10k)", "n C"), new("L Notes (5k)", "n L"), new("X Notes (1k)", "n X"),
|
||||
new("V Notes (500)", "n V"), new("I Notes (100)", "n I"),
|
||||
};
|
||||
public const int DefaultWithdraw = 5; // MMD notes
|
||||
|
||||
public static readonly Currency[] Transferable =
|
||||
{
|
||||
new("Legendary Keys", "k"), new("Luminance", "l"), new("MMD Notes (250k)", "p", 250_000, 1_000), new("Pyreals", "p"),
|
||||
};
|
||||
public const int DefaultTransfer = 1; // Luminance
|
||||
|
||||
/// <summary>"/bank withdraw <token> <n>", or null when the amount isn't a whole number above 0.</summary>
|
||||
public static string? WithdrawCommand(Currency c, string amount) =>
|
||||
long.TryParse((amount ?? "").Replace(",", "").Trim(), out long n) && n > 0 ? $"/bank withdraw {c.Token} {n}" : null;
|
||||
|
||||
/// <summary>"/bank transfer <token> <n> "name"", or null when the amount or name isn't usable.</summary>
|
||||
public static string? TransferCommand(Currency c, string amount, string target)
|
||||
{
|
||||
target = (target ?? "").Trim().Replace("\"", "");
|
||||
if (target.Length == 0 || !long.TryParse((amount ?? "").Replace(",", "").Trim(), out long n) || n <= 0 || n > c.Max) return null;
|
||||
try { return $"/bank transfer {c.Token} {checked(n * c.Multiplier)} \"{target}\""; }
|
||||
catch (OverflowException) { return null; }
|
||||
}
|
||||
|
||||
// ── Levels and enlightenment (ConquestAC's levels 276-300, upstream's table) ──
|
||||
|
||||
private static readonly long[] Levels276To300 =
|
||||
{
|
||||
194665023377, 198152685223, 201689992550, 205277652043, 208916380445,
|
||||
212606904701, 216349962105, 220146300445, 223996678153, 227901864460,
|
||||
231862639544, 235879794689, 239954132442, 244086466776, 248277623248,
|
||||
252528439169, 256839763767, 261212458359, 265647396522, 270145464270,
|
||||
274707560226, 279334595807, 284027495403, 288787196561, 293614650176,
|
||||
};
|
||||
public const int MaxLevel = 300;
|
||||
|
||||
/// <summary>Total XP to reach a level 276-300 (0 otherwise).</summary>
|
||||
public static long XpForLevel(int level) => level >= 276 && level <= 300 ? Levels276To300[level - 276] : 0;
|
||||
|
||||
private static double EnlMultiplier(int target) => target >= 75 ? 7.5 : target >= 50 ? 5.0 : target >= 25 ? 2.5 : 1.0;
|
||||
public static long EnlCoinCost(int target) => (long)(target * 100 * EnlMultiplier(target));
|
||||
public static long EnlLuminanceCost(int target) => (long)(target * 1_000_000L * EnlMultiplier(target));
|
||||
|
||||
/// <summary>Void DoT duration on ConquestAC: × (1 + Archmage's Endurance × 0.2 + Duration augs × 0.05).</summary>
|
||||
public double VoidDurationMultiplier(int archmagesEndurance) => 1.0 + archmagesEndurance * 0.2 + DurationAugs * 0.05;
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
// ConquestFeature.cs - What RynthConquest does on Conquest, without the host (ConquestPlugin.cs wires it
|
||||
// to the engine, ConquestPages.cs draws it). Moved out of RynthOracle on 2026-10-20 so that only players
|
||||
// who installed RynthConquest get Conquest's features, and the automatic /bank deposit with them:
|
||||
// * reads the replies of Conquest's own commands (ConquestData: /b, /augs, /enl augs, /bonus,
|
||||
// /fship list, /top) and the quest flags (/myquests, for the custom quest worklist), and hides
|
||||
// the replies to its own requests when HideOwnReplies is on;
|
||||
// * reads the advanced augmentations once after login (the Void DoT rule needs the Duration augs);
|
||||
// * deposits everything at each ten-minute mark when AutoDeposit is on (off unless the player
|
||||
// turned it on, in RynthOracle before or here);
|
||||
// * works out the Void DoT duration rule for this character, which RynthOracle's Void timers read
|
||||
// from the server profile ("voidDotDurationScale") instead of knowing about Conquest.
|
||||
// Settings: rynthconquest.json (ServerPackSettings), taken over once from rynthoracle.json.
|
||||
// Threads: everything here runs under Gate. Chat and tick come from the pump, the pages draw on the
|
||||
// render thread holding it too; nothing in here calls the host.
|
||||
// Pure: RynthServerPack.Tests covers it.
|
||||
using System;
|
||||
using RynthCore.Plugin.RynthOracle.Data;
|
||||
using RynthCore.Plugin.ServerPack;
|
||||
|
||||
namespace RynthCore.Plugin.RynthConquest;
|
||||
|
||||
internal sealed class ConquestFeature
|
||||
{
|
||||
public const string SettingAutoDeposit = "autoDeposit";
|
||||
public const string SettingHideOwnReplies = "hideOwnReplies";
|
||||
/// <summary>Set once rynthoracle.json's Conquest settings were taken over (they're never read again).</summary>
|
||||
public const string MigrationMarker = "migratedFromRynthOracle";
|
||||
/// <summary>The profile value RynthOracle's Void timers apply ("RynthServer.Profile" values).</summary>
|
||||
public const string VoidScaleKey = "voidDotDurationScale";
|
||||
/// <summary>After login, before the hidden /augs (RynthOracle's old timing: its quest read plus 4 s).</summary>
|
||||
public const long AugsReadDelayMs = 10_000;
|
||||
/// <summary>The character's level, XP and augmentation are read this often.</summary>
|
||||
public const long CharacterReadMs = 1000;
|
||||
|
||||
/// <summary>RynthConquest's pages (ConquestPages draws them): id, label, tooltip.</summary>
|
||||
public static readonly (string Id, string Label, string Tooltip)[] PageList =
|
||||
{
|
||||
("main", "Conquest", "Conquest: bank and auto-deposit, augmentations, levels past 275, fellowships and custom quests (RynthConquest)."),
|
||||
("boards", "Leaderboards", "Conquest's /top boards (RynthConquest)."),
|
||||
};
|
||||
|
||||
/// <summary>Held for everything below (pump and render thread).</summary>
|
||||
public readonly object Gate = new();
|
||||
public readonly ConquestData Data = new();
|
||||
public readonly QuestFlagStore Flags = new();
|
||||
|
||||
/// <summary>"/bank deposit" at every ten-minute mark (upstream's auto-deposit). Off by default.</summary>
|
||||
public bool AutoDeposit;
|
||||
/// <summary>Hide the replies to RynthConquest's own requests (a command typed by hand always shows).</summary>
|
||||
public bool HideOwnReplies = true;
|
||||
|
||||
// The character (ConquestPlugin reads them every CharacterReadMs).
|
||||
public bool CharacterKnown;
|
||||
public int Level, Enlightenment, ArchmagesEndurance;
|
||||
public long TotalXp;
|
||||
|
||||
private long _loginMs;
|
||||
private bool _augsAsked;
|
||||
private long _lastDepositBlock = -1;
|
||||
|
||||
/// <summary>
|
||||
/// Takes over the settings RynthOracle had for Conquest (rynthoracle.json at <paramref name="oraclePath"/>),
|
||||
/// once per settings file; a value that isn't there keeps this plugin's default (auto-deposit off,
|
||||
/// hiding on, as they were in RynthOracle). True when it ran now.
|
||||
/// </summary>
|
||||
public static bool Migrate(ServerPackSettings settings, string oraclePath) => settings.MigrateOnce(MigrationMarker, s =>
|
||||
{
|
||||
if (ServerPackSettings.ReadBoolFrom(oraclePath, "conquestAutoDeposit") is bool deposit) s.SetBool(SettingAutoDeposit, deposit);
|
||||
if (ServerPackSettings.ReadBoolFrom(oraclePath, "hideOwnQuestReplies") is bool hide) s.SetBool(SettingHideOwnReplies, hide);
|
||||
});
|
||||
|
||||
public void LoadSettings(ServerPackSettings s)
|
||||
{
|
||||
AutoDeposit = s.GetBool(SettingAutoDeposit, false);
|
||||
HideOwnReplies = s.GetBool(SettingHideOwnReplies, true);
|
||||
}
|
||||
|
||||
public void SaveSettings(ServerPackSettings s)
|
||||
{
|
||||
bool changed = s.SetBool(SettingAutoDeposit, AutoDeposit);
|
||||
changed |= s.SetBool(SettingHideOwnReplies, HideOwnReplies);
|
||||
if (changed) s.Save();
|
||||
}
|
||||
|
||||
/// <summary>A character logged in (or the plugin loaded in game): everything is read fresh.</summary>
|
||||
public void Login(long nowMs)
|
||||
{
|
||||
_loginMs = nowMs;
|
||||
_augsAsked = false;
|
||||
Data.Clear();
|
||||
Flags.Clear();
|
||||
CharacterKnown = false;
|
||||
Level = Enlightenment = ArchmagesEndurance = 0;
|
||||
TotalXp = 0;
|
||||
}
|
||||
|
||||
public void Logout()
|
||||
{
|
||||
Data.Clear();
|
||||
Flags.Clear();
|
||||
CharacterKnown = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An incoming chat line on Conquest. True when it should be hidden: a reply to one of
|
||||
/// RynthConquest's own requests, with HideOwnReplies on.
|
||||
/// </summary>
|
||||
public bool OnChatLine(string text, long nowMs)
|
||||
{
|
||||
string line = text.TrimEnd('\r', '\n');
|
||||
MyQuestsLine kind = Flags.OnChatLine(line, nowMs);
|
||||
if (kind != MyQuestsLine.None)
|
||||
return Flags.AwaitingOurs && HideOwnReplies && kind is MyQuestsLine.Quest or MyQuestsLine.Empty;
|
||||
return Data.OnChatLine(line, nowMs, out bool ours) && ours && HideOwnReplies;
|
||||
}
|
||||
|
||||
/// <summary>The once-after-login /augs: the command to send now, or null.</summary>
|
||||
public string? LoginAugsDue(long nowMs)
|
||||
{
|
||||
if (_augsAsked || nowMs - _loginMs <= AugsReadDelayMs) return null;
|
||||
_augsAsked = true;
|
||||
return Data.RequestAugs(nowMs);
|
||||
}
|
||||
|
||||
/// <summary>The automatic deposit: "/bank deposit" when one is due now, else null.</summary>
|
||||
public string? AutoDepositDue(DateTime local, long nowMs)
|
||||
=> AutoDeposit && DepositDue(local, ref _lastDepositBlock) ? Data.AutoDeposit(nowMs) : null;
|
||||
|
||||
/// <summary>
|
||||
/// True once in each ten-minute block, at its first minute (:00, :10, :20 ... local time), as
|
||||
/// upstream does; <paramref name="lastBlock"/> remembers the block already done.
|
||||
/// </summary>
|
||||
public static bool DepositDue(DateTime local, ref long lastBlock)
|
||||
{
|
||||
long block = local.Ticks / TimeSpan.TicksPerMinute / 10;
|
||||
if (local.Minute % 10 != 0 || block == lastBlock) return false;
|
||||
lastBlock = block;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>This character's Void DoT duration multiplier on Conquest (Archmage's Endurance and the Duration augs).</summary>
|
||||
public double VoidScale => Data.VoidDurationMultiplier(ArchmagesEndurance);
|
||||
}
|
||||
417
Plugins/RynthCore.Plugin.RynthConquest/Conquest/ConquestPages.cs
Normal file
417
Plugins/RynthCore.Plugin.RynthConquest/Conquest/ConquestPages.cs
Normal file
|
|
@ -0,0 +1,417 @@
|
|||
// Ported from Oracle of Dereth by Advis Eveldan (advis61), MIT. See THIRD_PARTY_NOTICES.md.
|
||||
// RynthOracle's Conquest tab (Views/ConquestTab.cs) and the Conquest half of its Leaderboards tab
|
||||
// (Views/BoardsTab.cs), moved here on 2026-10-20 and redrawn with ImGui as RynthConquest's pages:
|
||||
// sub-tabs of the Mini Remote's Server section while on Conquest, and tabs of the /rserver window.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.RynthOracle.Data;
|
||||
using RynthCore.Plugin.ServerPack;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthConquest;
|
||||
|
||||
/// <summary>
|
||||
/// The Conquest page (bank balances and bank commands, advanced and enlightenment augmentations,
|
||||
/// levels past 275 and the XP bonus breakdown, fellowships looking for members, the custom quest
|
||||
/// worklist: upstream's Bank, Conquest Augs, Conquest XP, Fship and Custom tabs) and the
|
||||
/// Leaderboards page (Conquest's /top boards: upstream's Top Players tab).
|
||||
/// Render thread: each page draws holding the feature's lock, and queues what it sends for the tick.
|
||||
/// </summary>
|
||||
internal sealed class ConquestPages
|
||||
{
|
||||
private static readonly Vector4 Gold = new(1.00f, 0.84f, 0.30f, 1f);
|
||||
private static readonly Vector4 Green = new(0.45f, 0.85f, 0.45f, 1f);
|
||||
private static readonly Vector4 Grey = new(0.55f, 0.57f, 0.60f, 1f);
|
||||
private static readonly Vector4 Selected = new(0.26f, 0.45f, 0.70f, 1f);
|
||||
|
||||
private static readonly string[] Views = { "Bank", "Augs", "Enlightenment", "Experience", "Fellowships", "Custom quests" };
|
||||
private static readonly string[] FshipSorts = { "Name", "Leader", "Most members", "Location" };
|
||||
|
||||
private readonly ConquestFeature _f;
|
||||
private readonly Func<bool> _active;
|
||||
private readonly Action<Action> _runOnTick;
|
||||
private readonly Func<string, bool> _send;
|
||||
private readonly Action<string> _print;
|
||||
private readonly Action _saveSettings;
|
||||
private readonly ServerRefreshRow _refresh = new();
|
||||
|
||||
private int _view;
|
||||
private int _withdrawIndex = ConquestData.DefaultWithdraw, _transferIndex = ConquestData.DefaultTransfer;
|
||||
private string _withdrawAmount = "", _transferAmount = "", _transferTarget = "";
|
||||
private int _fshipSort;
|
||||
private int _board;
|
||||
|
||||
/// <param name="active">RynthConquest's server is this world.</param>
|
||||
/// <param name="runOnTick">Queues work for the plugin tick (ServerPackPlugin.RunOnTick).</param>
|
||||
/// <param name="send">Sends a chat command as if typed (pump thread).</param>
|
||||
/// <param name="print">A line in the chat window (pump thread).</param>
|
||||
/// <param name="saveSettings">Writes the feature's settings (pump thread).</param>
|
||||
public ConquestPages(ConquestFeature feature, Func<bool> active, Action<Action> runOnTick, Func<string, bool> send,
|
||||
Action<string> print, Action saveSettings)
|
||||
{
|
||||
_f = feature;
|
||||
_active = active;
|
||||
_runOnTick = runOnTick;
|
||||
_send = send;
|
||||
_print = print;
|
||||
_saveSettings = saveSettings;
|
||||
}
|
||||
|
||||
public ServerPage[] Pages()
|
||||
{
|
||||
var list = ConquestFeature.PageList;
|
||||
return new[]
|
||||
{
|
||||
new ServerPage(list[0].Id, list[0].Label, list[0].Tooltip, DrawConquest),
|
||||
new ServerPage(list[1].Id, list[1].Label, list[1].Tooltip, DrawBoards),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Logout: the next character's status lines start empty.</summary>
|
||||
public void Reset() => _refresh.Reset();
|
||||
|
||||
// ── Conquest page ───────────────────────────────────────────────────
|
||||
|
||||
private void DrawConquest()
|
||||
{
|
||||
if (!Ready()) return;
|
||||
lock (_f.Gate)
|
||||
{
|
||||
for (int i = 0; i < Views.Length; i++)
|
||||
{
|
||||
if (i > 0) ImGui.SameLine();
|
||||
if (Toggle(Views[i] + "##cq_v" + i, i == _view)) _view = i;
|
||||
}
|
||||
_refresh.Draw("cq" + _view, ConquestHelp(), RefreshConquest);
|
||||
ImGui.Separator();
|
||||
switch (_view)
|
||||
{
|
||||
case 0: DrawBank(); break;
|
||||
case 1: DrawAugs(); break;
|
||||
case 2: DrawEnl(); break;
|
||||
case 3: DrawXp(); break;
|
||||
case 4: DrawFships(); break;
|
||||
default: DrawCustom(); break;
|
||||
}
|
||||
ImGui.Spacing();
|
||||
bool hide = _f.HideOwnReplies;
|
||||
if (ImGui.Checkbox("Hide the replies to RynthConquest's own requests##cq_hide", ref hide))
|
||||
{
|
||||
_f.HideOwnReplies = hide;
|
||||
_runOnTick(_saveSettings);
|
||||
}
|
||||
Tooltip("/b, /augs, /top, /myquests and the like when RynthConquest sends them. A command you type yourself always shows its reply.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>True when the page has something to show; otherwise says why.</summary>
|
||||
private bool Ready()
|
||||
{
|
||||
if (_active()) return true;
|
||||
SafeImGui.TextWrapped("These pages are for Conquest. RynthCore doesn't see this world as Conquest "
|
||||
+ "(check RynthCore Options > Diagnostics, or /rserver info).");
|
||||
return false;
|
||||
}
|
||||
|
||||
private static string ReadAt(DateTime utc) => utc == DateTime.MinValue ? "not read yet" : $"read at {utc.ToLocalTime():HH:mm}";
|
||||
|
||||
private void DrawBank()
|
||||
{
|
||||
ConquestData cq = _f.Data;
|
||||
SafeImGui.TextDisabled(ReadAt(cq.BankUtc));
|
||||
foreach (NamedValue b in cq.Bank.OrderBy(b => b.Name, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
SafeImGui.TextDisabled(Cut(b.Name, 34));
|
||||
ImGui.SameLine(260f);
|
||||
SafeImGui.Text(b.Value);
|
||||
}
|
||||
if (cq.Bank.Count == 0) SafeImGui.TextDisabled("No balances read yet.");
|
||||
|
||||
ImGui.SeparatorText("Deposit");
|
||||
if (ImGui.Button("Deposit everything##cq_dep")) Queue("/bank deposit");
|
||||
Tooltip("Sends /bank deposit.");
|
||||
bool auto = _f.AutoDeposit;
|
||||
if (ImGui.Checkbox("Deposit by itself every ten minutes##cq_auto", ref auto))
|
||||
{
|
||||
_f.AutoDeposit = auto;
|
||||
_runOnTick(_saveSettings);
|
||||
}
|
||||
Tooltip("At :00, :10, :20 ... while you're logged in on Conquest. Its reply is hidden.");
|
||||
|
||||
ImGui.SeparatorText("Withdraw");
|
||||
string[] wl = ConquestData.Withdrawable.Select(c => c.Label).ToArray();
|
||||
ImGui.SetNextItemWidth(200f);
|
||||
if (ImGui.Combo("Currency##cq_wcur", ref _withdrawIndex, wl, wl.Length)) _withdrawIndex = Math.Clamp(_withdrawIndex, 0, wl.Length - 1);
|
||||
ImGui.SetNextItemWidth(200f);
|
||||
ImGui.InputText("Amount##cq_wamt", ref _withdrawAmount, 16);
|
||||
if (ImGui.Button("Withdraw##cq_withdraw"))
|
||||
{
|
||||
string? cmd = ConquestData.WithdrawCommand(ConquestData.Withdrawable[_withdrawIndex], _withdrawAmount);
|
||||
if (cmd == null) Print("Withdraw: type a whole number above 0.");
|
||||
else Queue(cmd);
|
||||
}
|
||||
|
||||
ImGui.SeparatorText("Transfer to a character");
|
||||
string[] tl = ConquestData.Transferable.Select(c => c.Label).ToArray();
|
||||
ImGui.SetNextItemWidth(200f);
|
||||
if (ImGui.Combo("Currency##cq_tcur", ref _transferIndex, tl, tl.Length)) _transferIndex = Math.Clamp(_transferIndex, 0, tl.Length - 1);
|
||||
ImGui.SetNextItemWidth(200f);
|
||||
ImGui.InputText("Amount##cq_tamt", ref _transferAmount, 16);
|
||||
ImGui.SetNextItemWidth(200f);
|
||||
ImGui.InputText("Character##cq_tgt", ref _transferTarget, 40);
|
||||
if (ImGui.Button("Transfer##cq_transfer"))
|
||||
{
|
||||
string? cmd = ConquestData.TransferCommand(ConquestData.Transferable[_transferIndex], _transferAmount, _transferTarget);
|
||||
if (cmd == null) Print("Transfer: type a whole number above 0 (MMD notes: at most 1,000) and a character name.");
|
||||
else Queue(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawAugs()
|
||||
{
|
||||
ConquestData cq = _f.Data;
|
||||
SafeImGui.TextDisabled($"{ReadAt(cq.AugsUtc)}, {cq.AugTotal} in total");
|
||||
ImGui.TextDisabled("Aug"); ImGui.SameLine(120f); ImGui.TextDisabled("Have"); ImGui.SameLine(170f);
|
||||
ImGui.TextDisabled("Next costs"); ImGui.SameLine(330f); ImGui.TextDisabled("Effect now");
|
||||
foreach (ConquestAug a in cq.Augs)
|
||||
{
|
||||
SafeImGui.Text(a.Name);
|
||||
ImGui.SameLine(120f);
|
||||
SafeImGui.Text(a.Count.ToString());
|
||||
ImGui.SameLine(170f);
|
||||
SafeImGui.Text(a.NextCostText());
|
||||
ImGui.SameLine(330f);
|
||||
SafeImGui.TextDisabled(Cut(a.Effect(), 48));
|
||||
Tooltip(a.Effect());
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawEnl()
|
||||
{
|
||||
ConquestData cq = _f.Data;
|
||||
SafeImGui.TextDisabled(ReadAt(cq.EnlUtc));
|
||||
foreach (NamedValue a in cq.EnlAugs)
|
||||
{
|
||||
SafeImGui.Text(Cut(a.Name, 26));
|
||||
ImGui.SameLine(200f);
|
||||
SafeImGui.Text(a.Value);
|
||||
ImGui.SameLine(360f);
|
||||
SafeImGui.TextDisabled(ConquestData.EnlCost(a.Name));
|
||||
}
|
||||
if (cq.EnlAugs.Count == 0) ImGui.TextDisabled("Nothing read yet. Press Refresh.");
|
||||
}
|
||||
|
||||
private void DrawXp()
|
||||
{
|
||||
ConquestData cq = _f.Data;
|
||||
int level = _f.Level;
|
||||
if (!_f.CharacterKnown) ImGui.TextDisabled("Reading your character...");
|
||||
ImGui.SeparatorText($"Level {level}");
|
||||
if (level >= ConquestData.MaxLevel) ImGui.TextUnformatted("Maximum level.");
|
||||
else if (level < 275)
|
||||
{
|
||||
// Retail levels: RynthOracle's Character tab has the progress to the next one.
|
||||
SafeImGui.TextDisabled($"Conquest's own levels start at 276. {Number(Math.Max(0, ConquestData.XpForLevel(276) - _f.TotalXp))} XP to level 276.");
|
||||
}
|
||||
else
|
||||
{
|
||||
long start = level >= 276 ? ConquestData.XpForLevel(level) : 0;
|
||||
long next = ConquestData.XpForLevel(level + 1);
|
||||
long toNext = Math.Max(0, next - _f.TotalXp);
|
||||
long begin = level == 275 ? 191_226_310_247 : start;
|
||||
float frac = next > begin ? (float)Math.Clamp((double)(_f.TotalXp - begin) / (next - begin), 0, 1) : 1f;
|
||||
ImGui.ProgressBar(frac, new Vector2(-1f, 0f), $"{Number(toNext)} to level {level + 1}");
|
||||
long toMax = Math.Max(0, ConquestData.XpForLevel(ConquestData.MaxLevel) - _f.TotalXp);
|
||||
SafeImGui.TextDisabled($"{Number(toMax)} to level {ConquestData.MaxLevel}");
|
||||
}
|
||||
int target = _f.Enlightenment + 1;
|
||||
ImGui.SeparatorText($"Enlightenment {_f.Enlightenment}");
|
||||
SafeImGui.Text($"Next costs {Number(ConquestData.EnlCoinCost(target))} coins and {(ConquestData.EnlLuminanceCost(target) / 1_000_000.0):0.##}M luminance");
|
||||
|
||||
ImGui.SeparatorText("Experience bonuses");
|
||||
SafeImGui.TextDisabled(ReadAt(cq.BonusUtc));
|
||||
foreach (NamedValue b in cq.Bonuses)
|
||||
{
|
||||
SafeImGui.TextDisabled(b.Name);
|
||||
ImGui.SameLine(200f);
|
||||
SafeImGui.Text(b.Value.Length > 0 ? b.Value : "-");
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawFships()
|
||||
{
|
||||
ConquestData cq = _f.Data;
|
||||
SafeImGui.TextDisabled($"{ReadAt(cq.FshipUtc)}, {cq.Fellowships.Count} looking for members");
|
||||
ImGui.SetNextItemWidth(160f);
|
||||
ImGui.Combo("Sort##cq_fsort", ref _fshipSort, FshipSorts, FshipSorts.Length);
|
||||
IEnumerable<ConquestFellowship> list = _fshipSort switch
|
||||
{
|
||||
1 => cq.Fellowships.OrderBy(f => f.Leader, StringComparer.OrdinalIgnoreCase),
|
||||
2 => cq.Fellowships.OrderByDescending(f => f.MemberCount),
|
||||
3 => cq.Fellowships.OrderBy(f => f.Location, StringComparer.OrdinalIgnoreCase),
|
||||
_ => cq.Fellowships.OrderBy(f => f.Name, StringComparer.OrdinalIgnoreCase),
|
||||
};
|
||||
if (ImGui.BeginChild("##cq_fships", new Vector2(0f, 220f), ImGuiChildFlags.Borders))
|
||||
{
|
||||
foreach (ConquestFellowship f in list)
|
||||
{
|
||||
SafeImGui.Text(Cut(f.Name, 26));
|
||||
ImGui.SameLine(200f);
|
||||
SafeImGui.Text(Cut(f.Leader, 20));
|
||||
ImGui.SameLine(350f);
|
||||
SafeImGui.Text(f.Members);
|
||||
if (f.Location.Length > 0) { ImGui.SameLine(410f); SafeImGui.TextDisabled(Cut(f.Location, 26)); }
|
||||
}
|
||||
if (cq.Fellowships.Count == 0) ImGui.TextDisabled("None read yet. Press Refresh.");
|
||||
}
|
||||
ImGui.EndChild();
|
||||
}
|
||||
|
||||
private void DrawCustom()
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
int i = 0;
|
||||
foreach (CustomQuest q in CustomQuestList.All)
|
||||
{
|
||||
bool done = q.IsComplete(_f.Flags, now);
|
||||
SafeImGui.TextColored(done ? Green : Grey, done ? "done" : "--");
|
||||
ImGui.SameLine(50f);
|
||||
string status = q.Status(_f.Flags, now);
|
||||
CustomQuest row = q;
|
||||
if (ImGui.Selectable(Cut(q.Name, 34) + "##cq_cust" + i++, false, ImGuiSelectableFlags.None, new Vector2(280f, 0f)))
|
||||
PrintEntry(row.Name, row.Flag, status, row.Hint, row.Url);
|
||||
Tooltip("Click: the quest's hint in chat.");
|
||||
ImGui.SameLine(340f);
|
||||
SafeImGui.Text(status);
|
||||
}
|
||||
if (CustomQuestList.All.Count == 0) ImGui.TextDisabled("No custom quests listed.");
|
||||
if (_f.Flags.LastReadUtc == DateTime.MinValue) ImGui.TextDisabled("Press Refresh to read your quest flags (/myquests) for their status.");
|
||||
}
|
||||
|
||||
/// <summary>An entry's name, status, hint and link in chat (upstream "thinks" them).</summary>
|
||||
private void PrintEntry(string name, string flag, string status, string details, string url)
|
||||
{
|
||||
Print(flag.Length > 0 ? $"{name} ({flag}){(status.Length > 0 ? " - " + status : "")}" : name);
|
||||
if (details.Length > 0) Print(details);
|
||||
if (url.Length > 0) Print(url);
|
||||
}
|
||||
|
||||
// ── Leaderboards page ───────────────────────────────────────────────
|
||||
|
||||
private void DrawBoards()
|
||||
{
|
||||
if (!Ready()) return;
|
||||
lock (_f.Gate)
|
||||
{
|
||||
ConquestData cq = _f.Data;
|
||||
_board = Math.Clamp(_board, 0, cq.Boards.Count - 1);
|
||||
for (int i = 0; i < cq.Boards.Count; i++)
|
||||
{
|
||||
if (i > 0) ImGui.SameLine();
|
||||
if (Toggle(cq.Boards[i].Label + "##cb_tab" + i, i == _board)) _board = i;
|
||||
}
|
||||
ConquestBoard b = cq.Boards[_board];
|
||||
_refresh.Draw("board" + b.Key, $"Sends {b.Command} and reads the reply.", () => Ask("board" + b.Key, () => b.UpdatedUtc.Ticks, b.Command,
|
||||
now => cq.RequestBoard(b, now)));
|
||||
ImGui.Separator();
|
||||
SafeImGui.TextDisabled(b.UpdatedUtc == DateTime.MinValue ? "not read yet" : $"read at {b.UpdatedUtc.ToLocalTime():HH:mm}");
|
||||
if (b.You != null) SafeImGui.Text($"You: #{b.You.Rank} with {b.You.Value}");
|
||||
if (ImGui.BeginChild("##cb_rows", Vector2.Zero, ImGuiChildFlags.Borders))
|
||||
{
|
||||
ImGui.TextDisabled("Rank"); ImGui.SameLine(60f); ImGui.TextDisabled("Name"); ImGui.SameLine(280f); ImGui.TextDisabled("Value");
|
||||
foreach (BoardRow r in b.Rows)
|
||||
{
|
||||
SafeImGui.Text(r.Rank.ToString());
|
||||
ImGui.SameLine(60f);
|
||||
if (r.IsYou) SafeImGui.TextColored(Gold, Cut(r.Name, 30));
|
||||
else SafeImGui.Text(Cut(r.Name, 30));
|
||||
ImGui.SameLine(280f);
|
||||
SafeImGui.Text(r.Value);
|
||||
if (r.Extra.Length > 0) { ImGui.SameLine(420f); SafeImGui.TextDisabled(Cut(r.Extra, 40)); }
|
||||
}
|
||||
if (b.Rows.Count == 0) ImGui.TextDisabled("Nothing read yet. Press Refresh.");
|
||||
}
|
||||
ImGui.EndChild();
|
||||
}
|
||||
}
|
||||
|
||||
// ── Refresh (RynthOracle's RefreshBar, Conquest's part) ──────────────
|
||||
|
||||
private ServerRefreshResult RefreshConquest()
|
||||
{
|
||||
ConquestData cq = _f.Data;
|
||||
switch (_view)
|
||||
{
|
||||
case 0: return Ask("bank", () => cq.BankUtc.Ticks, "/b", now => cq.RequestBank(now));
|
||||
case 1: return Ask("augs", () => cq.AugsUtc.Ticks, "/augs", now => cq.RequestAugs(now));
|
||||
case 2: return Ask("enl", () => cq.EnlUtc.Ticks, "/enl augs", now => cq.RequestEnl(now));
|
||||
case 3: return Ask("bonus", () => cq.BonusUtc.Ticks, "/bonus", now => cq.RequestBonus(now));
|
||||
case 4: return Ask("fship", () => cq.FshipUtc.Ticks, "/fship list", now => cq.RequestFships(now));
|
||||
default:
|
||||
if (_refresh.CoolingDown("quests", Environment.TickCount64)) return new ServerRefreshResult(ServerRefreshRow.TooSoon);
|
||||
QuestFlagStore flags = _f.Flags;
|
||||
int rev = flags.Revision;
|
||||
int wait = flags.ThrottleSecondsLeft(Environment.TickCount64);
|
||||
if (wait > 0) return new ServerRefreshResult($"The server answers one /myquests a minute; try again in {wait}s (the flags shown are kept).");
|
||||
_runOnTick(() =>
|
||||
{
|
||||
lock (_f.Gate) flags.Request(_send, Environment.TickCount64);
|
||||
});
|
||||
return new ServerRefreshResult("Asked the server for your quest flags (/myquests).", () => flags.Revision != rev);
|
||||
}
|
||||
}
|
||||
|
||||
private string ConquestHelp() => _view switch
|
||||
{
|
||||
0 => "Sends /b and reads your balances.",
|
||||
1 => "Sends /augs and reads your advanced augmentations.",
|
||||
2 => "Sends /enl augs and reads your enlightenment augmentations.",
|
||||
3 => "Sends /bonus for the experience bonuses (your level is read from the game).",
|
||||
4 => "Sends /fship list and reads the fellowships looking for members.",
|
||||
_ => "Sends /myquests: the custom quests' status comes from your quest flags.",
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Sends one of the page's own commands on the next tick (marking it as RynthConquest's, so its
|
||||
/// reply can be hidden) and waits for <paramref name="state"/> to change.
|
||||
/// </summary>
|
||||
private ServerRefreshResult Ask(string key, Func<long> state, string command, Action<long> markSent)
|
||||
{
|
||||
if (_refresh.CoolingDown(key, Environment.TickCount64)) return new ServerRefreshResult(ServerRefreshRow.TooSoon);
|
||||
long before = state();
|
||||
_runOnTick(() =>
|
||||
{
|
||||
lock (_f.Gate) markSent(Environment.TickCount64);
|
||||
if (!_send(command)) _print($"Couldn't send {command} (not in the world).");
|
||||
});
|
||||
return new ServerRefreshResult($"Sent {command}.", () => state() != before);
|
||||
}
|
||||
|
||||
// ── Helpers ─────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>A command from a button, sent on the next tick.</summary>
|
||||
private void Queue(string command) => _runOnTick(() => _send(command));
|
||||
|
||||
/// <summary>A line in chat, written on the next tick.</summary>
|
||||
private void Print(string text) => _runOnTick(() => _print(text));
|
||||
|
||||
private static bool Toggle(string label, bool selected)
|
||||
{
|
||||
if (selected) ImGui.PushStyleColor(ImGuiCol.Button, Selected);
|
||||
bool clicked = ImGui.SmallButton(label);
|
||||
if (selected) ImGui.PopStyleColor();
|
||||
return clicked;
|
||||
}
|
||||
|
||||
private static void Tooltip(string text)
|
||||
{
|
||||
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip(text);
|
||||
}
|
||||
|
||||
private static string Cut(string s, int max) => s.Length <= max ? s : s.Substring(0, Math.Max(0, max - 3)) + "...";
|
||||
|
||||
private static string Number(long n) => TimeText.Number(n);
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
// Ported from Oracle of Dereth by Advis Eveldan (advis61), MIT. See THIRD_PARTY_NOTICES.md.
|
||||
// Moved here from RynthOracle (Data/CustomQuests.cs) on 2026-10-20, with Resources\customquests.csv.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using RynthCore.Plugin.RynthOracle.Data;
|
||||
|
||||
namespace RynthCore.Plugin.RynthConquest;
|
||||
|
||||
/// <summary>
|
||||
/// Conquest's custom quest worklist (customquests.csv: Server, Name, QuestFlag, Url, Hint; every row
|
||||
/// is Conquest's), upstream's Custom tab. The status comes from the character's quest flags
|
||||
/// (/myquests, read with RynthOracle's parser, linked source). A repeatable counts as done only
|
||||
/// while on cooldown (upstream's rule).
|
||||
/// </summary>
|
||||
internal sealed class CustomQuest
|
||||
{
|
||||
public string Server = "", Name = "", Flag = "", Url = "", Hint = "";
|
||||
|
||||
public bool IsComplete(QuestFlagStore flags, DateTime utcNow)
|
||||
{
|
||||
if (!flags.TryGet(Flag, out QuestFlag q)) return false;
|
||||
if (q.RepeatTime == TimeSpan.Zero) return q.Solves > 0;
|
||||
return !q.Ready(utcNow);
|
||||
}
|
||||
|
||||
public string Status(QuestFlagStore flags, DateTime utcNow)
|
||||
{
|
||||
if (!flags.TryGet(Flag, out QuestFlag q)) return "ready";
|
||||
if (q.RepeatTime == TimeSpan.Zero) return q.Solves > 0 ? "completed" : "ready";
|
||||
return q.NextAvailable(utcNow);
|
||||
}
|
||||
}
|
||||
|
||||
internal static class CustomQuestList
|
||||
{
|
||||
/// <summary>The embedded list's logical name (RynthCore.Plugin.RynthConquest.csproj).</summary>
|
||||
public const string ResourceName = "RynthConquest.customquests.csv";
|
||||
|
||||
public static List<CustomQuest> All { get; } = Load();
|
||||
|
||||
private static List<CustomQuest> Load()
|
||||
{
|
||||
var list = new List<CustomQuest>();
|
||||
Stream? stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(ResourceName);
|
||||
if (stream == null) return list;
|
||||
using var r = new StreamReader(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true);
|
||||
r.ReadLine(); // Server,Name,QuestFlag,Url,Hint
|
||||
while (r.ReadLine() is string line)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line)) continue;
|
||||
string[] f = Csv.ParseLine(line);
|
||||
list.Add(new CustomQuest
|
||||
{
|
||||
Server = Csv.Field(f, 0), Name = Csv.Field(f, 1), Flag = Csv.Field(f, 2).ToLowerInvariant(),
|
||||
Url = Csv.Field(f, 3), Hint = Csv.Field(f, 4),
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue