From 444d39c11acfe0c1bdd0562acb5ce452acadb5e9 Mon Sep 17 00:00:00 2001 From: gibbed Date: Sun, 23 Jun 2019 23:11:21 -0500 Subject: [PATCH] Fix weapon/item balance validation checking. Fixes #31. --- .../ItemBalanceDefinition.cs | 17 ++++++----------- .../WeaponBalanceDefinition.cs | 5 ----- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/projects/Gibbed.BorderlandsOz.GameInfo/ItemBalanceDefinition.cs b/projects/Gibbed.BorderlandsOz.GameInfo/ItemBalanceDefinition.cs index a96d808..9641f2e 100644 --- a/projects/Gibbed.BorderlandsOz.GameInfo/ItemBalanceDefinition.cs +++ b/projects/Gibbed.BorderlandsOz.GameInfo/ItemBalanceDefinition.cs @@ -44,14 +44,14 @@ public bool IsSuitableFor(ItemDefinition item) var current = this; do { - if (current.Item != null && current.Item == item) + if (current.Item != null || current.Items?.Count > 0) { - return true; - } + if (current.Item == item || current.Items?.Contains(item) == true) + { + return true; + } - if (current.Items != null && current.Items.Contains(item) == true) - { - return true; + return false; } current = current.Base; @@ -139,11 +139,6 @@ List getList(IEnumerable enumerable) } } - if (result.Item != item && result.Items.Contains(item) == false) - { - throw new ResourceNotFoundException($"item type '{item.ResourcePath}' is not valid for '{this.ResourcePath}'"); - } - return result; } diff --git a/projects/Gibbed.BorderlandsOz.GameInfo/WeaponBalanceDefinition.cs b/projects/Gibbed.BorderlandsOz.GameInfo/WeaponBalanceDefinition.cs index 6332861..07af05a 100644 --- a/projects/Gibbed.BorderlandsOz.GameInfo/WeaponBalanceDefinition.cs +++ b/projects/Gibbed.BorderlandsOz.GameInfo/WeaponBalanceDefinition.cs @@ -123,11 +123,6 @@ public WeaponBalanceDefinition Create(WeaponTypeDefinition weaponType) AddPartList(balance.Parts.MaterialParts, balance.Parts.Mode, result.Parts.MaterialParts); } - if (result.WeaponType != weaponType) - { - throw new ResourceNotFoundException($"weapon type '{weaponType.ResourcePath}' is not valid for '{this.ResourcePath}'"); - } - return result; }