From 2b4159d3d6cb131bccad9133c65de9517366f45d Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Wed, 5 Feb 2025 13:36:21 +0100 Subject: [PATCH] Add IPC to get currently active seasonal event quests --- Questionable/External/QuestionableIpc.cs | 16 +++++++++++++++- .../QuestComponents/EventInfoComponent.cs | 7 +++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Questionable/External/QuestionableIpc.cs b/Questionable/External/QuestionableIpc.cs index c6459134..760a76cd 100644 --- a/Questionable/External/QuestionableIpc.cs +++ b/Questionable/External/QuestionableIpc.cs @@ -1,7 +1,10 @@ using System; +using System.Collections.Generic; +using System.Linq; using Dalamud.Plugin; using Dalamud.Plugin.Ipc; using Questionable.Controller; +using Questionable.Windows.QuestComponents; namespace Questionable.External; @@ -9,11 +12,16 @@ internal sealed class QuestionableIpc : IDisposable { private const string IpcIsRunning = "Questionable.IsRunning"; private const string IpcGetCurrentQuestId = "Questionable.GetCurrentQuestId"; + private const string IpcGetCurrentlyActiveEventQuests = "Questionable.GetCurrentlyActiveEventQuests"; private readonly ICallGateProvider _isRunning; private readonly ICallGateProvider _getCurrentQuestId; + private readonly ICallGateProvider> _getCurrentlyActiveEventQuests; - public QuestionableIpc(QuestController questController, IDalamudPluginInterface pluginInterface) + public QuestionableIpc( + QuestController questController, + EventInfoComponent eventInfoComponent, + IDalamudPluginInterface pluginInterface) { _isRunning = pluginInterface.GetIpcProvider(IpcIsRunning); _isRunning.RegisterFunc(() => @@ -21,11 +29,17 @@ internal sealed class QuestionableIpc : IDisposable _getCurrentQuestId = pluginInterface.GetIpcProvider(IpcGetCurrentQuestId); _getCurrentQuestId.RegisterFunc(() => questController.CurrentQuest?.Quest.Id.ToString()); + + _getCurrentlyActiveEventQuests = + pluginInterface.GetIpcProvider>(IpcGetCurrentlyActiveEventQuests); + _getCurrentlyActiveEventQuests.RegisterFunc(() => + eventInfoComponent.GetCurrentlyActiveEventQuests().Select(q => q.ToString()).ToList()); } public void Dispose() { + _getCurrentlyActiveEventQuests.UnregisterFunc(); _getCurrentQuestId.UnregisterFunc(); _isRunning.UnregisterFunc(); } diff --git a/Questionable/Windows/QuestComponents/EventInfoComponent.cs b/Questionable/Windows/QuestComponents/EventInfoComponent.cs index 11986cf8..48c37f1d 100644 --- a/Questionable/Windows/QuestComponents/EventInfoComponent.cs +++ b/Questionable/Windows/QuestComponents/EventInfoComponent.cs @@ -136,5 +136,12 @@ internal sealed class EventInfoComponent return !eventQuest.QuestIds.All(x => _questFunctions.IsQuestComplete(x)); } + public IEnumerable GetCurrentlyActiveEventQuests() + { + return _eventQuests + .Where(x => x.EndsAtUtc <= DateTime.UtcNow) + .SelectMany(x => x.QuestIds); + } + private sealed record EventQuest(string Name, List QuestIds, DateTime EndsAtUtc); }