Neoband's bookless spell system is a dreadful mess at the moment.
What I have: a bunch of similar looking source files, one for each bookless realm, each containing a full set of functions for dealing with the spells (i.e. lots of code duplication).
What I want: each bookless realm being an object, containing a variable number of spells.
(In C I guess that would translate into "typedef struct blah blah, etc.")
Furthermore, each spell in a bookless realm would be an object, containing an integer mana cost, a description string, and methods for casting the spell, printing info, calculating fail rates, etc.
I think I could achieve this with function pointers. e.g.
Still a pretty rough around the edges... But this way I could do things like having different spells rely on different stats, or fail under different conditions. And I could have any number of spells per realm; and it would be much easier to add spells; etc.
Does this sound sane or am I missing something obvious?
What I have: a bunch of similar looking source files, one for each bookless realm, each containing a full set of functions for dealing with the spells (i.e. lots of code duplication).
What I want: each bookless realm being an object, containing a variable number of spells.
(In C I guess that would translate into "typedef struct blah blah, etc.")
Furthermore, each spell in a bookless realm would be an object, containing an integer mana cost, a description string, and methods for casting the spell, printing info, calculating fail rates, etc.
I think I could achieve this with function pointers. e.g.
Code:
typedef struct { int cost; char *desc; int *cast; int *calc_fail; int *display_info; } spellholder; ... spellholder pyro_fire_bolt = { 1, "Hurls a bolt of fire", (int *)fire_bolt(GF_FIRE, ...), ... }; ...
Does this sound sane or am I missing something obvious?
Comment