Add IPC to get currently active seasonal event quests
authorLiza Carvelli <liza@carvel.li>
Wed, 5 Feb 2025 12:36:21 +0000 (13:36 +0100)
committerLiza Carvelli <liza@carvel.li>
Wed, 5 Feb 2025 12:37:13 +0000 (13:37 +0100)
Questionable/External/QuestionableIpc.cs
Questionable/Windows/QuestComponents/EventInfoComponent.cs

index c645913422310b7327d7b5d21b18e9b4f7036c77..760a76cd97210c2cc4d4b7bf26635b30682ebf66 100644 (file)
@@ -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<bool> _isRunning;
     private readonly ICallGateProvider<string?> _getCurrentQuestId;
+    private readonly ICallGateProvider<List<string>> _getCurrentlyActiveEventQuests;
 
-    public QuestionableIpc(QuestController questController, IDalamudPluginInterface pluginInterface)
+    public QuestionableIpc(
+        QuestController questController,
+        EventInfoComponent eventInfoComponent,
+        IDalamudPluginInterface pluginInterface)
     {
         _isRunning = pluginInterface.GetIpcProvider<bool>(IpcIsRunning);
         _isRunning.RegisterFunc(() =>
@@ -21,11 +29,17 @@ internal sealed class QuestionableIpc : IDisposable
 
         _getCurrentQuestId = pluginInterface.GetIpcProvider<string?>(IpcGetCurrentQuestId);
         _getCurrentQuestId.RegisterFunc(() => questController.CurrentQuest?.Quest.Id.ToString());
+
+        _getCurrentlyActiveEventQuests =
+            pluginInterface.GetIpcProvider<List<string>>(IpcGetCurrentlyActiveEventQuests);
+        _getCurrentlyActiveEventQuests.RegisterFunc(() =>
+            eventInfoComponent.GetCurrentlyActiveEventQuests().Select(q => q.ToString()).ToList());
     }
 
 
     public void Dispose()
     {
+        _getCurrentlyActiveEventQuests.UnregisterFunc();
         _getCurrentQuestId.UnregisterFunc();
         _isRunning.UnregisterFunc();
     }
index 11986cf856b4885d748fdb1ea6f4d048ceed9800..48c37f1dbda822e5a0deaad00c98fd83d4233ccc 100644 (file)
@@ -136,5 +136,12 @@ internal sealed class EventInfoComponent
         return !eventQuest.QuestIds.All(x => _questFunctions.IsQuestComplete(x));
     }
 
+    public IEnumerable<QuestId> GetCurrentlyActiveEventQuests()
+    {
+        return _eventQuests
+            .Where(x => x.EndsAtUtc <= DateTime.UtcNow)
+            .SelectMany(x => x.QuestIds);
+    }
+
     private sealed record EventQuest(string Name, List<QuestId> QuestIds, DateTime EndsAtUtc);
 }