Implement Equals/GetHashCode for EquipmentStats

This commit is contained in:
Liza 2024-12-22 22:53:55 +01:00
parent b581e2ea2a
commit b105987115
Signed by: liza
GPG Key ID: 2C41B84815CF6445

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace LLib.Gear; namespace LLib.Gear;
@ -30,4 +31,16 @@ public sealed record EquipmentStats(Dictionary<EBaseParam, StatInfo> Stats, byte
public bool Has(EBaseParam substat) => Stats.ContainsKey(substat); public bool Has(EBaseParam substat) => Stats.ContainsKey(substat);
public bool HasMateria() => Stats.Values.Any(x => x.MateriaValue > 0); 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);
}
} }