In my game, I have many different types of units that are instantiated/destroyed with regularity. They have certain values, like MaxHP or Level or Defense, which need to be referenced at instantiation, and may vary based on certain factors. For example, MaxHP may be higher if Level increases, but not based on a strict formula, which varies by unit. So, for example:
- Soldier Level 1 Max HP: 5
- Soldier Level 2 Max HP: 6
Soldier Level 3 Max HP: 8
Mage Level 1 Max HP: 3
- Mage Level 2 Max HP: 4
- Mage Level 3 Max HP: 5
The class name would be easy to reference, and the level of the units would be stored elsewhere, and I'd need to know which trait I'm looking up to look it up in the first place. Therefore, what makes sense to me is to store these as key/value pairs. I can programmatically check something like (className + lvlString + traitName) as the key, so the key would end up being Mage2MaxHP and the value would be 4.
Usually my instincts in this regard are pretty bad since I never learned much about data structures. So, I'm wondering if there's a better way to achieve this and organize this amount of data. For example, it seems like this would be incredibly large for a dictionary. Perhaps it would be more manageable split into several dictionaries (one for MaxHP, one for Defense, etc.), but I still feel like I'm overlooking a data structure more suitable for this purpose. Any recommendations?