Compare commits
No commits in common. "master" and "v2.0" have entirely different histories.
@ -4,7 +4,6 @@ using System.Linq;
|
||||
using Gearsetter.GameData;
|
||||
using Gearsetter.Model;
|
||||
using LLib.GameData;
|
||||
using LLib.Gear;
|
||||
using Lumina.Excel.Sheets;
|
||||
using Xunit;
|
||||
|
||||
@ -17,10 +16,6 @@ public sealed class ItemSortingTest
|
||||
[Fact]
|
||||
public void Test1()
|
||||
{
|
||||
var gearStatsCalculator = new GearStatsCalculator(_lumina.GetExcelSheet<ItemLevel>()!,
|
||||
_lumina.GetExcelSheet<ExtendedBaseParam>()!,
|
||||
_lumina.GetExcelSheet<Materia>()!,
|
||||
_lumina.GetExcelSheet<Item>()!);
|
||||
var items = _lumina.GetExcelSheet<Item>()!;
|
||||
List<uint> initialItemIds =
|
||||
[
|
||||
@ -35,13 +30,12 @@ public sealed class ItemSortingTest
|
||||
32558,
|
||||
];
|
||||
|
||||
|
||||
var itemList = new ItemList
|
||||
{
|
||||
ClassJob = EClassJob.Marauder,
|
||||
EquipSlotCategory = EEquipSlotCategory.Ears,
|
||||
ItemUiCategory = 41,
|
||||
Items = initialItemIds.Select(rowId => new EquipmentItem(items.GetRow(rowId), false, gearStatsCalculator.CalculateGearStats(items.GetRow(rowId), false, [])))
|
||||
Items = initialItemIds.Select(rowId => new EquipmentItem(items.GetRow(rowId), false))
|
||||
.Cast<BaseItem>()
|
||||
.ToList(),
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Dalamud.Configuration;
|
||||
using LLib.Gear;
|
||||
using Gearsetter.GameData;
|
||||
|
||||
namespace Gearsetter;
|
||||
|
||||
|
34
Gearsetter/GameData/EBaseParam.cs
Normal file
34
Gearsetter/GameData/EBaseParam.cs
Normal file
@ -0,0 +1,34 @@
|
||||
namespace Gearsetter.GameData;
|
||||
|
||||
internal enum EBaseParam : byte
|
||||
{
|
||||
None = 0,
|
||||
|
||||
Strength = 1,
|
||||
Dexterity = 2,
|
||||
Vitality = 3,
|
||||
Intelligence = 4,
|
||||
Mind = 5,
|
||||
Piety = 6,
|
||||
|
||||
GP = 10,
|
||||
CP = 11,
|
||||
|
||||
DamagePhys = 12,
|
||||
DamageMag = 13,
|
||||
|
||||
DefensePhys = 21,
|
||||
DefenseMag = 24,
|
||||
|
||||
Tenacity = 19,
|
||||
Crit = 27,
|
||||
DirectHit = 22,
|
||||
Determination = 44,
|
||||
SpellSpeed = 46,
|
||||
SkillSpeed = 45,
|
||||
|
||||
Craftsmanship = 70,
|
||||
Control = 71,
|
||||
Gathering = 72,
|
||||
Perception = 73,
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dalamud;
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using Gearsetter.Model;
|
||||
using LLib.GameData;
|
||||
using LLib.Gear;
|
||||
using Lumina.Excel.Sheets;
|
||||
|
||||
namespace Gearsetter.GameData;
|
||||
@ -14,15 +14,12 @@ namespace Gearsetter.GameData;
|
||||
internal sealed class GameDataHolder
|
||||
{
|
||||
private readonly Configuration _configuration;
|
||||
private readonly GearStatsCalculator _gearStatsCalculator;
|
||||
private readonly Dictionary<uint, List<EClassJob>> _classJobCategories;
|
||||
private readonly IReadOnlyList<ItemList> _allItemLists;
|
||||
|
||||
public GameDataHolder(IDataManager dataManager, Configuration configuration,
|
||||
GearStatsCalculator gearStatsCalculator)
|
||||
public GameDataHolder(IDataManager dataManager, Configuration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_gearStatsCalculator = gearStatsCalculator;
|
||||
_classJobCategories = dataManager.GetExcelSheet<ClassJobCategory>()
|
||||
.ToDictionary(x => x.RowId, x =>
|
||||
new Dictionary<EClassJob, bool>
|
||||
@ -90,6 +87,9 @@ internal sealed class GameDataHolder
|
||||
.ThenBy(x => x.OrderMinor)
|
||||
.Select(x => (x.RowId, x.Name.ToString()))
|
||||
.ToList();
|
||||
Materias = dataManager.GetExcelSheet<Materia>()
|
||||
.Where(x => x.RowId > 0 && Enum.IsDefined(typeof(EBaseParam), (byte)x.BaseParam.RowId))
|
||||
.ToDictionary(x => x.RowId, x => new MateriaStat((EBaseParam)x.BaseParam.RowId, x.Value.ToArray()));
|
||||
|
||||
_allItemLists =
|
||||
dataManager.GetExcelSheet<Item>()
|
||||
@ -135,6 +135,7 @@ internal sealed class GameDataHolder
|
||||
public IReadOnlyList<(EClassJob ClassJob, string Name)> ClassJobNames { get; }
|
||||
public IReadOnlyList<(uint ItemUiCategory, string Name)> ItemUiCategoryNames { get; }
|
||||
public Dictionary<EClassJob, EBaseParam> PrimaryStats { get; }
|
||||
public Dictionary<uint, MateriaStat> Materias { get; set; }
|
||||
|
||||
public Dictionary<EBaseParam, string> StatNames { get; } = new()
|
||||
{
|
||||
@ -206,14 +207,8 @@ internal sealed class GameDataHolder
|
||||
private IEnumerable<(EquipmentItem Item, List<EClassJob> ClassJobs)> LoadItem(Item item)
|
||||
{
|
||||
var classJobCategories = _classJobCategories[item.ClassJobCategory.RowId];
|
||||
yield return (
|
||||
new EquipmentItem(item, false, _gearStatsCalculator.CalculateGearStats(item, false, [])),
|
||||
classJobCategories);
|
||||
yield return (new EquipmentItem(item, false), classJobCategories);
|
||||
if (item.CanBeHq)
|
||||
{
|
||||
yield return (
|
||||
new EquipmentItem(item, true, _gearStatsCalculator.CalculateGearStats(item, true, [])),
|
||||
classJobCategories);
|
||||
}
|
||||
yield return (new EquipmentItem(item, true), classJobCategories);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Dalamud.NET.Sdk/11.0.0">
|
||||
<PropertyGroup>
|
||||
<Version>2.1</Version>
|
||||
<Version>2.0</Version>
|
||||
<OutputPath>dist</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -17,7 +17,6 @@ using Gearsetter.GameData;
|
||||
using Gearsetter.Model;
|
||||
using Gearsetter.Windows;
|
||||
using LLib.GameData;
|
||||
using LLib.Gear;
|
||||
using Lumina.Excel.Sheets;
|
||||
using GrandCompany = FFXIVClientStructs.FFXIV.Client.UI.Agent.GrandCompany;
|
||||
using InventoryItem = FFXIVClientStructs.FFXIV.Client.Game.InventoryItem;
|
||||
@ -36,7 +35,6 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
private readonly IClientState _clientState;
|
||||
private readonly GearsetterIpc _gearsetterIpc;
|
||||
private readonly Configuration _configuration;
|
||||
private readonly GearStatsCalculator _gearStatsCalculator;
|
||||
private readonly GameDataHolder _gameDataHolder;
|
||||
private readonly EquipmentBrowserWindow _equipmentBrowserWindow;
|
||||
private readonly ConfigWindow _configWindow;
|
||||
@ -64,8 +62,7 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
}
|
||||
|
||||
_configuration = configuration;
|
||||
_gearStatsCalculator = new GearStatsCalculator(dataManager);
|
||||
_gameDataHolder = new GameDataHolder(dataManager, _configuration, _gearStatsCalculator);
|
||||
_gameDataHolder = new GameDataHolder(dataManager, _configuration);
|
||||
_equipmentBrowserWindow = new EquipmentBrowserWindow(this, _gameDataHolder, _clientState, _chatGui);
|
||||
_windowSystem.AddWindow(_equipmentBrowserWindow);
|
||||
_configWindow = new ConfigWindow(_pluginInterface, _configuration);
|
||||
@ -178,19 +175,19 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
name.Contains("Bozja", StringComparison.OrdinalIgnoreCase))
|
||||
return null;
|
||||
|
||||
return new GearsetData(_dataManager, _gearStatsCalculator, gearset, name);
|
||||
return new GearsetData(_dataManager, gearset, name);
|
||||
}
|
||||
|
||||
internal unsafe List<RecommendedItemChange> GetRecommendedUpgrades(RaptureGearsetModule.GearsetEntry* gearset,
|
||||
byte? level = null)
|
||||
{
|
||||
GearsetData gearsetData = new GearsetData(_dataManager, _gearStatsCalculator, gearset, GetGearsetName(gearset));
|
||||
Dictionary<(uint ItemId, bool Hq), List<EquipmentStats>> inventoryItems = GetAllInventoryItems();
|
||||
GearsetData gearsetData = new GearsetData(_dataManager, gearset, GetGearsetName(gearset));
|
||||
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems = GetAllInventoryItems();
|
||||
return GetRecommendedUpgrades(gearsetData, inventoryItems, level);
|
||||
}
|
||||
|
||||
private List<RecommendedItemChange> GetRecommendedUpgrades(GearsetData gearset,
|
||||
Dictionary<(uint ItemId, bool Hql), List<EquipmentStats>> inventoryItems, byte? level)
|
||||
Dictionary<(uint ItemId, bool Hql), List<MateriaStats>> inventoryItems, byte? level)
|
||||
{
|
||||
List<RecommendedItemChange> Handle(string label,
|
||||
(EquipmentItem?, RaptureGearsetModule.GearsetItemIndex)[] gearsetItems,
|
||||
@ -228,7 +225,7 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
|
||||
|
||||
private bool HandleGearset(GearsetData gearset,
|
||||
Dictionary<(uint ItemId, bool Hq), List<EquipmentStats>> inventoryItems, byte? level)
|
||||
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems, byte? level)
|
||||
{
|
||||
List<RecommendedItemChange> upgrades = GetRecommendedUpgrades(gearset, inventoryItems, level);
|
||||
if (upgrades.Count == 0)
|
||||
@ -261,7 +258,7 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
|
||||
private List<RecommendedItemChange> HandleGearsetItem(string label, GearsetData gearset,
|
||||
(EquipmentItem? Item, RaptureGearsetModule.GearsetItemIndex Slot)[] gearsetItems,
|
||||
Dictionary<(uint ItemId, bool Hq), List<EquipmentStats>> inventoryItems,
|
||||
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems,
|
||||
EEquipSlotCategory equipSlotCategory, byte? level)
|
||||
{
|
||||
EClassJob classJob = gearset.ClassJob;
|
||||
@ -341,7 +338,7 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
}
|
||||
|
||||
private List<RecommendedItemChange> HandleOffHand(GearsetData gearset,
|
||||
Dictionary<(uint ItemId, bool Hq), List<EquipmentStats>> inventoryItems, byte? level)
|
||||
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems, byte? level)
|
||||
{
|
||||
var mainHand = gearset.MainHand;
|
||||
if (mainHand == null)
|
||||
@ -375,8 +372,8 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
if (item != null && item->ItemId == baseItem.ItemId &&
|
||||
item->Flags.HasFlag(InventoryItem.ItemFlags.HighQuality) == baseItem.Hq)
|
||||
{
|
||||
EquipmentStats expectedMateriaStats = baseItem.Stats;
|
||||
EquipmentStats actualMateriaStats = FetchMateriaStats(item);
|
||||
MateriaStats expectedMateriaStats = baseItem.MateriaStats ?? new([]);
|
||||
MateriaStats actualMateriaStats = FetchMateriaStats(item);
|
||||
|
||||
if (expectedMateriaStats == actualMateriaStats)
|
||||
return new RecommendedItemChange(item->ItemId, inventoryType, i, targetSlot, text);
|
||||
@ -387,9 +384,9 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
return new RecommendedItemChange(baseItem.ItemId, null, null, targetSlot, text);
|
||||
}
|
||||
|
||||
internal unsafe Dictionary<(uint ItemId, bool Hq), List<EquipmentStats>> GetAllInventoryItems()
|
||||
internal unsafe Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> GetAllInventoryItems()
|
||||
{
|
||||
Dictionary<(uint, bool), List<EquipmentStats>> inventoryItems = new();
|
||||
Dictionary<(uint, bool), List<MateriaStats>> inventoryItems = new();
|
||||
InventoryManager* inventoryManager = InventoryManager.Instance();
|
||||
foreach (var inventoryType in _gameDataHolder.DefaultInventoryTypes)
|
||||
{
|
||||
@ -402,7 +399,7 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
var key = (item->ItemId, item->Flags.HasFlag(InventoryItem.ItemFlags.HighQuality));
|
||||
if (!inventoryItems.TryGetValue(key, out var list))
|
||||
{
|
||||
list = new List<EquipmentStats>();
|
||||
list = new List<MateriaStats>();
|
||||
inventoryItems[key] = list;
|
||||
}
|
||||
|
||||
@ -414,8 +411,22 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
return inventoryItems;
|
||||
}
|
||||
|
||||
private unsafe EquipmentStats FetchMateriaStats(InventoryItem* item)
|
||||
=> _gearStatsCalculator.CalculateGearStats(item);
|
||||
private unsafe MateriaStats FetchMateriaStats(InventoryItem* item)
|
||||
{
|
||||
// FIXME item->GetMateriaCount is broken on API 10, so this seems to be somewhat slow
|
||||
List<(MateriaStat, byte)> materias = new();
|
||||
for (int slot = 0; slot < 5; ++slot)
|
||||
{
|
||||
var materiaId = item->Materia[slot];
|
||||
if (materiaId == 0)
|
||||
break;
|
||||
|
||||
if (_gameDataHolder.Materias.TryGetValue(materiaId, out MateriaStat? value))
|
||||
materias.Add((value, item->MateriaGrades[slot]));
|
||||
}
|
||||
|
||||
return new MateriaStats(materias);
|
||||
}
|
||||
|
||||
internal unsafe byte GetLevel(EClassJob classJob)
|
||||
{
|
||||
|
@ -1,12 +1,10 @@
|
||||
using System.Linq;
|
||||
using Gearsetter.GameData;
|
||||
using Gearsetter.GameData;
|
||||
using LLib.GameData;
|
||||
using LLib.Gear;
|
||||
using Lumina.Excel.Sheets;
|
||||
|
||||
namespace Gearsetter.Model;
|
||||
|
||||
internal abstract record BaseItem(Item Item, bool Hq, EquipmentStats Stats)
|
||||
internal abstract record BaseItem(Item Item, bool Hq, MateriaStats? MateriaStats = null)
|
||||
{
|
||||
public Item Item { get; } = Item;
|
||||
public uint ItemId { get; } = Item.RowId;
|
||||
@ -19,7 +17,7 @@ internal abstract record BaseItem(Item Item, bool Hq, EquipmentStats Stats)
|
||||
public EEquipSlotCategory EquipSlotCategory { get; } = (EEquipSlotCategory)Item.EquipSlotCategory.RowId;
|
||||
public uint ItemUiCategory { get; } = Item.ItemUICategory.RowId;
|
||||
public abstract EClassJob ClassJob { get; init; }
|
||||
public EquipmentStats Stats { get; } = Stats;
|
||||
public EquipmentStats Stats { get; } = new(Item, Hq, MateriaStats);
|
||||
|
||||
public int PrimaryStat { get; init; } = -1;
|
||||
|
||||
@ -37,7 +35,15 @@ internal abstract record BaseItem(Item Item, bool Hq, EquipmentStats Stats)
|
||||
}
|
||||
|
||||
public bool HasAnyStat(params EBaseParam[] substats)
|
||||
=> substats.Any(x => Stats.Has(x));
|
||||
{
|
||||
foreach (EBaseParam substat in substats)
|
||||
{
|
||||
if (Stats.Get(substat) > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsCombatRelicWithoutSubstats()
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
using LLib.GameData;
|
||||
using LLib.Gear;
|
||||
using Gearsetter.GameData;
|
||||
using LLib.GameData;
|
||||
using Lumina.Excel.Sheets;
|
||||
|
||||
namespace Gearsetter.Model;
|
||||
|
||||
internal sealed record EquipmentItem(Item Item, bool Hq, EquipmentStats Stats) : BaseItem(Item, Hq, Stats)
|
||||
internal sealed record EquipmentItem(Item Item, bool Hq) : BaseItem(Item, Hq)
|
||||
{
|
||||
public override EClassJob ClassJob { get; init; } = EClassJob.Adventurer;
|
||||
}
|
||||
|
@ -1,5 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using LLib.Gear;
|
||||
using Gearsetter.GameData;
|
||||
using Lumina.Excel.Sheets;
|
||||
|
||||
namespace Gearsetter.Model;
|
||||
|
||||
internal sealed class EquipmentStats
|
||||
{
|
||||
private readonly Dictionary<EBaseParam, short> _equipmentValues;
|
||||
private readonly Dictionary<EBaseParam, short> _materiaValues;
|
||||
|
||||
public EquipmentStats(Item item, bool hq, MateriaStats? materiaStats)
|
||||
{
|
||||
_equipmentValues = Enumerable.Range(0, item.BaseParam.Count)
|
||||
.Where(i => item.BaseParam[i].RowId > 0)
|
||||
.ToDictionary(i => (EBaseParam)item.BaseParam[i].RowId, i => item.BaseParamValue[i]);
|
||||
if (hq)
|
||||
{
|
||||
for (int i = 0; i < item.BaseParamSpecial.Count; ++i)
|
||||
{
|
||||
EBaseParam baseParam = (EBaseParam)item.BaseParamSpecial[i].RowId;
|
||||
if (baseParam == EBaseParam.None)
|
||||
continue;
|
||||
|
||||
var baseParamValue = item.BaseParamValueSpecial[i];
|
||||
if (_equipmentValues.TryGetValue(baseParam, out var stat))
|
||||
_equipmentValues[baseParam] = (short)(stat + baseParamValue);
|
||||
else
|
||||
_equipmentValues[baseParam] = baseParamValue;
|
||||
}
|
||||
}
|
||||
|
||||
_materiaValues = new();
|
||||
if (materiaStats != null)
|
||||
{
|
||||
foreach (var materiaStat in materiaStats.Values)
|
||||
{
|
||||
if (_materiaValues.TryGetValue(materiaStat.Key, out var stat))
|
||||
_materiaValues[materiaStat.Key] = (short)(stat + materiaStat.Value);
|
||||
else
|
||||
_materiaValues[materiaStat.Key] = materiaStat.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public short Get(EBaseParam param)
|
||||
{
|
||||
return (short)(GetEquipment(param) + GetMateria(param));
|
||||
}
|
||||
|
||||
public short GetEquipment(EBaseParam param)
|
||||
{
|
||||
_equipmentValues.TryGetValue(param, out short v);
|
||||
return v;
|
||||
}
|
||||
|
||||
public short GetMateria(EBaseParam param)
|
||||
{
|
||||
_materiaValues.TryGetValue(param, out short v);
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
@ -1,43 +1,40 @@
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
||||
using LLib.GameData;
|
||||
using LLib.Gear;
|
||||
using Lumina.Excel.Sheets;
|
||||
|
||||
namespace Gearsetter.Model;
|
||||
|
||||
internal sealed class GearsetData
|
||||
{
|
||||
public unsafe GearsetData(IDataManager dataManager, GearStatsCalculator gearStatsCalculator,
|
||||
RaptureGearsetModule.GearsetEntry* gearset, string name)
|
||||
public unsafe GearsetData(IDataManager dataManager, RaptureGearsetModule.GearsetEntry* gearset, string name)
|
||||
{
|
||||
Id = gearset->Id;
|
||||
ClassJob = (EClassJob)gearset->ClassJob;
|
||||
Name = name;
|
||||
MainHand = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.MainHand);
|
||||
OffHand = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.OffHand);
|
||||
Head = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Head);
|
||||
Body = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Body);
|
||||
Hands = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Hands);
|
||||
Legs = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Legs);
|
||||
Feet = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Feet);
|
||||
Ears = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Ears);
|
||||
Neck = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Neck);
|
||||
Wrists = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Wrists);
|
||||
RingLeft = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.RingLeft);
|
||||
RingRight = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.RingRight);
|
||||
MainHand = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.MainHand);
|
||||
OffHand = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.OffHand);
|
||||
Head = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Head);
|
||||
Body = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Body);
|
||||
Hands = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Hands);
|
||||
Legs = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Legs);
|
||||
Feet = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Feet);
|
||||
Ears = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Ears);
|
||||
Neck = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Neck);
|
||||
Wrists = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Wrists);
|
||||
RingLeft = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.RingLeft);
|
||||
RingRight = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.RingRight);
|
||||
}
|
||||
|
||||
private static unsafe EquipmentItem? GetItem(IDataManager dataManager, GearStatsCalculator gearStatsCalculator,
|
||||
RaptureGearsetModule.GearsetEntry* gearset, RaptureGearsetModule.GearsetItemIndex index)
|
||||
private static unsafe EquipmentItem? GetItem(IDataManager dataManager, RaptureGearsetModule.GearsetEntry* gearset,
|
||||
RaptureGearsetModule.GearsetItemIndex index)
|
||||
{
|
||||
var gearsetItem = gearset->GetItem(index);
|
||||
if (gearsetItem.ItemId == 0)
|
||||
return null;
|
||||
|
||||
var item = dataManager.GetExcelSheet<Item>().GetRow(gearsetItem.ItemId % 1_000_000);
|
||||
bool hq = gearsetItem.ItemId > 1_000_000;
|
||||
return new EquipmentItem(item, hq, gearStatsCalculator.CalculateGearStats(item, hq, []));
|
||||
return new EquipmentItem(item, gearsetItem.ItemId > 1_000_000);
|
||||
}
|
||||
|
||||
public byte Id { get; }
|
||||
|
@ -1,10 +1,9 @@
|
||||
using LLib.GameData;
|
||||
using LLib.Gear;
|
||||
using Lumina.Excel.Sheets;
|
||||
|
||||
namespace Gearsetter.Model;
|
||||
|
||||
internal sealed record InventoryItem(Item Item, bool Hq, EquipmentStats Stats, EClassJob ClassJob)
|
||||
: BaseItem(Item, Hq, Stats)
|
||||
internal sealed record InventoryItem(Item Item, bool Hq, MateriaStats MateriaStats, EClassJob ClassJob)
|
||||
: BaseItem(Item, Hq, MateriaStats)
|
||||
{
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Gearsetter.GameData;
|
||||
using LLib.GameData;
|
||||
using LLib.Gear;
|
||||
|
||||
namespace Gearsetter.Model;
|
||||
|
||||
@ -23,7 +22,7 @@ internal sealed class ItemList
|
||||
public required uint ItemUiCategory { get; init; }
|
||||
public required List<BaseItem> Items { get; set; }
|
||||
public EBaseParam PrimaryStat { get; set; }
|
||||
public IReadOnlyList<EBaseParam> SubstatPriorities { get; private set; } = new List<EBaseParam>();
|
||||
public IReadOnlyList<EBaseParam> SubstatPriorities { get; set; } = new List<EBaseParam>();
|
||||
|
||||
public void Sort()
|
||||
{
|
||||
@ -63,7 +62,7 @@ internal sealed class ItemList
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyFromInventory(Dictionary<(uint ItemId, bool Hq), List<EquipmentStats>> inventoryItems,
|
||||
public void ApplyFromInventory(Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems,
|
||||
bool includeWithoutMateria)
|
||||
{
|
||||
foreach (var inventoryItem in inventoryItems)
|
||||
@ -73,11 +72,11 @@ internal sealed class ItemList
|
||||
if (basicItem == null)
|
||||
continue;
|
||||
|
||||
foreach (var inventoryStats in inventoryItem.Value)
|
||||
foreach (var materias in inventoryItem.Value)
|
||||
{
|
||||
if (includeWithoutMateria || inventoryStats.HasMateria())
|
||||
if (includeWithoutMateria || materias.Values.Count > 0)
|
||||
Items.Add(
|
||||
new InventoryItem(basicItem.Item, basicItem.Hq, inventoryStats, basicItem.ClassJob)
|
||||
new InventoryItem(basicItem.Item, basicItem.Hq, materias, basicItem.ClassJob)
|
||||
{
|
||||
PrimaryStat = basicItem.Stats.Get(PrimaryStat)
|
||||
});
|
||||
@ -173,7 +172,7 @@ internal sealed class ItemList
|
||||
return string.CompareOrdinal(a.Name, b.Name);
|
||||
}
|
||||
|
||||
private static bool TryGetPreferredItemPriority(BaseItem self, BaseItem other, out byte priority)
|
||||
public static bool TryGetPreferredItemPriority(BaseItem self, BaseItem other, out byte priority)
|
||||
{
|
||||
if (PreferredItems.TryGetValue(self.ItemId, out byte levelSelf))
|
||||
{
|
||||
|
11
Gearsetter/Model/MateriaStat.cs
Normal file
11
Gearsetter/Model/MateriaStat.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Gearsetter.GameData;
|
||||
|
||||
namespace Gearsetter.Model;
|
||||
|
||||
internal sealed class MateriaStat(EBaseParam baseParam, short[] values)
|
||||
{
|
||||
public EBaseParam BaseParam { get; } = baseParam;
|
||||
public List<short> Values { get; } = values.ToList();
|
||||
}
|
64
Gearsetter/Model/MateriaStats.cs
Normal file
64
Gearsetter/Model/MateriaStats.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Gearsetter.GameData;
|
||||
|
||||
namespace Gearsetter.Model;
|
||||
|
||||
internal sealed class MateriaStats : IEquatable<MateriaStats>
|
||||
{
|
||||
private readonly List<(EBaseParam, short)> _list;
|
||||
|
||||
public MateriaStats(IEnumerable<(MateriaStat Stat, byte Grade)> materias)
|
||||
{
|
||||
foreach (var materia in materias)
|
||||
{
|
||||
if (Values.TryGetValue(materia.Stat.BaseParam, out short value))
|
||||
Values[materia.Stat.BaseParam] = (short)(value + materia.Stat.Values[materia.Grade]);
|
||||
else
|
||||
Values[materia.Stat.BaseParam] = materia.Stat.Values[materia.Grade];
|
||||
|
||||
++Count;
|
||||
}
|
||||
|
||||
_list = Enum.GetValues<EBaseParam>()
|
||||
.Select(x => (x, Values.GetValueOrDefault(x, (short)0)))
|
||||
.Where(x => x.Item2 > 0)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public Dictionary<EBaseParam, short> Values { get; } = new();
|
||||
public byte Count { get; }
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return ReferenceEquals(this, obj) || obj is MateriaStats other && Equals(other);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _list.GetHashCode();
|
||||
}
|
||||
|
||||
public bool Equals(MateriaStats? other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
return _list.SequenceEqual(other._list);
|
||||
}
|
||||
|
||||
public static bool operator ==(MateriaStats? left, MateriaStats? right)
|
||||
{
|
||||
return Equals(left, right);
|
||||
}
|
||||
|
||||
public static bool operator !=(MateriaStats? left, MateriaStats? right)
|
||||
{
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Materias[{string.Join(", ", _list.Select(x => $"{x.Item1}:{x.Item2}"))}]";
|
||||
}
|
||||
}
|
@ -11,7 +11,6 @@ using Gearsetter.GameData;
|
||||
using Gearsetter.Model;
|
||||
using ImGuiNET;
|
||||
using LLib.GameData;
|
||||
using LLib.Gear;
|
||||
using LLib.ImGui;
|
||||
|
||||
namespace Gearsetter.Windows;
|
||||
@ -112,7 +111,7 @@ internal sealed class EquipmentBrowserWindow : LWindow
|
||||
ImGui.SameLine();
|
||||
ImGui.Checkbox("Hide normal quality items", ref _hideNormalQualityItems);
|
||||
|
||||
Dictionary<(uint ItemId, bool Hq), List<EquipmentStats>> ownedItems = _plugin.GetAllInventoryItems();
|
||||
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> ownedItems = _plugin.GetAllInventoryItems();
|
||||
try
|
||||
{
|
||||
itemList.ApplyFromInventory(ownedItems, _onlyShowOwnedItems);
|
||||
@ -145,7 +144,7 @@ internal sealed class EquipmentBrowserWindow : LWindow
|
||||
|
||||
ImGui.PushStyleColor(ImGuiCol.HeaderHovered, hoverColor);
|
||||
foreach (var item in itemList.Items.DistinctBy(x => new
|
||||
{ x.ItemId, x.Hq, Stats = x.Stats.GetHashCode() }))
|
||||
{ x.ItemId, x.Hq, Materia = x.MateriaStats?.GetHashCode() }))
|
||||
{
|
||||
if (item is not InventoryItem)
|
||||
{
|
||||
@ -175,9 +174,9 @@ internal sealed class EquipmentBrowserWindow : LWindow
|
||||
string name = item.Name;
|
||||
if (item.Hq)
|
||||
name += $" {SeIconChar.HighQuality.ToIconString()}";
|
||||
if (item is InventoryItem { Stats.MateriaCount: > 0 } inventoryItem)
|
||||
if (item is InventoryItem { MateriaStats: not null } inventoryItem)
|
||||
name +=
|
||||
$" {string.Join("", Enumerable.Repeat(SeIconChar.Circle.ToIconString(), inventoryItem.Stats.MateriaCount))}";
|
||||
$" {string.Join("", Enumerable.Repeat(SeIconChar.Circle.ToIconString(), inventoryItem.MateriaStats!.Count))}";
|
||||
|
||||
if (color != null)
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, color.Value);
|
||||
@ -223,12 +222,6 @@ internal sealed class EquipmentBrowserWindow : LWindow
|
||||
ImGui.Text(string.Create(CultureInfo.InvariantCulture, $"{estat}"));
|
||||
else
|
||||
ImGui.Text(string.Create(CultureInfo.InvariantCulture, $"{estat} +{mstat}"));
|
||||
|
||||
if (item.Stats.IsOvercapped(substat))
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.Text(SeIconChar.Debuff.ToIconString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
LLib
2
LLib
@ -1 +1 @@
|
||||
Subproject commit 783fea977a2524dd63e717367fc026c52efe6c23
|
||||
Subproject commit e4bbc05ede6f6f01e7028b24614ed8cb333e909c
|
Loading…
Reference in New Issue
Block a user