Snapshot for release 2026.10.19.1 (internal f0bdcf8)
This commit is contained in:
parent
5419838250
commit
39de36d3af
131 changed files with 11266 additions and 520 deletions
41
Plugins/RynthCore.Plugin.RynthOracle/Data/QuestText.cs
Normal file
41
Plugins/RynthCore.Plugin.RynthOracle/Data/QuestText.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// Ported from Oracle of Dereth by Advis Eveldan (advis61), MIT. See THIRD_PARTY_NOTICES.md.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RynthCore.Plugin.RynthOracle.Data;
|
||||
|
||||
/// <summary>
|
||||
/// The lines a click on a quest prints in chat. Upstream's quest list "thinks" them to the player:
|
||||
/// the quest's info and hint text ("{flag}: {details}", or "{flag}: No hint available"), its wiki
|
||||
/// link ("{flag}: No url available" when there is none), and the flag's own history
|
||||
/// ("{flag}: {description} CompletedOn:... Solves:... MaxSolves:... RepeatTime:...", or
|
||||
/// "{flag}: Never completed"). The texts come from the quest list's Info and Hint columns.
|
||||
/// </summary>
|
||||
internal static class QuestText
|
||||
{
|
||||
public static List<string> Lines(Quest q, QuestFlagStore flags, QuestBook book, DateTime utcNow)
|
||||
{
|
||||
string flag = q.Flag;
|
||||
var lines = new List<string>();
|
||||
|
||||
string status = q.IsComplete(flags) ? q.Status(flags, utcNow) : "not done";
|
||||
string name = q.IsNew ? (q.Name.Length > 0 ? q.Name : "Not in the quest list") : q.DisplayName;
|
||||
lines.Add($"{name} ({flag}) - {status}");
|
||||
|
||||
string details = q.Details();
|
||||
lines.Add(details.Length > 0 ? $"{flag}: {details}" : $"{flag}: No hint available");
|
||||
lines.Add(q.Url.Length > 0 ? $"{flag}: {q.Url}" : $"{flag}: No url available");
|
||||
lines.Add(History(flag, flags));
|
||||
|
||||
if (book.TryGetReward(flag, out QuestReward r)) lines.Add("Rewards: " + r.LongSummary());
|
||||
return lines;
|
||||
}
|
||||
|
||||
/// <summary>Upstream's QuestFlag.ToString(), or "Never completed" for a flag the character doesn't hold.</summary>
|
||||
public static string History(string flag, QuestFlagStore flags)
|
||||
{
|
||||
if (!flags.TryGet(flag, out QuestFlag f)) return $"{flag}: Never completed";
|
||||
string done = f.CompletedOnUtc == DateTime.MinValue ? "never" : f.CompletedOnUtc.ToLocalTime().ToString("yyyy-MM-dd HH:mm");
|
||||
return $"{f.Key}: {f.Description} CompletedOn:{done} Solves:{f.Solves} MaxSolves:{f.MaxSolves} RepeatTime:{TimeText.Friendly(f.RepeatTime)}";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RynthCore.Plugin.RynthOracle.Data;
|
||||
|
||||
/// <summary>
|
||||
/// Notices when a quest timer comes up. It remembers which watched quests were on cooldown and
|
||||
/// reports each one once, the moment its timer runs out. A quest that is simply ready when first
|
||||
/// seen (the login read) is not reported: only the step from waiting to ready is.
|
||||
/// </summary>
|
||||
internal sealed class QuestTimerWatcher
|
||||
{
|
||||
private readonly HashSet<string> _waiting = new(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly HashSet<string> _seen = new(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly List<Quest> _ready = new();
|
||||
|
||||
/// <summary>Forget everything (logout, or a different character).</summary>
|
||||
public void Reset() => _waiting.Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Checks the watched quests and returns those whose timers came up since the last check (the
|
||||
/// list is reused: read it before the next call). <paramref name="watch"/> is the flags to
|
||||
/// watch, or null for every quest the character holds.
|
||||
/// </summary>
|
||||
public IReadOnlyList<Quest> Check(QuestFlagStore flags, QuestCatalog catalog, IEnumerable<string>? watch, DateTime utcNow)
|
||||
{
|
||||
_ready.Clear();
|
||||
if (flags.LastReadUtc == DateTime.MinValue) return _ready;
|
||||
|
||||
_seen.Clear();
|
||||
foreach (string flag in watch ?? flags.Flags.Keys)
|
||||
{
|
||||
_seen.Add(flag);
|
||||
Quest q = catalog.TryGet(flag, out Quest known) ? known : new Quest { Flag = flag, IsNew = true };
|
||||
if (!flags.TryGet(flag, out _)) { _waiting.Remove(flag); continue; }
|
||||
QuestTimerState state = QuestTimer.State(q, flags, utcNow, out _);
|
||||
if (state == QuestTimerState.Waiting) _waiting.Add(flag);
|
||||
else if (state == QuestTimerState.Ready && _waiting.Remove(flag)) _ready.Add(q);
|
||||
else _waiting.Remove(flag); // in progress, or done for good
|
||||
}
|
||||
_waiting.RemoveWhere(k => !_seen.Contains(k)); // no longer watched
|
||||
return _ready;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue