So a lot of games now contain items that you collect, often along with a rarity for example, a standard dog pet has a rarity of common whilst a dragon pet has a rarity of legendary. I plan to adopt to this method and plan to use tables and dictionaries. But is it best to create stats of the object and have the rarity in it for example:
Dog = {Damage = 50, Rarity = Common}
Now the problem with this method is that if I were to have a system where players buy an egg or loot box with an allocated rarity, how would the loot box or egg know which pet rarity is what without cycling through all of them and adding them up again, to then cycle this new rarity specific table. But to get around this is to create a table for rarities for example:
Common = {Dog, Cat}
But now the problem here is that let’s say the player opens their inventory and each item will be highlighted in a different colour depending on the rarity, how would the client side know if an item is common unless it cycles through the table above until it matches the name, and finds at which rarity the cycle has stopped at.
The last way that I see to do this is by implementing two different tables, a stats table and a rarity table, but I feel there is a more efficient way. How do the big games such as pet sim do this?

1 comment
I somewhat actually understand this and makes me feel good about my coding capabilities, I feel I can use the source code and manipulate relatively easily. Thank you so much!