ID:265469
 
Would it be better to do classes like:
#define WIZARD 1
#define PILGRIM 2
#define HERO 4
#define SOLDIER 8
#define FIGHTER 16
#define SAGE WIZARD|PILGRIM
#define DRAGOON SOLDIER|FIGHTER
#define PALADIN FIGHTER|PILGRIM
#define RANGER WIZARD|SOLDIER

Or just use lists and stuff?
Ol' Yeller wrote:
Would it be better to do classes like:
> #define WIZARD 1
> #define PILGRIM 2
> #define HERO 4
> #define SOLDIER 8
> #define FIGHTER 16
> #define SAGE WIZARD|PILGRIM
> #define DRAGOON SOLDIER|FIGHTER
> #define PALADIN FIGHTER|PILGRIM
> #define RANGER WIZARD|SOLDIER

Or just use lists and stuff?

Depends. If you have a very simple old-school style RPG this would be an exceedingly easy way to go about implementing classes, but it only really makes sense if class properties are so minimalistic that they function on a binary level to begin with--if, for example, anyone with (class & WIZARD) would have access to the same wizard spells, anyone with (class & SOLDIER) would have access to the same heavy equipment, etc. If you want a finer degree of control than this, such as giving each class a unique set of equipment, magic, skills, etc. then the bitflag system is probably not ideal for your game; you'd probably end up with a bunch of big ugly switch statements everywhere. You could extend it somewhat by adding in a few more bitflags to express certain meta-categories; if, for example, you wanted "hybrid" fighter/magic-users to gain spells at half the rate of pure spellcasters, you could add in a HYBRID flag and have RANGER = SOLDIER|WIZARD|HYBRID, PALADIN = SOLDIER|PILGRIM|HYBRID, etc. But there's still a limit as to how far you could reasonably go with this, as it turns into a big unmanageable mess very quickly if you start adding in too many flags.

As far as alternatives go, generally I prefer to define this kind of thing as a class of datum and then have the game generate a master list when the world boots up.
In response to Leftley (#1)
In addition to what Leftley points out, that style of programming is generally used to minimize savefile space because "1" takes up less space than "fighter". Howerver, if you are using these factors to determine class abilities, why not just rank abilities? IE Armor 3 can use any armor, 2 any medium or lighter, 1 only light, 0 none, etc. instead of class names? That way a fighty character might have armor 4 weapon 4 magic 0 evasion 0 skills 2 or something.