Hi
I have loads of constants for different game-states, groups, actions, item classes, armour types etc. I usually just use
#define ICLASS_SWORD 1
#define ICLASS_AXE 2
#define ACTION_SKIPTURN 0
#define ACTION_MOVE 1
#define ARMOUR_LIGHT 0
#define ARMOUR_MEDIUM 1
And so on. While this works, it seems a bit primitive Also sometimes (eg my latest project) i end up with well over a hundred of these. Is there a more clever way to do this? I know about enums but it's still similar usage.
I still have config files (txt-files) which holds most of the data (eg all data about each sword and axe, all the skills and actions etc) but i need to be able to reference these things in the code itself and dont want to use magic constants (obviously).
Any better idea?
//this is horrible (magic constant)
if (unit.action == 1)
unit.move();
//this is better (what I use now for most things)
if (unit.action == ACTION_MOVE)
unit.move();