Fixed blocking check failure

This commit is contained in:
Chomp
2025-02-24 16:29:06 +00:00
parent e0f9b2dd06
commit 903001aa68
+10 -3
View File
@@ -390,10 +390,9 @@ public class BotGeneratorHelper(
}
// Does an equipped item have a property that blocks the desired item - check for prop "BlocksX" .e.g BlocksEarpiece / BlocksFaceCover
var blockingPropertyName = $"blocks{equipmentSlot}";
var templateItems = equippedItemsDb.ToList();
var blockingItem = templateItems.FirstOrDefault(
item => item?.Properties?.GetType().GetProperties().FirstOrDefault(x => string.Equals(x.Name.ToLower(), $"blocks{equipmentSlot}", StringComparison.OrdinalIgnoreCase))?.GetValue(item) is not null
);
var blockingItem = templateItems.FirstOrDefault(item => HasBlockingProperty(item, blockingPropertyName));
if (blockingItem is not null)
// this.logger.warning(`1 incompatibility found between - {itemToEquip[1]._name} and {blockingItem._name} - {equipmentSlot}`);
{
@@ -504,6 +503,14 @@ public class BotGeneratorHelper(
};
}
protected bool HasBlockingProperty(TemplateItem? item, string blockingPropertyName)
{
return item?.Properties?.GetType().GetProperties()
.FirstOrDefault(x =>x.PropertyType == typeof(bool)
&& x.Name.ToLower() == blockingPropertyName
&& (bool)x.GetValue(item.Properties)) is not null;
}
/// <summary>
/// Convert a bots role to the equipment role used in config/bot.json
/// </summary>