From 8bdec80dafc705aaed0f6fa87f78ff099279358f Mon Sep 17 00:00:00 2001 From: Chomp Date: Sun, 19 Jan 2025 23:53:50 +0000 Subject: [PATCH 1/3] Implemented AdjustWeighting --- .../Services/BotEquipmentFilterService.cs | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/Libraries/Core/Services/BotEquipmentFilterService.cs b/Libraries/Core/Services/BotEquipmentFilterService.cs index 1f41006a..4bcf5bfb 100644 --- a/Libraries/Core/Services/BotEquipmentFilterService.cs +++ b/Libraries/Core/Services/BotEquipmentFilterService.cs @@ -347,6 +347,8 @@ public class BotEquipmentFilterService Dictionary> botItemPool, bool showEditWarnings = true) { + //TODO, bad typing by key with method below due to, EquipmentSlots + // MAKE CONSISTENT BEFORE IMPLEMENTING throw new NotImplementedException(); } @@ -355,12 +357,51 @@ public class BotEquipmentFilterService /// /// Weighting change to apply to bot /// Bot item dictionary to adjust + /// protected void AdjustWeighting( - AdjustmentDetails weightingAdjustments, + AdjustmentDetails? weightingAdjustments, Dictionary> botItemPool, bool showEditWarnings = true) { - throw new NotImplementedException(); + if (weightingAdjustments is null) + { + return; + } + + if (weightingAdjustments.Add?.Count > 0) + { + foreach (var poolAdjustmentKvP in weightingAdjustments.Add) + { + var locationToUpdate = botItemPool[poolAdjustmentKvP.Key]; + foreach (var itemToAddKvP in poolAdjustmentKvP.Value) + { + locationToUpdate[itemToAddKvP.Key] = poolAdjustmentKvP.Value[itemToAddKvP.Key]; + } + } + } + + if (weightingAdjustments.Edit?.Count > 0) + { + foreach (var poolAdjustmentKvP in weightingAdjustments.Edit) + { + var locationToUpdate = botItemPool[poolAdjustmentKvP.Key]; + foreach (var itemToEditKvP in poolAdjustmentKvP.Value) + { + // Only make change if item exists as we're editing, not adding + if (locationToUpdate[itemToEditKvP.Key] != null || locationToUpdate[itemToEditKvP.Key] == 0) + { + locationToUpdate[itemToEditKvP.Key] = poolAdjustmentKvP.Value[itemToEditKvP.Key]; + } + else + { + if (showEditWarnings) + { + _logger.Debug($"Tried to edit a non - existent item for slot: {poolAdjustmentKvP} {itemToEditKvP}"); + } + } + } + } + } } /// From 93ebe58d0927404653dc394ecd8ff57276a356da Mon Sep 17 00:00:00 2001 From: Chomp Date: Sun, 19 Jan 2025 23:55:32 +0000 Subject: [PATCH 2/3] Fix --- Libraries/Core/Services/BotEquipmentFilterService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/Core/Services/BotEquipmentFilterService.cs b/Libraries/Core/Services/BotEquipmentFilterService.cs index 4bcf5bfb..1d495749 100644 --- a/Libraries/Core/Services/BotEquipmentFilterService.cs +++ b/Libraries/Core/Services/BotEquipmentFilterService.cs @@ -344,7 +344,7 @@ public class BotEquipmentFilterService /// Bot item dictionary to adjust protected void AdjustWeighting( AdjustmentDetails weightingAdjustments, - Dictionary> botItemPool, + Dictionary> botItemPool, bool showEditWarnings = true) { //TODO, bad typing by key with method below due to, EquipmentSlots @@ -360,7 +360,7 @@ public class BotEquipmentFilterService /// protected void AdjustWeighting( AdjustmentDetails? weightingAdjustments, - Dictionary> botItemPool, + Dictionary> botItemPool, bool showEditWarnings = true) { if (weightingAdjustments is null) From 7297db6b1dbcd5a8e2f9c83ec57b6292252d159c Mon Sep 17 00:00:00 2001 From: Chomp Date: Sun, 19 Jan 2025 23:57:20 +0000 Subject: [PATCH 3/3] `AdjustWeighting` cleanup --- Libraries/Core/Services/BotEquipmentFilterService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/Core/Services/BotEquipmentFilterService.cs b/Libraries/Core/Services/BotEquipmentFilterService.cs index 1d495749..c8b490bb 100644 --- a/Libraries/Core/Services/BotEquipmentFilterService.cs +++ b/Libraries/Core/Services/BotEquipmentFilterService.cs @@ -375,7 +375,7 @@ public class BotEquipmentFilterService var locationToUpdate = botItemPool[poolAdjustmentKvP.Key]; foreach (var itemToAddKvP in poolAdjustmentKvP.Value) { - locationToUpdate[itemToAddKvP.Key] = poolAdjustmentKvP.Value[itemToAddKvP.Key]; + locationToUpdate[itemToAddKvP.Key] = itemToAddKvP.Value; } } } @@ -390,7 +390,7 @@ public class BotEquipmentFilterService // Only make change if item exists as we're editing, not adding if (locationToUpdate[itemToEditKvP.Key] != null || locationToUpdate[itemToEditKvP.Key] == 0) { - locationToUpdate[itemToEditKvP.Key] = poolAdjustmentKvP.Value[itemToEditKvP.Key]; + locationToUpdate[itemToEditKvP.Key] = itemToEditKvP.Value; } else {