forked from liza/Deliveroo
Fix tickets of the wrong GC messing up turn-in window, fix adding itemId 0 to your purchase list
This commit is contained in:
parent
5723b64142
commit
62bc3fe03c
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
|
||||
namespace Deliveroo.GameData;
|
||||
@ -9,7 +10,7 @@ internal sealed class GcRewardItem : IEquatable<GcRewardItem>
|
||||
{
|
||||
ItemId = 0,
|
||||
Name = "---",
|
||||
GrandCompany = GrandCompany.None,
|
||||
GrandCompanies = new List<GrandCompany>().AsReadOnly(),
|
||||
Tier = RewardTier.First,
|
||||
SubCategory = RewardSubCategory.Unknown,
|
||||
RequiredRank = 0,
|
||||
@ -19,14 +20,14 @@ internal sealed class GcRewardItem : IEquatable<GcRewardItem>
|
||||
|
||||
public required uint ItemId { get; init; }
|
||||
public required string Name { get; init; }
|
||||
public required GrandCompany GrandCompany { get; init; }
|
||||
public required IReadOnlyList<GrandCompany> GrandCompanies { get; init; }
|
||||
public required RewardTier Tier { get; init; }
|
||||
public required RewardSubCategory SubCategory { get; init; }
|
||||
public required uint RequiredRank { get; init; }
|
||||
public required uint StackSize { get; init; }
|
||||
public required uint SealCost { get; init; }
|
||||
|
||||
public bool IsValid() => ItemId > 0 && GrandCompany != GrandCompany.None;
|
||||
public bool IsValid() => ItemId > 0 && GrandCompanies.Count > 0;
|
||||
|
||||
public bool Equals(GcRewardItem? other)
|
||||
{
|
||||
|
@ -18,34 +18,42 @@ internal sealed class GcRewardsCache
|
||||
Tier: (RewardTier)x.Tier,
|
||||
SubCategory: (RewardSubCategory)x.SubCategory));
|
||||
|
||||
var items = dataManager.GetExcelSheet<GCScripShopItem>()!
|
||||
Rewards = dataManager.GetExcelSheet<GCScripShopItem>()!
|
||||
.Where(x => x.RowId > 0 && x.Item.Row > 0)
|
||||
.ToList();
|
||||
|
||||
foreach (var item in items)
|
||||
.GroupBy(item =>
|
||||
{
|
||||
var category = categories[item.RowId];
|
||||
Rewards[category.GrandCompany].Add(new GcRewardItem
|
||||
return new
|
||||
{
|
||||
ItemId = item.Item.Row,
|
||||
Name = item.Item.Value!.Name.ToString(),
|
||||
GrandCompany = category.GrandCompany,
|
||||
Tier = category.Tier,
|
||||
SubCategory = category.SubCategory,
|
||||
category.Tier,
|
||||
category.SubCategory,
|
||||
RequiredRank = item.RequiredGrandCompanyRank.Row,
|
||||
StackSize = item.Item!.Value.StackSize,
|
||||
item.Item!.Value.StackSize,
|
||||
SealCost = item.CostGCSeals,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<GrandCompany, List<GcRewardItem>> Rewards { get; } = new()
|
||||
{
|
||||
{ GrandCompany.Maelstrom, new() },
|
||||
{ GrandCompany.TwinAdder, new() },
|
||||
{ GrandCompany.ImmortalFlames, new() }
|
||||
};
|
||||
|
||||
public GcRewardItem GetReward(GrandCompany grandCompany, uint itemId)
|
||||
=> Rewards[grandCompany].Single(x => x.ItemId == itemId);
|
||||
})
|
||||
.Select(item => new GcRewardItem
|
||||
{
|
||||
ItemId = item.Key.ItemId,
|
||||
Name = item.Key.Name,
|
||||
Tier = item.Key.Tier,
|
||||
SubCategory = item.Key.SubCategory,
|
||||
RequiredRank = item.Key.RequiredRank,
|
||||
StackSize = item.Key.StackSize,
|
||||
SealCost = item.Key.SealCost,
|
||||
GrandCompanies = item.Select(x => categories[x.RowId].GrandCompany)
|
||||
.ToList()
|
||||
.AsReadOnly(),
|
||||
})
|
||||
.ToList()
|
||||
.AsReadOnly();
|
||||
RewardLookup = Rewards.ToDictionary(x => x.ItemId).AsReadOnly();
|
||||
}
|
||||
|
||||
public IReadOnlyList<GcRewardItem> Rewards { get; }
|
||||
public IReadOnlyDictionary<uint, GcRewardItem> RewardLookup { get; }
|
||||
|
||||
public GcRewardItem GetReward(uint itemId) => RewardLookup[itemId];
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ internal sealed class ConfigWindow : Window
|
||||
private readonly IClientState _clientState;
|
||||
private readonly IPluginLog _pluginLog;
|
||||
|
||||
private readonly Dictionary<uint, GcRewardItem> _itemLookup;
|
||||
private uint _dragDropSource = 0;
|
||||
private readonly IReadOnlyDictionary<uint, GcRewardItem> _itemLookup;
|
||||
private uint _dragDropSource;
|
||||
|
||||
public ConfigWindow(DalamudPluginInterface pluginInterface, DeliverooPlugin plugin, Configuration configuration,
|
||||
GcRewardsCache gcRewardsCache, IClientState clientState, IPluginLog pluginLog)
|
||||
@ -37,10 +37,7 @@ internal sealed class ConfigWindow : Window
|
||||
_clientState = clientState;
|
||||
_pluginLog = pluginLog;
|
||||
|
||||
_itemLookup = _gcRewardsCache.Rewards.Values
|
||||
.SelectMany(x => x)
|
||||
.Distinct()
|
||||
.ToDictionary(x => x.ItemId, x => x);
|
||||
_itemLookup = _gcRewardsCache.RewardLookup;
|
||||
|
||||
Size = new Vector2(420, 300);
|
||||
SizeCondition = ImGuiCond.Appearing;
|
||||
@ -136,11 +133,8 @@ internal sealed class ConfigWindow : Window
|
||||
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)
|
||||
List<(uint ItemId, string Name)> comboValues = _gcRewardsCache.Rewards
|
||||
.Where(x => x.SubCategory is RewardSubCategory.Materials or RewardSubCategory.Materiel)
|
||||
.Where(x => x.StackSize > 1)
|
||||
.Where(x => !_configuration.ItemsAvailableForPurchase.Contains(x.ItemId))
|
||||
.Select(x => (x.ItemId, x.Name))
|
||||
@ -150,20 +144,12 @@ 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)
|
||||
&& comboValues[currentItem].ItemId != GcRewardItem.None.ItemId)
|
||||
{
|
||||
_configuration.ItemsAvailableForPurchase.Add(comboValues[currentItem].ItemId);
|
||||
Save();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.BeginDisabled();
|
||||
int currentItem = 0;
|
||||
ImGui.Combo("Add Item", ref currentItem, new[] { "(Not part of a GC)" }, 1);
|
||||
ImGui.EndDisabled();
|
||||
}
|
||||
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
@ -185,7 +171,6 @@ internal sealed class ConfigWindow : Window
|
||||
var charConfiguration = _plugin.CharacterConfiguration;
|
||||
if (charConfiguration != null)
|
||||
{
|
||||
|
||||
bool disableForCharacter = charConfiguration.DisableForCharacter;
|
||||
if (ImGui.Checkbox("Disable plugin for this character", ref disableForCharacter))
|
||||
{
|
||||
@ -203,7 +188,8 @@ internal sealed class ConfigWindow : Window
|
||||
}
|
||||
|
||||
if (charConfiguration.ItemsToPurchase.Count > 1 ||
|
||||
(charConfiguration.ItemsToPurchase.Count == 1 && charConfiguration.ItemsToPurchase[0].ItemId != GcRewardItem.None.ItemId))
|
||||
(charConfiguration.ItemsToPurchase.Count == 1 &&
|
||||
charConfiguration.ItemsToPurchase[0].ItemId != GcRewardItem.None.ItemId))
|
||||
{
|
||||
ImGui.SameLine();
|
||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Trash, "Clear"))
|
||||
@ -219,8 +205,10 @@ internal sealed class ConfigWindow : Window
|
||||
charConfiguration.UseHideArmouryChestItemsFilter = useHideArmouryChestItemsFilter;
|
||||
charConfiguration.Save(_pluginInterface);
|
||||
}
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("The default filter for all characters is 'Hide Gear Set Items', but you may want to override this to hide all Armoury Chest items (regardless of whether they're part of a gear set) e.g. for your main character.");
|
||||
ImGui.SetTooltip(
|
||||
"The default filter for all characters is 'Hide Gear Set Items', but you may want to override this to hide all Armoury Chest items (regardless of whether they're part of a gear set) e.g. for your main character.");
|
||||
|
||||
ImGui.EndDisabled();
|
||||
ImGui.Spacing();
|
||||
|
@ -50,7 +50,8 @@ internal sealed class TurnInWindow : Window
|
||||
public decimal Multiplier { private get; set; }
|
||||
public string Error { private get; set; } = string.Empty;
|
||||
|
||||
private bool UseCharacterSpecificItemsToPurchase => _plugin.CharacterConfiguration is {OverrideItemsToPurchase: true };
|
||||
private bool UseCharacterSpecificItemsToPurchase =>
|
||||
_plugin.CharacterConfiguration is { OverrideItemsToPurchase: true };
|
||||
|
||||
private IItemsToPurchase ItemsWrapper => UseCharacterSpecificItemsToPurchase
|
||||
? new CharacterSpecificItemsToPurchase(_plugin.CharacterConfiguration!, _pluginInterface)
|
||||
@ -67,7 +68,8 @@ internal sealed class TurnInWindow : Window
|
||||
var rank = _plugin.GetGrandCompanyRank();
|
||||
return ItemsWrapper.GetItemsToPurchase()
|
||||
.Where(x => x.ItemId != 0)
|
||||
.Select(x => new { Item = x, Reward = _gcRewardsCache.GetReward(grandCompany, x.ItemId) })
|
||||
.Select(x => new { Item = x, Reward = _gcRewardsCache.GetReward(x.ItemId) })
|
||||
.Where(x => x.Reward.GrandCompanies.Contains(grandCompany))
|
||||
.Where(x => x.Reward.RequiredRank <= rank)
|
||||
.Select(x => new PurchaseItemRequest
|
||||
{
|
||||
@ -147,16 +149,18 @@ internal sealed class TurnInWindow : Window
|
||||
var itemsWrapper = ItemsWrapper;
|
||||
ImGui.Text($"Items to buy ({itemsWrapper.Name}):");
|
||||
|
||||
List<(uint ItemId, string Name, uint Rank)> comboValues = new()
|
||||
{ (GcRewardItem.None.ItemId, GcRewardItem.None.Name, GcRewardItem.None.RequiredRank) };
|
||||
List<(uint ItemId, string Name, IReadOnlyList<GrandCompany> GrandCompanies, uint Rank)> comboValues = new()
|
||||
{
|
||||
(GcRewardItem.None.ItemId, GcRewardItem.None.Name, new List<GrandCompany>(), GcRewardItem.None.RequiredRank)
|
||||
};
|
||||
foreach (uint itemId in _configuration.ItemsAvailableForPurchase)
|
||||
{
|
||||
var gcReward = _gcRewardsCache.GetReward(grandCompany, itemId);
|
||||
var gcReward = _gcRewardsCache.GetReward(itemId);
|
||||
int itemCount = _plugin.GetItemCount(itemId);
|
||||
string itemName = gcReward.Name;
|
||||
if (itemCount > 0)
|
||||
itemName += $" ({itemCount:N0})";
|
||||
comboValues.Add((itemId, itemName, gcReward.RequiredRank));
|
||||
comboValues.Add((itemId, itemName, gcReward.GrandCompanies, gcReward.RequiredRank));
|
||||
}
|
||||
|
||||
if (itemsWrapper.GetItemsToPurchase().Count == 0)
|
||||
@ -216,11 +220,20 @@ internal sealed class TurnInWindow : Window
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
|
||||
if (comboValueIndex > 0 && comboValues[comboValueIndex].Rank > _plugin.GetGrandCompanyRank())
|
||||
if (comboValueIndex > 0)
|
||||
{
|
||||
var comboItem = comboValues[comboValueIndex];
|
||||
if (!comboItem.GrandCompanies.Contains(grandCompany))
|
||||
{
|
||||
ImGui.TextColored(ImGuiColors.DalamudRed,
|
||||
"This item will be skipped, as you are in the wrong Grand Company.");
|
||||
}
|
||||
else if (comboItem.Rank > _plugin.GetGrandCompanyRank())
|
||||
{
|
||||
ImGui.TextColored(ImGuiColors.DalamudRed,
|
||||
"This item will be skipped, your rank isn't high enough to buy it.");
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.Unindent(27);
|
||||
ImGui.PopID();
|
||||
@ -232,7 +245,8 @@ internal sealed class TurnInWindow : Window
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
|
||||
if (_configuration.ItemsAvailableForPurchase.Any(x => itemsWrapper.GetItemsToPurchase().All(y => x != y.ItemId)))
|
||||
if (_configuration.ItemsAvailableForPurchase.Any(x =>
|
||||
itemsWrapper.GetItemsToPurchase().All(y => x != y.ItemId)))
|
||||
{
|
||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Plus, "Add Item"))
|
||||
{
|
||||
@ -284,7 +298,8 @@ internal sealed class TurnInWindow : Window
|
||||
private readonly CharacterConfiguration _characterConfiguration;
|
||||
private readonly DalamudPluginInterface _pluginInterface;
|
||||
|
||||
public CharacterSpecificItemsToPurchase(CharacterConfiguration characterConfiguration, DalamudPluginInterface pluginInterface)
|
||||
public CharacterSpecificItemsToPurchase(CharacterConfiguration characterConfiguration,
|
||||
DalamudPluginInterface pluginInterface)
|
||||
{
|
||||
_characterConfiguration = characterConfiguration;
|
||||
_pluginInterface = pluginInterface;
|
||||
|
Loading…
Reference in New Issue
Block a user