Update check for class/jobs to make one shb role quest mandatory, and ew/dt role...
authorLiza Carvelli <liza@carvel.li>
Sat, 10 Aug 2024 23:00:45 +0000 (01:00 +0200)
committerLiza Carvelli <liza@carvel.li>
Sat, 10 Aug 2024 23:03:14 +0000 (01:03 +0200)
Questionable/Controller/QuestController.cs
Questionable/Data/QuestData.cs

index 562c7e52cd9cde3a88536546283bf16dd36ed24d..5619c11998ee4a15a6e42fefb1ab89280bdd60bd 100644 (file)
@@ -310,7 +310,8 @@ internal sealed class QuestController : MiniTaskController<QuestController>, IDi
 
                         if (_clientState.LocalPlayer!.Level < quest.Info.Level)
                         {
-                            _logger.LogInformation("Stopping automation, player level ({PlayerLevel}) < quest level ({QuestLevel}",
+                            _logger.LogInformation(
+                                "Stopping automation, player level ({PlayerLevel}) < quest level ({QuestLevel}",
                                 _clientState.LocalPlayer!.Level, quest.Info.Level);
                             Stop("Quest level too high");
                         }
@@ -364,7 +365,8 @@ internal sealed class QuestController : MiniTaskController<QuestController>, IDi
             if (questToRun.Sequence != currentSequence)
             {
                 questToRun.SetSequence(currentSequence);
-                CheckNextTasks($"New sequence {questToRun == _startedQuest}/{_questFunctions.GetCurrentQuestInternal()}");
+                CheckNextTasks(
+                    $"New sequence {questToRun == _startedQuest}/{_questFunctions.GetCurrentQuestInternal()}");
             }
 
             var q = questToRun.Quest;
@@ -760,13 +762,28 @@ internal sealed class QuestController : MiniTaskController<QuestController>, IDi
         ];
 
         EClassJob classJob = (EClassJob?)_clientState.LocalPlayer?.ClassJob.Id ?? EClassJob.Adventurer;
+        ushort[] shadowbringersRoleQuestChapters = QuestData.AllRoleQuestChapters.Select(x => x[0]).ToArray();
         if (classJob != EClassJob.Adventurer)
         {
             priorityQuests.AddRange(_questRegistry.GetKnownClassJobQuests(classJob)
-                .Where(x => _questRegistry.TryGetQuest(x.QuestId, out Quest? quest) && quest.Info is QuestInfo
+                .Where(x =>
                 {
-                    // ignore Endwalker/Dawntrail, as the class quests are optional
-                    Expansion: EExpansionVersion.ARealmReborn or EExpansionVersion.Heavensward or EExpansionVersion.Stormblood or EExpansionVersion.Shadowbringers
+                    if (!_questRegistry.TryGetQuest(x.QuestId, out Quest? quest) ||
+                        quest.Info is not QuestInfo questInfo)
+                        return false;
+
+                    // if no shadowbringers role quest is complete, (at least one) is required
+                    if (shadowbringersRoleQuestChapters.Contains(questInfo.NewGamePlusChapter))
+                        return !QuestData.FinalShadowbringersRoleQuests.Any(_questFunctions.IsQuestComplete);
+
+                    // ignore all other role quests
+                    if (QuestData.AllRoleQuestChapters.Any(y => y.Contains(questInfo.NewGamePlusChapter)))
+                        return false;
+
+                    // even job quests for the later expacs (after role quests were introduced) might have skills locked
+                    // behind them, e.g. reaper and sage
+
+                    return true;
                 })
                 .Select(x => x.QuestId));
         }
index 8b961c817818c543e4a0123ea5ae2f79a84d3b47..3e00ba1a82a4e2efe8dae3d624a4b6c87e8ffeab 100644 (file)
@@ -14,6 +14,24 @@ internal sealed class QuestData
 {
     public static readonly IReadOnlyList<QuestId> CrystalTowerQuests =
         [new(1709), new(1200), new(1201), new(1202), new(1203), new(1474), new(494), new(495)];
+
+    public static readonly IReadOnlyList<ushort> TankRoleQuests = [136, 154, 178];
+    public static readonly IReadOnlyList<ushort> HealerRoleQuests = [137, 155, 179];
+    public static readonly IReadOnlyList<ushort> MeleeRoleQuests = [138, 156, 180];
+    public static readonly IReadOnlyList<ushort> PhysicalRangedRoleQuests = [138, 157, 181];
+    public static readonly IReadOnlyList<ushort> CasterRoleQuests = [139, 158, 182];
+    public static readonly IReadOnlyList<IReadOnlyList<ushort>> AllRoleQuestChapters =
+    [
+        TankRoleQuests,
+        HealerRoleQuests,
+        MeleeRoleQuests,
+        PhysicalRangedRoleQuests,
+        CasterRoleQuests
+    ];
+
+    public static readonly IReadOnlyList<QuestId> FinalShadowbringersRoleQuests =
+        [new(3248), new(3272), new(3278), new(3628)];
+
     private readonly Dictionary<ElementId, IQuestInfo> _quests;
 
     public QuestData(IDataManager dataManager)
@@ -134,11 +152,11 @@ internal sealed class QuestData
 
         chapterIds.AddRange(classJob switch
         {
-            _ when classJob.IsTank() => [136, 154, 178],
-            _ when classJob.IsHealer() => [137, 155, 179],
-            _ when classJob.IsMelee() => [138, 156, 180],
-            _ when classJob.IsPhysicalRanged() => [138, 157, 181],
-            _ when classJob.IsCaster() && classJob != EClassJob.BlueMage => [139, 158, 182],
+            _ when classJob.IsTank() => TankRoleQuests,
+            _ when classJob.IsHealer() => HealerRoleQuests,
+            _ when classJob.IsMelee() => MeleeRoleQuests,
+            _ when classJob.IsPhysicalRanged() => PhysicalRangedRoleQuests,
+            _ when classJob.IsCaster() && classJob != EClassJob.BlueMage => CasterRoleQuests,
             _ => []
         });