What is the best way to create a rather dynamic upgrade system for a tower defence game? I thought of two possibilities:
Create enums for stats and math operation (latter could be just a char as well), and use the following function:
Upgrade (Stat, Value, Operation);
Like:
Upgrade (STAT_HEALTH, 2, OP_MULT);
would double health.
(Using an entity system with each one having an ID) Every tower, and its possible upgrades, are different entities, so:
Upgrade(int id);
would upgrade the entity to entity of ID id. This one doesn't look very good for me, as it looks like a waste of memory. This also makes me think of a system using a tree of stats nodes to define their dependencies, but I'm not sure what to do exactly.
Just started learning about JSON so the information needed would be available through it.