Rework some code parts

This commit is contained in:
Liza 2024-04-26 19:53:44 +02:00
parent 79f8959852
commit 8cc11c9389
Signed by: liza
GPG Key ID: 7199F8D727D55F67
9 changed files with 300 additions and 184 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<Version>4.3</Version>
<Version>4.4</Version>
<LangVersion>12</LangVersion>
<Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

View File

@ -46,7 +46,6 @@ partial class DeliverooPlugin
_pluginLog.Verbose($" Choice {i} → {text}");
if (text == desiredText)
{
_pluginLog.Information($"Selecting choice {i} ({text})");
addonSelectString->AtkUnitBase.FireCallbackInt(i);
@ -60,13 +59,13 @@ partial class DeliverooPlugin
private void OpenGcSupplySelectStringFollowUp()
{
ResetTurnInErrorHandling();
_supplyHandler.ResetTurnInErrorHandling();
CurrentStage = Stage.SelectExpertDeliveryTab;
}
private void CloseGcSupplySelectStringFollowUp()
{
if (GetNextItemToPurchase() == null)
if (_exchangeHandler.GetNextItemToPurchase() == null)
{
_turnInWindow.State = false;
CurrentStage = Stage.RequestStop;
@ -74,26 +73,27 @@ partial class DeliverooPlugin
else
{
// you can occasionally get a 'not enough seals' warning lol
_continueAt = DateTime.Now.AddSeconds(1);
ContinueAt = DateTime.Now.AddSeconds(1);
CurrentStage = Stage.TargetQuartermaster;
}
}
private void CloseGcSupplySelectStringThenStopFollowUp()
{
if (GetNextItemToPurchase() == null)
if (_exchangeHandler.GetNextItemToPurchase() == null)
{
_turnInWindow.State = false;
CurrentStage = Stage.RequestStop;
}
else if (GetCurrentSealCount() <= EffectiveReservedSealCount + GetNextItemToPurchase()!.SealCost)
else if (_gameFunctions.GetCurrentSealCount() <=
EffectiveReservedSealCount + _exchangeHandler.GetNextItemToPurchase()!.SealCost)
{
_turnInWindow.State = false;
CurrentStage = Stage.RequestStop;
}
else
{
_continueAt = DateTime.Now.AddSeconds(1);
ContinueAt = DateTime.Now.AddSeconds(1);
CurrentStage = Stage.TargetQuartermaster;
}
}

View File

@ -19,7 +19,7 @@ partial class DeliverooPlugin
if (CurrentStage == Stage.ConfirmReward &&
_gameStrings.ExchangeItems.IsMatch(text))
{
PurchaseItemRequest? item = GetNextItemToPurchase();
PurchaseItemRequest? item = _exchangeHandler.GetNextItemToPurchase();
if (item == null)
{
addonSelectYesNo->AtkUnitBase.FireCallbackInt(1);
@ -33,12 +33,12 @@ partial class DeliverooPlugin
item.OnPurchase?.Invoke((int)item.TemporaryPurchaseQuantity);
item.TemporaryPurchaseQuantity = 0;
var nextItem = GetNextItemToPurchase(item);
if (nextItem != null && GetCurrentSealCount() >= EffectiveReservedSealCount + nextItem.SealCost)
var nextItem = _exchangeHandler.GetNextItemToPurchase(item);
if (nextItem != null && _gameFunctions.GetCurrentSealCount() >= EffectiveReservedSealCount + nextItem.SealCost)
CurrentStage = Stage.SelectRewardTier;
else
CurrentStage = Stage.CloseGcExchange;
_continueAt = DateTime.Now.AddSeconds(0.5);
ContinueAt = DateTime.Now.AddSeconds(0.5);
}
else if (CurrentStage == Stage.TurnInSelected &&
_gameStrings.TradeHighQualityItem == text)

View File

@ -14,13 +14,12 @@ using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using Deliveroo.External;
using Deliveroo.GameData;
using Deliveroo.Handlers;
using Deliveroo.Windows;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Component.GUI;
using LLib;
using LLib.GameUI;
using Lumina.Excel;
using Lumina.Excel.GeneratedSheets;
namespace Deliveroo;
@ -33,8 +32,6 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
private readonly IGameGui _gameGui;
private readonly IFramework _framework;
private readonly IClientState _clientState;
private readonly IObjectTable _objectTable;
private readonly ITargetManager _targetManager;
private readonly ICondition _condition;
private readonly ICommandManager _commandManager;
private readonly IPluginLog _pluginLog;
@ -44,23 +41,19 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
private readonly Configuration _configuration;
private readonly GameStrings _gameStrings;
private readonly GameFunctions _gameFunctions;
private readonly ExternalPluginHandler _externalPluginHandler;
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
private readonly GcRewardsCache _gcRewardsCache;
private readonly IconCache _iconCache;
private readonly ItemCache _itemCache;
private readonly ExchangeHandler _exchangeHandler;
private readonly SupplyHandler _supplyHandler;
private readonly ConfigWindow _configWindow;
private readonly TurnInWindow _turnInWindow;
private readonly ReadOnlyDictionary<uint, GcRankInfo> _gcRankInfo;
private readonly Dictionary<uint, int> _retainerItemCache = new();
private Stage _currentStageInternal = Stage.Stopped;
private DateTime _continueAt = DateTime.MinValue;
private int _lastTurnInListSize = int.MaxValue;
private uint _turnInErrors;
private List<PurchaseItemRequest> _itemsToPurchaseNow = new();
public DeliverooPlugin(DalamudPluginInterface pluginInterface, IChatGui chatGui, IGameGui gameGui,
IFramework framework, IClientState clientState, IObjectTable objectTable, ITargetManager targetManager,
@ -74,8 +67,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
_gameGui = gameGui;
_framework = framework;
_clientState = clientState;
_objectTable = objectTable;
_targetManager = targetManager;
ITargetManager targetManager1 = targetManager;
_condition = condition;
_commandManager = commandManager;
_pluginLog = pluginLog;
@ -83,36 +75,29 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
_gameStrings = new GameStrings(dataManager, _pluginLog);
_externalPluginHandler = new ExternalPluginHandler(_pluginInterface, _pluginLog);
_gameFunctions = new GameFunctions(objectTable, _clientState, targetManager, dataManager,
_externalPluginHandler, _pluginLog);
_configuration = (Configuration?)_pluginInterface.GetPluginConfig() ?? new Configuration();
_gcRewardsCache = new GcRewardsCache(dataManager);
_iconCache = new IconCache(textureProvider);
_itemCache = new ItemCache(dataManager);
_configWindow = new ConfigWindow(_pluginInterface, this, _configuration, _gcRewardsCache, _clientState, _pluginLog, _iconCache);
_windowSystem.AddWindow(_configWindow);
_turnInWindow = new TurnInWindow(this, _pluginInterface, _configuration, _condition, _clientState, _gcRewardsCache, _configWindow, _iconCache);
_windowSystem.AddWindow(_turnInWindow);
var itemCache = new ItemCache(dataManager);
_gcRankInfo = dataManager.GetExcelSheet<GrandCompanyRank>()!.Where(x => x.RowId > 0)
.ToDictionary(x => x.RowId, x => new GcRankInfo
{
NameTwinAddersMale = ExtractRankName<GCRankGridaniaMaleText>(dataManager, x.RowId, r => r.Singular),
NameTwinAddersFemale = ExtractRankName<GCRankGridaniaFemaleText>(dataManager, x.RowId, r => r.Singular),
NameMaelstromMale = ExtractRankName<GCRankLimsaMaleText>(dataManager, x.RowId, r => r.Singular),
NameMaelstromFemale = ExtractRankName<GCRankLimsaFemaleText>(dataManager, x.RowId, r => r.Singular),
NameImmortalFlamesMale = ExtractRankName<GCRankUldahMaleText>(dataManager, x.RowId, r => r.Singular),
NameImmortalFlamesFemale = ExtractRankName<GCRankUldahFemaleText>(dataManager, x.RowId, r => r.Singular),
MaxSeals = x.MaxSeals,
RequiredSeals = x.RequiredSeals,
RequiredHuntingLog = x.Unknown10,
})
.AsReadOnly();
_exchangeHandler = new ExchangeHandler(this, _gameFunctions, targetManager1, _gameGui, _chatGui, _pluginLog);
_supplyHandler = new SupplyHandler(this, _gameFunctions, targetManager1, _gameGui, _chatGui, itemCache,
_pluginLog);
_configWindow = new ConfigWindow(_pluginInterface, this, _configuration, _gcRewardsCache, _clientState,
_pluginLog, _iconCache, _gameFunctions);
_windowSystem.AddWindow(_configWindow);
_turnInWindow = new TurnInWindow(this, _pluginInterface, _configuration, _condition, _clientState,
_gcRewardsCache, _configWindow, _iconCache, _gameFunctions);
_windowSystem.AddWindow(_turnInWindow);
_framework.Update += FrameworkUpdate;
_pluginInterface.UiBuilder.Draw += _windowSystem.Draw;
_pluginInterface.UiBuilder.OpenConfigUi += _configWindow.Toggle;
_clientState.Login += Login;
_clientState.Logout += Logout;
_clientState.TerritoryChanged += TerritoryChanged;
_chatGui.ChatMessage += ChatMessage;
_commandManager.AddHandler("/deliveroo", new CommandInfo(ProcessCommand)
{
@ -129,13 +114,8 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
_addonLifecycle.RegisterListener(AddonEvent.PostSetup, "SelectYesno", SelectYesNoPostSetup);
}
private static string ExtractRankName<T>(IDataManager dataManager, uint rankId, Func<T, Lumina.Text.SeString> func)
where T : ExcelRow
{
return func(dataManager.GetExcelSheet<T>()!.GetRow(rankId)!).ToString();
}
private void ChatMessage(XivChatType type, uint senderId, ref SeString sender, ref SeString message, ref bool isHandled)
private void ChatMessage(XivChatType type, uint senderId, ref SeString sender, ref SeString message,
ref bool isHandled)
{
if (_configuration.PauseAtRank <= 0)
return;
@ -175,6 +155,20 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
}
}
internal DateTime ContinueAt { private get; set; } = DateTime.MinValue;
internal List<PurchaseItemRequest> ItemsToPurchaseNow { get; set; } = new();
internal int LastTurnInListSize { get; set; } = int.MaxValue;
internal bool TurnInState
{
set => _turnInWindow.State = value;
}
internal string TurnInError
{
set => _turnInWindow.Error = value;
}
public int EffectiveReservedSealCount
{
get
@ -182,7 +176,8 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
if (CharacterConfiguration is { IgnoreMinimumSealsToKeep: true })
return 0;
return _configuration.ReserveDifferentSealCountAtMaxRank && GetSealCap() == MaxSealCap
return _configuration.ReserveDifferentSealCountAtMaxRank &&
_gameFunctions.GetSealCap() == _gameFunctions.MaxSealCap
? _configuration.ReservedSealCountAtMaxRank
: _configuration.ReservedSealCount;
}
@ -224,13 +219,6 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
private void Logout()
{
CharacterConfiguration = null;
_retainerItemCache.Clear();
}
private void TerritoryChanged(ushort territoryType)
{
// there is no GC area that is in the same zone as a retainer bell, so this should be often enough.
_retainerItemCache.Clear();
}
private unsafe void FrameworkUpdate(IFramework f)
@ -239,8 +227,9 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
if (!_clientState.IsLoggedIn ||
_clientState.TerritoryType is not 128 and not 130 and not 132 ||
_condition[ConditionFlag.OccupiedInCutSceneEvent] ||
GetDistanceToNpc(GetQuartermasterId(), out GameObject? quartermaster) >= 7f ||
GetDistanceToNpc(GetPersonnelOfficerId(), out GameObject? personnelOfficer) >= 7f ||
_gameFunctions.GetDistanceToNpc(_gameFunctions.GetQuartermasterId(), out GameObject? quartermaster) >= 7f ||
_gameFunctions.GetDistanceToNpc(_gameFunctions.GetPersonnelOfficerId(), out GameObject? personnelOfficer) >=
7f ||
CharacterConfiguration is { DisableForCharacter: true } ||
_configWindow.IsOpen)
{
@ -252,10 +241,10 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
CurrentStage = Stage.Stopped;
}
}
else if (DateTime.Now > _continueAt)
else if (DateTime.Now > ContinueAt)
{
_turnInWindow.IsOpen = true;
_turnInWindow.Multiplier = GetSealMultiplier();
_turnInWindow.Multiplier = _gameFunctions.GetSealMultiplier();
if (!_turnInWindow.State)
{
@ -270,23 +259,25 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
else if (_turnInWindow.State && CurrentStage == Stage.Stopped)
{
CurrentStage = Stage.TargetPersonnelOfficer;
_itemsToPurchaseNow = _turnInWindow.SelectedItems;
ResetTurnInErrorHandling();
if (_itemsToPurchaseNow.Count > 0)
ItemsToPurchaseNow = _turnInWindow.SelectedItems;
_supplyHandler.ResetTurnInErrorHandling();
if (ItemsToPurchaseNow.Count > 0)
{
_pluginLog.Information("Items to purchase:");
foreach (var item in _itemsToPurchaseNow)
foreach (var item in ItemsToPurchaseNow)
_pluginLog.Information($" {item.Name} (limit = {item.EffectiveLimit})");
}
else
_pluginLog.Information("No items to purchase configured or available");
var nextItem = GetNextItemToPurchase();
if (nextItem != null && GetCurrentSealCount() >= EffectiveReservedSealCount + nextItem.SealCost)
var nextItem = _exchangeHandler.GetNextItemToPurchase();
if (nextItem != null && _gameFunctions.GetCurrentSealCount() >=
EffectiveReservedSealCount + nextItem.SealCost)
CurrentStage = Stage.TargetQuartermaster;
if (_gameGui.TryGetAddonByName<AddonGrandCompanySupplyList>("GrandCompanySupplyList", out var gcSupplyList) &&
if (_gameGui.TryGetAddonByName<AddonGrandCompanySupplyList>("GrandCompanySupplyList",
out var gcSupplyList) &&
LAddon.IsAddonReady(&gcSupplyList->AtkUnitBase))
CurrentStage = Stage.SelectExpertDeliveryTab;
@ -301,7 +292,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
switch (CurrentStage)
{
case Stage.TargetPersonnelOfficer:
InteractWithPersonnelOfficer(personnelOfficer!, quartermaster!);
_supplyHandler.InteractWithPersonnelOfficer(personnelOfficer!, quartermaster!);
break;
case Stage.OpenGcSupply:
@ -309,19 +300,19 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
break;
case Stage.SelectExpertDeliveryTab:
SelectExpertDeliveryTab();
_supplyHandler.SelectExpertDeliveryTab();
break;
case Stage.SelectItemToTurnIn:
SelectItemToTurnIn();
_supplyHandler.SelectItemToTurnIn();
break;
case Stage.TurnInSelected:
TurnInSelectedItem();
_supplyHandler.TurnInSelectedItem();
break;
case Stage.FinalizeTurnIn:
FinalizeTurnInItem();
_supplyHandler.FinalizeTurnInItem();
break;
case Stage.CloseGcSupplySelectString:
@ -333,23 +324,23 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
break;
case Stage.CloseGcSupplyWindowThenStop:
CloseGcSupplyWindow();
_supplyHandler.CloseGcSupplyWindow();
break;
case Stage.TargetQuartermaster:
InteractWithQuartermaster(personnelOfficer!, quartermaster!);
_exchangeHandler.InteractWithQuartermaster(personnelOfficer!, quartermaster!);
break;
case Stage.SelectRewardTier:
SelectRewardTier();
_exchangeHandler.SelectRewardTier();
break;
case Stage.SelectRewardSubCategory:
SelectRewardSubCategory();
_exchangeHandler.SelectRewardSubCategory();
break;
case Stage.SelectReward:
SelectReward();
_exchangeHandler.SelectReward();
break;
case Stage.ConfirmReward:
@ -357,7 +348,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
break;
case Stage.CloseGcExchange:
CloseGcExchange();
_exchangeHandler.CloseGcExchange();
break;
case Stage.RequestStop:
@ -383,15 +374,13 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
_commandManager.RemoveHandler("/deliveroo");
_chatGui.ChatMessage -= ChatMessage;
_clientState.TerritoryChanged -= TerritoryChanged;
_clientState.Logout -= Logout;
_clientState.Login -= Login;
_pluginInterface.UiBuilder.OpenConfigUi -= _configWindow.Toggle;
_pluginInterface.UiBuilder.Draw -= _windowSystem.Draw;
_framework.Update -= FrameworkUpdate;
_externalPluginHandler.Restore();
_gameFunctions.Dispose();
_externalPluginHandler.Dispose();
_iconCache.Dispose();
}

View File

@ -1,22 +1,85 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.InteropServices;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Memory;
using Dalamud.Plugin.Services;
using Deliveroo.External;
using Deliveroo.GameData;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Control;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Common.Math;
using Lumina.Excel;
using Lumina.Excel.GeneratedSheets;
using GrandCompany = FFXIVClientStructs.FFXIV.Client.UI.Agent.GrandCompany;
namespace Deliveroo;
partial class DeliverooPlugin
internal sealed class GameFunctions : IDisposable
{
private unsafe void InteractWithTarget(GameObject obj)
private readonly IObjectTable _objectTable;
private readonly IClientState _clientState;
private readonly ITargetManager _targetManager;
private readonly ExternalPluginHandler _externalPluginHandler;
private readonly IPluginLog _pluginLog;
private readonly ReadOnlyDictionary<uint, GcRankInfo> _gcRankInfo;
private readonly Dictionary<uint, int> _retainerItemCache = new();
public GameFunctions(IObjectTable objectTable, IClientState clientState, ITargetManager targetManager,
IDataManager dataManager, ExternalPluginHandler externalPluginHandler, IPluginLog pluginLog)
{
_objectTable = objectTable;
_clientState = clientState;
_targetManager = targetManager;
_externalPluginHandler = externalPluginHandler;
_pluginLog = pluginLog;
_gcRankInfo = dataManager.GetExcelSheet<GrandCompanyRank>()!.Where(x => x.RowId > 0)
.ToDictionary(x => x.RowId, x => new GcRankInfo
{
NameTwinAddersMale = ExtractRankName<GCRankGridaniaMaleText>(dataManager, x.RowId, r => r.Singular),
NameTwinAddersFemale = ExtractRankName<GCRankGridaniaFemaleText>(dataManager, x.RowId, r => r.Singular),
NameMaelstromMale = ExtractRankName<GCRankLimsaMaleText>(dataManager, x.RowId, r => r.Singular),
NameMaelstromFemale = ExtractRankName<GCRankLimsaFemaleText>(dataManager, x.RowId, r => r.Singular),
NameImmortalFlamesMale = ExtractRankName<GCRankUldahMaleText>(dataManager, x.RowId, r => r.Singular),
NameImmortalFlamesFemale =
ExtractRankName<GCRankUldahFemaleText>(dataManager, x.RowId, r => r.Singular),
MaxSeals = x.MaxSeals,
RequiredSeals = x.RequiredSeals,
RequiredHuntingLog = x.Unknown10,
})
.AsReadOnly();
_clientState.Logout += Logout;
_clientState.TerritoryChanged += TerritoryChanged;
}
private static string ExtractRankName<T>(IDataManager dataManager, uint rankId, Func<T, Lumina.Text.SeString> func)
where T : ExcelRow
{
return func(dataManager.GetExcelSheet<T>()!.GetRow(rankId)!).ToString();
}
private void Logout()
{
_retainerItemCache.Clear();
}
private void TerritoryChanged(ushort territoryType)
{
// there is no GC area that is in the same zone as a retainer bell, so this should be often enough.
_retainerItemCache.Clear();
}
public unsafe void InteractWithTarget(GameObject obj)
{
_pluginLog.Information($"Setting target to {obj}");
if (_targetManager.Target == null || _targetManager.Target != obj)
@ -28,7 +91,7 @@ partial class DeliverooPlugin
(FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)obj.Address, false);
}
internal unsafe int GetCurrentSealCount()
public unsafe int GetCurrentSealCount()
{
InventoryManager* inventoryManager = InventoryManager.Instance();
switch ((GrandCompany)PlayerState.Instance()->GrandCompany)
@ -44,11 +107,11 @@ partial class DeliverooPlugin
}
}
internal unsafe GrandCompany GetGrandCompany() => (GrandCompany)PlayerState.Instance()->GrandCompany;
public unsafe GrandCompany GetGrandCompany() => (GrandCompany)PlayerState.Instance()->GrandCompany;
internal unsafe byte GetGrandCompanyRank() => PlayerState.Instance()->GetGrandCompanyRank();
public unsafe byte GetGrandCompanyRank() => PlayerState.Instance()->GetGrandCompanyRank();
private float GetDistanceToNpc(int npcId, out GameObject? o)
public float GetDistanceToNpc(int npcId, out GameObject? o)
{
foreach (var obj in _objectTable)
{
@ -66,12 +129,12 @@ partial class DeliverooPlugin
return float.MaxValue;
}
private static int GetNpcId(GameObject obj)
public static int GetNpcId(GameObject obj)
{
return Marshal.ReadInt32(obj.Address + 128);
}
private int GetPersonnelOfficerId()
public int GetPersonnelOfficerId()
{
return GetGrandCompany() switch
{
@ -82,7 +145,7 @@ partial class DeliverooPlugin
};
}
private int GetQuartermasterId()
public int GetQuartermasterId()
{
return GetGrandCompany() switch
{
@ -93,17 +156,17 @@ partial class DeliverooPlugin
};
}
private uint GetSealCap() => _gcRankInfo.TryGetValue(GetGrandCompanyRank(), out var rank) ? rank.MaxSeals : 0;
public uint GetSealCap() => _gcRankInfo.TryGetValue(GetGrandCompanyRank(), out var rank) ? rank.MaxSeals : 0;
public uint MaxSealCap => _gcRankInfo[11].MaxSeals;
internal uint GetSealsRequiredForNextRank()
public uint GetSealsRequiredForNextRank()
=> _gcRankInfo.GetValueOrDefault(GetGrandCompanyRank())?.RequiredSeals ?? 0;
internal byte GetRequiredHuntingLogForNextRank()
public byte GetRequiredHuntingLogForNextRank()
=> _gcRankInfo.GetValueOrDefault(GetGrandCompanyRank() + 1u)?.RequiredHuntingLog ?? 0;
internal string? GetNextGrandCompanyRankName()
public string? GetNextGrandCompanyRankName()
{
bool female = _clientState.LocalPlayer!.Customize[(int)CustomizeIndex.Gender] == 1;
GrandCompany grandCompany = GetGrandCompany();
@ -128,7 +191,7 @@ partial class DeliverooPlugin
return count;
}
private decimal GetSealMultiplier()
public decimal GetSealMultiplier()
{
// priority seal allowance
if (_clientState.LocalPlayer!.StatusList.Any(x => x.StatusId == 1078))
@ -147,7 +210,7 @@ partial class DeliverooPlugin
/// <summary>
/// This returns ALL items that can be turned in, regardless of filter settings.
/// </summary>
private unsafe List<TurnInItem> BuildTurnInList(AgentGrandCompanySupply* agent)
public unsafe List<TurnInItem> BuildTurnInList(AgentGrandCompanySupply* agent)
{
List<TurnInItem> list = new();
for (int i = 11 /* skip over provisioning items */; i < agent->NumItems; ++i)
@ -170,4 +233,10 @@ partial class DeliverooPlugin
.ThenBy(x => x.ItemId)
.ToList();
}
public void Dispose()
{
_clientState.TerritoryChanged -= TerritoryChanged;
_clientState.Logout -= Logout;
}
}

View File

@ -1,34 +1,54 @@
using System;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Plugin.Services;
using Deliveroo.GameData;
using FFXIVClientStructs.FFXIV.Component.GUI;
using LLib.GameUI;
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
namespace Deliveroo;
namespace Deliveroo.Handlers;
partial class DeliverooPlugin
internal sealed class ExchangeHandler
{
private void InteractWithQuartermaster(GameObject personnelOfficer, GameObject quartermaster)
private readonly DeliverooPlugin _plugin;
private readonly GameFunctions _gameFunctions;
private readonly ITargetManager _targetManager;
private readonly IGameGui _gameGui;
private readonly IChatGui _chatGui;
private readonly IPluginLog _pluginLog;
public ExchangeHandler(DeliverooPlugin plugin, GameFunctions gameFunctions, ITargetManager targetManager,
IGameGui gameGui, IChatGui chatGui, IPluginLog pluginLog)
{
if (GetCurrentSealCount() < EffectiveReservedSealCount)
_plugin = plugin;
_gameFunctions = gameFunctions;
_targetManager = targetManager;
_gameGui = gameGui;
_chatGui = chatGui;
_pluginLog = pluginLog;
}
public void InteractWithQuartermaster(GameObject personnelOfficer, GameObject quartermaster)
{
CurrentStage = Stage.RequestStop;
if (_gameFunctions.GetCurrentSealCount() < _plugin.EffectiveReservedSealCount)
{
_plugin.CurrentStage = Stage.RequestStop;
return;
}
if (_targetManager.Target == personnelOfficer)
return;
InteractWithTarget(quartermaster);
CurrentStage = Stage.SelectRewardTier;
_gameFunctions.InteractWithTarget(quartermaster);
_plugin.CurrentStage = Stage.SelectRewardTier;
}
private PurchaseItemRequest? GetNextItemToPurchase(PurchaseItemRequest? previousRequest = null)
public PurchaseItemRequest? GetNextItemToPurchase(PurchaseItemRequest? previousRequest = null)
{
foreach (PurchaseItemRequest request in _itemsToPurchaseNow)
foreach (PurchaseItemRequest request in _plugin.ItemsToPurchaseNow)
{
int toBuy = 0;
if (request == previousRequest)
@ -40,7 +60,8 @@ partial class DeliverooPlugin
if (request.Type == Configuration.PurchaseType.KeepStocked)
{
if (GetItemCount(request.ItemId, request.CheckRetainerInventory) + toBuy < request.EffectiveLimit)
if (_gameFunctions.GetItemCount(request.ItemId, request.CheckRetainerInventory) + toBuy <
request.EffectiveLimit)
return request;
}
else
@ -53,12 +74,12 @@ partial class DeliverooPlugin
return null;
}
private unsafe void SelectRewardTier()
public unsafe void SelectRewardTier()
{
PurchaseItemRequest? item = GetNextItemToPurchase();
if (item == null)
{
CurrentStage = Stage.CloseGcExchange;
_plugin.CurrentStage = Stage.CloseGcExchange;
return;
}
@ -79,17 +100,17 @@ partial class DeliverooPlugin
new() { Type = 0, Int = 0 }
};
addonExchange->FireCallback(9, selectRank);
_continueAt = DateTime.Now.AddSeconds(0.5);
CurrentStage = Stage.SelectRewardSubCategory;
_plugin.ContinueAt = DateTime.Now.AddSeconds(0.5);
_plugin.CurrentStage = Stage.SelectRewardSubCategory;
}
}
private unsafe void SelectRewardSubCategory()
public unsafe void SelectRewardSubCategory()
{
PurchaseItemRequest? item = GetNextItemToPurchase();
if (item == null)
{
CurrentStage = Stage.CloseGcExchange;
_plugin.CurrentStage = Stage.CloseGcExchange;
return;
}
@ -110,25 +131,25 @@ partial class DeliverooPlugin
new() { Type = 0, Int = 0 }
};
addonExchange->FireCallback(9, selectType);
_continueAt = DateTime.Now.AddSeconds(0.5);
CurrentStage = Stage.SelectReward;
_plugin.ContinueAt = DateTime.Now.AddSeconds(0.5);
_plugin.CurrentStage = Stage.SelectReward;
}
}
private unsafe void SelectReward()
public unsafe void SelectReward()
{
if (_gameGui.TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
LAddon.IsAddonReady(addonExchange))
{
if (SelectRewardItem(addonExchange))
{
_continueAt = DateTime.Now.AddSeconds(0.2);
CurrentStage = Stage.ConfirmReward;
_plugin.ContinueAt = DateTime.Now.AddSeconds(0.2);
_plugin.CurrentStage = Stage.ConfirmReward;
}
else
{
_continueAt = DateTime.Now.AddSeconds(0.2);
CurrentStage = Stage.CloseGcExchange;
_plugin.ContinueAt = DateTime.Now.AddSeconds(0.2);
_plugin.CurrentStage = Stage.CloseGcExchange;
}
}
}
@ -146,9 +167,11 @@ partial class DeliverooPlugin
if (itemId == item.ItemId)
{
_pluginLog.Information($"Selecting item {itemId}, {i}");
long toBuy = (GetCurrentSealCount() - EffectiveReservedSealCount) / item.SealCost;
long toBuy = (_gameFunctions.GetCurrentSealCount() - _plugin.EffectiveReservedSealCount) /
item.SealCost;
if (item.Type == Configuration.PurchaseType.KeepStocked)
toBuy = Math.Min(toBuy, item.EffectiveLimit - GetItemCount(item.ItemId, item.CheckRetainerInventory));
toBuy = Math.Min(toBuy,
item.EffectiveLimit - _gameFunctions.GetItemCount(item.ItemId, item.CheckRetainerInventory));
else
toBuy = Math.Min(toBuy, item.EffectiveLimit);
@ -186,7 +209,7 @@ partial class DeliverooPlugin
return false;
}
private unsafe void CloseGcExchange()
public unsafe void CloseGcExchange()
{
if (_gameGui.TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
LAddon.IsAddonReady(addonExchange))
@ -194,15 +217,15 @@ partial class DeliverooPlugin
addonExchange->FireCallbackInt(-1);
// If we just turned in the final item, there's no need to talk to the personnel officer again
if (_lastTurnInListSize == 1)
if (_plugin.LastTurnInListSize == 1)
{
_turnInWindow.State = false;
CurrentStage = Stage.RequestStop;
_plugin.TurnInState = false;
_plugin.CurrentStage = Stage.RequestStop;
}
else
{
_continueAt = DateTime.Now.AddSeconds(1);
CurrentStage = Stage.TargetPersonnelOfficer;
_plugin.ContinueAt = DateTime.Now.AddSeconds(1);
_plugin.CurrentStage = Stage.TargetPersonnelOfficer;
}
}
}

View File

@ -1,29 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Plugin.Services;
using Deliveroo.GameData;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Component.GUI;
using LLib;
using LLib.GameUI;
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
namespace Deliveroo;
partial class DeliverooPlugin
internal sealed class SupplyHandler
{
private void InteractWithPersonnelOfficer(GameObject personnelOfficer, GameObject quartermaster)
private readonly DeliverooPlugin _plugin;
private readonly GameFunctions _gameFunctions;
private readonly ITargetManager _targetManager;
private readonly IGameGui _gameGui;
private readonly IChatGui _chatGui;
private readonly ItemCache _itemCache;
private readonly IPluginLog _pluginLog;
private uint _turnInErrors;
public SupplyHandler(DeliverooPlugin plugin, GameFunctions gameFunctions, ITargetManager targetManager,
IGameGui gameGui, IChatGui chatGui, ItemCache itemCache, IPluginLog pluginLog)
{
_plugin = plugin;
_gameFunctions = gameFunctions;
_targetManager = targetManager;
_gameGui = gameGui;
_chatGui = chatGui;
_itemCache = itemCache;
_pluginLog = pluginLog;
}
public void InteractWithPersonnelOfficer(GameObject personnelOfficer, GameObject quartermaster)
{
if (_targetManager.Target == quartermaster)
return;
InteractWithTarget(personnelOfficer);
CurrentStage = Stage.OpenGcSupply;
_gameFunctions.InteractWithTarget(personnelOfficer);
_plugin.CurrentStage = Stage.OpenGcSupply;
}
private unsafe void SelectExpertDeliveryTab()
public unsafe void SelectExpertDeliveryTab()
{
var agentInterface = AgentModule.Instance()->GetAgentByInternalId(AgentId.GrandCompanySupply);
if (agentInterface != null && agentInterface->IsAgentActive())
@ -42,7 +67,7 @@ partial class DeliverooPlugin
{
_pluginLog.Information("Tab already selected, probably due to haseltweaks");
ResetTurnInErrorHandling();
CurrentStage = Stage.SelectItemToTurnIn;
_plugin.CurrentStage = Stage.SelectItemToTurnIn;
return;
}
@ -55,18 +80,18 @@ partial class DeliverooPlugin
};
addon->FireCallback(3, selectExpertDeliveryTab);
ResetTurnInErrorHandling();
CurrentStage = Stage.SelectItemToTurnIn;
_plugin.CurrentStage = Stage.SelectItemToTurnIn;
}
}
private void ResetTurnInErrorHandling(int listSize = int.MaxValue)
public void ResetTurnInErrorHandling(int listSize = int.MaxValue)
{
_pluginLog.Verbose("Resetting error handling state");
_lastTurnInListSize = listSize;
_plugin.LastTurnInListSize = listSize;
_turnInErrors = 0;
}
private unsafe void SelectItemToTurnIn()
public unsafe void SelectItemToTurnIn()
{
var agentInterface = AgentModule.Instance()->GetAgentByInternalId(AgentId.GrandCompanySupply);
if (agentInterface != null && agentInterface->IsAgentActive())
@ -86,14 +111,14 @@ partial class DeliverooPlugin
if (addonGc->SelectedTab != 2)
{
_turnInWindow.Error = "Wrong tab selected";
_plugin.TurnInError = "Wrong tab selected";
return;
}
ItemFilterType configuredFilter = ResolveSelectedSupplyFilter();
if (addonGc->SelectedFilter == 0 || addonGc->SelectedFilter != (int)configuredFilter)
{
_turnInWindow.Error =
_plugin.TurnInError =
$"Wrong filter selected (expected {configuredFilter}, but is {(ItemFilterType)addonGc->SelectedFilter})";
return;
}
@ -103,7 +128,7 @@ partial class DeliverooPlugin
{
_pluginLog.Information(
$"No items to turn in ({addonGc->ListEmptyTextNode->AtkResNode.IsVisible}, {currentListSize})");
CurrentStage = Stage.CloseGcSupplySelectStringThenStop;
_plugin.CurrentStage = Stage.CloseGcSupplySelectStringThenStop;
addon->FireCallbackInt(-1);
return;
}
@ -112,29 +137,29 @@ partial class DeliverooPlugin
// something is wrong.
if (_turnInErrors > 10)
{
_turnInWindow.Error = "Unable to refresh item list";
_plugin.TurnInError = "Unable to refresh item list";
return;
}
if (currentListSize >= _lastTurnInListSize)
if (currentListSize >= _plugin.LastTurnInListSize)
{
_turnInErrors++;
_pluginLog.Information(
$"Trying to refresh expert delivery list manually ({_turnInErrors}, old list size = {_lastTurnInListSize}, new list size = {currentListSize})...");
$"Trying to refresh expert delivery list manually ({_turnInErrors}, old list size = {_plugin.LastTurnInListSize}, new list size = {currentListSize})...");
addon->FireCallbackInt(2);
_continueAt = DateTime.Now.AddSeconds(0.1);
_plugin.ContinueAt = DateTime.Now.AddSeconds(0.1);
return;
}
ResetTurnInErrorHandling(currentListSize);
var agent = (AgentGrandCompanySupply*)agentInterface;
List<TurnInItem> items = BuildTurnInList(agent);
List<TurnInItem> items = _gameFunctions.BuildTurnInList(agent);
if (items.Count == 0)
{
// probably shouldn't happen with the previous node visibility check
CurrentStage = Stage.CloseGcSupplySelectStringThenStop;
_plugin.CurrentStage = Stage.CloseGcSupplySelectStringThenStop;
addon->FireCallbackInt(-1);
return;
}
@ -158,9 +183,9 @@ partial class DeliverooPlugin
// ---------------------------------------------------------------------------------------------------------
// TODO If we ever manage to obtain a mapping name to itemId here, we can try and exclude e.g. Red Onion
// Helms from being turned in.
if (GetCurrentSealCount() + items[0].SealsWithBonus > GetSealCap())
if (_gameFunctions.GetCurrentSealCount() + items[0].SealsWithBonus > _gameFunctions.GetSealCap())
{
CurrentStage = Stage.CloseGcSupplySelectString;
_plugin.CurrentStage = Stage.CloseGcSupplySelectString;
addon->FireCallbackInt(-1);
return;
}
@ -172,11 +197,11 @@ partial class DeliverooPlugin
new() { Type = 0, Int = 0 }
};
addon->FireCallback(3, selectFirstItem);
CurrentStage = Stage.TurnInSelected;
_plugin.CurrentStage = Stage.TurnInSelected;
}
}
private unsafe void TurnInSelectedItem()
public unsafe void TurnInSelectedItem()
{
if (_gameGui.TryGetAddonByName<AddonGrandCompanySupplyReward>("GrandCompanySupplyReward",
out var addonSupplyReward) && LAddon.IsAddonReady(&addonSupplyReward->AtkUnitBase))
@ -191,19 +216,19 @@ partial class DeliverooPlugin
.Build());
addonSupplyReward->AtkUnitBase.FireCallbackInt(1);
CurrentStage = Stage.CloseGcSupplyWindowThenStop;
_plugin.CurrentStage = Stage.CloseGcSupplyWindowThenStop;
return;
}
_pluginLog.Information($"Turning in '{itemName}'");
addonSupplyReward->AtkUnitBase.FireCallbackInt(0);
_continueAt = DateTime.Now.AddSeconds(0.58);
CurrentStage = Stage.FinalizeTurnIn;
_plugin.ContinueAt = DateTime.Now.AddSeconds(0.58);
_plugin.CurrentStage = Stage.FinalizeTurnIn;
}
}
private unsafe void FinalizeTurnInItem()
public unsafe void FinalizeTurnInItem()
{
if (_gameGui.TryGetAddonByName<AddonGrandCompanySupplyList>("GrandCompanySupplyList",
out var addonSupplyList) && LAddon.IsAddonReady(&addonSupplyList->AtkUnitBase))
@ -215,19 +240,19 @@ partial class DeliverooPlugin
new() { Type = 0, Int = 0 }
};
addonSupplyList->AtkUnitBase.FireCallback(3, updateFilter);
CurrentStage = Stage.SelectItemToTurnIn;
_plugin.CurrentStage = Stage.SelectItemToTurnIn;
}
}
private ItemFilterType ResolveSelectedSupplyFilter()
{
if (CharacterConfiguration is { UseHideArmouryChestItemsFilter: true })
if (_plugin.CharacterConfiguration is { UseHideArmouryChestItemsFilter: true })
return ItemFilterType.HideArmouryChestItems;
return ItemFilterType.HideGearSetItems;
}
private unsafe void CloseGcSupplyWindow()
public unsafe void CloseGcSupplyWindow()
{
var agentInterface = AgentModule.Instance()->GetAgentByInternalId(AgentId.GrandCompanySupply);
if (agentInterface != null && agentInterface->IsAgentActive())
@ -240,7 +265,7 @@ partial class DeliverooPlugin
if (addon == null || !LAddon.IsAddonReady(addon))
return;
CurrentStage = Stage.CloseGcSupplySelectStringThenStop;
_plugin.CurrentStage = Stage.CloseGcSupplySelectStringThenStop;
addon->FireCallbackInt(-1);
}
}

