How to check if 2 items in the array are of specific classes and specific quantities, and then if so, show them in a boolean.

I just need to check if I have the correct amount of requirements in my inventory are correct to craft an item.

How are items stored in your inventory?

They are stored by slot structures and within this slot structure I have:

Int- Quantity
Float- Slot weight
Bool − Is using item?
Bool- is selected?
Item structure
and this final variable (Item structure) contains:

Class (Of master item) - Class
Name, description, icon, etc… The most important thing I imagine would be the class and quantity.

This is the basic structure of an item within my inventory.
Now, I have plans, which are also similar in structure, but I just use the amount needed to create the item and the type of class. What I want to do is search within my inventory to find the corresponding class and correct quantity to create the item. However, if it is more than one requirement, I am unable to form a cohesive logic to query my inventory.

Sorry, I don’t know if that’s exactly what you meant with your question, about how I store my items. Let me know. :v:

Think that a linear search with a reverse loop comparing IDs would be the obvious choice for a small array. Other search solutions would depend on the number of slots and the number of requirements since the loop will end up being slots * requirements in worse case.

Are you using the class as an ID? I would personally change the class ID to an int, enum, or gameplay tag. Store this ID in an array and check every slot for each. When the required amount of a specific ID is met, remove it from the array so that the next slot only checks the remaining IDs. The search would return true when there are no IDs left to search. If it reaches the end of the array and there are still IDs to check, it would return false.

Is there a quantity limit for each slot, or can multiple slots have the same item? Maybe the item to craft requires more than what a single slot can offer. In this case, the search needs to hold an index of the slots until the sum of all found slots is equal or greater. When consumed, the empty slots will automatically be set to blank from last to first (if this is desired).

Makes sense?