RynthSuite as of 2026-11-29 (internal 46bae49): release 2026.11.28.1
This commit is contained in:
parent
25552fa794
commit
598f49c899
131 changed files with 11825 additions and 329 deletions
313
Plugins/RynthCore.Plugin.RynthOracle/Data/CommunityWikiFeed.cs
Normal file
313
Plugins/RynthCore.Plugin.RynthOracle/Data/CommunityWikiFeed.cs
Normal file
|
|
@ -0,0 +1,313 @@
|
|||
// The AC Community Wiki feed (2026-11-27): RynthOracle's own quest guide, read from asheron.fandom.com's public
|
||||
// MediaWiki API (no login), on every server. OFF by default: nothing is fetched until the player turns it on, and
|
||||
// the About tab, the Guide tab and "/ro wiki on" say what is read and from where before the first read.
|
||||
// Only the reader ships: no wiki text is bundled. The read follows SilentKelpie's (Forgejo rynth PR #12);
|
||||
// re-implemented here. What it reads:
|
||||
// - the quests: every page with the {{Quest Summary}} box, and the pages under Category:Quests (its
|
||||
// sub-categories followed, item / NPC / image lists left out);
|
||||
// - the kill tasks: Category:Kill_Tasks and its sub-categories;
|
||||
// - the society quests: Category:Society_Quests, each page's rank from the sub-category it is in;
|
||||
// - the contracts: Category:Contracts' item pages.
|
||||
// Only pages edited since the last read are fetched (their revision ids), unless the page reader is newer
|
||||
// (QuestWikiText.ReaderVersion). Saved to %APPDATA%\RynthCore\RynthOracle\community-wiki-guide.json. The read runs
|
||||
// on a pool thread and only builds a new guide and writes the file; the pump takes it (TakeResult). With the feed
|
||||
// on, it reads at login when the saved copy is a day old (or none), and on "Read now".
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthOracle.Data;
|
||||
|
||||
internal sealed class CommunityWikiFeed
|
||||
{
|
||||
public const string Host = "asheron.fandom.com";
|
||||
public const string Api = "https://asheron.fandom.com/api.php";
|
||||
public const string WikiBase = "https://asheron.fandom.com/wiki/";
|
||||
public const string QuestTemplate = "Template:Quest_Summary";
|
||||
public const string QuestsCategory = "Category:Quests";
|
||||
public const string KillTasksCategory = "Category:Kill_Tasks";
|
||||
public const string SocietyCategory = "Category:Society_Quests";
|
||||
public const string ContractsCategory = "Category:Contracts";
|
||||
public static readonly TimeSpan RefreshAfter = TimeSpan.FromHours(24);
|
||||
/// <summary>Category:Quests is a tree: at most this many categories are followed.</summary>
|
||||
internal const int MaxCategories = 400;
|
||||
/// <summary>No read lists more pages than this (a wiki that grew wildly, or a loop).</summary>
|
||||
internal const int MaxPages = 5000;
|
||||
private const int RequestGapMs = 250;
|
||||
|
||||
/// <summary>What the feed reads and from where: said before the first read (About, Guide, /ro wiki on).</summary>
|
||||
public const string WhatItReads =
|
||||
"the quest, kill task, society quest and contract pages of the AC Community Wiki, from " + Api
|
||||
+ " (public pages, no login; about a thousand pages the first time, then only the pages edited since; "
|
||||
+ "requests a quarter second apart). Nothing about you or your character is sent.";
|
||||
|
||||
/// <summary>Where the tests keep the guide file (a scratch path); null is the player's %APPDATA% copy.</summary>
|
||||
internal static string? PathOverride;
|
||||
|
||||
public static string DefaultPath => PathOverride ?? Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RynthCore", "RynthOracle", "community-wiki-guide.json");
|
||||
|
||||
private readonly string _path;
|
||||
private CancellationTokenSource? _cts;
|
||||
private Task? _task;
|
||||
private volatile QuestGuide? _ready;
|
||||
private volatile string _status;
|
||||
private bool _loginReadDone;
|
||||
|
||||
/// <summary>The guide in use (pump thread): the saved one until a read replaces it.</summary>
|
||||
public QuestGuide Guide { get; private set; } = new();
|
||||
/// <summary>Goes up when <see cref="Guide"/> is replaced.</summary>
|
||||
public int Revision { get; private set; }
|
||||
public bool Running => _task is { IsCompleted: false };
|
||||
public string Status => _status;
|
||||
public string FilePath => _path;
|
||||
|
||||
public CommunityWikiFeed(string? path = null)
|
||||
{
|
||||
_path = path ?? DefaultPath;
|
||||
try
|
||||
{
|
||||
if (File.Exists(_path)) Guide = QuestGuide.Parse(File.ReadAllText(_path));
|
||||
}
|
||||
catch { Guide = new QuestGuide(); }
|
||||
_status = Guide.IsEmpty ? "not read yet" : Summary(Guide);
|
||||
}
|
||||
|
||||
public static string Summary(QuestGuide g) =>
|
||||
$"{g.Quests.Count} quests, {g.KillTasks.Count} kill tasks, {g.Society.Count} society quests, {g.Contracts.Count} contracts"
|
||||
+ (g.UpdatedUtc == DateTime.MinValue ? "" : $" (read {g.UpdatedUtc.ToLocalTime():yyyy-MM-dd HH:mm})");
|
||||
|
||||
/// <summary>The saved guide wants reading: none yet, a day old, or made by an older page reader.</summary>
|
||||
internal static bool Due(QuestGuide g, DateTime utcNow) =>
|
||||
g.IsEmpty || g.Reader < QuestWikiText.ReaderVersion || utcNow - g.UpdatedUtc >= RefreshAfter;
|
||||
|
||||
/// <summary>Pump thread, at login with the feed on: one read a session, when the saved guide is due. True when it started one.</summary>
|
||||
public bool LoginRead(bool on, bool daily, DateTime utcNow)
|
||||
{
|
||||
if (!on || !daily || _loginReadDone) return false;
|
||||
_loginReadDone = true;
|
||||
return Due(Guide, utcNow) && Start(on);
|
||||
}
|
||||
|
||||
/// <summary>Starts a read: only with the feed on, and not while one runs. Pump thread.</summary>
|
||||
public bool Start(bool on)
|
||||
{
|
||||
if (!on || Running) return false;
|
||||
_cts?.Dispose();
|
||||
_cts = new CancellationTokenSource();
|
||||
CancellationToken token = _cts.Token;
|
||||
QuestGuide old = Guide;
|
||||
_status = "reading...";
|
||||
_task = Task.Run(async () =>
|
||||
{
|
||||
try { _status = await ReadAsync(old, token).ConfigureAwait(false); }
|
||||
catch (OperationCanceledException) { _status = "stopped"; }
|
||||
catch (Exception ex) { _status = "couldn't read the wiki: " + ex.GetType().Name + ": " + ex.Message; }
|
||||
}, token);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Stops a read under way (the feed turned off). Pump thread.</summary>
|
||||
public void Stop()
|
||||
{
|
||||
try { _cts?.Cancel(); } catch { }
|
||||
}
|
||||
|
||||
/// <summary>Pump thread: takes a finished read's guide; true when the guide changed.</summary>
|
||||
public bool TakeResult()
|
||||
{
|
||||
QuestGuide? g = _ready;
|
||||
if (g == null) return false;
|
||||
_ready = null;
|
||||
Guide = g;
|
||||
Revision++;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Uses a guide (the tests).</summary>
|
||||
internal void Use(QuestGuide g)
|
||||
{
|
||||
Guide = g;
|
||||
Revision++;
|
||||
}
|
||||
|
||||
public void Shutdown()
|
||||
{
|
||||
try { _cts?.Cancel(); _task?.Wait(2000); } catch { }
|
||||
}
|
||||
|
||||
// ── The read (pool thread) ──────────────────────────────────────────────
|
||||
|
||||
private static readonly Regex RankRx = new(@"(?:^|:\s*)(\w+)\s+Rank\b", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||
|
||||
/// <summary>The society rank a society sub-category stands for ("Society Quests: Knight Rank" is Knight), or "".</summary>
|
||||
internal static string RankOf(string category)
|
||||
{
|
||||
Match m = RankRx.Match(category);
|
||||
if (m.Success) return char.ToUpperInvariant(m.Groups[1].Value[0]) + m.Groups[1].Value.Substring(1).ToLowerInvariant();
|
||||
return category.Contains("Joining", StringComparison.OrdinalIgnoreCase) ? "Joining" : "";
|
||||
}
|
||||
|
||||
/// <summary>A sub-category not followed: item, NPC, image and map lists, not quests.</summary>
|
||||
internal static bool SkipCategory(string category) =>
|
||||
category.Contains("Quest Items", StringComparison.OrdinalIgnoreCase)
|
||||
|| category.Contains("Items", StringComparison.OrdinalIgnoreCase) && !category.Contains("Quest", StringComparison.OrdinalIgnoreCase)
|
||||
|| category.Contains("NPC", StringComparison.OrdinalIgnoreCase)
|
||||
|| category.Contains("Images", StringComparison.OrdinalIgnoreCase)
|
||||
|| category.Contains("Maps", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private async Task<string> ReadAsync(QuestGuide old, CancellationToken token)
|
||||
{
|
||||
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
|
||||
http.DefaultRequestHeaders.UserAgent.ParseAdd("RynthOracle/" + RynthOraclePlugin.Version + " (RynthCore quest guide)");
|
||||
|
||||
var titles = new SortedSet<string>(StringComparer.Ordinal);
|
||||
var killTasks = new SortedSet<string>(StringComparer.Ordinal);
|
||||
var contracts = new SortedSet<string>(StringComparer.Ordinal);
|
||||
var society = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
void Add(string p) { if (titles.Count < MaxPages) titles.Add(p); }
|
||||
|
||||
_status = "listing the quest pages...";
|
||||
await ListAsync(http, "embeddedin", new[] { ("list", "embeddedin"), ("eititle", QuestTemplate), ("einamespace", "0"), ("eilimit", "max") },
|
||||
Add, _ => { }, token).ConfigureAwait(false);
|
||||
await WalkAsync(http, QuestsCategory, (p, _) => Add(p), token).ConfigureAwait(false);
|
||||
_status = "listing the kill tasks...";
|
||||
await WalkAsync(http, KillTasksCategory, (p, _) => { killTasks.Add(p); Add(p); }, token).ConfigureAwait(false);
|
||||
_status = "listing the society quests...";
|
||||
await WalkAsync(http, SocietyCategory, (p, cat) =>
|
||||
{
|
||||
Add(p);
|
||||
string rank = RankOf(cat);
|
||||
if (rank.Length > 0) society.TryAdd(p, rank);
|
||||
}, token).ConfigureAwait(false);
|
||||
_status = "listing the contracts...";
|
||||
await ListAsync(http, "categorymembers", new[] { ("list", "categorymembers"), ("cmtitle", ContractsCategory), ("cmlimit", "max"), ("cmtype", "page") },
|
||||
p => { contracts.Add(p); Add(p); }, _ => { }, token).ConfigureAwait(false);
|
||||
if (titles.Count == 0) return "the wiki listed no quest pages";
|
||||
|
||||
var list = new List<string>(titles);
|
||||
var revs = new Dictionary<string, long>(StringComparer.Ordinal);
|
||||
int done = 0;
|
||||
foreach (string batch in QuestWikiText.Batches(list))
|
||||
{
|
||||
_status = $"checking pages ({done}/{list.Count})...";
|
||||
string json = await GetAsync(http, QuestWikiText.ApiUrl(Api, ("action", "query"), ("prop", "info"), ("titles", batch)), token).ConfigureAwait(false);
|
||||
foreach (KeyValuePair<string, long> kv in QuestWikiText.LastRevisions(json)) revs[kv.Key] = kv.Value;
|
||||
done += QuestWikiText.TitlesPerRequest;
|
||||
}
|
||||
List<string> changed = PagesToRead(old, revs);
|
||||
|
||||
var fresh = new Dictionary<string, GuideQuest>(StringComparer.Ordinal);
|
||||
var freshContracts = new Dictionary<string, GuideContract>(StringComparer.Ordinal);
|
||||
int read = 0;
|
||||
foreach (string batch in QuestWikiText.Batches(changed))
|
||||
{
|
||||
_status = $"reading pages ({read}/{changed.Count})...";
|
||||
string json = await GetAsync(http, QuestWikiText.ApiUrl(Api, ("action", "query"), ("prop", "revisions"), ("rvprop", "content|ids"),
|
||||
("rvslots", "main"), ("titles", batch)), token).ConfigureAwait(false);
|
||||
foreach (var (title, rev, text) in QuestWikiText.Contents(json))
|
||||
{
|
||||
if (QuestWikiText.IsQuestPage(text)) fresh[title] = QuestWikiText.ParseQuest(title, text, rev, WikiBase);
|
||||
else if (contracts.Contains(title) && QuestWikiText.IsContractPage(title, text))
|
||||
freshContracts[title] = QuestWikiText.ParseContract(title, text, rev, WikiBase);
|
||||
}
|
||||
read += QuestWikiText.TitlesPerRequest;
|
||||
}
|
||||
|
||||
QuestGuide g = Merge(old, revs, fresh, freshContracts, DateTime.UtcNow);
|
||||
g.KillTasks = new List<string>(killTasks);
|
||||
g.Society = society;
|
||||
token.ThrowIfCancellationRequested();
|
||||
string saved = "";
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(_path)!);
|
||||
File.WriteAllText(_path + ".tmp", g.ToJson());
|
||||
File.Move(_path + ".tmp", _path, overwrite: true);
|
||||
}
|
||||
catch (Exception ex) { saved = "; couldn't save it: " + ex.Message; }
|
||||
_ready = g;
|
||||
return $"{Summary(g)}; {fresh.Count + freshContracts.Count} pages read now{saved}";
|
||||
}
|
||||
|
||||
/// <summary>The pages to read: new or edited since the saved guide; every one when it came from an older reader.</summary>
|
||||
internal static List<string> PagesToRead(QuestGuide old, IReadOnlyDictionary<string, long> revs)
|
||||
{
|
||||
var known = new Dictionary<string, long>(StringComparer.Ordinal);
|
||||
foreach (GuideQuest q in old.Quests) known[q.Title] = q.Rev;
|
||||
foreach (GuideContract c in old.Contracts) known[c.Title] = c.Rev;
|
||||
bool whole = old.Reader < QuestWikiText.ReaderVersion;
|
||||
var changed = new List<string>();
|
||||
foreach (KeyValuePair<string, long> kv in revs)
|
||||
if (whole || kv.Value == 0 || !known.TryGetValue(kv.Key, out long rev) || rev != kv.Value) changed.Add(kv.Key);
|
||||
return changed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The new guide: the pages listed now, each the fresh read when there is one, else the saved one. A page no longer
|
||||
/// listed goes; a page that isn't a quest or contract isn't kept (it is checked again next time).
|
||||
/// </summary>
|
||||
internal static QuestGuide Merge(QuestGuide old, IReadOnlyDictionary<string, long> listed,
|
||||
IReadOnlyDictionary<string, GuideQuest> fresh, IReadOnlyDictionary<string, GuideContract> freshContracts, DateTime utcNow)
|
||||
{
|
||||
var oldQuests = new Dictionary<string, GuideQuest>(StringComparer.Ordinal);
|
||||
foreach (GuideQuest q in old.Quests) oldQuests[q.Title] = q;
|
||||
var oldContracts = new Dictionary<string, GuideContract>(StringComparer.Ordinal);
|
||||
foreach (GuideContract c in old.Contracts) oldContracts[c.Title] = c;
|
||||
var g = new QuestGuide { Source = Host, UpdatedUtc = utcNow, Reader = QuestWikiText.ReaderVersion, KillTasks = old.KillTasks, Society = old.Society };
|
||||
foreach (string title in listed.Keys)
|
||||
{
|
||||
if (fresh.TryGetValue(title, out GuideQuest? f)) g.Quests.Add(f);
|
||||
else if (oldQuests.TryGetValue(title, out GuideQuest? o)) g.Quests.Add(o);
|
||||
if (freshContracts.TryGetValue(title, out GuideContract? fc)) g.Contracts.Add(fc);
|
||||
else if (oldContracts.TryGetValue(title, out GuideContract? oc)) g.Contracts.Add(oc);
|
||||
}
|
||||
g.Quests.Sort((a, b) => string.Compare(a.Title, b.Title, StringComparison.OrdinalIgnoreCase));
|
||||
g.Contracts.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase));
|
||||
return g;
|
||||
}
|
||||
|
||||
/// <summary>A category's pages and, breadth first, its sub-categories' (each page with the category it was in).</summary>
|
||||
private static async Task WalkAsync(HttpClient http, string root, Action<string, string> page, CancellationToken token)
|
||||
{
|
||||
var queue = new Queue<string>();
|
||||
var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { root.Replace('_', ' '), root };
|
||||
queue.Enqueue(root);
|
||||
while (queue.Count > 0 && seen.Count <= MaxCategories)
|
||||
{
|
||||
string cat = queue.Dequeue();
|
||||
await ListAsync(http, "categorymembers", new[] { ("list", "categorymembers"), ("cmtitle", cat), ("cmlimit", "max"), ("cmtype", "page|subcat") },
|
||||
p => page(p, cat), sub => { if (!SkipCategory(sub) && seen.Add(sub)) queue.Enqueue(sub); }, token).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task ListAsync(HttpClient http, string listName, (string, string)[] args, Action<string> page, Action<string> sub, CancellationToken token)
|
||||
{
|
||||
var cont = new List<(string, string)>();
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
var all = new List<(string, string)> { ("action", "query") };
|
||||
all.AddRange(args);
|
||||
all.AddRange(cont);
|
||||
string json = await GetAsync(http, QuestWikiText.ApiUrl(Api, all.ToArray()), token).ConfigureAwait(false);
|
||||
var (pages, subs, next) = QuestWikiText.Members(json, listName);
|
||||
foreach (string p in pages) page(p);
|
||||
foreach (string s in subs) sub(s);
|
||||
if (next.Count == 0) return;
|
||||
cont = next;
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<string> GetAsync(HttpClient http, string url, CancellationToken token)
|
||||
{
|
||||
await Task.Delay(RequestGapMs, token).ConfigureAwait(false);
|
||||
using HttpResponseMessage resp = await http.GetAsync(url + "&maxlag=5", token).ConfigureAwait(false);
|
||||
resp.EnsureSuccessStatusCode();
|
||||
return await resp.Content.ReadAsStringAsync(token).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
383
Plugins/RynthCore.Plugin.RynthOracle/Data/GuideProgress.cs
Normal file
383
Plugins/RynthCore.Plugin.RynthOracle/Data/GuideProgress.cs
Normal file
|
|
@ -0,0 +1,383 @@
|
|||
// Where a guide quest stands for this character (2026-11-27), worked out from the quest flags (/myquests) and the
|
||||
// stamps seen in chat this session. The four states, the kill tasks' counts and "first time / done before", and the
|
||||
// kill lines in chat follow SilentKelpie's Guide (Forgejo rynth PR #12); re-implemented here.
|
||||
// - A stamp is held when /myquests has its flag (any spelling: GuideStamp.Key) or it was stamped this session.
|
||||
// - For a repeatable quest, a held stamp counts for this run while its flag's timer runs (or, with no timer on the
|
||||
// flag, while the quest's repeat time since it was stamped hasn't passed); after that it was done "earlier".
|
||||
// - The quest's wait is the longest redo time left on any held stamp.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthOracle.Data;
|
||||
|
||||
/// <summary>A quest's state in the guide's lists.</summary>
|
||||
internal enum GuideState
|
||||
{
|
||||
/// <summary>No stamp held.</summary>
|
||||
NotDone,
|
||||
/// <summary>Some stamps held, some still to get, the held ones' redo timer still running.</summary>
|
||||
PartWaiting,
|
||||
/// <summary>Some stamps held, some still to get, no timer left.</summary>
|
||||
PartReady,
|
||||
/// <summary>Every stamp held.</summary>
|
||||
Done,
|
||||
}
|
||||
|
||||
/// <summary>A stamp of a quest for this run.</summary>
|
||||
internal enum StampState { Missing, Done, Earlier }
|
||||
|
||||
/// <summary>A kill task's progress, in the order the Kill Tasks list shows them.</summary>
|
||||
internal enum KillState { TurnIn, Counting, Ready, NotStarted, Waiting, Completed }
|
||||
|
||||
/// <summary>What the guide knows of this character: its flags, the stamps seen this session and the kill lines.</summary>
|
||||
internal sealed class GuideProgress
|
||||
{
|
||||
private readonly QuestFlagStore _flags;
|
||||
private readonly HashSet<string> _sessionStamps;
|
||||
private readonly KillChat _kills;
|
||||
private Dictionary<string, QuestFlag>? _byKey;
|
||||
private int _byKeyRevision = -1;
|
||||
|
||||
public GuideProgress(QuestFlagStore flags, HashSet<string> sessionStamps, KillChat kills)
|
||||
{
|
||||
_flags = flags;
|
||||
_sessionStamps = sessionStamps;
|
||||
_kills = kills;
|
||||
}
|
||||
|
||||
/// <summary>The flag a stamp is in /myquests, by any spelling of it, or null.</summary>
|
||||
public QuestFlag? FlagOf(string stamp)
|
||||
{
|
||||
if (_flags.TryGet(stamp, out QuestFlag f)) return f;
|
||||
if (_byKeyRevision != _flags.Revision || _byKey == null)
|
||||
{
|
||||
_byKey = new Dictionary<string, QuestFlag>(StringComparer.Ordinal);
|
||||
foreach (KeyValuePair<string, QuestFlag> kv in _flags.Flags) _byKey.TryAdd(GuideStamp.Key(kv.Key), kv.Value);
|
||||
_byKeyRevision = _flags.Revision;
|
||||
}
|
||||
return _byKey.TryGetValue(GuideStamp.Key(stamp), out QuestFlag? byKey) ? byKey : null;
|
||||
}
|
||||
|
||||
public bool StampedThisSession(string stamp) => _sessionStamps.Contains(GuideStamp.Key(stamp));
|
||||
|
||||
/// <summary>A stamp of <paramref name="q"/> for this run (see the file's note).</summary>
|
||||
public StampState StateOf(GuideQuest q, string stamp, DateTime utcNow)
|
||||
{
|
||||
if (StampedThisSession(stamp)) return StampState.Done;
|
||||
if (FlagOf(stamp) is not QuestFlag f) return StampState.Missing;
|
||||
if (q.RepeatSec == 0) return StampState.Done;
|
||||
if (f.RepeatTime > TimeSpan.Zero) return f.NextAvailableTime(utcNow) > TimeSpan.Zero ? StampState.Done : StampState.Earlier;
|
||||
if (q.RepeatSec > 0 && f.CompletedOnUtc != DateTime.MinValue)
|
||||
return f.CompletedOnUtc.AddSeconds(q.RepeatSec) > utcNow ? StampState.Done : StampState.Earlier;
|
||||
return StampState.Done;
|
||||
}
|
||||
|
||||
/// <summary>The longest redo time left on the quest's held stamps; zero when none runs.</summary>
|
||||
public TimeSpan Wait(GuideQuest q, DateTime utcNow)
|
||||
{
|
||||
TimeSpan wait = TimeSpan.Zero;
|
||||
foreach (string st in q.AllStamps())
|
||||
{
|
||||
if (FlagOf(st) is not QuestFlag f) continue;
|
||||
TimeSpan left = TimeSpan.Zero;
|
||||
if (f.RepeatTime > TimeSpan.Zero) left = f.NextAvailableTime(utcNow);
|
||||
else if (q.RepeatSec > 0 && f.CompletedOnUtc != DateTime.MinValue) left = f.CompletedOnUtc.AddSeconds(q.RepeatSec) - utcNow;
|
||||
if (left > wait) wait = left;
|
||||
}
|
||||
return wait;
|
||||
}
|
||||
|
||||
/// <summary>A quest's row: its state, the list's short text, the tooltip's sentence, and whether "Hide done" leaves it out.</summary>
|
||||
public readonly record struct Row(GuideState State, string Status, string Tip, bool HideWhenDone, int Held, int All);
|
||||
|
||||
/// <summary>
|
||||
/// A quest with stamps: the four states from the stamps held and the wait. Without stamps (the AC Community Wiki
|
||||
/// lists none for most quests), <paramref name="flagDone"/> (the quest list's flag of its name) gives Done or Not done,
|
||||
/// and null means its state isn't known.
|
||||
/// </summary>
|
||||
public Row RowOf(GuideQuest q, DateTime utcNow, bool? flagDone = null)
|
||||
{
|
||||
List<string> stamps = q.AllStamps();
|
||||
if (stamps.Count == 0)
|
||||
{
|
||||
if (flagDone is bool fd)
|
||||
return fd ? new Row(GuideState.Done, "Done", "Done: the quest list's flag for it is held.", q.RepeatSec == 0, 1, 1)
|
||||
: new Row(GuideState.NotDone, "Not done", "Not done: the quest list's flag for it isn't held yet.", false, 0, 1);
|
||||
return new Row(GuideState.NotDone, "no stamps", "The wiki lists no stamps for this quest and the quest list has no flag of its name, so its state isn't known.", false, 0, 0);
|
||||
}
|
||||
int held = 0, now = 0;
|
||||
foreach (string st in stamps)
|
||||
{
|
||||
StampState s = StateOf(q, st, utcNow);
|
||||
if (s != StampState.Missing) held++;
|
||||
if (s == StampState.Done) now++;
|
||||
}
|
||||
TimeSpan wait = Wait(q, utcNow);
|
||||
bool repeats = q.RepeatSec != 0 || wait > TimeSpan.Zero;
|
||||
GuideState state = held == 0 ? GuideState.NotDone : held >= stamps.Count ? GuideState.Done
|
||||
: wait > TimeSpan.Zero ? GuideState.PartWaiting : GuideState.PartReady;
|
||||
(string status, string tip) = Text(state, held, stamps.Count, wait, repeats);
|
||||
bool hide = state == GuideState.Done && (!repeats || wait > TimeSpan.Zero || now == stamps.Count);
|
||||
return new Row(state, status, tip, hide, held, stamps.Count);
|
||||
}
|
||||
|
||||
/// <summary>The list's short status and the tooltip's sentence.</summary>
|
||||
public static (string Status, string Tip) Text(GuideState s, int held, int all, TimeSpan wait, bool repeats) => s switch
|
||||
{
|
||||
GuideState.Done when wait > TimeSpan.Zero => ("Done " + Short(wait), $"Done: all {all} stamps held. It can be done again in {Short(wait)}."),
|
||||
GuideState.Done when repeats => ("Done, redo", $"Done: all {all} stamps held, and its timer is up: it can be done again now."),
|
||||
GuideState.Done => ("Done", $"Done: all {all} stamps held."),
|
||||
GuideState.PartWaiting => ($"{held}/{all} wait {Short(wait)}", $"Part done: {held} of {all} stamps held, {all - held} still to get. The redo timer has {Short(wait)} left."),
|
||||
GuideState.PartReady => ($"{held}/{all} ready", $"Part done: {held} of {all} stamps held, {all - held} still to get. No timer is running: go get them."),
|
||||
_ => ("Not done", $"Not done: none of its {all} stamps held yet."),
|
||||
};
|
||||
|
||||
/// <summary>"3d 4h", "5h 12m", "9m".</summary>
|
||||
public static string Short(TimeSpan t)
|
||||
{
|
||||
if (t.TotalDays >= 1) return $"{(int)t.TotalDays}d {t.Hours}h";
|
||||
if (t.TotalHours >= 1) return $"{(int)t.TotalHours}h {t.Minutes:00}m";
|
||||
return $"{Math.Max(1, (int)Math.Ceiling(t.TotalMinutes))}m";
|
||||
}
|
||||
|
||||
/// <summary>"Daily (every 20h 00m)", "Weekly (every 7d 0h)", "One-time", or the wiki's own words.</summary>
|
||||
public static string RepeatText(GuideQuest q)
|
||||
{
|
||||
if (q.RepeatSec == 0) return q.Repeat.Length > 0 ? "One-time (" + q.Repeat + ")" : "One-time";
|
||||
if (q.RepeatSec < 0) return "Repeats: " + q.Repeat;
|
||||
string every = Short(TimeSpan.FromSeconds(q.RepeatSec));
|
||||
return q.IsDaily ? $"Daily (every {every})" : q.IsWeekly ? $"Weekly (every {every})" : $"Repeats every {every}";
|
||||
}
|
||||
|
||||
// ── Kill tasks ──────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>A kill task's progress: kills and goal, where the count came from, its state and whether it was done before.</summary>
|
||||
public sealed record Kill(KillState State, int Kills, int Goal, QuestFlag? Counter, bool FromChat, string Status, bool DoneBefore);
|
||||
|
||||
/// <summary>
|
||||
/// The task's counter flag: a stamp of it /myquests holds with a solve limit over 1, else a kill-task flag that names its creature.
|
||||
/// </summary>
|
||||
public QuestFlag? KillCounter(GuideQuest q)
|
||||
{
|
||||
foreach (string st in q.AllStamps())
|
||||
if (FlagOf(st) is QuestFlag f && f.MaxSolves > 1) return f;
|
||||
string key = q.KillCreatureKey;
|
||||
if (key.Length < 5) return null;
|
||||
foreach (QuestFlag f in _flags.Flags.Values)
|
||||
if (QuestTimer.IsKillTask(f) && GuideStamp.Key(f.Key).Contains(key, StringComparison.Ordinal)) return f;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Kill KillOf(GuideQuest q, DateTime utcNow, bool? flagDone = null)
|
||||
{
|
||||
int goal = q.KillTarget, kills = 0;
|
||||
QuestFlag? counter = KillCounter(q);
|
||||
if (counter != null)
|
||||
{
|
||||
kills = counter.Solves;
|
||||
if (counter.MaxSolves > 1) goal = counter.MaxSolves;
|
||||
}
|
||||
bool fromChat = false;
|
||||
// A kill line newer than the last /myquests read wins: it moves with every kill.
|
||||
if (_kills.For(q.KillCreatureKey) is KillCount k && k.AtUtc > _flags.LastReadUtc && (k.Goal > 0 || k.Kills > 0))
|
||||
{
|
||||
kills = k.Kills;
|
||||
if (k.Goal > 0) goal = k.Goal;
|
||||
fromChat = true;
|
||||
}
|
||||
Row row = RowOf(q, utcNow, flagDone);
|
||||
TimeSpan wait = Wait(q, utcNow);
|
||||
bool counted = counter != null || fromChat;
|
||||
KillState state;
|
||||
string status;
|
||||
if (counted && goal > 0 && kills < goal && !(row.HideWhenDone && wait > TimeSpan.Zero)) { state = KillState.Counting; status = $"{kills} / {goal}"; }
|
||||
else if (counted && goal > 0 && kills >= goal && wait <= TimeSpan.Zero && row.State != GuideState.Done) { state = KillState.TurnIn; status = "Turn in"; }
|
||||
else if (row.State == GuideState.Done && wait > TimeSpan.Zero) { state = KillState.Waiting; status = "Done " + Short(wait); }
|
||||
else if (row.State == GuideState.Done && q.RepeatSec == 0) { state = KillState.Completed; status = "Completed"; }
|
||||
else if (row.State == GuideState.Done || counter != null) { state = KillState.Ready; status = "Ready"; }
|
||||
else { state = KillState.NotStarted; status = goal > 0 ? $"0 / {goal}" : "Not started"; }
|
||||
bool before = state is KillState.Waiting or KillState.Completed || DoneBefore(q, counter, flagDone);
|
||||
return new Kill(state, kills, goal, counter, fromChat, status, before);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Done before: a stamp of the task is held other than those a first run holds too (the live counter, a "start" flag,
|
||||
/// the first step's), a flag of it is on a redo timer, or the quest list's flag of its name is held.
|
||||
/// </summary>
|
||||
private bool DoneBefore(GuideQuest q, QuestFlag? counter, bool? flagDone)
|
||||
{
|
||||
string counterKey = counter != null ? GuideStamp.Key(counter.Key) : "";
|
||||
var first = new HashSet<string>(StringComparer.Ordinal);
|
||||
if (q.Steps.Count > 1)
|
||||
foreach (string st in q.Steps[0].Stamps) first.Add(GuideStamp.Key(st));
|
||||
foreach (string st in q.AllStamps())
|
||||
{
|
||||
string k = GuideStamp.Key(st);
|
||||
if (k == counterKey || first.Contains(k) || k.Contains("start", StringComparison.Ordinal)) continue;
|
||||
if (StampedThisSession(st) || FlagOf(st) != null) return true;
|
||||
}
|
||||
return flagDone == true;
|
||||
}
|
||||
|
||||
/// <summary>The two-word tag a kill task row shows, and its tooltip.</summary>
|
||||
public static (string Tag, string Tip) KillTag(bool doneBefore) => doneBefore
|
||||
? ("Again", "Done before: a stamp or flag of this kill task is held.")
|
||||
: ("1st", "First time: no stamp or flag of this kill task held yet.");
|
||||
|
||||
/// <summary>"KillTaskSampleBeasts_0101" -> "Kill Task Sample Beasts 0101".</summary>
|
||||
public static string FlagLabel(string flag)
|
||||
{
|
||||
var sb = new System.Text.StringBuilder(flag.Length + 8);
|
||||
for (int i = 0; i < flag.Length; i++)
|
||||
{
|
||||
char c = flag[i];
|
||||
if (c == '_') { if (sb.Length > 0 && sb[^1] != ' ') sb.Append(' '); continue; }
|
||||
bool brk = i > 0 && (char.IsUpper(c) && (char.IsLower(flag[i - 1]) || char.IsDigit(flag[i - 1])) || char.IsDigit(c) && char.IsLetter(flag[i - 1]));
|
||||
if (brk && sb.Length > 0 && sb[^1] != ' ') sb.Append(' ');
|
||||
sb.Append(c);
|
||||
}
|
||||
return sb.ToString().Trim();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>One creature's last kill line this session: the count and the goal (0: the line gave none), and when.</summary>
|
||||
internal readonly record struct KillCount(string Creature, int Kills, int Goal, DateTime AtUtc);
|
||||
|
||||
/// <summary>
|
||||
/// Kill task counts from chat: the server's "You have killed 27 Sample Beasts! You must kill 50 to complete your task."
|
||||
/// (and "You have killed some ..."), so the Kill Tasks list moves with every kill though /myquests is read at most once a
|
||||
/// minute. The last line per creature this session. Pump thread.
|
||||
/// </summary>
|
||||
internal sealed class KillChat
|
||||
{
|
||||
private static readonly Regex CountRx = new(
|
||||
@"^You have killed (?<n>\d{1,6}) (?<what>.+?)! You must kill (?<max>\d{1,6}) to complete your task", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex SomeRx = new(@"^You have killed (?:some|enough|all(?: the)?) (?<what>.+?)[.!]*$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
|
||||
|
||||
private readonly Dictionary<string, KillCount> _byKey = new(StringComparer.Ordinal);
|
||||
|
||||
/// <summary>Goes up with every kill line taken.</summary>
|
||||
public int Revision { get; private set; }
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
if (_byKey.Count == 0) return;
|
||||
_byKey.Clear();
|
||||
Revision++;
|
||||
}
|
||||
|
||||
/// <summary>Takes a chat line; true when it was a kill task's kill line.</summary>
|
||||
public bool OnChatLine(string? line, DateTime utcNow)
|
||||
{
|
||||
if (string.IsNullOrEmpty(line) || !line.StartsWith("You have killed ", StringComparison.OrdinalIgnoreCase)) return false;
|
||||
string text = line.Trim();
|
||||
Match m = CountRx.Match(text);
|
||||
if (m.Success)
|
||||
{
|
||||
string what = m.Groups["what"].Value.Trim();
|
||||
_byKey[GuideQuest.KillKey(what)] = new KillCount(what,
|
||||
int.Parse(m.Groups["n"].Value, NumberStyles.None, CultureInfo.InvariantCulture),
|
||||
int.Parse(m.Groups["max"].Value, NumberStyles.None, CultureInfo.InvariantCulture), utcNow);
|
||||
Revision++;
|
||||
return true;
|
||||
}
|
||||
m = SomeRx.Match(text);
|
||||
if (!m.Success) return false;
|
||||
string some = m.Groups["what"].Value.Trim();
|
||||
string key = GuideQuest.KillKey(some);
|
||||
_byKey[key] = _byKey.TryGetValue(key, out KillCount had) ? had with { AtUtc = utcNow } : new KillCount(some, 0, 0, utcNow);
|
||||
Revision++;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>The last line for a creature key: the same key, else one holding the other (keys of 5+ letters only), newest first.</summary>
|
||||
public KillCount? For(string creatureKey)
|
||||
{
|
||||
if (creatureKey.Length == 0) return null;
|
||||
if (_byKey.TryGetValue(creatureKey, out KillCount k)) return k;
|
||||
if (creatureKey.Length < 5) return null;
|
||||
KillCount? best = null;
|
||||
foreach (KeyValuePair<string, KillCount> kv in _byKey)
|
||||
if (kv.Key.Length >= 5 && (kv.Key.Contains(creatureKey, StringComparison.Ordinal) || creatureKey.Contains(kv.Key, StringComparison.Ordinal))
|
||||
&& (best == null || kv.Value.AtUtc > best.Value.AtUtc))
|
||||
best = kv.Value;
|
||||
return best;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The guides in use, merged: the active server plugin's own guide first (its quests replace the AC Community Wiki's of the
|
||||
/// same name), then the AC Community Wiki's. Kill tasks, society ranks and contracts come from either.
|
||||
/// </summary>
|
||||
internal sealed class GuideSet
|
||||
{
|
||||
public readonly List<GuideQuest> Quests = new();
|
||||
public readonly List<GuideContract> Contracts = new();
|
||||
private readonly QuestGuide? _server;
|
||||
private readonly QuestGuide _wiki;
|
||||
private readonly HashSet<GuideQuest> _fromServer = new();
|
||||
|
||||
public GuideSet(QuestGuide? server, QuestGuide wiki)
|
||||
{
|
||||
_server = server is { IsEmpty: false } ? server : null;
|
||||
_wiki = wiki;
|
||||
var names = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
if (_server != null)
|
||||
foreach (GuideQuest q in _server.Quests)
|
||||
if (names.Add(q.Title)) { Quests.Add(q); _fromServer.Add(q); }
|
||||
foreach (GuideQuest q in wiki.Quests)
|
||||
if (names.Add(q.Title)) Quests.Add(q);
|
||||
var contracts = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
if (_server != null)
|
||||
foreach (GuideContract c in _server.Contracts) if (contracts.Add(c.Title)) Contracts.Add(c);
|
||||
foreach (GuideContract c in wiki.Contracts) if (contracts.Add(c.Title)) Contracts.Add(c);
|
||||
}
|
||||
|
||||
public bool IsEmpty => Quests.Count == 0 && Contracts.Count == 0;
|
||||
|
||||
/// <summary>The quest came from the server plugin's guide.</summary>
|
||||
public bool FromServer(GuideQuest q) => _fromServer.Contains(q);
|
||||
|
||||
public bool IsKillTask(GuideQuest q) => (_server?.IsKillTask(q) ?? false) || _wiki.IsKillTask(q);
|
||||
|
||||
public string SocietyRankOf(GuideQuest q)
|
||||
{
|
||||
string r = _server?.SocietyRankOf(q) ?? "";
|
||||
return r.Length > 0 ? r : _wiki.SocietyRankOf(q);
|
||||
}
|
||||
|
||||
public GuideQuest? Find(string title)
|
||||
{
|
||||
foreach (GuideQuest q in Quests)
|
||||
if (string.Equals(q.Title, title, StringComparison.OrdinalIgnoreCase)) return q;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Society ranks in order (the wiki's names); a rank not in the list sorts last.</summary>
|
||||
public static readonly string[] SocietyRanks = { "Joining", "Initiate", "Adept", "Knight", "Lord", "Master" };
|
||||
|
||||
public static int RankOrder(string rank)
|
||||
{
|
||||
for (int i = 0; i < SocietyRanks.Length; i++)
|
||||
if (string.Equals(SocietyRanks[i], rank, StringComparison.OrdinalIgnoreCase)) return i;
|
||||
return SocietyRanks.Length;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The seam for running a guide quest later (RynthNav walking its steps; not in this version). Nothing implements it
|
||||
/// yet: the Guide tab draws run controls only when <see cref="OracleContext.GuideRunner"/> is set.
|
||||
/// </summary>
|
||||
internal interface IGuideQuestRunner
|
||||
{
|
||||
/// <summary>The quest being run, or null.</summary>
|
||||
GuideQuest? Running { get; }
|
||||
/// <summary>The step under way (0-based), -1 none.</summary>
|
||||
int Step { get; }
|
||||
/// <summary>Starts the quest at a step; the answer to show.</summary>
|
||||
string Start(GuideQuest q, int fromStep);
|
||||
void Stop();
|
||||
}
|
||||
|
|
@ -25,6 +25,9 @@ internal sealed class QuestCatalogUpdater
|
|||
|
||||
public bool Running => _task is { IsCompleted: false };
|
||||
|
||||
/// <summary>A day or more since the last check started.</summary>
|
||||
public static bool Due(DateTime nowUtc, DateTime lastCheckUtc) => nowUtc - lastCheckUtc >= Interval;
|
||||
|
||||
/// <summary>Starts a check unless one is running. Pump thread.</summary>
|
||||
public void Start()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ using RynthCore.Plugin.Shared;
|
|||
|
||||
namespace RynthCore.Plugin.RynthOracle;
|
||||
|
||||
internal enum OracleVerb { Window, Void, Timers, Quests, Tab, Trackers, Status, About, Help, Unknown }
|
||||
internal enum OracleVerb { Window, Void, Timers, Quests, Tab, Trackers, Status, About, Help, Wiki, Unknown }
|
||||
|
||||
/// <summary>A parsed "/ro ..." (the words after /ro, lower case): its verb, and the tab or the trackers it shows.</summary>
|
||||
internal readonly record struct OracleCommand(OracleVerb Verb, string Tab = "", QuestKind? Trackers = null, string Word = "")
|
||||
|
|
@ -35,9 +35,17 @@ internal readonly record struct OracleCommand(OracleVerb Verb, string Tab = "",
|
|||
"skills" or "skill" => new(OracleVerb.Tab, OracleView.TabSkills),
|
||||
"attributes" or "attrs" or "attribute" or "vitals" => new(OracleVerb.Tab, OracleView.TabAttributes),
|
||||
"progress" or "progression" => new(OracleVerb.Tab, OracleView.TabProgress),
|
||||
// The Guide tab (wiki quests with their steps), on one of its lists.
|
||||
"guide" => new(OracleVerb.Tab, OracleView.TabGuide),
|
||||
"killtasks" or "kill tasks" or "guide kill tasks" or "guide killtasks" => new(OracleVerb.Tab, OracleView.TabGuide, Word: "killtasks"),
|
||||
"guide society" => new(OracleVerb.Tab, OracleView.TabGuide, Word: "society"),
|
||||
"contracts" or "guide contracts" => new(OracleVerb.Tab, OracleView.TabGuide, Word: "contracts"),
|
||||
"status" => new(OracleVerb.Status),
|
||||
"about" => new(OracleVerb.About, OracleView.TabAbout),
|
||||
"help" or "?" => new(OracleVerb.Help),
|
||||
// The AC Community Wiki feed (off by default): /ro wiki [on|off|read|status].
|
||||
"wiki" or "wiki status" => new(OracleVerb.Wiki, Word: "status"),
|
||||
"wiki on" or "wiki off" or "wiki read" or "wiki refresh" => new(OracleVerb.Wiki, Word: a.Substring(5)),
|
||||
_ => new(OracleVerb.Unknown, Word: a),
|
||||
};
|
||||
}
|
||||
|
|
@ -47,7 +55,7 @@ internal readonly record struct OracleCommand(OracleVerb Verb, string Tab = "",
|
|||
+ "/ro skills|attributes|progress (those tabs), /ro void (Void window), "
|
||||
+ "/ro timers (Quest Timers window), /ro fellowship (Fellowship tab), "
|
||||
+ "/ro trackers (Quests tab, trackers only), /ro legendary (John's 30 key quests), /ro markers, "
|
||||
+ "/ro quests (read quest flags), /ro status, "
|
||||
+ "/ro guide (Guide tab: wiki quests with steps; /ro killtasks, /ro guide society, /ro contracts), /ro quests (read quest flags), /ro wiki on|off|read|status (the AC Community Wiki feed, off until turned on), /ro status, "
|
||||
+ "/ro about (About tab: settings, server, quest list). A server's own pages are its server plugin's (/rserver).";
|
||||
|
||||
public const string NoWindows =
|
||||
|
|
@ -57,7 +65,7 @@ internal readonly record struct OracleCommand(OracleVerb Verb, string Tab = "",
|
|||
|
||||
public static string Shown(string window, bool shown) => CommandReply.Shown(window, shown);
|
||||
|
||||
public static string OnTab(string tab) => $"Oracle window shown on its {tab} tab.";
|
||||
public static string OnTab(string tab, string list = "") => list.Length > 0 ? $"Oracle window shown on its {tab} tab: {list}." : $"Oracle window shown on its {tab} tab.";
|
||||
|
||||
public static string OnTrackers(QuestKind? kind) => kind switch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,6 +35,73 @@ internal sealed class OracleContext
|
|||
/// </summary>
|
||||
public readonly RynthCore.Plugin.Shared.ServerQuestPackClient QuestPacks = new();
|
||||
/// <summary>
|
||||
/// The active server plugin's own quest guide ("RynthServer.QuestGuide", 2026-11-27): its wiki's quests
|
||||
/// with their steps, shown in the Guide tab over the AC Community Wiki's. None without one.
|
||||
/// </summary>
|
||||
public readonly RynthCore.Plugin.Shared.ServerQuestGuideClient ServerGuide = new();
|
||||
/// <summary>The AC Community Wiki feed (off by default; Settings.WikiFeedOn): the Guide tab's quests on every server.</summary>
|
||||
public readonly CommunityWikiFeed Wiki = new();
|
||||
/// <summary>Stamps seen in chat this session ("You've stamped X!"), as GuideStamp keys; SessionStampRevision goes up with each.</summary>
|
||||
public readonly System.Collections.Generic.HashSet<string> SessionStamps = new(StringComparer.Ordinal);
|
||||
public int SessionStampRevision;
|
||||
/// <summary>Kill task lines seen in chat this session.</summary>
|
||||
public readonly KillChat Kills = new();
|
||||
/// <summary>Where guide quests stand for this character (the flags, the session's stamps and kill lines).</summary>
|
||||
public readonly GuideProgress Progress;
|
||||
/// <summary>The seam for running a guide quest later; null in this version (no run controls drawn).</summary>
|
||||
public IGuideQuestRunner? GuideRunner;
|
||||
|
||||
public OracleContext()
|
||||
{
|
||||
Progress = new GuideProgress(Flags, SessionStamps, Kills);
|
||||
}
|
||||
|
||||
/// <summary>A chat line for the guide: a stamp ("You've stamped X!") or a kill task's kill line. True when it was one.</summary>
|
||||
public bool OnGuideChatLine(string line, DateTime utcNow)
|
||||
{
|
||||
if (GuideStamp.FromChat(line) is string stamp && line.TrimStart().StartsWith("You've stamped ", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (SessionStamps.Add(GuideStamp.Key(stamp))) SessionStampRevision++;
|
||||
return true;
|
||||
}
|
||||
return Kills.OnChatLine(line, utcNow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns the AC Community Wiki feed on or off (the About and Guide tabs' buttons, /ro wiki on|off). Turning it on
|
||||
/// says what it reads and from where, then starts the first read. The answer, for the caller to show.
|
||||
/// </summary>
|
||||
public (bool Ok, string Text) SetWikiFeed(bool on)
|
||||
{
|
||||
if (Settings.WikiFeedOn == on)
|
||||
return (true, on ? "The AC Community Wiki feed is already on. " + WikiStatus() : "The AC Community Wiki feed is already off: nothing is fetched.");
|
||||
Settings.WikiFeedOn = on;
|
||||
Settings.Save();
|
||||
if (!on)
|
||||
{
|
||||
Wiki.Stop();
|
||||
return (true, "AC Community Wiki feed off: nothing more is fetched (the copy already saved stays in the Guide tab).");
|
||||
}
|
||||
bool started = Wiki.Start(on: true);
|
||||
return (true, "AC Community Wiki feed on. It reads " + CommunityWikiFeed.WhatItReads
|
||||
+ (started ? " Reading it now." : " A read is already under way."));
|
||||
}
|
||||
|
||||
/// <summary>Reads the wiki now (the Guide tab's Read now, /ro wiki read): only with the feed on.</summary>
|
||||
public (bool Ok, string Text) ReadWikiNow()
|
||||
{
|
||||
if (!Settings.WikiFeedOn)
|
||||
return (false, "The AC Community Wiki feed is off, so nothing is fetched. Turn it on first (About tab, Guide tab, or /ro wiki on); it reads "
|
||||
+ CommunityWikiFeed.WhatItReads);
|
||||
if (Wiki.Running) return (false, "The AC Community Wiki is being read already: " + Wiki.Status);
|
||||
return Wiki.Start(on: true)
|
||||
? (true, "Reading the AC Community Wiki (" + CommunityWikiFeed.Host + "): only the pages edited since the last read.")
|
||||
: (false, "Couldn't start reading the AC Community Wiki.");
|
||||
}
|
||||
|
||||
/// <summary>"on: 812 quests, ... (read ...)" or "off".</summary>
|
||||
public string WikiStatus() => (Settings.WikiFeedOn ? "On: " : "Off (nothing is fetched). Saved copy: ") + Wiki.Status + ".";
|
||||
/// <summary>
|
||||
/// The active server's Void DoT duration rule: its plugin's profile value "voidDotDurationScale"
|
||||
/// (RynthConquest publishes Conquest's), 1 on every other server or without the plugin.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,15 @@ internal sealed class OracleSettings
|
|||
public bool AlertTimers = true;
|
||||
/// <summary>false: only tracked quests are watched; true: every quest the character holds.</summary>
|
||||
public bool AlertAllTimers;
|
||||
/// <summary>
|
||||
/// Read the AC Community Wiki's quest pages for the Guide tab (CommunityWikiFeed). OFF by default: nothing is
|
||||
/// fetched until the player turns it on, and the About and Guide tabs say what it reads and from where first.
|
||||
/// </summary>
|
||||
public bool WikiFeedOn;
|
||||
/// <summary>With the feed on: read it again at login when the saved copy is a day old.</summary>
|
||||
public bool WikiFeedDaily = true;
|
||||
/// <summary>The Guide tab's "Hide done" (quests with nothing to do now).</summary>
|
||||
public bool GuideHideDone;
|
||||
|
||||
/// <summary>Where the tests keep the settings file (a scratch path); null means the rynthoracle.json in RynthCore's %APPDATA% folder.</summary>
|
||||
internal static string? PathOverride;
|
||||
|
|
@ -42,7 +51,7 @@ internal sealed class OracleSettings
|
|||
private static readonly string[] KnownNames =
|
||||
{
|
||||
"readQuestsAtLogin", "hideOwnQuestReplies", "checkQuestListDaily", "lastQuestListCheck", "autoShowVoidWindow",
|
||||
"mainWindowOpen", "questTimersOpen", "alertTimers", "alertAllTimers", "tabName",
|
||||
"mainWindowOpen", "questTimersOpen", "alertTimers", "alertAllTimers", "tabName", "wikiFeedOn", "wikiFeedDaily", "guideHideDone",
|
||||
};
|
||||
// "conquestAutoDeposit" moved to RynthConquest (2026-10-20), which takes it over from this file once;
|
||||
// it is kept here (as any value this version doesn't use) until then.
|
||||
|
|
@ -72,6 +81,9 @@ internal sealed class OracleSettings
|
|||
QuestTimersOpen = Bool(r, "questTimersOpen", QuestTimersOpen);
|
||||
AlertTimers = Bool(r, "alertTimers", AlertTimers);
|
||||
AlertAllTimers = Bool(r, "alertAllTimers", AlertAllTimers);
|
||||
WikiFeedOn = Bool(r, "wikiFeedOn", WikiFeedOn);
|
||||
WikiFeedDaily = Bool(r, "wikiFeedDaily", WikiFeedDaily);
|
||||
GuideHideDone = Bool(r, "guideHideDone", GuideHideDone);
|
||||
if (r.TryGetProperty("tabName", out JsonElement t) && t.ValueKind == JsonValueKind.String) TabName = t.GetString() ?? TabName;
|
||||
if (r.TryGetProperty("lastQuestListCheck", out JsonElement c) && c.ValueKind == JsonValueKind.String
|
||||
&& DateTime.TryParse(c.GetString(), CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out DateTime when))
|
||||
|
|
@ -98,6 +110,9 @@ internal sealed class OracleSettings
|
|||
sb.Append(" \"questTimersOpen\": ").Append(QuestTimersOpen ? "true" : "false").Append(",\n");
|
||||
sb.Append(" \"alertTimers\": ").Append(AlertTimers ? "true" : "false").Append(",\n");
|
||||
sb.Append(" \"alertAllTimers\": ").Append(AlertAllTimers ? "true" : "false").Append(",\n");
|
||||
sb.Append(" \"wikiFeedOn\": ").Append(WikiFeedOn ? "true" : "false").Append(",\n");
|
||||
sb.Append(" \"wikiFeedDaily\": ").Append(WikiFeedDaily ? "true" : "false").Append(",\n");
|
||||
sb.Append(" \"guideHideDone\": ").Append(GuideHideDone ? "true" : "false").Append(",\n");
|
||||
sb.Append(" \"tabName\": \"").Append(JsonEncodedText.Encode(TabName).ToString()).Append('"');
|
||||
foreach ((string name, string raw) in _kept)
|
||||
sb.Append(",\n \"").Append(JsonEncodedText.Encode(name).ToString()).Append("\": ").Append(raw);
|
||||
|
|
|
|||
|
|
@ -64,6 +64,13 @@
|
|||
<!-- "RynthServer.QuestPack": the active server plugin's quest pack, merged into the Quests list. -->
|
||||
<Compile Include="..\Shared\RynthServerQuestPackApi.cs" Link="Shared\RynthServerQuestPackApi.cs" />
|
||||
<Compile Include="..\Shared\ServerQuestPackClient.cs" Link="Shared\ServerQuestPackClient.cs" />
|
||||
<!-- "RynthServer.QuestGuide": the active server plugin's own quest guide (its wiki's quests), shown in
|
||||
the Guide tab; the guide's format is shared with whoever writes one. -->
|
||||
<Compile Include="..\Shared\RynthServerQuestGuideApi.cs" Link="Shared\RynthServerQuestGuideApi.cs" />
|
||||
<Compile Include="..\Shared\QuestGuideData.cs" Link="Shared\QuestGuideData.cs" />
|
||||
<Compile Include="..\Shared\ServerQuestGuideClient.cs" Link="Shared\ServerQuestGuideClient.cs" />
|
||||
<!-- The MediaWiki quest page reader (the AC Community Wiki feed's; a server plugin may link it for its own wiki). -->
|
||||
<Compile Include="..\Shared\QuestWikiText.cs" Link="Shared\QuestWikiText.cs" />
|
||||
<!-- How a chat command answers (2026-10-28): the shared reply queue and colours. -->
|
||||
<Compile Include="..\Shared\CommandReply.cs" Link="Shared\CommandReply.cs" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -52,12 +52,12 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
private long _nextCharacterReadMs;
|
||||
private long _nextCharacterExtrasMs;
|
||||
private bool _voidAutoDecided;
|
||||
private bool _dailyCheckStarted;
|
||||
private int _seenFlagRevision = -1, _seenCatalogRevision = -1, _seenVoidRevision = -1;
|
||||
// RynthCore's server list (ServerStateClient.Revision) last applied to the server identity.
|
||||
private int _seenServerStateRevision = -1;
|
||||
private string? _catalogKey; // what the catalog was loaded for (QuestPackSource.Key; "" = retail only)
|
||||
private int _seenPackRevision = -1; // the active server plugin's quest pack (ServerQuestPackClient.Revision)
|
||||
private int _seenServerGuideRevision = -1; // its quest guide (ServerQuestGuideClient.Revision)
|
||||
private int _titleCount = -2;
|
||||
private uint _titleCurrent;
|
||||
private long _nextAutoReadMs;
|
||||
|
|
@ -144,6 +144,11 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
_c.QuestPacks.Clear();
|
||||
_c.QuestPacks.Poll(Host, Shared.ServerQuestPackClient.OwnerOf(_c.ServerState.State), Environment.TickCount64, force: true);
|
||||
_seenPackRevision = _c.QuestPacks.Revision;
|
||||
_c.ServerGuide.Clear();
|
||||
_c.SessionStamps.Clear();
|
||||
_c.SessionStampRevision++;
|
||||
_c.Kills.Clear();
|
||||
_c.ServerGuide.Poll(Host, Shared.ServerQuestPackClient.OwnerOf(_c.ServerState.State), Environment.TickCount64, force: true);
|
||||
_catalogKey = null;
|
||||
ApplyServer();
|
||||
_titleCount = -2;
|
||||
|
|
@ -157,7 +162,6 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
_nextCharacterExtrasMs = now;
|
||||
ClearCharacterExtras();
|
||||
_voidAutoDecided = false;
|
||||
_dailyCheckStarted = false;
|
||||
if (_main != null) { _main.Visible = _c.Settings.MainWindowOpen; _main.NeedsPass = true; }
|
||||
if (_void != null) { _void.Visible = false; _void.NeedsPass = true; }
|
||||
// The quest book loads once the character's name (and world) are known (TickData).
|
||||
|
|
@ -194,6 +198,7 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
_c.VoidDotScale = 1.0;
|
||||
_c.ServerState.Clear();
|
||||
_c.QuestPacks.Clear();
|
||||
_c.ServerGuide.Clear();
|
||||
_c.TitlesKnown = false;
|
||||
_c.EarnedTitles.Clear();
|
||||
ClearCharacterExtras();
|
||||
|
|
@ -269,6 +274,7 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
_skills?.Shutdown();
|
||||
_ui.SubmitEmpty(Host);
|
||||
_c.Updater.Shutdown();
|
||||
_c.Wiki.Shutdown();
|
||||
_c.Settings.Save();
|
||||
}
|
||||
|
||||
|
|
@ -300,6 +306,15 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
}
|
||||
if (!_c.InWorld) return;
|
||||
|
||||
// The Guide: a stamp ("You've stamped X!") or a kill task's kill line. Kills with the Kill Tasks list on
|
||||
// screen ask for a fresh /myquests (RereadIfStale sends it, at most once a minute).
|
||||
if (_c.OnGuideChatLine(line.Trim(), DateTime.UtcNow))
|
||||
{
|
||||
if (_mainView?.KillTasksShowing == true && _main?.Visible == true) _c.Flags.WantReread();
|
||||
if (_main != null) _main.NeedsPass = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// A server's own command replies (Conquest's /b, Aelrynth's /top, ...) are its server plugin's.
|
||||
// A server's own Void DoT duration rule comes from its plugin's profile (RynthConquest's for
|
||||
// Conquest); 1 everywhere else (VoidScaleFrom).
|
||||
|
|
@ -375,7 +390,13 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
case OracleVerb.Tab:
|
||||
// RynthAi, the server plugins and RynthCore's menus link to these; they show, never toggle off.
|
||||
ShowTab(c.Tab);
|
||||
Shown(OracleCommand.OnTab(c.Tab));
|
||||
if (c.Tab == OracleView.TabGuide && c.Word.Length > 0 && _mainView != null)
|
||||
{
|
||||
GuideList list = c.Word switch { "killtasks" => GuideList.KillTasks, "society" => GuideList.Society, _ => GuideList.Contracts };
|
||||
_mainView.ShowGuide(list);
|
||||
Shown(OracleCommand.OnTab(c.Tab, list == GuideList.KillTasks ? "Kill Tasks" : list.ToString()));
|
||||
}
|
||||
else Shown(OracleCommand.OnTab(c.Tab));
|
||||
break;
|
||||
case OracleVerb.Trackers:
|
||||
// A server's own trackers and tabs are its server plugin's pages (since 2026-10-21).
|
||||
|
|
@ -396,6 +417,20 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
case OracleVerb.Help:
|
||||
_c.Print(OracleCommand.Usage);
|
||||
break;
|
||||
case OracleVerb.Wiki:
|
||||
{
|
||||
// The AC Community Wiki feed: off until turned on; "on" says what it reads and from where first.
|
||||
var (ok, text) = c.Word switch
|
||||
{
|
||||
"on" => _c.SetWikiFeed(true),
|
||||
"off" => _c.SetWikiFeed(false),
|
||||
"read" or "refresh" => _c.ReadWikiNow(),
|
||||
_ => (true, "AC Community Wiki feed: " + _c.WikiStatus() + (_c.Settings.WikiFeedOn ? "" : " /ro wiki on reads " + CommunityWikiFeed.WhatItReads)),
|
||||
};
|
||||
if (ok) _c.Print(text); else _c.PrintFail(text);
|
||||
if (_main != null) _main.NeedsPass = true;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
_c.PrintFail(OracleCommand.Unknown(c.Word));
|
||||
break;
|
||||
|
|
@ -437,7 +472,7 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
if (_timers?.Visible == true) return true;
|
||||
if (_main?.Visible != true || _mainView == null) return false;
|
||||
string tab = _mainView.Tab;
|
||||
return tab == OracleView.TabQuests || tab == OracleView.TabAugs || tab == OracleView.TabSociety;
|
||||
return tab == OracleView.TabQuests || tab == OracleView.TabGuide || tab == OracleView.TabAugs || tab == OracleView.TabSociety;
|
||||
}
|
||||
|
||||
/// <summary>Re-reads /myquests when the flags are known stale, or old and on screen; at most once a minute.</summary>
|
||||
|
|
@ -615,6 +650,13 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
if (_main != null) _main.NeedsPass = true;
|
||||
}
|
||||
|
||||
// A finished read of the AC Community Wiki (the feed is off by default; nothing reads it then).
|
||||
if (_c.Wiki.TakeResult())
|
||||
{
|
||||
Host.Log("[RynthOracle] AC Community Wiki read: " + _c.Wiki.Status);
|
||||
if (_main != null) _main.NeedsPass = true;
|
||||
}
|
||||
|
||||
if (!_c.InWorld) return;
|
||||
|
||||
ReadCharacterExtras(now);
|
||||
|
|
@ -636,6 +678,13 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
ApplyServer();
|
||||
if (_main != null) _main.NeedsPass = true;
|
||||
}
|
||||
// The active server plugin's quest guide (every 2 s; the guide is read only when it changed).
|
||||
_c.ServerGuide.Poll(Host, Shared.ServerQuestPackClient.OwnerOf(_c.ServerState.State), now, force: serverChanged);
|
||||
if (_c.ServerGuide.Revision != _seenServerGuideRevision)
|
||||
{
|
||||
_seenServerGuideRevision = _c.ServerGuide.Revision;
|
||||
if (_main != null) _main.NeedsPass = true;
|
||||
}
|
||||
|
||||
if (_questReadAtMs >= 0 && now >= _questReadAtMs)
|
||||
{
|
||||
|
|
@ -645,10 +694,16 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
}
|
||||
RereadIfStale(now);
|
||||
|
||||
if (!_dailyCheckStarted && _c.Settings.CheckQuestListDaily
|
||||
&& _c.UtcNow - _c.Settings.LastQuestListCheckUtc >= QuestCatalogUpdater.Interval)
|
||||
// With the feed on (and its daily read on): once a session, after the login read's delay, when the copy is a day old.
|
||||
if (_questReadAtMs < 0 && now - _loginMs >= QuestReadDelayMs
|
||||
&& _c.Wiki.LoginRead(_c.Settings.WikiFeedOn, _c.Settings.WikiFeedDaily, _c.UtcNow))
|
||||
Host.Log($"[RynthOracle] Reading the AC Community Wiki ({CommunityWikiFeed.Host}): the saved copy is a day old or missing.");
|
||||
|
||||
// Once a day, however long the session (it ran once per login only, so a client that stayed
|
||||
// logged in never checked again).
|
||||
if (_c.Settings.CheckQuestListDaily && !_c.Updater.Running
|
||||
&& QuestCatalogUpdater.Due(_c.UtcNow, _c.Settings.LastQuestListCheckUtc))
|
||||
{
|
||||
_dailyCheckStarted = true;
|
||||
_c.Settings.LastQuestListCheckUtc = _c.UtcNow;
|
||||
_c.Settings.Save();
|
||||
_c.Updater.Start();
|
||||
|
|
|
|||
|
|
@ -30,6 +30,11 @@ internal sealed partial class OracleView
|
|||
w.Checkbox("Check once a day for a newer quest list", "o.daily", s.CheckQuestListDaily, v => { s.CheckQuestListDaily = v; s.Save(); });
|
||||
w.Tooltip("Downloads Oracle of Dereth's master quest list from GitHub, as the original plugin does.");
|
||||
|
||||
w.SeparatorText("Quest guide (the Guide tab)");
|
||||
DrawWikiFeedControls(w, "o", full: true);
|
||||
if (_c.ServerGuide.Available)
|
||||
w.TextDisabled($"{_c.ServerGuide.Tag}'s own guide (from its server plugin): {_c.ServerGuide.Guide.Quests.Count} quests. {_c.ServerGuide.Info?.Status}");
|
||||
|
||||
w.SeparatorText("Server");
|
||||
ServerIdentity sv = _c.Server;
|
||||
QuestCatalog pc = _c.Catalog;
|
||||
|
|
@ -83,6 +88,8 @@ internal sealed partial class OracleView
|
|||
w.BulletText("/ro about this tab (settings, server, quest list)");
|
||||
w.BulletText("/ro void open or close the Void window");
|
||||
w.BulletText("/ro quests read your quest flags now");
|
||||
w.BulletText("/ro guide the Guide tab: wiki quests with their steps (/ro killtasks, /ro guide society, /ro contracts)");
|
||||
w.BulletText("/ro wiki on|off|read|status the AC Community Wiki feed (off until you turn it on)");
|
||||
w.BulletText("/ro help list the commands in chat");
|
||||
w.TextDisabled("A server quest pack can be replaced without a rebuild: put quests.<server id>.csv in %APPDATA%\\RynthCore\\RynthOracle\\packs.");
|
||||
}
|
||||
|
|
|
|||
640
Plugins/RynthCore.Plugin.RynthOracle/Views/GuideTab.cs
Normal file
640
Plugins/RynthCore.Plugin.RynthOracle/Views/GuideTab.cs
Normal file
|
|
@ -0,0 +1,640 @@
|
|||
// The Guide tab (2026-11-27): wiki quests with their steps. The list on the left with where each quest stands, the
|
||||
// opened quest on the right: its timer, where it starts (Go), its steps with their coordinates (Go) and the stamps each
|
||||
// gives (ticked when held), its loot and rewards. Lists: All / Story / Dailies / Weekly, Kill Tasks, Society, Contracts.
|
||||
// The quests come from the active server plugin's own guide ("RynthServer.QuestGuide") and the AC Community Wiki feed
|
||||
// (off until the player turns it on). The layout follows SilentKelpie's Guide (Forgejo rynth PR #12); re-implemented
|
||||
// here, without "Run this quest" (IGuideQuestRunner is the seam for it).
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RynthCore.Plugin.RynthOracle.Data;
|
||||
using RynthCore.Plugin.RynthOracle.Ui;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthOracle.Views;
|
||||
|
||||
/// <summary>The Guide tab's lists.</summary>
|
||||
internal enum GuideList { All, Story, Dailies, Weekly, KillTasks, Society, Contracts }
|
||||
|
||||
internal sealed partial class OracleView
|
||||
{
|
||||
private static readonly string[] GuideListNames = { "All", "Story", "Dailies", "Weekly", "Kill Tasks", "Society", "Contracts" };
|
||||
private const int GuidePageSize = 40;
|
||||
private const float GuideListWidth = 310f;
|
||||
private const int GuideMaxSteps = 40;
|
||||
private const int ColText = 0; // ImGuiCol_Text
|
||||
|
||||
private GuideList _gList;
|
||||
private string _gSearch = "";
|
||||
private int _gPage;
|
||||
private string _gSel = "";
|
||||
private string _gMsg = "";
|
||||
private GuideSet? _gSet;
|
||||
private string _gSetKey = "";
|
||||
private readonly List<GuideRow> _gRows = new();
|
||||
private string _gRowsKey = "";
|
||||
private Dictionary<string, Quest> _catalogByName = new(StringComparer.OrdinalIgnoreCase);
|
||||
private int _catalogByNameRev = -1;
|
||||
|
||||
private sealed class GuideRow
|
||||
{
|
||||
public string Key = "";
|
||||
public string Label = "";
|
||||
public string Status = "";
|
||||
public string Tip = "";
|
||||
public uint Color = UiColors.Grey;
|
||||
/// <summary>"Hide done" leaves it out (done, with nothing to do now).</summary>
|
||||
public bool Hide;
|
||||
public string Tag = "";
|
||||
public string TagTip = "";
|
||||
public uint TagColor = UiColors.Grey;
|
||||
public int Order;
|
||||
public GuideQuest? Q;
|
||||
public QuestFlag? Flag;
|
||||
public GuideContract? C;
|
||||
}
|
||||
|
||||
/// <summary>Shows the Guide tab on a list (and a row). Internal for /ro and the tests.</summary>
|
||||
internal void ShowGuide(GuideList list, string? select = null)
|
||||
{
|
||||
_gList = list;
|
||||
_gPage = 0;
|
||||
if (select != null) _gSel = select;
|
||||
Tab = TabGuide;
|
||||
}
|
||||
|
||||
/// <summary>The Kill Tasks list is on screen (kill lines then ask for a fresh /myquests).</summary>
|
||||
public bool KillTasksShowing => Tab == TabGuide && _gList == GuideList.KillTasks;
|
||||
|
||||
/// <summary>The guides in use, merged (rebuilt when either changes). Internal for the tests.</summary>
|
||||
internal GuideSet GuideSources()
|
||||
{
|
||||
string key = $"{_c.ServerGuide.Revision}|{_c.Wiki.Revision}";
|
||||
if (_gSet == null || key != _gSetKey)
|
||||
{
|
||||
_gSetKey = key;
|
||||
_gSet = new GuideSet(_c.ServerGuide.Guide, _c.Wiki.Guide);
|
||||
}
|
||||
return _gSet;
|
||||
}
|
||||
|
||||
/// <summary>The quest list's flag for a quest of this name: done or not; null when the list has no quest of that name.</summary>
|
||||
private bool? CatalogDone(string title)
|
||||
{
|
||||
if (_catalogByNameRev != _c.Catalog.Revision)
|
||||
{
|
||||
var map = new Dictionary<string, Quest>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (Quest q in _c.Catalog.Quests)
|
||||
if (!q.IsNew && q.Name.Length > 0) map.TryAdd(q.Name, q);
|
||||
_catalogByName = map;
|
||||
_catalogByNameRev = _c.Catalog.Revision;
|
||||
}
|
||||
return _catalogByName.TryGetValue(title, out Quest? found) ? found.IsComplete(_c.Flags) : null;
|
||||
}
|
||||
|
||||
private static uint StateColor(GuideState s) => s switch
|
||||
{
|
||||
GuideState.Done => UiColors.Green,
|
||||
GuideState.PartWaiting => UiColors.Yellow,
|
||||
GuideState.PartReady => UiColors.Gold,
|
||||
_ => UiColors.Grey,
|
||||
};
|
||||
|
||||
private static uint KillColor(KillState s) => s switch
|
||||
{
|
||||
KillState.TurnIn => UiColors.Gold,
|
||||
KillState.Counting or KillState.Waiting => UiColors.Yellow,
|
||||
KillState.Ready or KillState.Completed => UiColors.Green,
|
||||
_ => UiColors.Grey,
|
||||
};
|
||||
|
||||
// ── The page ────────────────────────────────────────────────────────────
|
||||
|
||||
private void DrawGuide(UiWindow w)
|
||||
{
|
||||
GuideSet set = GuideSources();
|
||||
DrawGuideSources(w, set);
|
||||
if (set.IsEmpty)
|
||||
{
|
||||
w.Spacing();
|
||||
w.TextWrapped("No quest guide yet. The AC Community Wiki feed gives one on every server once you turn it on;"
|
||||
+ " a server plugin can also hand RynthOracle its own server's guide.");
|
||||
DrawWikiFeedControls(w, "g", full: false);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < GuideListNames.Length; i++)
|
||||
{
|
||||
var list = (GuideList)i;
|
||||
if (i > 0) w.SameLine();
|
||||
w.ToggleButton(GuideListNames[i], "g.list." + i, _gList == list, () => { _gList = list; _gPage = 0; }, small: true);
|
||||
}
|
||||
w.Checkbox("Hide done", "g.hide", _c.Settings.GuideHideDone, v => { _c.Settings.GuideHideDone = v; _c.Settings.Save(); _gPage = 0; });
|
||||
w.Tooltip("Leave out the quests that are done with nothing to do now: one-time quests done, and quests whose timer is running.");
|
||||
w.SameLine();
|
||||
w.InputText("Search", "g.search", _gSearch, 64, s => { _gSearch = s; _gPage = 0; });
|
||||
w.Tooltip("Words to find: a quest's name, who and where it starts, its items or stamps.");
|
||||
if (_gMsg.Length > 0) w.TextDisabled(_gMsg);
|
||||
if (_gList == GuideList.KillTasks) DrawKillSummary(w, set);
|
||||
|
||||
List<GuideRow> rows = GuideRows(set);
|
||||
w.BeginChild("g.rows", GuideListWidth, 0f, border: true);
|
||||
if (rows.Count > GuidePageSize) _gPage = Pager(w, "g.page", _gPage, rows.Count, GuidePageSize, p => _gPage = p);
|
||||
else _gPage = 0;
|
||||
bool tags = rows.Exists(r => r.Tag.Length > 0);
|
||||
float statusX = GuideListWidth - 112f, tagX = statusX - 40f;
|
||||
float labelEnd = tags ? tagX : statusX;
|
||||
int chars = Math.Max(16, (int)((labelEnd - 14f) / 6.4f));
|
||||
int start = _gPage * GuidePageSize;
|
||||
for (int i = start; i < rows.Count && i < start + GuidePageSize; i++)
|
||||
{
|
||||
GuideRow r = rows[i];
|
||||
string key = r.Key;
|
||||
w.Selectable(Cut(r.Label, chars), "g.r." + key, key == _gSel, () => _gSel = key, labelEnd - 12f);
|
||||
if (r.Label.Length > chars) w.Tooltip(r.Label);
|
||||
if (r.Tag.Length > 0)
|
||||
{
|
||||
w.SameLine(tagX);
|
||||
w.TextColored(r.TagColor, r.Tag);
|
||||
w.Tooltip(r.TagTip);
|
||||
}
|
||||
if (r.Status.Length > 0)
|
||||
{
|
||||
w.SameLine(statusX);
|
||||
w.TextColored(r.Color, r.Status);
|
||||
if (r.Tip.Length > 0) w.Tooltip(r.Tip);
|
||||
}
|
||||
}
|
||||
if (rows.Count == 0) w.TextDisabled("Nothing here matches.");
|
||||
w.EndChild();
|
||||
|
||||
w.SameLine();
|
||||
w.BeginChild("g.detail", 0f, 0f, border: true);
|
||||
GuideRow? sel = rows.Find(r => r.Key == _gSel) ?? FindGuideRow(set, _gSel);
|
||||
if (sel == null) w.TextDisabled("Pick a quest on the left.");
|
||||
else if (sel.Q != null) DrawGuideQuest(w, set, sel.Q);
|
||||
else if (sel.Flag != null) DrawKillFlag(w, sel.Flag);
|
||||
else if (sel.C != null) DrawGuideContract(w, set, sel.C);
|
||||
w.EndChild();
|
||||
}
|
||||
|
||||
/// <summary>One line per source: the server plugin's guide (with its own commands) and the AC Community Wiki feed.</summary>
|
||||
private void DrawGuideSources(UiWindow w, GuideSet set)
|
||||
{
|
||||
ServerQuestGuideClient sg = _c.ServerGuide;
|
||||
if (sg.Available)
|
||||
{
|
||||
ServerQuestGuideInfo info = sg.Info!;
|
||||
w.TextDisabled(Cut($"{sg.Tag} Wiki ({info.Plugin}): {(info.Running ? "reading... " : "")}{sg.Guide.Quests.Count} quests. {info.Status}", 90));
|
||||
w.Tooltip($"{sg.Tag}'s own quests, from its server plugin; they come first, over the AC Community Wiki's of the same name.");
|
||||
if (info.Takes(RynthServerQuestGuide.CommandRefresh))
|
||||
{
|
||||
w.SameLine();
|
||||
w.SmallButton("Read it again", "g.sg.refresh", () => _gMsg = sg.Command(RynthServerQuestGuide.CommandRefresh)
|
||||
? $"Asked {info.Plugin} to read {sg.Tag}'s guide again." : $"{info.Plugin} didn't take the request.");
|
||||
}
|
||||
if (info.Takes(RynthServerQuestGuide.CommandSettings))
|
||||
{
|
||||
w.SameLine();
|
||||
w.SmallButton("Its settings", "g.sg.settings", () => _gMsg = sg.Command(RynthServerQuestGuide.CommandSettings)
|
||||
? $"{info.Plugin}'s guide settings are open." : $"{info.Plugin} didn't take the request.");
|
||||
}
|
||||
}
|
||||
CommunityWikiFeed feed = _c.Wiki;
|
||||
string line = _c.Settings.WikiFeedOn
|
||||
? "AC Community Wiki: " + (feed.Running ? "reading... " : "") + feed.Status
|
||||
: feed.Guide.IsEmpty ? "AC Community Wiki feed: off (nothing is fetched)." : "AC Community Wiki feed: off; the copy saved earlier: " + feed.Status;
|
||||
w.TextDisabled(Cut(line, 100));
|
||||
if (!set.IsEmpty && w.CollapsingHeader("AC Community Wiki feed", "g.feed"))
|
||||
DrawWikiFeedControls(w, "g", full: false);
|
||||
}
|
||||
|
||||
// ── Rows ────────────────────────────────────────────────────────────────
|
||||
|
||||
private static bool Matches(string hay, string[] terms)
|
||||
{
|
||||
foreach (string t in terms)
|
||||
if (hay.IndexOf(t, StringComparison.OrdinalIgnoreCase) < 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string Hay(GuideQuest q) =>
|
||||
$"{q.Title} {q.StartsWith} {q.StartsAt} {q.Type} {string.Join(" ", q.Loot)} {string.Join(" ", q.AllStamps())}";
|
||||
|
||||
private GuideRow GuideQuestRow(GuideQuest q)
|
||||
{
|
||||
GuideProgress.Row p = _c.Progress.RowOf(q, _c.UtcNow, CatalogDone(q.Title));
|
||||
return new GuideRow { Key = "w:" + q.Title, Label = q.Title, Q = q, Status = p.Status, Tip = p.Tip, Color = StateColor(p.State), Hide = p.HideWhenDone };
|
||||
}
|
||||
|
||||
private GuideRow? FindGuideRow(GuideSet set, string key)
|
||||
{
|
||||
if (key.StartsWith("w:", StringComparison.Ordinal) && set.Find(key.Substring(2)) is GuideQuest q) return GuideQuestRow(q);
|
||||
if (key.StartsWith("c:", StringComparison.Ordinal) && set.Contracts.Find(x => x.Title == key.Substring(2)) is GuideContract c) return ContractRow(set, c);
|
||||
if (key.StartsWith("k:", StringComparison.Ordinal) && _c.Flags.TryGet(key.Substring(2), out QuestFlag f))
|
||||
return new GuideRow { Key = key, Label = KillFlagLabel(f), Flag = f };
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>The rows of the list shown (rebuilt when anything they show changes, or each minute for the timers). Internal for the tests.</summary>
|
||||
private List<GuideRow> GuideRows(GuideSet set)
|
||||
{
|
||||
string key = $"{_gList}|{_gSearch}|{_c.Settings.GuideHideDone}|{_gSetKey}|{_c.Flags.Revision}|{_c.SessionStampRevision}|{_c.Kills.Revision}|{_c.Catalog.Revision}|{_c.UtcNow:yyyyMMddHHmm}";
|
||||
if (key == _gRowsKey) return _gRows;
|
||||
_gRowsKey = key;
|
||||
_gRows.Clear();
|
||||
string[] terms = _gSearch.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
bool hide = _c.Settings.GuideHideDone;
|
||||
switch (_gList)
|
||||
{
|
||||
case GuideList.KillTasks: KillRows(set, terms, hide); break;
|
||||
case GuideList.Society: SocietyRows(set, terms, hide); break;
|
||||
case GuideList.Contracts: ContractRows(set, terms, hide); break;
|
||||
default:
|
||||
foreach (GuideQuest q in set.Quests)
|
||||
{
|
||||
bool inList = _gList switch
|
||||
{
|
||||
GuideList.Story => q.IsOneTime,
|
||||
GuideList.Dailies => q.IsDaily,
|
||||
GuideList.Weekly => q.IsWeekly,
|
||||
_ => true,
|
||||
};
|
||||
if (!inList || !Matches(Hay(q), terms)) continue;
|
||||
GuideRow r = GuideQuestRow(q);
|
||||
if (hide && r.Hide) continue;
|
||||
_gRows.Add(r);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return _gRows;
|
||||
}
|
||||
|
||||
private void KillRows(GuideSet set, string[] terms, bool hide)
|
||||
{
|
||||
var named = new HashSet<string>(StringComparer.Ordinal);
|
||||
foreach (GuideQuest q in set.Quests)
|
||||
{
|
||||
if (!set.IsKillTask(q)) continue;
|
||||
GuideProgress.Kill p = _c.Progress.KillOf(q, _c.UtcNow, CatalogDone(q.Title));
|
||||
if (p.Counter != null) named.Add(GuideStamp.Key(p.Counter.Key));
|
||||
foreach (string st in q.AllStamps()) named.Add(GuideStamp.Key(st));
|
||||
if (!Matches(Hay(q), terms)) continue;
|
||||
bool done = p.State is KillState.Waiting or KillState.Completed;
|
||||
if (hide && done) continue;
|
||||
var r = new GuideRow { Key = "w:" + q.Title, Label = q.Title, Q = q, Status = p.Status, Color = KillColor(p.State), Order = (int)p.State };
|
||||
SetKillTag(r, p.DoneBefore);
|
||||
_gRows.Add(r);
|
||||
}
|
||||
// Counters the server keeps that no guide's kill task names: listed too, so nothing counted is left out.
|
||||
foreach (QuestFlag f in _c.Flags.Flags.Values)
|
||||
{
|
||||
if (!QuestTimer.IsKillTask(f) || named.Contains(GuideStamp.Key(f.Key)) || !Matches(f.Key + " " + f.Description, terms)) continue;
|
||||
QuestTimerState st = QuestTimer.State(f, true, _c.UtcNow, out string text);
|
||||
KillState ks = st switch
|
||||
{
|
||||
QuestTimerState.InProgress => KillState.Counting,
|
||||
QuestTimerState.Waiting => KillState.Waiting,
|
||||
QuestTimerState.Done => KillState.Completed,
|
||||
_ => KillState.Ready,
|
||||
};
|
||||
if (hide && ks is KillState.Waiting or KillState.Completed) continue;
|
||||
var r = new GuideRow
|
||||
{
|
||||
Key = "k:" + f.Key, Label = KillFlagLabel(f), Flag = f, Color = KillColor(ks), Order = (int)ks,
|
||||
Status = ks switch { KillState.Counting => $"{f.Solves} / {f.MaxSolves}", KillState.Waiting => "Done " + text, KillState.Completed => "Completed", _ => "Ready" },
|
||||
};
|
||||
SetKillTag(r, ks != KillState.Counting);
|
||||
_gRows.Add(r);
|
||||
}
|
||||
_gRows.Sort((a, b) => a.Order != b.Order ? a.Order.CompareTo(b.Order) : string.Compare(a.Label, b.Label, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
/// <summary>A counter flag's row: the server's description of it, else the flag split into words.</summary>
|
||||
private static string KillFlagLabel(QuestFlag f) => f.Description.Length > 1 ? f.Description : GuideProgress.FlagLabel(f.Key);
|
||||
|
||||
private static void SetKillTag(GuideRow r, bool doneBefore)
|
||||
{
|
||||
(r.Tag, r.TagTip) = GuideProgress.KillTag(doneBefore);
|
||||
r.TagColor = doneBefore ? UiColors.Green : UiColors.Gold;
|
||||
}
|
||||
|
||||
private void SocietyRows(GuideSet set, string[] terms, bool hide)
|
||||
{
|
||||
foreach (GuideQuest q in set.Quests)
|
||||
{
|
||||
string rank = set.SocietyRankOf(q);
|
||||
if (rank.Length == 0 || !Matches(rank + " " + Hay(q), terms)) continue;
|
||||
GuideRow r = GuideQuestRow(q);
|
||||
if (hide && r.Hide) continue;
|
||||
r.Label = rank + ": " + q.Title;
|
||||
r.Order = GuideSet.RankOrder(rank);
|
||||
_gRows.Add(r);
|
||||
}
|
||||
_gRows.Sort((a, b) => a.Order != b.Order ? a.Order.CompareTo(b.Order) : string.Compare(a.Label, b.Label, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
private GuideRow ContractRow(GuideSet set, GuideContract c)
|
||||
{
|
||||
var r = new GuideRow { Key = "c:" + c.Title, Label = c.Name, C = c };
|
||||
// The state of the quest it is for (the first one a guide has).
|
||||
foreach (string t in c.Quests)
|
||||
if (set.Find(t) is GuideQuest q)
|
||||
{
|
||||
GuideRow qr = GuideQuestRow(q);
|
||||
r.Status = qr.Status;
|
||||
r.Tip = q.Title + ": " + qr.Tip;
|
||||
r.Color = qr.Color;
|
||||
r.Hide = qr.Hide;
|
||||
return r;
|
||||
}
|
||||
if (c.Level.Length > 0) r.Status = "L" + c.Level;
|
||||
return r;
|
||||
}
|
||||
|
||||
private void ContractRows(GuideSet set, string[] terms, bool hide)
|
||||
{
|
||||
foreach (GuideContract c in set.Contracts)
|
||||
{
|
||||
if (!Matches($"{c.Name} {c.Description} {c.Where} {string.Join(" ", c.Quests)}", terms)) continue;
|
||||
GuideRow r = ContractRow(set, c);
|
||||
if (hide && r.Hide) continue;
|
||||
_gRows.Add(r);
|
||||
}
|
||||
_gRows.Sort((a, b) => string.Compare(a.Label, b.Label, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
// ── The opened quest ────────────────────────────────────────────────────
|
||||
|
||||
private void DrawGuideQuest(UiWindow w, GuideSet set, GuideQuest q)
|
||||
{
|
||||
GuideProgress p = _c.Progress;
|
||||
DateTime now = _c.UtcNow;
|
||||
w.TextColored(UiColors.Gold, q.Title);
|
||||
TimeSpan wait = p.Wait(q, now);
|
||||
w.TextDisabled(GuideProgress.RepeatText(q) + (wait > TimeSpan.Zero ? " - again in " + GuideProgress.Short(wait) : ""));
|
||||
GuideProgress.Row row = p.RowOf(q, now, CatalogDone(q.Title));
|
||||
w.TextColored(StateColor(row.State), row.Tip);
|
||||
var facts = new List<string>();
|
||||
if (q.Level.Length > 0) facts.Add("Level " + q.Level);
|
||||
if (q.RecommendedLevel.Length > 0) facts.Add("rec. " + q.RecommendedLevel);
|
||||
if (q.Type.Length > 0) facts.Add(q.Type);
|
||||
if (q.TimeToComplete.Length > 0) facts.Add(q.TimeToComplete);
|
||||
if (set.SocietyRankOf(q) is { Length: > 0 } rank) facts.Add("Society: " + rank);
|
||||
if (facts.Count > 0) w.TextDisabled(string.Join(" | ", facts));
|
||||
if (set.IsKillTask(q)) DrawKillLine(w, q);
|
||||
|
||||
// Running a quest along its steps comes later; the seam draws nothing until a runner is set.
|
||||
if (_c.GuideRunner is IGuideQuestRunner runner) DrawRunControls(w, runner, q);
|
||||
if (q.Url.Length > 0)
|
||||
{
|
||||
w.SmallButton("Wiki page", "g.url", () => _c.Print(q.Url));
|
||||
w.Tooltip("Prints the page's address in chat: " + q.Url);
|
||||
w.SameLine();
|
||||
}
|
||||
w.TextDisabled(set.FromServer(q) ? $"From {_c.ServerGuide.Tag}'s guide" : "From the AC Community Wiki");
|
||||
|
||||
if (q.StartsWith.Length > 0 || q.StartsAt.Length > 0)
|
||||
{
|
||||
w.Text("Starts" + (q.StartsWith.Length > 0 ? " with " + q.StartsWith : "") + (q.StartsAt.Length > 0 ? " at " + q.StartsAt : ""));
|
||||
string place = q.StartsAt.Length > 0 ? q.StartsAt : q.StartsWith;
|
||||
w.SameLine();
|
||||
w.SmallButton("Go", "g.start.go", () => _gMsg = SendRynthNav("go", new[] { place }));
|
||||
w.Tooltip("RynthNav goes to " + place + " (a place on its Atlas), walking and taking portals.");
|
||||
}
|
||||
if (q.Overview.Length > 0) w.TextWrapped(q.Overview);
|
||||
|
||||
DrawStampSummary(w, q);
|
||||
(bool[] done, bool[] passed, int next) = StepStates(q);
|
||||
w.SeparatorText(q.Steps.Count > 0 ? "Steps" : "Steps (the page has no walkthrough)");
|
||||
int current = _c.GuideRunner?.Running == q ? _c.GuideRunner.Step : -1;
|
||||
for (int i = 0; i < q.Steps.Count && i < GuideMaxSteps; i++) DrawGuideStep(w, q, i, done[i], passed[i], i == next, i == current);
|
||||
if (q.Steps.Count > GuideMaxSteps) w.TextDisabled($"... {q.Steps.Count - GuideMaxSteps} more steps on the wiki page.");
|
||||
if (q.ExtraStamps.Count > 0)
|
||||
{
|
||||
w.TextDisabled("Also stamps (the page doesn't say which step):");
|
||||
foreach (string st in q.ExtraStamps) StampLine(w, q, st);
|
||||
}
|
||||
if (q.Loot.Count > 0)
|
||||
{
|
||||
w.SeparatorText("Loot");
|
||||
w.TextWrapped(string.Join(", ", q.Loot));
|
||||
}
|
||||
if (q.Rewards.Count > 0 && w.CollapsingHeader("Rewards", "g.rewards"))
|
||||
foreach (string r in q.Rewards)
|
||||
if (r.EndsWith(':')) w.Text(r); else w.BulletText(r);
|
||||
}
|
||||
|
||||
private void DrawRunControls(UiWindow w, IGuideQuestRunner runner, GuideQuest q)
|
||||
{
|
||||
if (runner.Running == q)
|
||||
{
|
||||
w.Button("Stop", "g.run.stop", runner.Stop);
|
||||
w.SameLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
w.Button("Run this quest", "g.run", () => _gMsg = runner.Start(q, 0));
|
||||
w.SameLine();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Each step done (its stamps count now), passed (no stamp of its own, and a later step is done), and the next to do (-1: none).</summary>
|
||||
private (bool[] Done, bool[] Passed, int Next) StepStates(GuideQuest q)
|
||||
{
|
||||
int n = q.Steps.Count, last = -1;
|
||||
var done = new bool[n];
|
||||
var passed = new bool[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
GuideStep s = q.Steps[i];
|
||||
done[i] = s.Stamps.Count > 0 && s.Stamps.TrueForAll(st => _c.Progress.StateOf(q, st, _c.UtcNow) == StampState.Done);
|
||||
if (done[i]) last = i;
|
||||
}
|
||||
for (int i = 0; i < last; i++)
|
||||
if (!done[i] && q.Steps[i].Stamps.Count == 0) passed[i] = true;
|
||||
int next = -1;
|
||||
for (int i = 0; i < n; i++)
|
||||
if (!done[i] && !passed[i]) { next = i; break; }
|
||||
return (done, passed, next);
|
||||
}
|
||||
|
||||
/// <summary>How many stamps count now, and each one still to get with its step.</summary>
|
||||
private void DrawStampSummary(UiWindow w, GuideQuest q)
|
||||
{
|
||||
List<string> all = q.AllStamps();
|
||||
if (all.Count == 0)
|
||||
{
|
||||
w.TextDisabled("The page lists no stamps for this quest, so its steps can't be ticked: they are a guide only.");
|
||||
return;
|
||||
}
|
||||
var stepOf = new Dictionary<string, int>(StringComparer.Ordinal);
|
||||
for (int i = 0; i < q.Steps.Count; i++)
|
||||
foreach (string st in q.Steps[i].Stamps) stepOf.TryAdd(GuideStamp.Key(st), i + 1);
|
||||
int now = 0;
|
||||
var missing = new List<(string Text, bool Earlier)>();
|
||||
foreach (string st in all)
|
||||
{
|
||||
StampState s = _c.Progress.StateOf(q, st, _c.UtcNow);
|
||||
if (s == StampState.Done) { now++; continue; }
|
||||
string where = stepOf.TryGetValue(GuideStamp.Key(st), out int n) ? "step " + n : "no step";
|
||||
missing.Add(($"{st} ({where}{(s == StampState.Earlier ? ", done on an earlier run: ready again" : "")})", s == StampState.Earlier));
|
||||
}
|
||||
string run = q.RepeatSec != 0 ? " this run" : "";
|
||||
if (missing.Count == 0) { w.TextColored(UiColors.Green, $"All {all.Count} stamps done{run}."); return; }
|
||||
w.TextColored(now > 0 ? UiColors.Yellow : UiColors.Grey, $"{now} of {all.Count} stamps done{run}. Still to get:");
|
||||
for (int i = 0; i < missing.Count && i < 12; i++) w.TextColored(missing[i].Earlier ? UiColors.Yellow : UiColors.Red, " - " + missing[i].Text);
|
||||
if (missing.Count > 12) w.TextDisabled($" ... and {missing.Count - 12} more.");
|
||||
if (_c.Flags.LastReadUtc == DateTime.MinValue) w.TextDisabled("Your quest flags haven't been read yet: press Refresh.");
|
||||
}
|
||||
|
||||
private void DrawGuideStep(UiWindow w, GuideQuest q, int i, bool done, bool passed, bool isNext, bool isCurrent)
|
||||
{
|
||||
GuideStep s = q.Steps[i];
|
||||
// [x] done, [~] passed (no stamp of its own; a later step is done), [>] the next to do, [ ] still to do.
|
||||
string mark = done ? "[x]" : passed ? "[~]" : isNext ? "[>]" : "[ ]";
|
||||
uint color = isCurrent || isNext ? UiColors.Yellow : done ? UiColors.Green : passed ? UiColors.Grey : 0;
|
||||
if (color != 0) w.PushStyleColor(ColText, color);
|
||||
w.TextWrapped($"{mark} {i + 1}. {s.Text}");
|
||||
if (color != 0) w.PopStyleColor();
|
||||
if (passed) w.Tooltip("No stamp of its own; a step after it is done, so the quest went past it.");
|
||||
else if (isNext) w.Tooltip("The next step to do.");
|
||||
for (int k = 0; k < s.Coords.Count && k < 4; k++)
|
||||
{
|
||||
string c = s.Coords[k];
|
||||
if (k > 0) w.SameLine();
|
||||
w.SmallButton("Go " + c, $"g.s{i}.c{k}", () => _gMsg = SendRynthNav("go", new[] { c }));
|
||||
w.Tooltip("RynthNav plans the way to " + c + " and walks it.");
|
||||
}
|
||||
for (int k = 0; k < s.Notes.Count && k < 4; k++)
|
||||
{
|
||||
w.PushStyleColor(ColText, UiColors.Grey);
|
||||
w.TextWrapped(" " + s.Notes[k]);
|
||||
w.PopStyleColor();
|
||||
}
|
||||
foreach (string st in s.Stamps) StampLine(w, q, st);
|
||||
}
|
||||
|
||||
private void StampLine(UiWindow w, GuideQuest q, string stamp)
|
||||
{
|
||||
switch (_c.Progress.StateOf(q, stamp, _c.UtcNow))
|
||||
{
|
||||
case StampState.Done: w.TextColored(UiColors.Green, " [x] stamped " + stamp); break;
|
||||
case StampState.Earlier: w.TextColored(UiColors.Yellow, " [ ] " + stamp + " - done on an earlier run; ready again"); break;
|
||||
default: w.TextColored(UiColors.Red, " [ ] " + stamp + " - not stamped yet"); break;
|
||||
}
|
||||
w.Tooltip(StampWhy(stamp));
|
||||
}
|
||||
|
||||
/// <summary>Why a stamp reads the way it does: the flag it matched and its times, or that none did.</summary>
|
||||
private string StampWhy(string stamp)
|
||||
{
|
||||
if (_c.Progress.StampedThisSession(stamp)) return "Stamped this session (the server said so in chat).";
|
||||
if (_c.Progress.FlagOf(stamp) is QuestFlag f)
|
||||
{
|
||||
string when = f.CompletedOnUtc == DateTime.MinValue ? "" : $", last {f.CompletedOnUtc.ToLocalTime():yyyy-MM-dd HH:mm}";
|
||||
string timer = f.RepeatTime <= TimeSpan.Zero ? ""
|
||||
: f.NextAvailableTime(_c.UtcNow) > TimeSpan.Zero ? "; again in " + GuideProgress.Short(f.NextAvailableTime(_c.UtcNow)) : "; its timer is up";
|
||||
return $"Your quest flag '{f.Key}': {f.Solves} solve(s){when}{timer}.";
|
||||
}
|
||||
return _c.Flags.LastReadUtc == DateTime.MinValue
|
||||
? "Your quest flags haven't been read yet (Refresh)."
|
||||
: $"No quest flag named like '{stamp}' in your /myquests ({_c.Flags.Flags.Count} flags, read {_c.Flags.LastReadUtc.ToLocalTime():HH:mm}).";
|
||||
}
|
||||
|
||||
// ── Kill tasks ──────────────────────────────────────────────────────────
|
||||
|
||||
private void DrawKillSummary(UiWindow w, GuideSet set)
|
||||
{
|
||||
int counting = 0, turnIn = 0, ready = 0;
|
||||
foreach (GuideQuest q in set.Quests)
|
||||
{
|
||||
if (!set.IsKillTask(q)) continue;
|
||||
switch (_c.Progress.KillOf(q, _c.UtcNow, CatalogDone(q.Title)).State)
|
||||
{
|
||||
case KillState.Counting: counting++; break;
|
||||
case KillState.TurnIn: turnIn++; break;
|
||||
case KillState.Ready: ready++; break;
|
||||
}
|
||||
}
|
||||
string read = _c.Flags.LastReadUtc == DateTime.MinValue ? "not read yet" : "read " + GuideProgress.Short(_c.UtcNow - _c.Flags.LastReadUtc) + " ago";
|
||||
w.TextDisabled($"Kill tasks: {counting} counting, {turnIn} to turn in, {ready} ready | /myquests {read}");
|
||||
w.Tooltip("The kills come from your quest flags (/myquests): each task's counter. A kill line in chat moves the count at once,\n"
|
||||
+ "and with this list open the flags are read again after kills (at most once a minute, the server's limit).");
|
||||
}
|
||||
|
||||
private void DrawKillLine(UiWindow w, GuideQuest q)
|
||||
{
|
||||
GuideProgress.Kill p = _c.Progress.KillOf(q, _c.UtcNow, CatalogDone(q.Title));
|
||||
string goal = p.Goal > 0 ? p.Goal.ToString(System.Globalization.CultureInfo.InvariantCulture) : "?";
|
||||
string count = p.Counter != null || p.FromChat
|
||||
? $"Kills: {p.Kills} / {goal}" + (p.Goal > p.Kills ? $" ({p.Goal - p.Kills} left)" : "")
|
||||
: p.Goal > 0 ? $"Kills: not started (the task is {p.Goal} kills)" : "Kills: not started";
|
||||
w.TextColored(KillColor(p.State), count + " - " + p.Status);
|
||||
w.SameLine();
|
||||
w.TextColored(p.DoneBefore ? UiColors.Green : UiColors.Gold, p.DoneBefore ? "(done before)" : "(first time)");
|
||||
w.TextDisabled(p.FromChat ? "From the last kill line in chat."
|
||||
: p.Counter != null ? $"From /myquests: {p.Counter.Key} ({p.Counter.Solves} of {p.Counter.MaxSolves})."
|
||||
: "No counter flag in /myquests yet" + (q.StartsWith.Length > 0 ? $" (talk to {q.StartsWith} to start it)." : "."));
|
||||
}
|
||||
|
||||
/// <summary>A kill counter only /myquests knows.</summary>
|
||||
private void DrawKillFlag(UiWindow w, QuestFlag f)
|
||||
{
|
||||
w.TextColored(UiColors.Gold, KillFlagLabel(f));
|
||||
QuestTimerState st = QuestTimer.State(f, true, _c.UtcNow, out string text);
|
||||
w.Text($"Kills: {f.Solves} / {f.MaxSolves}" + (f.Solves < f.MaxSolves ? $" ({f.MaxSolves - f.Solves} left)" : ""));
|
||||
w.TextDisabled("State: " + (st == QuestTimerState.Waiting ? "again in " + text : text));
|
||||
if (f.Description.Length > 0) w.TextWrapped(f.Description);
|
||||
w.TextDisabled("Flag " + f.Key + ": no guide's kill task names this counter.");
|
||||
}
|
||||
|
||||
// ── Contracts ───────────────────────────────────────────────────────────
|
||||
|
||||
private void DrawGuideContract(UiWindow w, GuideSet set, GuideContract c)
|
||||
{
|
||||
w.TextColored(UiColors.Gold, c.Name);
|
||||
if (c.Level.Length > 0) w.TextDisabled("Recommended level " + c.Level);
|
||||
if (c.Description.Length > 0) w.TextWrapped(c.Description);
|
||||
if (c.Where.Length > 0) w.TextWrapped("Where: " + c.Where);
|
||||
if (c.Npc.Length > 0)
|
||||
{
|
||||
w.SmallButton("Go to " + Cut(c.Npc, 28), "g.c.go", () => _gMsg = SendRynthNav("go", new[] { c.Npc }));
|
||||
w.Tooltip("RynthNav goes to " + c.Npc + ".");
|
||||
}
|
||||
if (c.Quests.Count > 0)
|
||||
{
|
||||
w.SeparatorText(c.Quests.Count == 1 ? "The quest it is for" : "The quests it is for");
|
||||
for (int i = 0; i < c.Quests.Count && i < 10; i++)
|
||||
{
|
||||
string t = c.Quests[i];
|
||||
if (set.Find(t) is not GuideQuest q) { w.TextDisabled(" " + t + " (no page in the guide)"); continue; }
|
||||
GuideRow qr = GuideQuestRow(q);
|
||||
w.SmallButton("Open", "g.c.q." + i, () => ShowGuide(GuideList.All, "w:" + q.Title));
|
||||
w.Tooltip("Opens the quest in the All list: its steps and where it stands.");
|
||||
w.SameLine();
|
||||
w.Text(q.Title);
|
||||
w.SameLine();
|
||||
w.TextColored(qr.Color, qr.Status);
|
||||
}
|
||||
}
|
||||
if (c.Url.Length > 0)
|
||||
{
|
||||
w.SmallButton("Wiki page", "g.c.url", () => _c.Print(c.Url));
|
||||
w.Tooltip("Prints the page's address in chat: " + c.Url);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Refresh ─────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>The Guide's Refresh: /myquests, the server plugin's guide (when it takes "refresh") and the wiki feed (when on).</summary>
|
||||
private RefreshResult RefreshGuide()
|
||||
{
|
||||
string more = "";
|
||||
if (_c.ServerGuide.Available && _c.ServerGuide.Info!.Takes(RynthServerQuestGuide.CommandRefresh)
|
||||
&& _c.ServerGuide.Command(RynthServerQuestGuide.CommandRefresh))
|
||||
more += $" Asked {_c.ServerGuide.Info.Plugin} to read {_c.ServerGuide.Tag}'s guide again.";
|
||||
if (_c.Settings.WikiFeedOn && !_c.Wiki.Running && _c.Wiki.Start(on: true)) more += " Reading the AC Community Wiki (only pages edited since).";
|
||||
RefreshResult r = RefreshQuests();
|
||||
return r with { What = r.What + more };
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ namespace RynthCore.Plugin.RynthOracle.Views;
|
|||
/// </summary>
|
||||
internal sealed partial class OracleView
|
||||
{
|
||||
public const string TabQuests = "Quests", TabCharacter = "Character",
|
||||
public const string TabQuests = "Quests", TabGuide = "Guide", TabCharacter = "Character",
|
||||
TabSkills = "Skills", TabAttributes = "Attributes", TabProgress = "Progress",
|
||||
TabAugs = "Augs", TabSociety = "Society",
|
||||
TabTitles = "Titles", TabVoid = "Void", TabFellowship = "Fellowship",
|
||||
|
|
@ -40,6 +40,9 @@ internal sealed partial class OracleView
|
|||
{
|
||||
new(TabQuests, DrawQuests, true, () => RefreshQuests(),
|
||||
() => "Sends /myquests to the server and reads the reply."),
|
||||
// The quest guide (2026-11-27): wiki quests with their steps (the server plugin's guide and the AC Community Wiki feed).
|
||||
new(TabGuide, DrawGuide, true, RefreshGuide,
|
||||
() => "Reads your quest flags again (/myquests), and the guides: the server plugin's and, when its feed is on, the AC Community Wiki's."),
|
||||
new(TabCharacter, DrawCharacter, true, RefreshCharacter,
|
||||
() => "Re-reads your level, experience, buffs and skills from the game now (and RynthAi's session)."),
|
||||
// Skills / Attributes / Progress: RynthCore draws its Skills panel body under the tab
|
||||
|
|
|
|||
45
Plugins/RynthCore.Plugin.RynthOracle/Views/WikiFeedPanel.cs
Normal file
45
Plugins/RynthCore.Plugin.RynthOracle/Views/WikiFeedPanel.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// The AC Community Wiki feed's controls (2026-11-27): on the About tab and atop the Guide tab. The feed is off by
|
||||
// default, and these say what it reads and from where before anything is fetched (CommunityWikiFeed.WhatItReads).
|
||||
using RynthCore.Plugin.RynthOracle.Data;
|
||||
using RynthCore.Plugin.RynthOracle.Ui;
|
||||
|
||||
namespace RynthCore.Plugin.RynthOracle.Views;
|
||||
|
||||
internal sealed partial class OracleView
|
||||
{
|
||||
private string _wikiMsg = "";
|
||||
|
||||
/// <summary>The feed's on/off, Read now and its status. <paramref name="id"/> keeps the two copies' widgets apart.</summary>
|
||||
private void DrawWikiFeedControls(UiWindow w, string id, bool full)
|
||||
{
|
||||
OracleSettings s = _c.Settings;
|
||||
CommunityWikiFeed feed = _c.Wiki;
|
||||
if (!s.WikiFeedOn)
|
||||
{
|
||||
w.TextColored(UiColors.Yellow, "AC Community Wiki feed: off. Nothing is fetched.");
|
||||
w.TextWrapped("When on, RynthOracle reads " + CommunityWikiFeed.WhatItReads
|
||||
+ " The copy is saved on this PC: " + feed.FilePath + ".");
|
||||
w.Button("Turn the feed on and read it", id + ".wiki.on", () => _wikiMsg = _c.SetWikiFeed(true).Text);
|
||||
w.Tooltip("Reads " + CommunityWikiFeed.Api + " now, and again at login once the copy is a day old (the setting below).");
|
||||
}
|
||||
else
|
||||
{
|
||||
w.TextColored(UiColors.Green, "AC Community Wiki feed: on (" + CommunityWikiFeed.Host + ").");
|
||||
w.TextDisabled((feed.Running ? "Reading: " : "") + feed.Status);
|
||||
if (!feed.Running)
|
||||
{
|
||||
w.Button("Read now", id + ".wiki.read", () => _wikiMsg = _c.ReadWikiNow().Text);
|
||||
w.Tooltip("Reads the pages edited since the last read, from " + CommunityWikiFeed.Api + ".");
|
||||
w.SameLine();
|
||||
}
|
||||
w.Button("Turn the feed off", id + ".wiki.off", () => _wikiMsg = _c.SetWikiFeed(false).Text);
|
||||
w.Tooltip("Nothing more is fetched. The copy already saved stays in the Guide tab.");
|
||||
if (full)
|
||||
{
|
||||
w.Checkbox("Read it again at login once the copy is a day old", id + ".wiki.daily", s.WikiFeedDaily, v => { s.WikiFeedDaily = v; s.Save(); });
|
||||
w.Tooltip("Off: only Read now (or /ro wiki read) reads the wiki.");
|
||||
}
|
||||
}
|
||||
if (_wikiMsg.Length > 0) w.TextWrapped(_wikiMsg);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue