Make reserved seal count configurable, load seal cap from excel
This commit is contained in:
parent
a9b72380cd
commit
7a5dbe095d
@ -9,4 +9,6 @@ internal sealed class Configuration : IPluginConfiguration
|
||||
|
||||
public List<uint> ItemsAvailableForPurchase { get; set; } = new();
|
||||
public uint SelectedPurchaseItemId { get; set; } = 0;
|
||||
|
||||
public int ReservedSealCount { get; set; } = 0;
|
||||
}
|
||||
|
@ -22,7 +22,9 @@ using FFXIVClientStructs.FFXIV.Client.Game.UI;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using Character = Dalamud.Game.ClientState.Objects.Types.Character;
|
||||
using GrandCompany = FFXIVClientStructs.FFXIV.Client.UI.Agent.GrandCompany;
|
||||
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
|
||||
|
||||
namespace Deliveroo;
|
||||
@ -41,10 +43,12 @@ public sealed class DeliverooPlugin : IDalamudPlugin
|
||||
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
private readonly Configuration _configuration;
|
||||
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
private readonly GcRewardsCache _gcRewardsCache;
|
||||
private readonly ConfigWindow _configWindow;
|
||||
private readonly TurnInWindow _turnInWindow;
|
||||
private readonly IReadOnlyDictionary<uint, uint> _sealCaps;
|
||||
|
||||
private Stage _currentStageInternal = Stage.Stop;
|
||||
private DateTime _continueAt = DateTime.MinValue;
|
||||
@ -68,6 +72,8 @@ public sealed class DeliverooPlugin : IDalamudPlugin
|
||||
_windowSystem.AddWindow(_configWindow);
|
||||
_turnInWindow = new TurnInWindow(this, _pluginInterface, _configuration, _gcRewardsCache);
|
||||
_windowSystem.AddWindow(_turnInWindow);
|
||||
_sealCaps = dataManager.GetExcelSheet<GrandCompanyRank>()!.Where(x => x.RowId > 0)
|
||||
.ToDictionary(x => x.RowId, x => x.MaxSeals);
|
||||
|
||||
_framework.Update += FrameworkUpdate;
|
||||
_pluginInterface.UiBuilder.Draw += _windowSystem.Draw;
|
||||
@ -252,7 +258,8 @@ public sealed class DeliverooPlugin : IDalamudPlugin
|
||||
_turnInWindow.State = false;
|
||||
CurrentStage = Stage.Stop;
|
||||
}
|
||||
else if (GetCurrentSealCount() <= 2000 + _selectedRewardItem.SealCost)
|
||||
else if (GetCurrentSealCount() <=
|
||||
_configuration.ReservedSealCount + _selectedRewardItem.SealCost)
|
||||
{
|
||||
_turnInWindow.State = false;
|
||||
CurrentStage = Stage.Stop;
|
||||
@ -267,7 +274,7 @@ public sealed class DeliverooPlugin : IDalamudPlugin
|
||||
break;
|
||||
|
||||
case Stage.TargetQuartermaster:
|
||||
if (GetCurrentSealCount() < 2000) // fixme this should be selectable/dependent on shop item
|
||||
if (GetCurrentSealCount() < _configuration.ReservedSealCount)
|
||||
{
|
||||
CurrentStage = Stage.Stop;
|
||||
break;
|
||||
@ -499,7 +506,7 @@ public sealed class DeliverooPlugin : IDalamudPlugin
|
||||
uint itemId = addonExchange->AtkValues[317 + i].UInt;
|
||||
if (itemId == _selectedRewardItem.ItemId)
|
||||
{
|
||||
long toBuy = (GetCurrentSealCount() - 2000) / _selectedRewardItem.SealCost;
|
||||
long toBuy = (GetCurrentSealCount() - _configuration.ReservedSealCount) / _selectedRewardItem.SealCost;
|
||||
bool isVenture = _selectedRewardItem.ItemId == ItemIds.Venture;
|
||||
if (isVenture)
|
||||
toBuy = Math.Min(toBuy, 65000 - GetCurrentVentureCount());
|
||||
@ -575,24 +582,7 @@ public sealed class DeliverooPlugin : IDalamudPlugin
|
||||
};
|
||||
}
|
||||
|
||||
private int GetSealCap()
|
||||
{
|
||||
return GetGrandCompanyRank() switch
|
||||
{
|
||||
1 => 10_000,
|
||||
2 => 15_000,
|
||||
3 => 20_000,
|
||||
4 => 25_000,
|
||||
5 => 30_000,
|
||||
6 => 35_000,
|
||||
7 => 40_000,
|
||||
8 => 45_000,
|
||||
9 => 50_000,
|
||||
10 => 80_000,
|
||||
11 => 90_000,
|
||||
_ => 0,
|
||||
};
|
||||
}
|
||||
private uint GetSealCap() => _sealCaps.TryGetValue(GetGrandCompanyRank(), out var cap) ? cap : 0;
|
||||
|
||||
private unsafe int GetCurrentVentureCount()
|
||||
{
|
||||
|
@ -1,8 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Logging;
|
||||
using Dalamud.Plugin;
|
||||
using Deliveroo.GameData;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
@ -34,30 +35,48 @@ internal sealed class ConfigWindow : Window
|
||||
.Distinct()
|
||||
.ToDictionary(x => x.ItemId, x => x);
|
||||
|
||||
Size = new Vector2(400, 300);
|
||||
Size = new Vector2(420, 300);
|
||||
SizeCondition = ImGuiCond.Appearing;
|
||||
|
||||
SizeConstraints = new WindowSizeConstraints
|
||||
{
|
||||
MinimumSize = new Vector2(420, 300),
|
||||
MaximumSize = new Vector2(9999, 9999),
|
||||
};
|
||||
}
|
||||
|
||||
public override unsafe void Draw()
|
||||
public override void Draw()
|
||||
{
|
||||
ImGui.Text("Items available for Auto-Buy:");
|
||||
uint? itemToRemove = null;
|
||||
uint? itemToAdd = null;
|
||||
int indexToAdd = 0;
|
||||
|
||||
if (_configuration.ItemsAvailableForPurchase.Count == 0)
|
||||
{
|
||||
_configuration.ItemsAvailableForPurchase.Add(ItemIds.Venture);
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
Save();
|
||||
}
|
||||
|
||||
if (ImGui.BeginTabBar("DeliverooConfigTabs"))
|
||||
{
|
||||
DrawBuyList();
|
||||
DrawAdditionalSettings();
|
||||
|
||||
ImGui.EndTabBar();
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe void DrawBuyList()
|
||||
{
|
||||
if (ImGui.BeginTabItem("Items for Auto-Buy"))
|
||||
{
|
||||
uint? itemToRemove = null;
|
||||
uint? itemToAdd = null;
|
||||
int indexToAdd = 0;
|
||||
if (ImGui.BeginChild("Items", new Vector2(-1, -30), true, ImGuiWindowFlags.NoSavedSettings))
|
||||
{
|
||||
for (int i = 0; i < _configuration.ItemsAvailableForPurchase.Count; ++i)
|
||||
{
|
||||
uint itemId = _configuration.ItemsAvailableForPurchase[i];
|
||||
ImGui.PushID($"###Item{i}");
|
||||
ImGui.BeginDisabled(_configuration.ItemsAvailableForPurchase.Count == 1 && itemId == ItemIds.Venture);
|
||||
ImGui.BeginDisabled(
|
||||
_configuration.ItemsAvailableForPurchase.Count == 1 && itemId == ItemIds.Venture);
|
||||
|
||||
ImGui.Selectable(_itemLookup[itemId].Name);
|
||||
|
||||
@ -99,20 +118,21 @@ internal sealed class ConfigWindow : Window
|
||||
if (itemToRemove != null)
|
||||
{
|
||||
_configuration.ItemsAvailableForPurchase.Remove(itemToRemove.Value);
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
Save();
|
||||
}
|
||||
|
||||
if (itemToAdd != null)
|
||||
{
|
||||
_configuration.ItemsAvailableForPurchase.Remove(itemToAdd.Value);
|
||||
_configuration.ItemsAvailableForPurchase.Insert(indexToAdd, itemToAdd.Value);
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
Save();
|
||||
}
|
||||
|
||||
if (_plugin.GetGrandCompany() != GrandCompany.None)
|
||||
{
|
||||
List<(uint ItemId, string Name)> comboValues = _gcRewardsCache.Rewards[_plugin.GetGrandCompany()]
|
||||
.Where(x => x.SubCategory == RewardSubCategory.Materials || x.SubCategory == RewardSubCategory.Materiel)
|
||||
.Where(x => x.SubCategory == RewardSubCategory.Materials ||
|
||||
x.SubCategory == RewardSubCategory.Materiel)
|
||||
.Where(x => x.StackSize > 1)
|
||||
.Where(x => !_configuration.ItemsAvailableForPurchase.Contains(x.ItemId))
|
||||
.Select(x => (x.ItemId, x.Name))
|
||||
@ -122,10 +142,11 @@ internal sealed class ConfigWindow : Window
|
||||
comboValues.Insert(0, (0, ""));
|
||||
|
||||
int currentItem = 0;
|
||||
if (ImGui.Combo("Add Item", ref currentItem, comboValues.Select(x => x.Name).ToArray(), comboValues.Count))
|
||||
if (ImGui.Combo("Add Item", ref currentItem, comboValues.Select(x => x.Name).ToArray(),
|
||||
comboValues.Count))
|
||||
{
|
||||
_configuration.ItemsAvailableForPurchase.Add(comboValues[currentItem].ItemId);
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
Save();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -134,6 +155,24 @@ internal sealed class ConfigWindow : Window
|
||||
ImGui.Combo("Add Item", ref currentItem, new string[] { "(Not part of a GC)" }, 1);
|
||||
}
|
||||
|
||||
ImGui.Unindent(30);
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawAdditionalSettings()
|
||||
{
|
||||
if (ImGui.BeginTabItem("Additional Settings"))
|
||||
{
|
||||
ImGui.SetNextItemWidth(ImGuiHelpers.GlobalScale * 100);
|
||||
int reservedSealCount = _configuration.ReservedSealCount;
|
||||
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));
|
||||
Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Save() => _pluginInterface.SavePluginConfig(_configuration);
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Logging;
|
||||
using Dalamud.Plugin;
|
||||
using Deliveroo.GameData;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
|
Loading…
Reference in New Issue
Block a user