Add retry to opening the journal for initiating leves
authorLiza Carvelli <liza@carvel.li>
Thu, 8 Aug 2024 13:09:19 +0000 (15:09 +0200)
committerLiza Carvelli <liza@carvel.li>
Thu, 8 Aug 2024 13:10:06 +0000 (15:10 +0200)
Questionable/Controller/Steps/Leves/InitiateLeve.cs
Questionable/Questionable.csproj

index 794120cfe10468f67c19b4b22ff1b8fa51983226..1c9ee563ded434d22d5b815bb7ba7d3a62d4e0ad 100644 (file)
@@ -36,6 +36,7 @@ internal static class InitiateLeve
     {
         private ElementId _elementId = null!;
         private uint _questType;
+        private DateTime _openedAt = DateTime.MinValue;
 
         public ITask With(ElementId elementId)
         {
@@ -47,19 +48,25 @@ internal static class InitiateLeve
         public bool Start()
         {
             AgentQuestJournal.Instance()->OpenForQuest(_elementId.Value, _questType);
+            _openedAt = DateTime.Now;
             return true;
         }
 
         public ETaskResult Update()
         {
             AgentQuestJournal* agentQuestJournal = AgentQuestJournal.Instance();
-            if (!agentQuestJournal->IsAgentActive())
-                return ETaskResult.StillRunning;
+            if (agentQuestJournal->IsAgentActive() &&
+                agentQuestJournal->SelectedQuestId == _elementId.Value &&
+                agentQuestJournal->SelectedQuestType == _questType)
+                return ETaskResult.TaskComplete;
+
+            if (DateTime.Now > _openedAt.AddSeconds(3))
+            {
+                AgentQuestJournal.Instance()->OpenForQuest(_elementId.Value, _questType);
+                _openedAt = DateTime.Now;
+            }
 
-            return agentQuestJournal->SelectedQuestId == _elementId.Value &&
-                   agentQuestJournal->SelectedQuestType == _questType
-                ? ETaskResult.TaskComplete
-                : ETaskResult.StillRunning;
+            return ETaskResult.StillRunning;
         }
 
         public override string ToString() => $"OpenJournal({_elementId})";
@@ -118,5 +125,7 @@ internal static class InitiateLeve
 
             return ETaskResult.StillRunning;
         }
+
+        public override string ToString() => "SelectLeveDifficulty";
     }
 }
index 0fd5fa31895046114cc5f0e02bc2ea54bfd2dded..50a60e7ed294c40da65739531193ad292a47c2c8 100644 (file)
@@ -1,6 +1,6 @@
 <Project Sdk="Dalamud.NET.Sdk/10.0.0">
     <PropertyGroup>
-        <Version>2.3</Version>
+        <Version>2.4</Version>
         <OutputPath>dist</OutputPath>
         <PathMap Condition="$(SolutionDir) != ''">$(SolutionDir)=X:\</PathMap>
         <Platforms>x64</Platforms>