Add option for a (lower) reserved seal cap at max GC rank

This commit is contained in:
Liza 2023-10-18 10:12:27 +02:00
parent afd7cab940
commit 5de29f514c
Signed by: liza
GPG Key ID: 7199F8D727D55F67
8 changed files with 43 additions and 14 deletions

View File

@ -11,7 +11,9 @@ internal sealed class Configuration : IPluginConfiguration
public List<uint> ItemsAvailableForPurchase { get; set; } = new(); public List<uint> ItemsAvailableForPurchase { get; set; } = new();
public List<PurchasePriority> ItemsToPurchase { get; set; } = new(); public List<PurchasePriority> ItemsToPurchase { get; set; } = new();
public int ReservedSealCount { get; set; } = 0; public int ReservedSealCount { get; set; }
public bool ReserveDifferentSealCountAtMaxRank { get; set; }
public int ReservedSealCountAtMaxRank { get; set; }
/// <summary> /// <summary>
/// A config-only setting, not exposed in the UI. /// A config-only setting, not exposed in the UI.

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework> <TargetFramework>net7.0-windows</TargetFramework>
<Version>2.11</Version> <Version>2.12</Version>
<LangVersion>11.0</LangVersion> <LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

View File

@ -11,7 +11,7 @@ partial class DeliverooPlugin
{ {
private void InteractWithQuartermaster(GameObject personnelOfficer, GameObject quartermaster) private void InteractWithQuartermaster(GameObject personnelOfficer, GameObject quartermaster)
{ {
if (GetCurrentSealCount() < _configuration.ReservedSealCount) if (GetCurrentSealCount() < EffectiveReservedSealCount)
{ {
CurrentStage = Stage.RequestStop; CurrentStage = Stage.RequestStop;
return; return;
@ -132,7 +132,7 @@ partial class DeliverooPlugin
if (itemId == item.ItemId) if (itemId == item.ItemId)
{ {
_pluginLog.Information($"Selecting item {itemId}, {i}"); _pluginLog.Information($"Selecting item {itemId}, {i}");
long toBuy = (GetCurrentSealCount() - _configuration.ReservedSealCount) / item.SealCost; long toBuy = (GetCurrentSealCount() - EffectiveReservedSealCount) / item.SealCost;
toBuy = Math.Min(toBuy, item.EffectiveLimit - GetItemCount(item.ItemId)); toBuy = Math.Min(toBuy, item.EffectiveLimit - GetItemCount(item.ItemId));
if (item.ItemId != ItemIds.Venture && !_configuration.IgnoreCertainLimitations) if (item.ItemId != ItemIds.Venture && !_configuration.IgnoreCertainLimitations)

View File

@ -11,7 +11,6 @@ using FFXIVClientStructs.FFXIV.Client.Game.Control;
using FFXIVClientStructs.FFXIV.Client.Game.UI; using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent; using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Common.Math; using FFXIVClientStructs.FFXIV.Common.Math;
using FFXIVClientStructs.FFXIV.Component.GUI;
namespace Deliveroo; namespace Deliveroo;
@ -96,6 +95,8 @@ partial class DeliverooPlugin
private uint GetSealCap() => _sealCaps.TryGetValue(GetGrandCompanyRank(), out var cap) ? cap : 0; private uint GetSealCap() => _sealCaps.TryGetValue(GetGrandCompanyRank(), out var cap) ? cap : 0;
public uint GetMaxSealCap() => _sealCaps[11];
public unsafe int GetItemCount(uint itemId) public unsafe int GetItemCount(uint itemId)
{ {
InventoryManager* inventoryManager = InventoryManager.Instance(); InventoryManager* inventoryManager = InventoryManager.Instance();

View File

@ -86,8 +86,7 @@ partial class DeliverooPlugin
_turnInWindow.State = false; _turnInWindow.State = false;
CurrentStage = Stage.RequestStop; CurrentStage = Stage.RequestStop;
} }
else if (GetCurrentSealCount() <= else if (GetCurrentSealCount() <= EffectiveReservedSealCount + GetNextItemToPurchase()!.SealCost)
_configuration.ReservedSealCount + GetNextItemToPurchase()!.SealCost)
{ {
_turnInWindow.State = false; _turnInWindow.State = false;
CurrentStage = Stage.RequestStop; CurrentStage = Stage.RequestStop;

View File

@ -31,7 +31,7 @@ partial class DeliverooPlugin
addonSelectYesNo->AtkUnitBase.FireCallbackInt(0); addonSelectYesNo->AtkUnitBase.FireCallbackInt(0);
var nextItem = GetNextItemToPurchase(item); var nextItem = GetNextItemToPurchase(item);
if (nextItem != null && GetCurrentSealCount() >= _configuration.ReservedSealCount + nextItem.SealCost) if (nextItem != null && GetCurrentSealCount() >= EffectiveReservedSealCount + nextItem.SealCost)
CurrentStage = Stage.SelectRewardTier; CurrentStage = Stage.SelectRewardTier;
else else
CurrentStage = Stage.CloseGcExchange; CurrentStage = Stage.CloseGcExchange;

View File

@ -118,6 +118,11 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
} }
} }
public int EffectiveReservedSealCount =>
_configuration.ReserveDifferentSealCountAtMaxRank && GetSealCap() == GetMaxSealCap()
? _configuration.ReservedSealCountAtMaxRank
: _configuration.ReservedSealCount;
private void Login() private void Login()
{ {
try try
@ -205,7 +210,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
var nextItem = GetNextItemToPurchase(); var nextItem = GetNextItemToPurchase();
if (nextItem != null && GetCurrentSealCount() >= _configuration.ReservedSealCount + nextItem.SealCost) if (nextItem != null && GetCurrentSealCount() >= EffectiveReservedSealCount + nextItem.SealCost)
CurrentStage = Stage.TargetQuartermaster; CurrentStage = Stage.TargetQuartermaster;
if (_gameGui.TryGetAddonByName<AddonGrandCompanySupplyList>("GrandCompanySupplyList", out var gcSupplyList) && if (_gameGui.TryGetAddonByName<AddonGrandCompanySupplyList>("GrandCompanySupplyList", out var gcSupplyList) &&

View File

@ -39,12 +39,12 @@ internal sealed class ConfigWindow : Window
_itemLookup = _gcRewardsCache.RewardLookup; _itemLookup = _gcRewardsCache.RewardLookup;
Size = new Vector2(420, 300); Size = new Vector2(440, 300);
SizeCondition = ImGuiCond.Appearing; SizeCondition = ImGuiCond.FirstUseEver;
SizeConstraints = new WindowSizeConstraints SizeConstraints = new WindowSizeConstraints
{ {
MinimumSize = new Vector2(420, 300), MinimumSize = new Vector2(440, 300),
MaximumSize = new Vector2(9999, 9999), MaximumSize = new Vector2(9999, 9999),
}; };
} }
@ -261,14 +261,36 @@ internal sealed class ConfigWindow : Window
{ {
if (ImGui.BeginTabItem("Additional Settings")) if (ImGui.BeginTabItem("Additional Settings"))
{ {
ImGui.SetNextItemWidth(ImGuiHelpers.GlobalScale * 100); ImGui.SetNextItemWidth(ImGuiHelpers.GlobalScale * 120);
int reservedSealCount = _configuration.ReservedSealCount; int reservedSealCount = _configuration.ReservedSealCount;
if (ImGui.InputInt("Minimum Seals to keep (e.g. for Squadron Missions)", ref reservedSealCount, 1000)) if (ImGui.InputInt("Minimum Seals to keep (e.g. for Squadron Missions)", ref reservedSealCount, 1000))
{ {
_configuration.ReservedSealCount = Math.Max(0, Math.Min(90_000, reservedSealCount)); _configuration.ReservedSealCount = Math.Max(0, Math.Min((int)_plugin.GetMaxSealCap(), reservedSealCount));
Save(); Save();
} }
ImGui.BeginDisabled(reservedSealCount <= 0);
bool reserveDifferentSealCountAtMaxRank = _configuration.ReserveDifferentSealCountAtMaxRank;
if (ImGui.Checkbox("Use a different amount at max rank", ref reserveDifferentSealCountAtMaxRank))
{
_configuration.ReserveDifferentSealCountAtMaxRank = reserveDifferentSealCountAtMaxRank;
Save();
}
if (reserveDifferentSealCountAtMaxRank)
{
ImGui.Indent();
ImGui.SetNextItemWidth(ImGuiHelpers.GlobalScale * 100);
int reservedSealCountAtMaxRank = _configuration.ReservedSealCountAtMaxRank;
if (ImGui.InputInt("Minimum seals to keep at max rank", ref reservedSealCountAtMaxRank))
{
_configuration.ReservedSealCountAtMaxRank = Math.Max(0, Math.Min((int)_plugin.GetMaxSealCap(), reservedSealCountAtMaxRank));
Save();
}
ImGui.Unindent();
}
ImGui.EndDisabled();
ImGui.EndTabItem(); ImGui.EndTabItem();
} }
} }