locks

concepts
CONCEPT
	locks and keys


LAST UPDATE
	Mateese, 10-Jun-93 23:00 MET


USAGE
	#include <lock.h>


DESCRIPTION
	Keys and locks are important things>: treasure-chests and
	doors need to be locked to keep players from getting too rich.
	But they must also be standardized else the Thieves Guild
	could never justify their existance.

	Keys are simple things, identified by two aspects: their
	overall appearance (as defined by their Ids) and their exact
	form: their keycode.
	This way a lock can choose what keys it accepts: an old rusty
	lock could accept any key as long as it is an 'iron key',
	whereas a modern cylindrical lock doesn't care for the
	appearance but instead for the detailled form, the keycode.

	A key is a simple thing, equipped with three additional
	properties (as defined in /sys/lock.h):

	  P_KEYCODE  "KeyCode"
	    Define this to the (unique) keycode the key shall have.
	    It can be any value except 0 (which counts as 'no code').

	  P_NOLOCK     "NoLock"
	  P_NOUNLOCK   "NoUnlock"
	    Setting these properties to something non-zero
	    disables any (un)lock operation with the key.
	    If the value is a string, it is used as the failure
	    message.

	Since these properties can be soft properties, a special
	'/std/key' or '/obj/key' is not needed. However, there _is_ an
	'/obj/key' for your convenience :-)

	The lock (implemented as '/std/lock') is more complicated,
	since it contains the basic mechanics of the locking
	mechanism.
	It is not meant for stand-alone use, but instead of
	inheritance to make a thing lockable.

	The lock implements the three states 'open' (LOCK_OPEN),
	'closed' (LOCK_CLOSED) and 'locked' as the builtin property
	P_LOCKSTATE ("LockState").

 	NOTE: Even when inherited, SetLockState() is the ONLY way to
  	      change the state!
	      This is to allow the inheriting object to get notified
	      about any lock-state change by simple overloading of the
	      SetLockState() function.

	Besides this, a lock features also the two builtin properties

	  P_KEYCODE  "KeyCode"
	    Defines the (one!) keycode this lock accepts.

	  P_KEYIDS   "KeyIds"
	    This is an array of strings, determinating all key ids this
	    lock accepts.

	If no KeyIds are specified, the lock can't be locked, just
	opened and closed.

SEE ALSO
	lock(S), key(O)