Deluxe Doors
version 2 by Emily Short
Section 5 - Keyless Latching and Unlatching
Check an actor unlocking keylessly a latched door (this is the redirect to latching rule):
if the noun is unlocked:
if the actor is the player:
say "[The noun] is already unlocked." instead;
stop the action;
abide by the latching-redirect rule.
Check an actor locking keylessly a latched door (this is the redirect to unlatching rule):
if the noun is locked:
if the actor is the player:
say "[The noun] is already secure." instead;
stop the action;
abide by the latching-redirect rule.
This is the latching-redirect rule:
let target-latch be a random door-latch which is part of the noun;
if the target-latch is a thing:
try the person asked turning the target-latch instead;
otherwise:
if the person asked is the player:
say "The latch seems to be missing from [the noun].";
stop the action.
Check an actor locking a latched door with something (this is the can't lock latched doors with keys rule):
if the player is the actor:
say "[The noun] lock[s] [if the noun is a half-door of a door which is not a latched door]from this side [end if]with a latch, not with a key." instead;
otherwise:
stop the action.
Check an actor unlocking a latched door with something (this is the can't unlock latched doors with keys rule):
if the player is the actor:
say "[The noun] lock[s] [if the noun is a half-door of a door which is not a latched door]from this side [end if]with a latch, not with a key." instead;
otherwise:
stop the action.
Carry out an actor turning a door-latch which is part of something (called the parent door) (this is the carry out turning door-latches rule):
if the parent door is locked:
safely unlock parent door;
otherwise:
safely lock parent door.
Report an actor turning a door-latch which is part of something (called the parent door):
say "[The actor] [if the parent door is locked][otherwise]un[end if]latch[es] [the parent door]." instead.
Deluxe Doors ends here.