+ "You hear nothing unexpected.")\r
+\r
+(defaction drink (what)\r
+ "You can't drink that.")\r
+\r
+(defaction eat (what)\r
+ "You can't eat that.")\r
+\r
+(defmethod eat ((obj food))\r
+ (if (has obj :edible)\r
+ (progn \r
+ (rmv obj)\r
+ (when (run-action-after obj)\r
+ (format nil "You eat ~a." (the-name obj))))\r
+ (call-next-method)))\r
+\r
+(defaction rub (what)\r
+ "This action achieves nothing.")\r
+\r
+(defaction turn (what)\r
+ "That's fixed in place.")\r
+\r
+(defmethod turn ((item item))\r
+ (if (has item :item)\r
+ "This action achieves nothing."\r
+ (call-next-method)))\r
+\r
+(defaction switch-on (what)\r
+ "You can't switch this on")\r
+\r
+(defaction switch-off (what)\r
+ "You can't switch this off")\r
+\r
+(defmethod switch-on ((obj switchable))\r
+ (if (has obj :switchable)\r
+ (progn\r
+ (if (has obj :on)\r
+ (format nil "~a is already on." (the-name obj))\r
+ (progn (give obj :on)\r
+ (when (run-action-after obj) "Done."))))\r
+ (call-next-method)))\r
+\r
+(defmethod switch-off ((obj switchable))\r
+ (if (has obj :switchable)\r
+ (progn\r
+ (if (hasnt obj :on)\r
+ (format nil "~a is already off." (the-name obj))\r
+ (progn (give obj :~on)\r
+ (when (run-action-after obj) "Done."))))\r
+ (call-next-method))) \r
+ \r
+(defaction fill (what) "You can't fill that.")\r
+\r
+(defaction empty (what) "That doesn't make sense.")\r
+\r
+(defmethod empty ((obj container))\r
+ (unless (has obj :container) (return-from empty (call-next-method)))\r
+ (if (has obj :closed)\r
+ "But it is closed!"\r
+ (if (children obj)\r
+ (objectloop (in x obj)\r
+ (sprint "~a: " (print-name x))\r
+ (run-action 'extract (list x obj)))\r
+ "It is already empty.")))\r
+\r
+(defaction extract (obj1 obj2 &key silent) "You can't do that.")\r
+\r
+(defmethod extract ((item item) (host container) &key silent)\r
+ (unless (has item :item) (return-from extract (call-next-method)))\r
+ (unless (has host :container) (return-from extract (call-next-method)))\r
+ (when (has host :closed) \r
+ (return-from extract \r
+ (format nil "~a is closed." (the-name host :capital t))))\r
+ (and (run-action 'let-go (reverse *args*))\r
+ *after*\r
+ (run-action-after item) \r
+ (if silent t "Done."))) \r
+\r
+(defmethod extract ((item item) (host supporter) &key silent)\r
+ (unless (has item :item) (return-from extract (call-next-method)))\r
+ (unless (has host :supporter) (return-from extract (call-next-method)))\r
+ (and (run-action 'let-go (reverse *args*))\r
+ *after*\r
+ (run-action-after item)\r
+ (if silent t "Done.")))\r
+\r
+(defaction extract-silent (obj1 obj2)\r
+ (extract obj1 obj2 :silent t))\r
+\r
+(defaction let-go (host thing)\r
+ "Something's wrong happened.")\r
+\r
+(defmethod let-go ((host supporter) (item item))\r
+ (move item (parent host))\r
+ (run-action-after host))\r
+\r
+(defmethod let-go ((host container) (item item))\r
+ (move item (parent host))\r
+ (run-action-after host))\r
+\r
+(defaction open (obj)\r
+ "You cannot open this.")\r
+\r
+(defmethod open ((obj container))\r
+ (unless (and (has obj :container) (has obj :openable))\r
+ (return-from open (call-next-method))) \r
+ (if (has obj :closed)\r
+ (if (hasnt obj :locked)\r
+ (progn \r
+ (give obj :~closed)\r
+ (when (run-action-after obj)\r
+ (format nil "You open ~a." (the-name obj))))\r
+ "It's locked.")\r
+ (format nil "~a is already open." (the-name obj))))\r
+\r
+(defaction close (obj)\r
+ "You cannot close this.")\r
+\r
+(defmethod close ((obj container))\r
+ (unless (and (has obj :container) (has obj :openable))\r
+ (return-from close (call-next-method)))\r
+ (if (hasnt obj :closed)\r
+ (progn \r
+ (give obj :closed)\r
+ (when (run-action-after obj)\r
+ (format nil "You close ~a." (the-name obj))))\r
+ (format nil "~a is already closed." (the-name obj))))\r
+\r
+(defaction lock (obj key)\r
+ "Not lockable.")\r
+\r
+(defmethod lock ((obj container) (key item))\r
+ (unless (and (has obj :container) \r
+ (has obj :openable)\r
+ (has obj :lockable))\r
+ (return-from lock (call-next-method)))\r
+ (if (has obj :locked) \r
+ (format nil "~a is already locked." (the-name obj))\r
+ (if (hasnt obj :closed)\r
+ (format nil "~a is not closed." (the-name obj))\r
+ (if (with-keys obj key)\r
+ (progn\r
+ (give obj :locked)\r
+ (when (run-action-after obj)\r
+ (format nil "You lock ~a." (the-name obj))))\r
+ (format nil "You cannot lock ~a with ~a."\r
+ (the-name obj) (the-name key))))))\r
+\r
+(defaction unlock (obj key)\r
+ "There is nothing to unlock.")\r
+\r
+(defmethod unlock ((obj container) (key item))\r
+ (unless (and (has obj :container) \r
+ (has obj :openable)\r
+ (has obj :lockable))\r
+ (return-from unlock (call-next-method)))\r
+ (if (hasnt obj :locked) \r
+ (format nil "~a is already unlocked." (the-name obj))\r
+ (if (hasnt obj :closed)\r
+ (format nil "~a is not closed." (the-name obj))\r
+ (if (with-keys obj key)\r
+ (progn\r
+ (give obj :~locked)\r
+ (when (run-action-after obj)\r
+ (format nil "You unlock ~a." (the-name obj))))\r
+ (format nil "You cannot unlock ~a with ~a."\r
+ (the-name obj) (the-name key))))))\r
+\r
+(defaction open-unlock (obj key)\r
+ "You cannot open this.")\r
+\r
+(defmethod open-unlock ((obj container) (key item))\r
+ (unless (and (has obj :container) \r
+ (has obj :openable))\r
+ (return-from open-unlock (call-next-method)))\r
+ (and (run-action 'unlock *args*)\r
+ (run-action 'open obj)))\r