Iām actually experiencing a bug with the Trait Predicate after making the transition from ETrait ā EStat.
Hereās what is getting spat out now when attempting to pickup an Item with condition MinimumTrait
FormatException: Input string was not in a correct format.
System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Int32.Parse (System.String s) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Game.Attributes.StatStore.Evaluate (Game.Utils.EPredicate predicate, System.Collections.Generic.List`1[T] parameters) (at Assets/Scripts/Attributes/StatStore.cs:139)
Game.Utils.Condition+Predicate.Check (System.Collections.Generic.IEnumerable`1[T] evaluators) (at Assets/Scripts/Quests/Condition.cs:56)
Game.Utils.Condition+Disjunction.Check (System.Collections.Generic.IEnumerable`1[T] evaluators) (at Assets/Scripts/Quests/Condition.cs:35)
Game.Utils.Condition.Check (System.Collections.Generic.IEnumerable`1[T] evaluators) (at Assets/Scripts/Quests/Condition.cs:17)
Game.Inventories.EquipableItem.CanEquip (Game.Inventories.EquipLocation equipLocation, Game.Inventories.Equipment equipment) (at Assets/Scripts/Inventory/Items/EquipableItem.cs:39)
Game.Inventories.Inventory.AddToFirstEmptySlot (Game.Inventories.InventoryItem item, System.Int32 number) (at Assets/Scripts/Inventory/Equipment/Inventory.cs:164)
Game.Inventories.Pickup.PickupItem () (at Assets/Scripts/Inventory/Items/Pickup.cs:48)
Game.Control.PickupItem.OnTriggerEnter2D (UnityEngine.Collider2D other) (at Assets/Scripts/Inventory/Items/PickupItem.cs:13)
Double-clicking on the error inside Unity brings me to the TraitStore (I renamed to StatStore) evaluate code where itās checking against the parameters[0]
public bool? Evaluate(EPredicate predicate, List<string> parameters)
{
if (predicate == EPredicate.MinimumTrait)
{
if (Enum.TryParse<EStat>(parameters[0], out EStat traitStat))
{
return GetPoints(traitStat) >= Int32.Parse(parameters[0]);
}
}
return null;
}
If Wisdom is set to ā5ā and my Wisdom is 5 or greater it still throws this error. ā end of original post
Found the bug but not sure how to fix it yet. ā edited post
After some digging,
I enabled Debug inside my Inspector and noticed some Items have parameters[0] == ""
ā But then some items using the exact same predicate MinimumTrait
will have parameters[0] == "Strength"
It appears the ones that are causing that string format error have EStat listed under the parameters[0] == "Strength", "Wisdom"
etc.
And on the other hand the items that are blank can be equipped as if no condition was set.
But just to ensure that other Predicates were working, I tried the simplest one ā HasLevel and that works fine. If Iām level 1, and the condition requires the player to be level 2, I can pick the item up no errors and it goes to my bag, attempt to equip, rejects it as intended.
Level up ā can now slot it. So it just seems the MinimumTrait isnāt working as it once was