Spells
Spells are generally defined by the DM. Each spell must offer the following functions:
- setTarget(target) or setTargets(targets[]) or setTargetAOE(position)
- determineDamage(damageDie, caster)
setTarget(target)
Takes an object (a player, creature, other object) and makes it a target of a spell. If target is out of range, an ’OutOfRange’ exception is thrown.setTargets(targets[])
Takes an array of targets and makes them a target of spell.
If one of the targets is out of range, an OutOfRange exception is thrown.
If there’s too many targets, a TooManyItems exception is thrown.
setTargetAOE(position)
If we’re trying to cast an area-of-effect spell, we pass a position instead of a target. Position marks the center of the wanted area of effect. Throws an ’OutOfRange’ exception if the position is out of range.
determineDamage(dice, caster)
Determines the damage a spell will cause. You need to pass two arguments: dice that you need to roll for damage, and whoever is casting the spell (in order to determine bonuses and multipliers).