From b1059871154b84401020c0072fd089fcc022fb77 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Sun, 22 Dec 2024 22:53:55 +0100 Subject: [PATCH] Implement Equals/GetHashCode for EquipmentStats --- Gear/EquipmentStats.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Gear/EquipmentStats.cs b/Gear/EquipmentStats.cs index 2d1c1cc..b13f3b3 100644 --- a/Gear/EquipmentStats.cs +++ b/Gear/EquipmentStats.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; namespace LLib.Gear; @@ -30,4 +31,16 @@ public sealed record EquipmentStats(Dictionary Stats, byte public bool Has(EBaseParam substat) => Stats.ContainsKey(substat); public bool HasMateria() => Stats.Values.Any(x => x.MateriaValue > 0); + + public bool Equals(EquipmentStats? other) + { + return other != null && + MateriaCount == other.MateriaCount && + Stats.SequenceEqual(other.Stats); + } + + public override int GetHashCode() + { + return HashCode.Combine(MateriaCount, Stats); + } }