Remove estimated seals (wrong estimates), add some notes on seal overcapping

pull/3/head
Liza 2023-09-24 17:41:08 +02:00
parent 601c928f18
commit a8ba89da4c
Signed by: liza
GPG Key ID: 7199F8D727D55F67
4 changed files with 38 additions and 27 deletions

View File

@ -120,6 +120,9 @@ partial class DeliverooPlugin
return 1;
}
/// <summary>
/// This returns ALL items that can be turned in, regardless of filter settings.
/// </summary>
private unsafe List<TurnInItem> BuildTurnInList(AgentGrandCompanySupply* agent)
{
List<TurnInItem> list = new();

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Logging;
using Dalamud.Memory;
using Deliveroo.GameData;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
@ -72,11 +73,13 @@ partial class DeliverooPlugin
return;
AtkUnitBase* addon = GetAddonById(addonId);
if (addon == null || !IsAddonReady(addon) || addon->UldManager.NodeListCount <= 20 ||
!addon->UldManager.NodeList[5]->IsVisible)
if (addon == null || !IsAddonReady(addon) || addon->UldManager.NodeListCount <= 20)
return;
var addonGc = (AddonGrandCompanySupplyList*)addon;
if (addonGc->ExpertDeliveryList == null || !addonGc->ExpertDeliveryList->AtkComponentBase.OwnerNode->AtkResNode.IsVisible)
return;
if (addonGc->SelectedTab != 2)
{
_turnInWindow.Error = "Wrong tab selected";
@ -90,16 +93,42 @@ partial class DeliverooPlugin
return;
}
var agent = (AgentGrandCompanySupply*)agentInterface;
List<TurnInItem> items = BuildTurnInList(agent);
_turnInWindow.EstimatedGcSeals = GetCurrentSealCount() + items.Sum(x => x.SealsWithBonus);
if (items.Count == 0 || addon->UldManager.NodeList[20]->IsVisible)
if (addonGc->ListEmptyTextNode->AtkResNode.IsVisible)
{
CurrentStage = Stage.CloseGcSupplyThenStop;
addon->FireCallbackInt(-1);
return;
}
var agent = (AgentGrandCompanySupply*)agentInterface;
List<TurnInItem> items = BuildTurnInList(agent);
if (items.Count == 0)
{
// probably shouldn't happen with the previous node visibility check
CurrentStage = Stage.CloseGcSupplyThenStop;
addon->FireCallbackInt(-1);
return;
}
// TODO The way the items are handled above, we don't actually know if items[0] is the first visible item
// in the list, it is "only" the highest-value item to turn in.
//
// For example, if you have
// - Trojan Ring, SealsWithoutBonus = 1887, part of a gear set
// - Radiant Battleaxe, SealsWithoutBonus = 1879, not part of a gear set
// then this algorithm will ensure that you have enough space for the highest-value item (trojan ring), even
// though it turn in the Radiant Battleaxe.
//
// Alternatively, and probably easier:
// - look up how many seals the first item gets
// - find *any* item in the list with that seal count (and possibly matching the name) to determine the
// seals with bonus + whether it exists
// - use that item instead of items[0] here
//
// However, since this never over-caps seals, this isn't a very high priority.
// ---------------------------------------------------------------------------------------------------------
// 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())
{
CurrentStage = Stage.CloseGcSupply;

View File

@ -1,32 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.Gui;
using Dalamud.Interface.Windowing;
using Dalamud.Logging;
using Dalamud.Memory;
using Dalamud.Plugin;
using Deliveroo.External;
using Deliveroo.GameData;
using Deliveroo.Windows;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Control;
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;

View File

@ -47,7 +47,6 @@ internal sealed class TurnInWindow : Window
public bool State { get; set; }
public decimal Multiplier { private get; set; }
public int EstimatedGcSeals { private get; set; }
public string Error { private get; set; } = string.Empty;
public List<PurchaseItemRequest> SelectedItems
@ -135,15 +134,6 @@ internal sealed class TurnInWindow : Window
ImGui.Separator();
ImGui.Text($"Debug (State): {_plugin.CurrentStage}");
switch (_plugin.CurrentStage)
{
case Stage.SelectItemToTurnIn:
case Stage.TurnInSelected:
case Stage.FinalizeTurnIn:
case Stage.CloseGcSupply:
ImGui.Text($"Estimated Total Seal Count: {EstimatedGcSeals:N0}");
break;
}
}
private void DrawItemsToBuy(GrandCompany grandCompany)