This is a very general question and you can probably do it in multiple ways but here is my pick…
-
You should start with creating an effect_type enumerator (enum) like:
1-HP, 2-PhysicalDMG, 3-Mana, 4-Stun… -
Next you should create a attribute structure (struct) like: effect_type effect; float value; some other values…
-
Now your item should hold a name, type, mesh, icon and attribute array to hold as many effects as needed.
-
Generation: You will probably generate your items based on the drop location (bosses drop different items than normal minions) so it is logical for the item generator to be part of the chest or minion… The generator should hold the rules for creating the items including generating their names, assign their meshes and applying the values of their attributes before spawning the items.
-
Applying: Every time an item is equipped you should modify your character values - what the attack animation is, how fast it is and how much damage the character does along with HP and all other things.
That’s generally it.
Now in real commercial projects, the generator is usually a separate class or sometimes a separate application (service) run on the server which generates the items on game-play servers’ requests based on some weapon templates from a large database. This is done in order for the items to be updated or tweaked without turning off the main game-play servers.
Happy coding