From 96f84e9c90cc23efd63ae3670e33e1ebe67ff81c Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 13 Mar 2024 11:05:34 -0400 Subject: [PATCH] Add statistics recalculation to IDDB --- SabreTools.DatFiles/ItemDictionaryDB.cs | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/SabreTools.DatFiles/ItemDictionaryDB.cs b/SabreTools.DatFiles/ItemDictionaryDB.cs index 8d6e1721..3e20eb46 100644 --- a/SabreTools.DatFiles/ItemDictionaryDB.cs +++ b/SabreTools.DatFiles/ItemDictionaryDB.cs @@ -468,5 +468,31 @@ namespace SabreTools.DatFiles // TODO: Write a method that deduplicates items based on any of the fields selected #endregion + + #region Statistics + + /// + /// Recalculate the statistics for the Dat + /// + public void RecalculateStats() + { + // Wipe out any stats already there + DatStatistics.ResetStatistics(); + + // If there are no items + if (_items == null || !_items.Any()) + return; + + // Loop through and add + foreach (var item in _items.Values) + { + if (item == null) + continue; + + DatStatistics.AddItemStatistics(item); + } + } + + #endregion } }