Skip to content

Commit

Permalink
Merge pull request #5 from FFXIV-CombatReborn/sweep-improvements-2
Browse files Browse the repository at this point in the history
Supermarket sweep improvements
  • Loading branch information
NostraThomas99 authored Oct 11, 2024
2 parents 9b54584 + 7589ece commit e5cce4f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .idea/.idea.RebornToolbox/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public class MBShoppingList_Config
{
public bool Enabled { get; set; } = false;
public RegionType ShoppingRegion { get; set; } = RegionType.NorthAmerica;
public int MaxResults { get; set; } = 100;
public int LifeStreamTimeout { get; set; } = 300;
public bool UseVnavPathing { get; set; } = false;
public bool RemoveQuantityAutomatically { get; set; } = false;
Expand Down
6 changes: 0 additions & 6 deletions RebornToolbox/Features/MBShoppingList/MBShoppingList.UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ public override void Draw()
}

ImGui.SetNextItemWidth(100);
int maxResults = Plugin.Configuration.ShoppingListConfig.MaxResults;
if (ImGui.InputInt("Max Search Results", ref maxResults))
{
Plugin.Configuration.ShoppingListConfig.MaxResults = maxResults;
Plugin.Configuration.SaveConfig();
}


if (Plugin.Configuration.ExpertMode)
Expand Down
2 changes: 2 additions & 0 deletions RebornToolbox/Features/MBShoppingList/MBShoppingList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ private void OnItemAdded((uint, InventoryItem.ItemFlags, ulong, uint) itemDetail
return;

wantedItem.Quantity -= itemDetails.Item4;
if (wantedItem.Quantity < 0)
wantedItem.Quantity = 0;
}


Expand Down
19 changes: 15 additions & 4 deletions RebornToolbox/Features/MBShoppingList/Models/ShoppingListItem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.Serialization;
using Dalamud.Plugin.Ipc.Exceptions;
using ECommons;
using ECommons.DalamudServices;
using FFXIVClientStructs.FFXIV.Client.Game;
Expand Down Expand Up @@ -62,8 +63,19 @@ public long InventoryCount
{
if (DateTime.Now.Subtract(_inventoryLastUpdated).TotalSeconds > 1)
{
_inventoryLastUpdated = DateTime.Now;
_inventoryCount = AllaganTools_IPCSubscriber.IsInitialized() ? AllaganTools_IPCSubscriber.ItemCountOwned(ItemId, !Plugin.Configuration.ShoppingListConfig.AllCharactersInventory, ValidInventoryTypes.Select(i => (uint)i).ToArray()) : 0;
try
{
_inventoryCount = AllaganTools_IPCSubscriber.IsInitialized()
? AllaganTools_IPCSubscriber.ItemCountOwned(ItemId,
!Plugin.Configuration.ShoppingListConfig.AllCharactersInventory,
ValidInventoryTypes.Select(i => (uint)i).ToArray())
: 0;
_inventoryLastUpdated = DateTime.Now;
}
catch (Exception ex)
{
Svc.Log.Error($"Allagan Tools IPC failed: {ex.Message}");
}
}

return _inventoryCount;
Expand Down Expand Up @@ -227,10 +239,9 @@ private async Task FetchMarketDataAsync()
{
using var client = new HttpClient();

var maxResults = Plugin.Configuration.ShoppingListConfig.MaxResults;
var responseString = await client
.GetStringAsync(
$"https://universalis.app/api/v2/{Plugin.Configuration.ShoppingListConfig.ShoppingRegion.ToUniversalisString()}/{ItemId}?listings={maxResults}&entries={maxResults}")
$"https://universalis.app/api/v2/{Plugin.Configuration.ShoppingListConfig.ShoppingRegion.ToUniversalisString()}/{ItemId}")
.ConfigureAwait(false);

if (!string.IsNullOrEmpty(responseString))
Expand Down

0 comments on commit e5cce4f

Please sign in to comment.