
From Exemplary Game Magic Systems to Code Recipes ◾ 41
#define NUM_SPELL_EFFECT_PARAMS 5
struct SpellEffect {
enum ESpellEffectType type;
int params[NUM_SPELL_EFFECT_PARAMS];
};
#define NUM_SPELL_EFFECTS 5
struct Spell {
char* name;
int mpCost;
int level;
struct SpellEffect effects[NUM_SPELL_EFFECTS];
};
vo id CastSpell (const struct Spell* spell, struct Actor*
source, struct Actor* target) {
int effectIndex;
Pr intLog("%s cast%s on%s", source->name, spell->name,
target->name);
for (effectIndex = 0; effectIndex < NUM_SPELL_EFFECTS &&
sp ell->effects[effectIndex].type! = kEffectNone; ++
effectIndex) {
co nst struct SpellEffect* ...