View File

@ -25,13 +25,15 @@ internal sealed class ConfigWindow : LWindow
private readonly IClientState _clientState;
private readonly IPluginLog _pluginLog;
private readonly IconCache _iconCache;
private readonly GameFunctions _gameFunctions;
private readonly IReadOnlyDictionary<uint, GcRewardItem> _itemLookup;
private string _searchString = string.Empty;
private uint _dragDropSource;
public ConfigWindow(DalamudPluginInterface pluginInterface, DeliverooPlugin plugin, Configuration configuration,
GcRewardsCache gcRewardsCache, IClientState clientState, IPluginLog pluginLog, IconCache iconCache)
GcRewardsCache gcRewardsCache, IClientState clientState, IPluginLog pluginLog, IconCache iconCache,
GameFunctions gameFunctions)
: base("Deliveroo - Configuration###DeliverooConfig")
{
_pluginInterface = pluginInterface;
@ -41,6 +43,7 @@ internal sealed class ConfigWindow : LWindow
_clientState = clientState;
_pluginLog = pluginLog;
_iconCache = iconCache;
_gameFunctions = gameFunctions;
_itemLookup = _gcRewardsCache.RewardLookup;
@ -76,7 +79,8 @@ internal sealed class ConfigWindow : LWindow
uint? itemToRemove = null;
uint? itemToAdd = null;
int indexToAdd = 0;
if (ImGui.BeginChild("Items", new Vector2(-1, -ImGui.GetFrameHeightWithSpacing()), true, ImGuiWindowFlags.NoSavedSettings))
if (ImGui.BeginChild("Items", new Vector2(-1, -ImGui.GetFrameHeightWithSpacing()), true,
ImGuiWindowFlags.NoSavedSettings))
{
for (int i = 0; i < _configuration.ItemsAvailableForPurchase.Count; ++i)
{
@ -91,10 +95,12 @@ internal sealed class ConfigWindow : LWindow
Vector2 iconSize = new Vector2(ImGui.GetTextLineHeight() + ImGui.GetStyle().ItemSpacing.Y);
if (icon != null)
{
ImGui.SetCursorPos(pos + new Vector2(iconSize.X + ImGui.GetStyle().FramePadding.X, ImGui.GetStyle().ItemSpacing.Y / 2));
ImGui.SetCursorPos(pos + new Vector2(iconSize.X + ImGui.GetStyle().FramePadding.X,
ImGui.GetStyle().ItemSpacing.Y / 2));
}
ImGui.Selectable($"{item.Name}{(item.Limited ? $" {SeIconChar.Hyadelyn.ToIconString()}" : "")}", false, ImGuiSelectableFlags.SpanAllColumns);
ImGui.Selectable($"{item.Name}{(item.Limited ? $" {SeIconChar.Hyadelyn.ToIconString()}" : "")}",
false, ImGuiSelectableFlags.SpanAllColumns);
if (icon != null)
{
@ -168,7 +174,8 @@ internal sealed class ConfigWindow : LWindow
bool addFirst = ImGui.InputTextWithHint("", "Filter...", ref _searchString, 256,
ImGuiInputTextFlags.AutoSelectAll | ImGuiInputTextFlags.EnterReturnsTrue);
foreach (var item in comboValues.Where(x => x.Name.Contains(_searchString, StringComparison.OrdinalIgnoreCase)))
foreach (var item in comboValues.Where(x =>
x.Name.Contains(_searchString, StringComparison.OrdinalIgnoreCase)))
{
IDalamudTextureWrap? icon = _iconCache.GetIcon(item.IconId);
if (icon != null)
@ -322,7 +329,7 @@ internal sealed class ConfigWindow : LWindow
if (ImGui.InputInt("Minimum Seals to keep (e.g. for Squadron Missions)", ref reservedSealCount, 1000))
{
_configuration.ReservedSealCount =
Math.Max(0, Math.Min((int)_plugin.MaxSealCap, reservedSealCount));
Math.Max(0, Math.Min((int)_gameFunctions.MaxSealCap, reservedSealCount));
Save();
}
@ -343,7 +350,7 @@ internal sealed class ConfigWindow : LWindow
if (ImGui.InputInt("Minimum seals to keep at max rank", ref reservedSealCountAtMaxRank))
{
_configuration.ReservedSealCountAtMaxRank = Math.Max(0,
Math.Min((int)_plugin.MaxSealCap, reservedSealCountAtMaxRank));
Math.Min((int)_gameFunctions.MaxSealCap, reservedSealCountAtMaxRank));
Save();
}

View File

@ -52,12 +52,13 @@ internal sealed class TurnInWindow : LWindow
private readonly GcRewardsCache _gcRewardsCache;
private readonly ConfigWindow _configWindow;
private readonly IconCache _iconCache;
private readonly GameFunctions _gameFunctions;
private bool _state;
public TurnInWindow(DeliverooPlugin plugin, DalamudPluginInterface pluginInterface, Configuration configuration,
ICondition condition, IClientState clientState, GcRewardsCache gcRewardsCache, ConfigWindow configWindow,
IconCache iconCache)
IconCache iconCache, GameFunctions gameFunctions)
: base("GC Delivery###DeliverooTurnIn")
{
_plugin = plugin;
@ -68,6 +69,7 @@ internal sealed class TurnInWindow : LWindow
_gcRewardsCache = gcRewardsCache;
_configWindow = configWindow;
_iconCache = iconCache;
_gameFunctions = gameFunctions;
Position = new Vector2(100, 100);
PositionCondition = ImGuiCond.FirstUseEver;
@ -128,11 +130,11 @@ internal sealed class TurnInWindow : LWindow
{
get
{
GrandCompany grandCompany = _plugin.GetGrandCompany();
GrandCompany grandCompany = _gameFunctions.GetGrandCompany();
if (grandCompany == GrandCompany.None)
return new List<PurchaseItemRequest>();
var rank = _plugin.GetGrandCompanyRank();
var rank = _gameFunctions.GetGrandCompanyRank();
return ItemsWrapper.GetItemsToPurchase()
.Where(x => x.ItemId != GcRewardItem.None.ItemId)
.Where(x => x.Enabled)
@ -176,7 +178,7 @@ internal sealed class TurnInWindow : LWindow
public override unsafe void Draw()
{
GrandCompany grandCompany = _plugin.GetGrandCompany();
GrandCompany grandCompany = _gameFunctions.GetGrandCompany();
if (grandCompany == GrandCompany.None)
{
// not sure we should ever get here
@ -184,7 +186,7 @@ internal sealed class TurnInWindow : LWindow
return;
}
if (_plugin.GetGrandCompanyRank() < 6)
if (_gameFunctions.GetGrandCompanyRank() < 6)
{
State = false;
ImGui.TextColored(ImGuiColors.DalamudRed, "You do not have the required rank for Expert Delivery.");
@ -262,18 +264,19 @@ internal sealed class TurnInWindow : LWindow
private unsafe void DrawNextRankPrequesites()
{
string? rankName = _plugin.GetNextGrandCompanyRankName();
string? rankName = _gameFunctions.GetNextGrandCompanyRankName();
if (rankName != null)
{
int currentSeals = _plugin.GetCurrentSealCount();
uint requiredSeals = _plugin.GetSealsRequiredForNextRank();
int currentSeals = _gameFunctions.GetCurrentSealCount();
uint requiredSeals = _gameFunctions.GetSealsRequiredForNextRank();
int currentHuntingLog = MonsterNoteManager.Instance()->RankDataArraySpan[(int)_plugin.GetGrandCompany() + 7]
int currentHuntingLog =
MonsterNoteManager.Instance()->RankDataArraySpan[(int)_gameFunctions.GetGrandCompany() + 7]
.Rank;
byte requiredHuntingLog = _plugin.GetRequiredHuntingLogForNextRank();
byte requiredHuntingLog = _gameFunctions.GetRequiredHuntingLogForNextRank();
bool enoughSeals = currentSeals >= requiredSeals;
bool enoughHuntingLog = requiredHuntingLog >= currentHuntingLog;
bool enoughHuntingLog = currentHuntingLog >= requiredHuntingLog;
if (enoughSeals && enoughHuntingLog)
ImGui.TextColored(ImGuiColors.HealerGreen, $"You meet all requirements to rank up to {rankName}.");
@ -318,8 +321,8 @@ internal sealed class TurnInWindow : LWindow
foreach (uint itemId in _configuration.ItemsAvailableForPurchase)
{
var gcReward = _gcRewardsCache.GetReward(itemId);
int itemCountWithoutRetainers = _plugin.GetItemCount(itemId, false);
int itemCountWithRetainers = _plugin.GetItemCount(itemId, true);
int itemCountWithoutRetainers = _gameFunctions.GetItemCount(itemId, false);
int itemCountWithRetainers = _gameFunctions.GetItemCount(itemId, true);
string itemNameWithoutRetainers = gcReward.Name;
string itemNameWithRetainers = gcReward.Name;
if (itemCountWithoutRetainers > 0)
@ -479,7 +482,7 @@ internal sealed class TurnInWindow : LWindow
ImGui.TextColored(ImGuiColors.DalamudRed,
"This item will be skipped, as you are in the wrong Grand Company.");
}
else if (comboItem.Item.RequiredRank > _plugin.GetGrandCompanyRank())
else if (comboItem.Item.RequiredRank > _gameFunctions.GetGrandCompanyRank())
{
ImGui.TextColored(ImGuiColors.DalamudRed,
"This item will be skipped, your rank isn't high enough to buy it.");