forked from liza/Questionable
master #2
@ -12,11 +12,11 @@ using FFXIVClientStructs.FFXIV.Component.GUI;
|
|||||||
using LLib.GameData;
|
using LLib.GameData;
|
||||||
using LLib.GameUI;
|
using LLib.GameUI;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Questionable.Controller;
|
using Questionable.Controller;
|
||||||
using Questionable.Controller.Steps.Interactions;
|
using Questionable.Controller.Steps.Interactions;
|
||||||
using Questionable.Data;
|
using Questionable.Data;
|
||||||
using Questionable.Model;
|
using Questionable.Model;
|
||||||
using Questionable.Model.Common;
|
|
||||||
using Questionable.Model.Questing;
|
using Questionable.Model.Questing;
|
||||||
using GrandCompany = FFXIVClientStructs.FFXIV.Client.UI.Agent.GrandCompany;
|
using GrandCompany = FFXIVClientStructs.FFXIV.Client.UI.Agent.GrandCompany;
|
||||||
using Quest = Questionable.Model.Quest;
|
using Quest = Questionable.Model.Quest;
|
||||||
@ -32,6 +32,7 @@ internal sealed unsafe class QuestFunctions
|
|||||||
private readonly IDataManager _dataManager;
|
private readonly IDataManager _dataManager;
|
||||||
private readonly IClientState _clientState;
|
private readonly IClientState _clientState;
|
||||||
private readonly IGameGui _gameGui;
|
private readonly IGameGui _gameGui;
|
||||||
|
private readonly ILogger<QuestFunctions> _logger;
|
||||||
|
|
||||||
public QuestFunctions(
|
public QuestFunctions(
|
||||||
QuestRegistry questRegistry,
|
QuestRegistry questRegistry,
|
||||||
@ -40,7 +41,8 @@ internal sealed unsafe class QuestFunctions
|
|||||||
Configuration configuration,
|
Configuration configuration,
|
||||||
IDataManager dataManager,
|
IDataManager dataManager,
|
||||||
IClientState clientState,
|
IClientState clientState,
|
||||||
IGameGui gameGui)
|
IGameGui gameGui,
|
||||||
|
ILogger<QuestFunctions> logger)
|
||||||
{
|
{
|
||||||
_questRegistry = questRegistry;
|
_questRegistry = questRegistry;
|
||||||
_questData = questData;
|
_questData = questData;
|
||||||
@ -49,6 +51,7 @@ internal sealed unsafe class QuestFunctions
|
|||||||
_dataManager = dataManager;
|
_dataManager = dataManager;
|
||||||
_clientState = clientState;
|
_clientState = clientState;
|
||||||
_gameGui = gameGui;
|
_gameGui = gameGui;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public (ElementId? CurrentQuest, byte Sequence) GetCurrentQuest()
|
public (ElementId? CurrentQuest, byte Sequence) GetCurrentQuest()
|
||||||
@ -251,8 +254,7 @@ internal sealed unsafe class QuestFunctions
|
|||||||
//
|
//
|
||||||
// Of course, they can still be accepted manually.
|
// Of course, they can still be accepted manually.
|
||||||
InventoryManager* inventoryManager = InventoryManager.Instance();
|
InventoryManager* inventoryManager = InventoryManager.Instance();
|
||||||
if (inventoryManager->GetItemCountInContainer(1, InventoryType.Currency) < 2000)
|
int gil = inventoryManager->GetItemCountInContainer(1, InventoryType.Currency);
|
||||||
return null;
|
|
||||||
|
|
||||||
return GetPriorityQuestsThatCanBeAccepted()
|
return GetPriorityQuestsThatCanBeAccepted()
|
||||||
.Where(x =>
|
.Where(x =>
|
||||||
@ -278,11 +280,20 @@ internal sealed unsafe class QuestFunctions
|
|||||||
if (!_questRegistry.TryGetQuest(x, out Quest? quest))
|
if (!_questRegistry.TryGetQuest(x, out Quest? quest))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (gil < EstimateTeleportCosts(quest))
|
||||||
|
return false;
|
||||||
|
|
||||||
return quest.AllSteps().All(y =>
|
return quest.AllSteps().All(y =>
|
||||||
{
|
{
|
||||||
if (y.Step.AetheryteShortcut is { } aetheryteShortcut &&
|
if (y.Step.AetheryteShortcut is { } aetheryteShortcut &&
|
||||||
_aetheryteFunctions.IsAetheryteUnlocked(aetheryteShortcut))
|
!_aetheryteFunctions.IsAetheryteUnlocked(aetheryteShortcut))
|
||||||
return false;
|
{
|
||||||
|
if (y.Step.SkipConditions?.AetheryteShortcutIf?.AetheryteLocked == aetheryteShortcut)
|
||||||
|
{
|
||||||
|
// _logger.LogTrace("Checking priority quest {QuestId}: aetheryte locked, but is listed as skippable", quest.Id);
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (y.Step.AethernetShortcut is { } aethernetShortcut &&
|
if (y.Step.AethernetShortcut is { } aethernetShortcut &&
|
||||||
(!_aetheryteFunctions.IsAetheryteUnlocked(aethernetShortcut.From) ||
|
(!_aetheryteFunctions.IsAetheryteUnlocked(aethernetShortcut.From) ||
|
||||||
@ -294,6 +305,17 @@ internal sealed unsafe class QuestFunctions
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int EstimateTeleportCosts(Quest quest)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
if (quest.Info.Expansion == EExpansionVersion.ARealmReborn)
|
||||||
|
return 300 * quest.AllSteps().Count(x => x.Step.AetheryteShortcut != null);
|
||||||
|
else
|
||||||
|
return 1000 * quest.AllSteps().Count(x => x.Step.AetheryteShortcut != null);
|
||||||
|
*/
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private List<ElementId> GetPriorityQuestsThatCanBeAccepted()
|
private List<ElementId> GetPriorityQuestsThatCanBeAccepted()
|
||||||
{
|
{
|
||||||
List<ElementId> priorityQuests =
|
List<ElementId> priorityQuests =
|
||||||
|
Loading…
Reference in New Issue
Block a user