Section 2(d) - The casting action
Affectedness relates various people to various spells. The verb to be affected by implies the affectedness relation.[1]
Casting it at is an action applying to one spell and one visible thing. Rule for supplying a missing second noun while casting: now the second noun is the location.[2]
Understand "cast [spell]" or "[spell]" as casting it at.
Understand "cast [spell] on/at [something]" or "[spell] [something]" as casting it at.
The current spell focus is an object which varies.[3] Before casting, now the current spell focus is the location.
Check casting (this is the can't cast what you don't know rule):[4]
if the player does not know the spell understood, say "You do not know the mystery of that enchantment." instead.
Check casting (this is the can't cast on the wrong sort of target rule):
if the targeting of the spell understood is targeted:
if the second noun is a room, say "That enchantment must be cast at something." instead;
otherwise:
unless the second noun is a room, say "That enchantment cannot be cast at anything." instead.
Check casting (this is the can't cast without strength rule):
if the strength of the player <= the strength cost of the spell understood to the player, say "You are weak, and have not sufficient strength of mind." instead.
Check casting (this is the can't cast at yourself rule):
if the player is the second noun, say "It is a cardinal rule of magic that no mage may cast an enchantment upon himself." instead.
Check casting (this is the can't cast without required materials rule):
let the stuff be the requirement of the spell understood;
unless the stuff is air:
if the player is carrying something (called the focus) which is made of the stuff,
now the current spell focus is the focus;
otherwise say "To weave that enchantment, you must have something made of [stuff] in your hands." instead.
Check casting (this is the can't magically attack a warded person rule):
if the nature of the spell understood is offensive and the second noun is a person:
let the intended victim be the second noun;
if the intended victim knows ward magic, say "With a contemptuous wave of orange sparks, [the intended victim] cancels your [spell understood] incantation." instead.[5]
Effect is a rulebook.[6]
The current spell outcome is an indexed text which varies. To record outcome (eventual message - text): now the current spell outcome is eventual message.
The current spell event is a rule which varies. To record event (eventual rule - rule): now the current spell event is eventual rule.
This is the no spell event at all rule: stop.
Carry out casting:
record outcome "but then nothing obvious happens";
record event the no spell event at all rule;
now the strength of the player is the strength of the player minus the strength cost of the spell understood to the player;
increase the usage count of the spell understood by 1;
if the usage count of the spell understood is less than 3[7]:
increase the score by cost of the spell understood;
increase the score by cost of the spell understood;
if the cost of the spell understood is at least 5 and the current spell focus is something, remove the current spell focus from play;
follow the effect rulebook.
Report casting:
say "As you intone the words of the [spell understood] spell, ";
if the current spell focus is something:
say "[the current spell focus] ";
unless the player is holding the current spell focus, say "vanishes as it ";
say "releases ";
otherwise:
say "your fingers release ";
say emission of the spell understood;
unless the second noun is a room, say " at [the second noun]";
say ", [current spell outcome]";
if the player is affected by the spell understood:
if duration of the spell understood is greater than 0:
say ", which will last for [duration of the spell understood in words] turn[s]";
now the duration timer of the spell understood is the duration of the spell understood;
increase the duration timer of the spell understood by 1;
say ".";
follow the current spell event.
Every turn:
repeat through the Table of Enchantments:
let the remaining effect be the duration timer entry;
decrease the remaining effect by 1;
if the remaining effect >= 0, now the duration timer entry is the remaining effect;
if the remaining effect is 0:
now the player is not affected by the spell entry;
say "(The [spell entry] spell wears off.)".[8]
Understand "xyzzy" and "plugh" as a mistake ("Nobody believes those old children's stories about a colossal cave with magic words any more. Magic's something you spend years and years learning.").
Notes
[1]. We now have two verbs connecting people and spells: we can write statements like "Radagast knows summon elemental", or "Henry is affected by ironbones".
[2]. "Casting it at" is an unusual action because it can take two forms, having a sort of transitive and intransitive version: one casts "detect trap" with no target, but "magic missile" must be aimed at something. Inform permits actions to have syntax which leaves a noun optional, but requires that we supply any missing nouns so that by the time the action is processed nothing is missing. We construe a missing target for a spell as being the current location: thus, "detect trap" is actually a spell cast on the ambient surroundings, which seems reasonable enough. (Inform's built-in action "listening" does something similar.)
[3]. The variable "current spell focus" typifies something which tends to happen in complex sequences of rules: later rules need to refer to something worked out in the course of an earlier rule. That means the sort of "let ..." variable will not do, because it is too temporary - it expires when the earlier rule finishes, so will be gone when the later rule is reached. Here we put the value into a permanent variable. This might be problematic if one casting action could be interrupted by another one, but here that never happens.
[4]. We're naming these rules so that the author of a W&W scenario could use procedural rules to suspend or alter them as needed.
[5]. The can't magically attack a warded person rule is a little sloppy: it does not sap the magical strength of the victim to cast the spell, which - if sauce for the wizard is sauce for the necromancer - it perhaps should.
[6]. The carry out and report rules for the casting action are going to be surprisingly short - considering the vast range of possible outcomes when a spell is cast - and they do this by using a more powerful mechanism to allow for more flexible reporting than would ordinarily be possible: they create a new rulebook, "Effect", whose task is to carry out the spell. Effect rules are also expected to set "current spell outcome" to a suitable message about what happens, and (optionally) "current spell event" to a rule which carries out further consequences.
[7]. You gain experience points the first couple of times you cast a spell, but then the novelty wears off.
[8]. For simplicity, and to keep storage requirements from going through the roof, time-limited spells can only be applied to the player.